Exploring Classical Report Events in ABAP: Initialization and At Selection-Screen
Welcome back everyone, So basically We were discussing about some best programming practices in our previous blog. Let’s discuss Classical Report Events.
Events :-
- Classical Reports are the most basic ABAP reports, in which we display the output using WRITE statement.
- Event is always triggered by a specific action or a specific occurrence ( when a particular time has been reached ).
- The example of specific actions are mouse click, pressing a key etc. The example of specific occurrence is running out of memory etc.
Classical Report Events :-
-
The same concept of events is applicable to classical reports. Some events trigger by specific user action and some events trigger at specific occurrence in classical reports.
-
The various classical report event are as follows :-
- Initialization
- At selection-screen
- Start of Selection
- End of Selection
- Top of page
- End of page
- At selection screen output
- At selection screen on value request for <field>
- At selection screen on help request for <field>
- At selection screen on <field>
1. Initialization
- This event calls before displaying the selection screen / Input screen.
- The purpose of this event is to assign the default values to parameters and select options.
Let’s create a program, so that we can understand the events easily,
Code :-
***********************************************
*Start of Program
***********************************************
DATA : lv_pm TYPE zar_payment_mode,
lv_curr TYPE zar_curency,
lv_date TYPE zar_order_date.
SELECT-OPTIONS : s_odate FOR lv_date NO-EXTENSION.
SELECT-OPTIONS : s_pm FOR lv_pm NO INTERVALS.
SELECT-OPTIONS : s_curr FOR lv_curr NO INTERVALS.
****************************
*Initializaton Events.
INITIALIZATION.
*****************
*For Date
s_odate-sign = 'I'.
s_odate-option = 'BT'.
s_odate-low = sy-datum - 100.
s_odate-high = sy-datum.
append s_odate.
********
*For Payement Mode
s_pm-low = 'C'.
append s_pm.
***************
*Currency
s_curr-low = 'INR'.
append s_curr.
*****************************************
*End OF Program
****************************************
Explanation :-
- In the above program, we have used our order header table which we have used in our previous blogs.
- We have created three select options for order date, payment mode, currency.
- Now, We will use initialization event to display the data on the input selection screen.
- Since, initialization event will be triggered just before displaying the input screen, So above code should display default entered value.
- Let’s run the program.
Output :-
At Selection-Screen :-
- This event triggers when the user performs some action ( enter, click etc.) on the selection screen or input screen.
- The purpose of this event is to validate the input.
- At selection screen makes sure the output should be displayed according to the requirement of the user.
Now, suppose If I comment the payment mode from the initialization from the below code for payment mode.
Code :-
***********************************************
*Start of Program
***********************************************
DATA : lv_pm TYPE zar_payment_mode,
lv_curr TYPE zar_curency,
lv_date TYPE zar_order_date.
SELECT-OPTIONS : s_odate FOR lv_date NO-EXTENSION.
SELECT-OPTIONS : s_pm FOR lv_pm NO INTERVALS.
SELECT-OPTIONS : s_curr FOR lv_curr NO INTERVALS.
****************************
*Initializaton Events.
INITIALIZATION.
*****************
*For Date
s_odate-sign = 'I'.
s_odate-option = 'BT'.
s_odate-low = sy-datum - 100.
s_odate-high = sy-datum.
APPEND s_odate.
********
*For Payement Mode
* s_pm-low = 'C'.
* APPEND s_pm.
***************
*Currency
s_curr-low = 'INR'.
APPEND s_curr.
***********************************
*At Selection Screen
AT SELECTION-SCREEN.
if s_pm-low is INITIAL.
if s_pm-low <> 'C'.
MESSAGE 'Payment mode is not entered' type 'E'.
endif.
ENDIF.
*****************************************
*End OF Program
****************************************
Selection Screen :-
Output Screen :-
- You can see the below message, It gets triggered after we press F8 on the selection screen.
- So, that’s why we say that At selection screen is used to validate the input.
So, that’s enough for today.
Thanx a lot for being a part of this wonderful journey.
Comments
Post a Comment