ABAP Keyword Documentation → ABAP − Reference → SAP GUI User Dialogs → General Dynpros → ABAP Statements for Dynpros → LOOP AT SCREEN
Dynpros, Dynamic Screen Modifications
This example demonstrates how to modify dynpro 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.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
LOOP AT SCREEN INTO DATA(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 dynpro number of dynpro 100 is 100. The input and output fields are from the structure DEMO_CONN in ABAP Dictionary. The bottom 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 associated with a pushbutton. When the program
is called, the four input/output fields at the bottom are not displayed as ready for input, because
the variable flag
initially contains a blank. The user can make the fields ready for input or not by using Display/Change.
The program DEMO_DYNPRO_MODIFY_SCREEN demonstrates further dynamic screen modifications.