on 07-26-2018 4:52 PM
Hello everyone! I recently started working with SAP at my stage in the HR industry and the first challenge was to create a macro for Excel VBA that logs into SAP, uses the PAAH transaction and opens / executes a given query and saves the generated data in a worksheet in excel. I was able to create the script for VBA through the Script Registration and Playback tool in SAP and use the macro without problems. But I came across a problem: In script playback it takes the value of the line I selected at the time of recording. If a new query is added in this list of queries, the index of my query will change. My question is how do I always find the desired query and execute it even if the list changes. Below is the code I was using, obtained through the Registration and Playback Script:
Session.findById("wnd[0]").maximize
Session.findById("wnd[0]/tbar[0]/okcd").Text = "/npaah"
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/tbar[1]/btn[6]").press
Session.findById("wnd[1]/usr/cmbDYNP4300-DD_WORKSPACE").SetFocus
Session.findById("wnd[1]/usr/cmbDYNP4300-DD_WORKSPACE").Key = "1"
Session.findById("wnd[1]/usr/cmbDYNP4300-DD_USERGROUP").SetFocus
Session.findById("wnd[1]/usr/cmbDYNP4300-DD_USERGROUP").Key = "102"
Session.findById("wnd[1]/usr/tblSAPLAQ_INT_FUNCTIONSTCH_OPEN_QUERIES").verticalScrollbar.Position = 2835
Session.findById("wnd[1]/usr/tblSAPLAQ_INT_FUNCTIONSTCH_OPEN_QUERIES").getAbsoluteRow(2837).Selected = True
Session.findById("wnd[1]/usr/tblSAPLAQ_INT_FUNCTIONSTCH_OPEN_QUERIES/txtDYNP4300_TC_QUERIES-NAME[0,2]").SetFocus
Session.findById("wnd[1]/usr/tblSAPLAQ_INT_FUNCTIONSTCH_OPEN_QUERIES/txtDYNP4300_TC_QUERIES-NAME[0,2]").caretPosition = 0
Session.findById("wnd[1]/tbar[0]/btn[0]").press
Session.findById("wnd[0]/shellcont[0]/shell").pressToolbarButton "GET_DATA"
Session.findById("wnd[0]/shellcont[0]/shell").pressToolbarContextButton "&MB_EXPORT"
Session.findById("wnd[0]/shellcont[0]/shell").selectContextMenuItem "&XXL"
Session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "P:\Desktop\Teste"
Session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "FUNCIONÁRIOS_SITUAÇÃO.XLSX"
Session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 13
Session.findById("wnd[1]/tbar[0]/btn[11]").press
Hello Jeancarlo,
welcome in the SAP Community.
To get the correct entry in the table you should code a loop in VBScript which detects the correct line.
You can find very good examples to do that here:
Please, use the search function, with the word GuiTableControl.
Best regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much Stefan! I'll read on.
Anyone help?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Incorrect tags selected - result: no answer...
Hello Jeancarlo and Vadim,
in my opinion is the tag correct. As far as I can see it is a SAP GUI Scripting question, how to search an entry in a GuiTableControl.
Best regards
Stefan
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.