ABAP Keyword Documentation → ABAP Programming Guidelines → Robust ABAP → Modularization units
Dialog Modules and Event Blocks
Other versions: 7.31 | 7.40 | 7.54
Background
Besides procedures, there are two further types of processing blocks. However, they do not have a parameter interface and do not allow declaration of local data:
(AT SELECTION-SCREEN
and GET
are exceptions but they should not be exploited):
- Dialog Modules
Dialog modules are introduced using theMODULE
statement and ended using theENDMODULE
statement. These modules form the functional interface between classic dynpros and the associated ABAP program. They are called from within the dynpro flow logic.
- Event Blocks
Event blocks are introduced by the corresponding keyword and implicitly ended by the next processing block. The processing of an event block is triggered by the ABAP runtime environment when the relevant event occurs. There are event blocks for:
- Loading a program (
LOAD-OF-PROGRAM
)
- Reporting events that occur during the processing of an executable program (with a logical database)
(
INITIALIZATION
,START-OF-SELECTION
,GET
,END-OF-SELECTION
)
- Selection screen events (
AT SELECTION-SCREEN ...
)
- List events of classic list processing (
AT LINE-SELECTION
,AT USER-COMMAND
)
Rule
No implementations in dialog modules and event blocks
Only use dialog modules and event routines if they are necessary from a technical viewpoint. In these cases, do not implement the required function. Instead, call the relevant (local) methods.
Details
Since it is not possible to declare local data in dialog modules and event blocks, you cannot implement any useful program logic. Therefore, dialog modules and event blocks # provided that they are still necessary # should only contain one method call. If you use ABAP Objects consistently, only the following elements are required:
LOAD-OF-PROGRAM
orINITIALIZATION
as the program constructor in cases where program types other than class pools are used
- Dialog modules and
AT SELECTION-SCREEN
when classic dynpros and selection screens are processed
START-OF-SELECTION
in executable programs for background processing To improve readability, you should always specify the statement explicitly (although it is optional in many situations).
- Although it is syntactically possible, you should never specify an event block several times within a program.
Note
Using LOAD-OF-PROGRAM
in a function group is basically the same as using
a static constructor in a global class. In executable programs, you can use INITIALIZATION
instead, if any parameters passed using SUBMIT
need to be evaluated.
Example
The following source code shows the PAI modules of the function groupDEMO_CR_CAR_RENTAL_SCREENS from the package SABAP_DEMOS_CAR_RENTAL_DYNPRO. The screens in this package can be called using transaction DEMO_CR_CAR_RENTAL. These dialog modules adhere to the above rule. They do not contain their own implementations. They call methods of a local class of the function group.
MODULE cancel INPUT.
screen_handler=>cancel( ).
ENDMODULE.
MODULE user_command_0100 INPUT.
screen_handler=>user_command_0100( ).
ENDMODULE.
MODULE customers_mark INPUT.
customer_table=>mark( ).
ENDMODULE.
MODULE reservations_mark INPUT.
reservation_table=>mark( ).
ENDMODULE.