SAP Jobsuche bei DV-Treff


Suchen
Michel01
  • Michel01
  • SAP Forum - User Thema Starter
vor 5 Jahre
Hallo zusammen,

ich habe mir ein Script ausgezeichnet und selbst was zu programmiert, das fehlende Daten in bestimmte Felder schreibt. Die Daten kommen aus einer Exceltabelle.

Ich melde mich also bei MM02 an, dann stehe ich im Reiter "Grunddaten 1" da werden einige Felder geschrieben,

z.B.

session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP27/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2952/ctxtMBEW-ZPLD1").Text = Date

dann geht es mit

session.findbyid("wnd[0]").sendVKey 0

weiter zum nächsten Reiter. Da aber nicht alle Sichten gepflegt sind, bricht das script natürlich ab wenn ich in ein Feld versuche zu schreiben, das es in dem Reiter nicht gibt. Das ist natürlich gut so, da kann man nichts falsches rein schreiben.

Gibt es eine Möglichkeit den Namen des Reiters auszulesen?

Also wie kann ich feststellen das ich mich bei "Disposition 1" befinde?

Gruß

Michael

wreichelt
vor 5 Jahre
Hallo Michael,

es gibt das Feld MARA-VPSTA Pflegestatus des kompletten Materials damit kann festgestellt werden

welche Sichten gepflegt sind.

Gruß Wolfgang

ScriptMan
vor 5 Jahre
Hallo Michael,

für den Reiter 'Grunddaten 1' würde es wie folgt aussehen:

on error resume next

if session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP27").text = "Grunddaten 1" then

on error goto 0

'tue irgendwas

end if

on error goto 0

Grüße,

ScriptMan

Michel01
  • Michel01
  • SAP Forum - User Thema Starter
vor 5 Jahre
Hallo ScriptMan,

Danke, das ist es, ist ja einfach... mit Text hätte ich selber drauf kommen können :-)

@Wolfgang, ja das Feld kenne ich, aber was sagen mir die Abkürzungen?

Die Hilfe die direkt im SAP angeboten wird ist nicht gerade sehr hilfreich, oder ich mache was falsch :-/

Vollständiger Status: KCVEDALSBGZXQ

PflegeStatus KCVEDALSBGQ

Gruß

Michael

wreichelt
vor 5 Jahre
Hallo Michael,

ich glaube es ist die Tabelle T133A die alle Schlüssel hat:

Fachbereich Pflegestatus

Arbeitsvorbereitung A

Buchhaltung B

Disposition D

Einkauf E

Fertigungshilfsmittel F

Grunddaten K

Kalkulation G

Klassifizierung C

Lagerortbestände Z*

Lagerung L

Lagerverwaltung S

Prognose P

Qualitätsmanagement Q

Vertrieb V

Werksbestände X*

Gruß Wolfgang

Michel01
  • Michel01
  • SAP Forum - User Thema Starter
vor 5 Jahre
Danke Wolfgang.

@Scriptman: Da hatte ich wohl einen Denkfehler :-(

SP01 ist der Reiter "Grunddaten 1" usw. habe ich inzwischen raus gefunden.

if session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP01").text = "Grunddaten 1" then

funktioniert nur wenn ich mich in tabpSP01 befinden, dann bekomme ich als Name "SP01"

ich muss also, wahrscheinlich, wissen in welchen tabpSPXX ich mich befinden.

Wenn ich mit der mit

Session.findbyid("wnd[0]").sendVKey 0

zum nächsten Reiter gehe bekomme ich mit der Abfrage von oben immer "SP01" als Name, bis Klassifizierung da geht es nicht mir sendVKey 0 weiter da brauche ich sendVKey 8

Hast du noch eine Idee?

ScriptMan
vor 5 Jahre
Hallo Michael,

man kommt nur weiter, wenn du uns dein Skript präsentieren könntest. Falls man auch irgendwelche Screenshots liefern kann, wäre es um so verständlicher für alle.

Ich z.B. arbeite überhaupt nicht in dem Bereich, wo man die Transaktion MM02 benötigt.

Grüße,

ScriptMan

Michel01
  • Michel01
  • SAP Forum - User Thema Starter
vor 5 Jahre
Hallo Scriptman,

hier mal ein Ausschnitt.

Ich lasse das aus Excel heraus laufen, dann kann ich schön mit Einzelschritt dadurch gehen :-)

Ich trage also in einem Reiter (z.B. Grundddaten 1) Daten ein und gehe dann blind mit

Session.findbyid("wnd[0]").sendVKey 0
zum nächsten Reiter, also von Grunddaten 1 zu Grunddaten 2

Da werden dann die nächsten Daten eintragen, siehe unten ---- Dispo 1-----

dann weiter zu ----- Dispo 2 ------

