Event in Selection Screen
Selection screens are special screens that are defined with the help of ABAP statements.
As programmers do not have access to the flow logic of selection screens, they cannot define dialog modules for selection screens. The ABAP runtime environment fully controls the processing flow of selection screens. To allow programmers to modify the selection screen before it is called (PBO) and react to user actions on the selection screen (PAI), the ABAP runtime environment generates a number of special selection screen events before the selection screen is displayed and after the user has executed actions on the selection screen. Programmers can define event blocks in the program to react to these events.
The basic form of the selection screen events is the AT SELECTION-SCREEN event. This event occurs after the runtime environment has passed all input data from the selection screen to the ABAP program. The other selection screen events allow programmers to modify the selection screen before it is sent and specifically check user input.
Selection screen events occur both during standard and user-defined selection screen processing. The SY-DYNNR system field contains the number of the active selection screen and helps you to determine which selection screen is currently being processed in the event blocks.
Overview of Selection Screen Events
Selection screen processing starts after the INITIALIZATION event with AT SELECTION SCREEN OUTPUT. The selection screen is then sent to the screen. User actions on the selection screen result in other events that are either used for field or possible entries help, or that trigger PAI processing of the selection screen. During PAI processing,
error messages in the relevant event blocks allow users to return to the selection screen. Only if the AT SELECTION-SCREEN event is exited properly, that is not through an error message, are the other events of the executable program triggered, starting with START-OF-SELECTION.
Choosing multiple selection calls the relevant dialog box. Similarly, events are triggered during its PAI processing.
This is the flow of events in Selection Screen Processing:
- Load Of Program: When a program is called using SUBMIT or using a transaction code, then – at every call – a new internal session is opened and the event block is executed once at every call. You can initialize global data objects of the program here. The event block must be executed completely; otherwise, a run-time error will occur.Therefore, no statements are allowed to be executed that leave the event block without returning.At the first call of an external Procedure (sub-program or function module), the framework program of the called procedure is loaded into the internal session of the caller, thus triggering the event LOAD-OF-PROGRAM.
- Initialization: triggered when the report is loaded in memory.
- At selection-screen output: triggered when the selection screen is loaded in memory before being displayed (PBO of selection screen). This event can be called multiple time when any changes happened on screen (e.g. select radio button).
- At selection-screen on value-request for: the possible entries pushbutton for F4 appears beside the appropriate field.
- At selection-screen: before leaving the selection screen. This event is also triggered when we press Enter on selection screen, this will not execute the report but will be helpful to check the validation of input parameters.
- Start-of-selection: the first event for displaying the report.
- End-of-selection: after the start-of-selection is completed.
- Top-of-page: every time a new page is started in the list.
- End-of-page: every time the list data reaches the footer region of the page.
Events in ABAP Program
1. AT PF<nn>.
This event will trigger whenever user clicks on any function buttons.
When the user chooses a function code PF<nn> (<nn> can be between 01 and 24), the system always triggers the AT PF<nn> event. In the standard list status, the function keys F<nn> that are not reserved for predefined system functions all have the function code PF<nn> as long as a corresponding event block is defined in the program.
If you use these event blocks at all, it should only be for temporary test versions. In production programs, you should only use AT USER-COMMAND with a dialog status of your own to assign function codes to function keys. When you use your own interfaces, the system displays a function text explaining what the function does. This does not happen when you use AT PF<nn> event blocks.
2. AT USER-COMMAND
This event will trigger whenever user clicks on any custom buttons of the GUI.
Example: This program works with a self-defined GUI status MYLIST. The function associated there with the function code MY_SELECTION triggers the event AT USER-COMMAND when the list is displayed and also creates details lists.
REPORT demo_at_user_command.
START-OF-SELECTION.
SET PF-STATUS 'MYLIST'.
WRITE 'List line'.
AT USER-COMMAND.
IF sy-lsind = 20.
SET PF-STATUS 'MYLIST' EXCLUDING 'MY_SELECTION'.
ENDIF.
CASE sy-ucomm.
WHEN 'MY_SELECTION'.
WRITE: / 'You worked on list', sy-listi,
/ 'You are on list', sy-lsind.
...
ENDCASE.
3. LOAD-OF-PROGRAM
LOAD-OF-PROGRAM will loads the program in to Application server and INITIALIZATION is used to initialize the values before program is going to execute.
When an ABAP program is loaded in an internal session, the runtime environment triggers the LOAD-OF-PROGRAM event, and the corresponding event block is executed.
4. At Line-Selection
This event will trigger whenever the user double click on any list line.
Syntax: AT LINE-SELECTION . "Triggers line selection
No comments:
Post a Comment