The following sections introduce you to the processing blocks supported in ABAP programs and explain how they are called. They can be called either from outside the ABAP program (as is the case for dialog modules and event blocks) or through ABAP commands which are themselves contained in processing blocks.
You call dialog modules from the screen flow logic (screen command MODULE). You can write a dialog module in an ABAP program for each state (PBO, PAI; user input) of any of the screens belonging to it. The PAI modules of a screen together with the PBO modules of the subsequent screen form a dialog step. The interaction between the flow logic and the screen is controlled by a dialog processor.
Dialog modules are introduced with the MODULEstatement and concluded with the ENDMODULE statement.
Fields on a dialog screen have the same name as a corresponding field in the ABAP program. Data is passed between identically-named fields in the program. You do notdefine dialog screens in the ABAP programs.
Event blocks are called through events which are triggered by user actions on selection screens and lists or by the ABAP runtime environment. You only have to define event blocks for events to which you want the program to react (whereas a subroutine call, for example, must have a corresponding subroutine). This ensures that while an ABAP program may react to a particular event, it is not forced to do so.
Directly after an executable program, a module pool, a function group or a subroutine pool has been loaded, a special processing block can be executed exactly once. This processing block is defined as an event block using the event keyword LOAD-OF-PROGRAM. The processing block for LOAD-OF-PROGRAM has the same function for ABAP programs as a constructor has for classes.
The different events in a selection screen (PAI, PBO, user input), are controlled by a selection screen processor. You can program processing logic for these events in your program. The selection screen processor controls the flow logic of the selection screen.
You do not have to create the screen flow logic yourself, neither can you create your own dialog modules for the PBO or PAI events . Data is passed between selection screen and ABAP program using the fields (parameters and selection tables) which you create in the selection screen definition in the declaration part of the ABAP program.
You can create them in any processing block in an ABAP program using a special set of commands (such as WRITE, NEW-PAGE and so on). The list processor displays the list on the screen and handles user actions within lists. The list processor controls the flow logic of the list. You do not have to create the list flow logic yourself, neither can you create your own dialog modules for the PBO or PAI events .
You can call various event blocks while the list is being created which are used in page formatting. The above illustration contains the event block TOP-OF-PAGE, which is called from the ABAP program itself. When the list is displayed, the user can carry out actions which trigger event blocks for interactive list events (such as AT LINE-SELECTION). You can program processing logic for the interactive list events in your program. Data is transferred from list to ABAP program via system fields or an internal memory area called the HIDE area.
When you run an executable program, it is controlled by a predefined process in the runtime environment. A series of processors is called, one after the other. These processors trigger events, for which you can define event blocks. Executable ABAP programs are event-driven.
The process is as follows:
1. The runtime environment creates the INITIALIZATION event and calls the corresponding event block (if it has been defined in the ABAP program).
2. If there is a selection screen defined in the program, control returns to the selection screen processor. This generates the corresponding events and calls their event blocks.
3. Control then passes to the reporting processor. It creates the START-OF-SELECTION event and calls the corresponding event block (if it has been defined in the ABAP program).
4. The logical database, if you are using one, calls further event blocks at this point.
5. The reporting processor creates the END-OF-SELECTION event and calls the corresponding event block (if it has been defined in the ABAP program).
6. If the program contains a list description, control now passes to the list processor. The list processor displays the list defined in the ABAP program. It converts user actions on the list into events and calls the corresponding event blocks.
7. If a selection screen is declared in the declaration part of the program, the same program is automatically called again after the program is ended (the list is exited).
Procedures are callable processing blocks which contain an interface and a local data area.
You call subroutines from ABAP programs using the PERFORMstatement.
Subroutines are introduced with the FORMstatement and concluded with the ENDFORMstatement.
You can define subroutines in any ABAP program. You can either call a subroutine that is part of the same program or an external subroutine, that is, one that belongs to a different program. If you call an internal subroutine, you can use global data to pass values between the main program and the subroutine. When you call an external subroutine, you must pass actual parameters from the main program to formal parameters in the subroutine.
Function modules are external functions with a defined interface. You call function modules from ABAP programs using the CALL FUNCTION statement.
Function modules are introduced with the FUNCTION statement and concluded with the ENDFUNCTION statement.
You can only create function groups within special ABAP programs called function groups using the Function Builder. This means that you can only call them externally from other ABAP programs. Unlike subroutines, you always pass data to function modules using an explicit parameter interface.
Methods describe the functions of classes. Like function modules, they have a defined interface. You call methods from ABAP programs using the CALL METHOD statement.
Methods are introduced with the METHOD statement and concluded with the ENDMETHOD statement.
Methods can only be defined in the implementation parts of classes. You can either do this globally in the Class Builder, or locally within ABAP programs. Methods can work with the attributes of their class and with data that you pass to them using their explicit parameter interface.