SAP Screen Personas 2.0 - How to access the selected row in a grid
Note: This article is about SAP Screen Personas 2.0. If you are looking for more information about SAP Screen Personas 3.0, please go to the SAP Screen Personas 3.0 Portal.
As an example, the transaction VA05N (List Sales Orders) has been chosen. On the first screen the user enters a search criteria and executes the search. The second screen shows a grid with all sales orders that meet the search criteria. Using Personas, we have extended the first screen with an additional display field which is to be automatically filled with the net value (column 18) of a sales order by a script that is executed on the 2nd screen. The script execution is started after the user selected a row in the grid an and the user pressed enter. The demo video shows, how to modify the screens and then two runs showing that the script works.
- Extend the first screen of VA05N
- Create some space for the new controls
- Add additional group box, label and text field
- Copy the id of the text field (temporarily paste into a text file)
- Save & Exit
- Execute the search with a sample search criteria (order number 0 to 5000)
- Switch into edit-mode
- Copy the id of the grid
- Add a script button
- Add a Copy Table action, as id use the previously copied grid id, as content define the variable name table
- args.value = args.table[parseInt(args.row) + 1];
- Add a Push action for the button that brings the user back to the first screen
- Add a Paste Value action that pastes the content of the parameter value into the additionally created text field
- Bind the script button to the event of pressing enter while the grid is focused
- Open the Properties Editor
- Select the script button
- Copy its id (left click on the id)
- Select the grid
- Scroll until you see the property PushOnEnter
- Paste as value the id of the script button
- Save & Exit
- Test the script
Important: the parameter args.row is only available in the script when it is triggered by the press-enter event on a table or grid. If the script is executed by pressing the button, args.row is not defined, therefore,it is recommended to hide the button, so that it cannot be clicked.
As usual, if you want to learn more or discuss anything related to how to make your SAP GUI screens more functional using SAP Screen Personas, please start a discussion in the SAP GUI space on SCN.