ABAP Keyword Documentation → ABAP − Reference → SAP GUI User Dialogs → General Dynpros → Statements in the Dynpro Flow Logic → MODULE → Module Call - Examples
Dynpros, Unconditional Module Call
This example demonstrates how a dynpro can be exited without the automatic input checks.
Other versions: 7.31 | 7.40 | 7.54
Source Code
PROGRAM demo_dynpro_at_exit_command .
DATA: ok_code TYPE sy-ucomm,
save_ok LIKE ok_code,
input1(20) TYPE c, input2(20) TYPE c.
CALL SCREEN 100.
MODULE init_screen_0100 OUTPUT.
SET PF-STATUS 'STATUS_100'.
ENDMODULE.
MODULE cancel INPUT.
MESSAGE i888(sabapdemos) WITH text-001 ok_code input1 input2.
IF ok_code = 'CANCEL'.
CLEAR ok_code.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.
MODULE back INPUT.
MESSAGE i888(sabapdemos) WITH text-002 ok_code input1 input2.
IF ok_code = 'BACK' OR ok_code = 'EXIT'.
CLEAR: ok_code, input1, input2.
LEAVE TO SCREEN 100.
ENDIF.
ENDMODULE.
MODULE execute1 INPUT.
MESSAGE i888(sabapdemos) WITH text-003 ok_code input1 input2.
save_ok = ok_code.
CLEAR ok_code.
ENDMODULE.
MODULE execute2 INPUT.
MESSAGE i888(sabapdemos) WITH text-004 ok_code input1 input2.
IF save_ok = 'EXECUTE'.
MESSAGE s888(sabapdemos) WITH text-005.
ENDIF.
ENDMODULE.
Description
The static next dynpro number of dynpro 100 is 100. The input fields have the dynpro fields input1
and input2
assigned to them. The input fields are marked in their attributes
as required fields. The function codes of the pushbuttons are EXECUTE and CANCEL, in which CANCEL has the function type E. In GUI status STATUS_100, the symbols Back
(F3) and Cancel
(F12) are activated using the function codes BACK and CANCEL. Both have
the function type E. Additionally, the function key F8
has the function code EXECUTE assigned to it. EXECUTE does not have the function type E. The screen flow logic is as follows:
MODULE init_screen_0100.
PROCESS AFTER INPUT.
MODULE execute1.
MODULE cancel AT EXIT-COMMAND.
MODULE back AT EXIT-COMMAND.
MODULE execute2.
Using information messages and status messages, the program demonstrates which modules are called after user actions and which data is transported.
- When "Execute" is selected without input in the mandatory fields, the automatic input check demands that the mandatory fields are filled.
- When "Execute" is selected with filled mandatory fields, all dynpro fields are transported and the modules
execute1
andexecute2
are called consecutively.
- When "Cancel" is selected with or without input in the mandatory fields, the OK field is transported and the module
cancel
is called. The program is exited at this point.
- When "Back" is selected with or without input in the mandatory fields, the OK field is transported
and the module
cancel
is called. However, the program is not exited there, because the function code is BACK. Instead, the automatic field checks are performed. If the mandatory fields are filled, the modulesexecute1
andexecute2
are called.
The back
module is never called. Two module calls using AT
EXIT-COMMAND are pointless in the dynpro flow logic. In the above example, the function code
BACK is to be handled in module cancel
as well. In this case, the position of the statement MODULE
with AT EXIT-COMMAND
is irrelevant.