ABAP Keyword Documentation → ABAP - Reference → User Dialogs → Screens → ABAP Statements for Screens → LOOP AT SCREEN
Screens, Dynamic Screen Modification
The example shows how to modify screen fields at runtime.
Other versions: 7.31 | 7.40 | 7.54
Source Code
REPORT demo_dynpro_modify_simple .
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA flag(1) TYPE c.
DATA screen_wa TYPE screen.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
LOOP AT SCREEN INTO screen_wa.
IF screen_wa-group1 = 'MOD'.
IF flag = ' '.
screen_wa-input = '0'.
ELSEIF flag = 'X'.
screen_wa-input = '1'.
ENDIF.
MODIFY SCREEN FROM screen_wa.
ENDIF.
ENDLOOP.
ENDMODULE.
MODULE cancel.
LEAVE PROGRAM.
ENDMODULE.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'TOGGLE'.
IF flag = ' '.
flag = 'X'.
ELSEIF flag = 'X'.
flag = ' '.
ENDIF.
ENDCASE.
ENDMODULE.
Description
The static next screen number of screen 100 is 100. The input and output fields have been copied from the structure DEMO_CONN of the ABAP Dictionary. The bottom-most four input and output fields are assigned to the modification group MOD. The screen flow logic is as follows:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
MODULE user_command_0100.
In GUI status SCREEN_100, the function code TOGGLE is linked to a pushbutton. When the program is called,
the bottommost four input and output fields are displayed as not ready for input since the variable
flag
initially contains a blank. The user can switch the ready-for-input status on and off using Display/Change.
Program DEMO_DYNPRO_MODIFY_SCREEN demonstrates further dynamic screen modifications.