Home > database >  How to get text from SAP to Excel CellValue via VBA Script
How to get text from SAP to Excel CellValue via VBA Script

Time:01-29

I just started with VBA and SAP GUI Scripts.

I am able to enter to the operation in SAP GUI via VBA but I am unable to find how to select or copy the value of these fields.

While recording the script via SAP GUI, copying the fields into the clipboard won't appear in the script as an action.

Any help or reference is highly appreciated.

Please find code and screenshot below.

Sub XXXX()
Call SAPConnections
Session.FindById("wnd[0]/tbar[0]/okcd").Text = "Operation"
Session.FindById("wnd[0]").SendVKey 0
Session.FindById("wnd[0]/usr/ctxtP_MATRL").Text = "PartNumber"
Session.FindById("wnd[0]").SendVKey 8
Session.FindById("wnd[0]/tbar[1]/btn[1]").Press

Screenshot

CodePudding user response:

The screen you are showing is named an "ABAP List".

It contains labels and text fields, they belong to the property Children of the GuiUserArea object, and their IDs are made of prefix lbl or txt followed by the column and row numbers. The respective SAP GUI Scripting objects are GuiLabel and GuiTextField, for example:

  • label at column 0 (first column) row 12: /app/con[0]/ses[0]/wnd[0]/usr/lbl[0,12]
  • text field at column 22 row 12: /app/con[0]/ses[0]/wnd[0]/usr/txt[22,12]

If you want to know all the fields which are in the ABAP list, you must loop at the property Children of the GuiUserArea object.

  •  Tags:  
  • Related