Thursday 14 December 2017

What are the Events in ABAP Report Programming ?

SAP ABAP is an event driven programming language, ABAP programs executed based on events not line-by-line.

But There is no mandatory event in a report program.
Events are actually used to organize the statements and control the flow of the program.
If the program contains no explicitly defined event blocks, all the statements in the program form the entire event block START-OF-SELECTION.
ABAP runtime environment automatically introduces a START-OF-SELECTION at the first execution line.
Below are some of the events available within ABAP programming.

1. Load-of-praogram:
This event is used to load program into memory for execution and this is the first event in execution sequence.
The purpose of load of program is to load the program into system memory so that the program can be executed.
The event Load-of-praogram is triggered each time when a program is called.

2. Initialization:
This event is used to initialize variables, screen default values and other default actions.
But before these are displayed to the user.
So you can use it to initialize input fields of the selection screen or change the default values of these before the user gets to enter data into them.
And we can Also USe for Refresh Internal table and Clear work Area before using them.

3. At Selection-Screen output:
By using this event we can manipulate dynamic selection-screen changes.
This is triggered when the selection screen is loaded in memory before being displayed.
We can use it to modify selection screen, for example (hide & unhide )parameter, (enable & disable ) input parameter.
For Example ->
LOOP AT SCREEN.
  IF SCREEN-name = 'S_FIELd'.
    SCREEN-input = '0'.
    MODIFY SCREEN.
  ENDIF.
ENDLOOP.

4. At Selection-Screen:
This event is used to validate multiple input fields.
The event AT SELECTION-SCREEN get trigger while the selection screen is being processed.

Following are the AT SELECTION-SCREEN events-

       1. AT SELECTION-SCREEN ON 'field' 
       This event is used to validate a single selection-screen input parameter.
       Syntax: AT SELECTION-SCREEN ON <parameter name>. "Validate a input parameter

       2. AT SELECTION-SCREEN ON VALUE-REQUEST for 'Field' 
       This event is used to provide value help ( field help ) for a input field.
       Syntax: AT SELECTION-SCREEN ON VALUE REQUEST FOR <parameter name>. "(i.e.           When press F4)

       3. AT SELECTION-SCREEN ON HELP-REQUEST for 'field'
       By using this event we can provide F1 help for a input field.
       Syntax: AT SELECTION-SCREEN ON HELP REQUEST FOR <parameter name>. "(i.e. When          press F1)

5. Start-of-Selection:
This is default event which is used to write actual business logic.
This event is called when If the user executes the program either by pressing the execute button or F8 this is the first event triggered after all screen selection processing has been completed.

6. Top-of-Page:
TOP-OF-PAGE is used for page headers on the basic list only.
This event prints constant heading for all pages.
This is called when a new page is started with an ABAP list and is used to display a header for the list.

7. End-of-Page:
The END-OF-PAGE event is used for page footers.
Before using this event, we need to reserve some lines for displaying footer.
Example: REPORT YTESTPROGRAM LINE-COUNT 38(5). " Here we reserve 5 lines for footer

8. End-of-Selection:
We can use this event just to state that start-of-selection is ended, this event is used with logical databases, logical databases are in HR ABAP only.
In normal ABAP we don`t have much importance .
If your report is linked to a logical database this event is called after the logical database has completely finished its work.
Otherwise this event is trigged after the START-OF-SELECTION event so you would generally use it to processes the data retrieved in that event.

The above events are available under classical report and interactive reports, there will be more events in interactive reports.

1.AT LINE-SELECTION:
This event will trigger whenever the user double click on any list line.

2.TOP-OF-PAGE DURING LINE-SELECTION:
This event is used to write something on top of every page of individual secondary lists.

3.At pF: 
This event will trigger whenever user clicks on any function buttons.

3.AT USER-COMMAND: 
This event will trigger whenever user clicks on any custom buttons of the GUI.

2 comments:

In this post we use some basics Events  and Control Break Statements for Generating Classical Report Based On single Table. If You want so...