Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Script Recording for SAP ABAP configurations

0 Kudos

My basic requirement is to automate the process of saving the entries of a particular configuration(Eg: SPRO) into a TR. When I recorded the process and changed the code, the place where I stucked was, the script is recording the row number also. How to capture the row number dynamically? Can anyone please help?

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

To access a given cell in a GuiTableControl object, by its row and column numbers, use the method GetCell.

To access the cells of one or more columns in a GuiTableControl object, use the property Columns (collection of GuiTableColumn object). mytablecontrol.Columns.ElementAt(0) = first column. To iterate the cells of one column object, use the method ElementAt: mytablecontrol.Columns.ElementAt(0).ElementAt(2) = cell at third row of first column.

But don't forget that you can only access the rows currently displayed. If you need to access the previous or next page of rows, you have to scroll up or down.

8 REPLIES 8

stanislaslemaire
Participant

Hello,
not sure to understand you need...
Do you use SAPGuiScripting to record the process ?
What is result and where do you want to improve "dynamically" ?

0 Kudos

configuration.jpg

Hi Stanislas,

Yes, I'm talking about SAP GUI Scripting. I have attached a screenshot. when I'm recording, I need to select a row and include that row in a TR. The row number in the script is dynamic right. So my question is, how to record it.

Thanks in advance.

stanislaslemaire
Participant

ok, when you record, selected row is hardcoded accordingly in script.
If you want to change it dynamically, you have to use VBScript code in script.
For sentence, you can include your script in a VBA macro and use Excel to populate data as you want.

Sandra_Rossi
Active Contributor

So, what? Here's what the SAP recorder generates when I select the third line of maintenance dialog for V_TITOBPROF and I click transport...:

session.findById("wnd[0]/usr/tblSAPLITO0CUSTTCTRL_V_TITOBPROF").getAbsoluteRow(2).selected = true
session.findById("wnd[0]/mbar/menu[0]/menu[5]").select
session.findById("wnd[1]/usr/btnSPOP-OPTION2").press
...

Please clarify your question.

0 Kudos

Hi Sandra,

Thanks for your reply. To be precise, my question is after recording, we change the code in the script by opening it in notepad, so that if we open an excel, the script will run automatically. In this context, I would like to know how can we pass the row number in the following statement dynamically.

session.findById("wnd[0]/usr/tblSAPLITO0CUSTTCTRL_V_TITOBPROF").getAbsoluteRow(2).selected = true

Thanks in Advance.

Sandra_Rossi
Active Contributor

You mean, a variable instead of 2? Like this:

variable = 2
session.findById("wnd[0]/usr/tblSAPLITO0CUSTTCTRL_V_TITOBPROF").getAbsoluteRow(variable).selected = true

Or do you mean that you want to scan the table to search a given value and get the line number where it's located?

0 Kudos

Exactly. I want to scan the table and identify the row where it is located and give the line number. Because, after selecting that row only, system will be able to include that line data into a TR. Is there a way?

Thanks in advance.

Sandra_Rossi
Active Contributor
0 Kudos

To access a given cell in a GuiTableControl object, by its row and column numbers, use the method GetCell.

To access the cells of one or more columns in a GuiTableControl object, use the property Columns (collection of GuiTableColumn object). mytablecontrol.Columns.ElementAt(0) = first column. To iterate the cells of one column object, use the method ElementAt: mytablecontrol.Columns.ElementAt(0).ElementAt(2) = cell at third row of first column.

But don't forget that you can only access the rows currently displayed. If you need to access the previous or next page of rows, you have to scroll up or down.