falls aber, wie schon geschrieben, nicht alle Sichten gepflegt sind, würde das Programm mit meiner Methode zb. bei Dispo 4 landen statt bei Dispo 3 (falls Dispo3 fehlen würde). Dort würden ja dann versucht Daten in Felder einzutragen die es in der Sicht nicht gibt und das Programm bricht dann mit Fehler ab. Deshalb würde ich gerne checken ob ich mich im richtigen Reiter (also Bsp. unten) in Dispo 1 befinde, bevor ich da versuche was reinzuschreiben.

Ist das verständlich?

Gruß

Michael


Sub anlegen()

Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set Session = SAPCon.Children(0) 'Get the first session (window) on that connection

'---- Legt x100 und x101 bei FERT an,  -----

Matnr = InputBox("Matnummer")

Session.findbyid("wnd[0]").resizeWorkingPane 120, 36, False
Session.findbyid("wnd[0]/usr/ctxtRMMG1-MATNR").Text = Matnr
Session.findbyid("wnd[0]/usr/ctxtRMMG1_REF-MATNR").Text = Matnr
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[1]/tbar[0]/btn[0]").press
Session.findbyid("wnd[1]/usr/ctxtRMMG1-WERKS").Text = "x100"
Session.findbyid("wnd[1]/usr/ctxtRMMG1-LGORT").Text = "0001"
Session.findbyid("wnd[1]/usr/ctxtRMMG1-VKORG").Text = "xx10"
Session.findbyid("wnd[1]/usr/ctxtRMMG1-VTWEG").Text = "10"
Session.findbyid("wnd[1]/usr/ctxtRMMG1-LGNUM").Text = "xx0"
Session.findbyid("wnd[1]/usr/ctxtRMMG1_REF-WERKS").Text = "xx40"
Session.findbyid("wnd[1]/usr/ctxtRMMG1_REF-LGORT").Text = "0001"
Session.findbyid("wnd[1]/usr/ctxtRMMG1_REF-VKORG").Text = "xx65"
Session.findbyid("wnd[1]/usr/ctxtRMMG1_REF-VTWEG").Text = "10"
Session.findbyid("wnd[1]/usr/ctxtRMMG1_REF-LGNUM").Text = "xx4"



Session.findbyid("wnd[1]/tbar[0]/btn[0]").press
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP04/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2158/ctxtMVKE-DWERK").Text = "x100"
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpBABA/ssubTABFRA1:SAPLMGMM:2200/subSUB2:SAPLMGD1:2181/tblSAPLMGD1TC_STEUERN/ctxtMG03STEUER-TAXKM[4,1]").Text = "0"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpBABA/ssubTABFRA1:SAPLMGMM:2200/subSUB2:SAPLMGD1:2181/tblSAPLMGD1TC_STEUERN/ctxtMG03STEUER-TAXKM[4,5]").Text = "0"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpBABA/ssubTABFRA1:SAPLMGMM:2200/subSUB2:SAPLMGD1:2181/tblSAPLMGD1TC_STEUERN/ctxtMG03STEUER-TAXKM[4,6]").Text = "0"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpBABA/ssubTABFRA1:SAPLMGMM:2200/subSUB2:SAPLMGD1:2181/tblSAPLMGD1TC_STEUERN/ctxtMG03STEUER-TAXKM[4,7]").Text = "0"
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0

'--------Dispo 1-------
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISMM").Text = "zr"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/txtMARC-FXHOR").Text = "0"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISPO").Text = "402"
Session.findbyid("wnd[0]").sendVKey 0
'--------Dispo 2-------
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-PLIFZ").Text = "21"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").Text = "2"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-BESKZ").Text = "f"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-SOBSL").Text = "46"
Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGPRO").Text = ""
Session.findbyid("wnd[0]").sendVKey 0 'Dispo 3
Session.findbyid("wnd[0]").sendVKey 0 'Dispo 4
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").sendVKey 0
ScriptMan
vor 5 Jahre
Hallo Michael,

ich kenne hierzu nur ein workaround.

z.B.

...

'--------Dispo 1-------

on error resume next

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISMM").Text = "zr"

if err.number = 0 then

on error goto 0

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/txtMARC-FXHOR").Text = "0"

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISPO").Text = "402"

end if

on error goto 0

Session.findbyid("wnd[0]").sendVKey 0

'--------Dispo 2-------

on error resume next

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-PLIFZ").Text = "21"

if err.number = 0 then

on error goto 0

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").Text = "2"

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-BESKZ").Text = "f"

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-SOBSL").Text = "46"

Session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGPRO").Text = ""

end if

on error goto 0

Session.findbyid("wnd[0]").sendVKey 0 'Dispo 3

Session.findbyid("wnd[0]").sendVKey 0 'Dispo 4

Session.findbyid("wnd[0]").sendVKey 0

Session.findbyid("wnd[0]").sendVKey 0

Session.findbyid("wnd[0]").sendVKey 0

Session.findbyid("wnd[0]").sendVKey 0

Grüße, ScriptMan

Michel01
  • Michel01
  • SAP Forum - User Thema Starter
vor 5 Jahre
Okay, danke, das probiere ich mal aus.

Gruß

Michael