SAP GUI Scripting VBA - checking the Dynamic ID

185 Views Asked by At

I want to write a code where the script selects the correct processes (e.g. A07) in the transaction MIGO in SAP GUI.

But apparently the SAPLMIGO:0007 in the code below is dynamic and can change.

Is there a way that I can check the actual ID and use this in the line of code?

session.findById("wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0007/subSUB_FIRSTLINE:SAPLMIGO:0011/cmbGODYNPRO-ACTION").Key = "A07"
1

There are 1 best solutions below

1
Storax On BEST ANSWER

The following code will return the ID of the object in question.

Let's assume session is a GUI session which points to a SAPGUI session with MIGO just started. Then Debug.Print session.FindById("wnd[0]/usr").Children(0).ID will return you the complete ID like /app/con[0]/ses[0]/wnd[0]/usr/ssubSUB_MAIN_CARRIER:SAPLMIGO:0007 You could now check the string for SAPLMIGO: and return the part you are interested in.

Dim migoID
migoID = session.FindById("wnd[0]/usr").Children(0).ID

Dim pos
pos = InStr(1, migoID, "SAPLMIGO:", vbTextCompare)

migoID = Mid(migoID, pos, 13)
Debug.Print migoID