Reputation: 13
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 (screen of type "ABAP List").
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
Upvotes: 1
Views: 1418
Reputation: 13646
The screen you are showing is named an "ABAP List".
An ABAP List is not like a general screen. Visually speaking, this is an ABAP List (monospaced font only):
And this is a general screen (labels using proportional font):
An ABAP List has fields which are not identified by their field names but by their positions. NB: consequently, the Technical Information is of no help for ABAP Lists to identify the fields.
An ABAP List may contain labels, text fields and checkboxes, they belong to the property Children
of the GuiUserArea object
, their IDs are made of prefix lbl
, txt
and chk
followed by the column and row numbers, and they correspond respectively to the SAP GUI Scripting objects GuiLabel
, GuiTextField
and GuiCheckBox
. For example:
GuiLabel
):
/app/con[0]/ses[0]/wnd[0]/usr/lbl[0,12]
GuiTextField
):
/app/con[0]/ses[0]/wnd[0]/usr/txt[22,12]
GuiCheckBox
):
/app/con[0]/ses[0]/wnd[0]/usr/chk[0,0]`
I guess other simple graphical elements objects like GuiButton
, GuiComboBox
, GuiCTextField
, GuiRadioButton
, etc., are not possible in ABAP Lists.
If you want to know all the fields which are in an ABAP List, you must loop at the property Children
of the GuiUserArea
object, as explained below.
This script loops at all the fields in an ABAP List:
text = ""
For Each field In session.findById("wnd[0]/usr").Children
text = text & field.CharTop & " " & field.CharLeft & " " & field.Text & " " _
& field.Id & " " & field.Type & chr(10)
Next
msgbox text
For the ABAP List above (first screenshot), the script will show:
The loop goes from top to bottom and from left to right. You can't just look at the fields of one row, but you can stop looping after a given row:
If field.CharTop > 2 Then
Exit For
End If
As previously said, each field can be of type GuiLabel
, GuiTextField
or GuiCheckBox
, and has these common properties:
CharLeft
: horizontal position in the ABAP ListCharTop
: vertical position in the ABAP ListText
(or DisplayedText
)Id
: the field name by its positionType
: the type of objectHere is an example how to interact in an ABAP List, to position the cursor at a given column and row (SetFocus
), and double-click (= press F2 function key/SendVKey
):
column = 10
row = 2
session.findById("wnd[0]/usr/lbl[" & column & "," & row & "]").SetFocus
session.findById("wnd[0]").SendVKey 2
EDIT: the below part of this answer was partially copied from this more specific question about ME49 ABAP List.
Upvotes: 1