Peter
Peter

Reputation: 148

Find field name references in SAP scripting vba

I need to find the field name references to textboxes in SAP using scripting under VBA!

Gridview doesn't show the names!

 Dim GridView As Object

 If Not IsObject(SapAPP) Then
   Set SapGuiAuto = GetObject("SAPGUI") 
   Set SapAPP = SapGuiAuto.GetScriptingEngine
 End If
 If Not IsObject(SAPConn) Then
   Set SAPConn = SapAPP.Children(0)
 End If 
 If Not IsObject(session) Then
   Set session = SAPConn.Children(0)
 End If
 If IsObject(WScript) Then
  WScript.ConnectObject session, "on"
  WScript.ConnectObject SapAPP, "on"
 End If
 session.FindById("wnd[0]").resizeWorkingPane 150, 31, False
 session.FindById("wnd[0]").resizeWorkingPane 150, 31, False
 session.FindById("wnd[0]/tbar[0]/okcd").Text = "cn46n"
 session.FindById("wnd[0]").SendVKey 0
 session.FindById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = "P-312313"
 session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").Text = "13123123"
 session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").SetFocus
 session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").CaretPosition = 7
 session.FindById("wnd[0]/tbar[1]/btn[8]").press
 session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell").CurrentCellColumn = "STATXT"
 session.FindById("wnd[0]/shellcont/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell").TopNode = "         23"
 'Set GridView = session.FindById("wnd[0]/shellcont/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell")
 Set GridView = session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell")
 session.FindById("wnd[0]/tbar[0]/btn[15]").press

Usually with gridview I can see what the text field names are and extract what I need with something like... MsgBox (" PSPID = ") & GridView.GetCellValue(i, "PSPID")

But I can't find a way to properly id the fields.

Upvotes: 0

Views: 6214

Answers (1)

ScriptMan
ScriptMan

Reputation: 1625

You could try the following:

for i = 0 to 9
msgbox "test = " & Session.FindById("wnd[0]/usr/tabsTABCJLE/tabpLEGR/ssubLISTE:SAPLCJWB:0902/tblSAPLCJWBTAB_902/txtPRPS-POST1[3," & cstr(i) & "]").text
...

Regards, ScriptMan

Upvotes: 1

Related Questions