Thursday, October 1, 2020

How to make ABAP programs selection screen test portable

While ABAP report developing; standard developer tools are having an option how to enter texts to elements of selection screen. It is available within t-code SE38 in menu Goto -> Text Elements -> Selection Texts. However, maintain the text in this way makes our ABAP programs not portable. This is because the texts entered there are not part of the source code. In case we want to move the program from one system to another just via copy & paste the Selection Texts won’t be moved and they need to be entered into target system again manually via the menu path.

However, there is a way to overcome this obstacle. The Selection Texts can be adjusted within the ABAP source code as well. For that, we can use ABAP program events like AT SELECTION-SCREEN OUTPUT or INITIALIZATION. Within those events it is possible to manipulate with variables created by PARAMETERS and SELECT-OPTIONS (also frames defined in the report can be covered like this) ABAP statements. Let say I have small ABAP program like below with the two parameters on its selection screen: 

DATAlt_adr6 TYPE adr6"just for SELECT-OPTIONS

PARAMETERS p1 TYPE uja_appset_info-appset_id.
SELECT-OPTIONSs_rec FOR lt_adr6-smtp_addr.

AT SELECTION-SCREEN OUTPUT"Set labels for sel scr
  %_p1_%_app_%
-text 'Environment Name' ##NO_TEXT .
  %_s_rec_%_app_%
-text 'Email Recipients' ##NO_TEXT .

In this case, the Selection Texts are taken not from menu but from the ABAP report source code itself.


 

No comments: