Preface – This post is part of the ABAP Beginner series.
In ABAP reports, very often we will be having a situation where we need to store single record of a table or take input from user and append that record to table, both at runtime. In this situation we will need a structure which has all the fields of that particular table with the same namespace. Every time the content of the table changes, we will have to update our structure. So, instead of using structure we can use something called work area that is the replica of single row of that table with same fields.
Definition
A work area in ABAP represents single row of an internal table and it is used to process internal table line by line. It holds only single data at runtime.
ABAP Work Area- Image Illustration
Syntax
A workarea can be defined in a report in two ways.
Case 1: Predefining the type of work area and allocating memory to it.
DATA: <YOUR_WORK_AREA_NAME> TYPE <Structure, Table, Line Type, View>.
Case 2: Using Open SQL to allocate memory and type to work area at runtime.
SELECT SINGLE * FROM <YOUR_TABLE_NAME> INTO DATA (<YOUR_WORK_AREA_NAME>).
*** Exclude the parenthesis <> from above while using them in your programs.
Examples
Case 1:
DATA: wa_emp TYPE zemployee.
SELECT SINGLE * FROM zemployee INTO wa_emp.
Note: If your work area does not match the structure of the table from which data is being pulled, you can write following:
SELECT SINGLE * FROM zemployee INTO CORRESPONDING FIELDS OF wa_emp.
Case 2:
SELECT SINGLE * FROM zemployee INTO DATA (wa_emp).
Preface – This post is part of the ABAP Beginner series.
Very often, there is a situation in ABAP where we need to store multiple data of a definite structure at runtime and perform some operations upon them. For runtime operations we cannot hit database every time. In that situation, we fetch required data from database table, store it in something called ABAP Internal Table and perform operations upon them.
Definition
An Internal table in ABAP is a runtime copy of a table or structure. It is a reusable object. Each line of an internal table has same structure. In SAP, Internal table is an alternative to Arrays.
ABAP Internal Table – Illustration Image
Syntax
DATA: <YOUR_INTERNAL_TABLE_NAME> TYPE TABLE OF <Structure, Table, Data type, Table Type>.
Note: An Internal table can also be defined at runtime. It is explained in one of the example below.
Examples
Case 1:
DATA: itab_emp TYPE TABLE OF zemployee. // Declaration of Internal table
SELECT * FROM zemployee INTO TABLE itab_emp. // feeding data in internal table
Case 2:
SELECT * FROM zemployee INTO TABLE @DATA (itab_emp). // Declaration of Internal table at runtime and feeding data there itself
Types of ABAP Internal Tables
According to the frequency of use, internal tables are of following types:
Type
Description
Example
Standard tables
A standard Internal table is the one which is accessed by its index. In this table we APPEND data one by one and later access data (Read, Modify and Delete) using INDEX statement.
DATA: itab_emp TYPE TABLE OF zemployee.
Sorted tables
A sorted internal table is just like a standard internal table except data is inserted not appended. It is sorted as we fill it. We fill sorted table using INSERT statement.
DATA: itab_emp TYPE SORTED TABLE OF zemployee WITH UNIQUE KEY empid.
Hashed tables
A hashed internal table is the one in which data is filled using UNIQUE KEY. To access data we need this key.
DATA: itab_emp TYPE HASHED TABLE OF zemployee
WITH UNIQUE KEY empid empname.
Operations on ABAP Internal Tables
Operations on Entire Internal Tables
Assigning Internal Tables
MOVE itab1 TO itab2.
OR
itab2 = itab1.
Initialize Internal Tables
CLEAR itab => To clear the header of the table
CLEAR itab [] => To initialize the table but the initial memory remains reserved.
REFRESH itab => Clears data of table but the initial memory remains reserved. It is same as CLEAR itab [].
FREE itab =>It clears data as well as the initial memory allocated to the table.
Compare Internal Tables
Suppose we have two Internal tables ITAB1 and ITAB2 with same data type but different number of data, let us say 2 and 3 Lines of data respectively. The statement returns Boolean result.
ITAB1 GT ITAB2 (Greater than) => False
ITAB1 EQ ITAB2 (Equal to) => False
ITAB1 LE ITAB2 ( Less than or equal to) => True
ITAB1 NE ITAB2 (Not Equal to) => True
ITAB1 LT ITAB2 (Less than) => True
Sort Internal Tables
SORT itab [ASCENDING|DESCENDING] [AS text] [STABLE]. The default is ascending order.
Internal Tables as Interface Parameters
We can use Internal table as a parameter in Forms and Interfaces. In forms Internal Table is written in addition to USING and CHANGING.
Preface – This post is part of the ABAP Beginner series.
Suppose in an ABAP Report, we have multiple data for a person. This data is name, address, contact number and salary. Now, again we have same data for another person. Will you create those variables again for the second person or would you like to reuse the above variables. In this case, you will need a group of these variables under a single component. This component is known as structure or local structure in ABAP report . ***Note: If you want to learn about ABAP SE11 (Data Dictionary) Structure, visit here.
Definition
A Local Structure in ABAP reports is a reusable component which acts as a collection of different variables of different data types under a single name. It holds only single data at runtime.
Syntax
A local structure in ABAP is defined within BEGIN OF…. END OF. And it starts either with TYPES or DATA.
BEGIN OF <Your_Structure_name>,
NAME TYPE c LENGTH 20,
SALARY TYPE i,
END OF <Your_Structure_name>.
Local Structure in ABAP Report – Image Illustration
NOTE: A local structure can also be created at runtime. We will show this in below example.
Examples
Case 1:
DATA: BEGIN OF LS_EMPLOYEE,
NAME TYPE c LENGTH 20,
SALARY TYPE i,
END OF LS_EMPLOYEE.
In this case, we directly fetch one data into this structure.
Select Single * from ZEMPLOYEE into corresponding fields of @LS_EMPLOYEE.
Case 2:
TYPES: BEGIN OF LS_EMPLOYEE,
NAME TYPE c LENGTH 20,
SALARY TYPE i,
END OF LS_EMPLOYEE.
Since it is a TYPE, hence it cannot hold data at runtime. Hence we will need to define a workarea first and then fetch data into that.
DATA: WA_ EMPLOYEE TYPE LS_EMPLOYEE.
Select Single * from ZEMPLOYEE into corresponding fields of WA_ EMPLOYEE.
CASE 3:
In latest update of ABAP, we can create a structure/workarea at runtime in given way:
SELECT Single * from ZEMPLOYEE into corresponding fields of DATA(WA_ EMPLOYEE).
In this way, we will not have to define a structure anymore and we can use this structure again in the program too.
Types of Structures
In real world development, we simply create a structure the way it is mentioned in above examples. But some time, as per scenario, we need to create structures in a different manner. SAP provides 4 types of structures:
Structure Type
Description
Use Case
Flat structures
The structure which contains only elementary data types.
A structure of employee basic data e.g. Name, age, salary, etc
Flat character-like structures
The structure which contains only character like elementary data types. Character like data types are text field (char), numeric text field (n), text string (string).
A structure which will be used only to read and no calculation will be made. In this case all data can be string type.
Nested structures
A structure inside a structure is called a nested structure.
A structure of school containing another structure of student details and teacher details.
Deep structures
A structure which has at least one deep component (string, internal table or reference variables).
A structure which saves mail content. Mail content can have unknown length, in this case data type of that field will be string.
Preface – This post is part of the ABAP Beginner series.
In this article, we have discussed a type of ABAP Report Events i.e. Selection Screen Events. To learn all about ABAP Report Events click here.
Introduction
In ABAP Report Events after ABAP Reporting Events of ABAP, we have Selection Screen Events which occur in a predefined manner. These events are called in similar a way of Dynpro sequence (PBO and PAI). These events are processed during selection screen processing.
In simple words, selection screen events are the events that are called after a selection screen block is opened and it is used to manipulate the selection screen block based on user interaction at runtime.
Basic Dynpro Events
Before we discuss Selection screen events, let us learn basic Dynpro events first:
PBO: Process Before Output
This event is triggered before a screen is sent to presentation layer (output screen).
PAI: Process After Input
This event is triggered by a user action on ABAP GUI.
POH: Process On Help Request
This event is triggered when F1 (Field Help) of an input field on the screen is requested.
POV: Process On Value Request
This event is triggered when F4 (Input Help) of an input field on the screen is requested.
Types of Selection Screen Events
Following are the types of Selection Screen Events:
Event
Description
· AT SELECTION-SCREEN OUTPUT
· It is raised by PBO event. Thus anything that needs to be changed dynamically on screen uses this event.
· This event is also useful in case we need to initialize something every time the selection screen code of a program is called because INITIALIZATION is loaded only once but AT SELECTION-SCREEN OUTPUT is loaded every time.
· MODIFY SCREEN can be used to manipulate screens during AT SELECTION-SCREEN OUTPUT event.
· AT SELECTION-SCREEN ON { Parameter | Selection Criteria }
· It is raised by PAI event. This event is triggered if content of Parameter or Selection Criteria is passed to ABAP program.
· A selection criterion (selection table) is generated using SELECT-OPTIONS. And for each line of selection table, different calls are made to AT SELECTION-SCREEN ON {Parameter | Selection Criteria} is made.
· If a warning or an error message is raised, the input parameters of this event blocks become ready for input again.
AT SELECTION-SCREEN ON END OF selcrit
· Unlike above event, call to this event is made with entire selection table.
· It is mainly used to mark the end of Selection Screen event calls.
AT SELECTION-SCREEN ON BLOCK block
· It is raised by PAI event. This event is triggered when all the inputs of a block is passed to the ABAP program.
· If a warning or an error message is raised, the input parameters of this event blocks become ready for input again.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP group
· It is raised by PAI event. This event is triggered when all the inputs of a block is passed to the ABAP program.
· If a warning or an error message is raised, the input parameters of this event blocks become ready for input again.
AT SELECTION-SCREEN
· This is the last event raised in selection screen processing
· All input values are passed to this event; hence we can perform all types of validations here.
· If a warning or an error message is raised, the input parameters of this event blocks become ready for input again.
AT SELECTION-SCREEN ON HELP-REQUEST|VALUE-REQUEST FOR {para|selcrit-low|selcrit-high} }
· This event is triggered on F1 or F4 Help request from screen.
· It is raised by POH and POV event.
AT SELECTION-SCREEN ON EXIT-COMMAND
· This event is triggered if any of the following actions are called on the screen: Back, Exit, or Cancel.
· Any cleanup activities can be taken care here.
Examples
AT SELECTION-SCREEN OUTPUT
In given example, if in Parameter ‘EXIT’ is passed, then the whole screen is hidden.
PARAMETERS: EXIT (10) TYPE c.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN INTO DATA (wa_screen).
IF wa_screen -name = ‘ EXIT ‘.
wa-invisible = ‘1’.
MODIFY screen FROM wa_screen.
ENDIF.
ENDLOOP.
*** Note: We will update examples for other events very soon.
Preface – This post is part of the ABAP Beginner series.
In this article, we have discussed a type of ABAP Report Events i.e. Reporting Events. To learn all about ABAP Report Events click here.
Introduction
In ABAP Report Events after Program Constructor Event of ABAP, we have ABAP Reporting Events which occur in a predefined manner. These events are called in a predefined sequence (as mentioned later in this post). These events are only called in Executable reports.
Types of Reporting Events
Following are the types of Reporting Events:
Event
Description
Status
INITIALIZATION
This event is called just after LOAD-OF-PROGRAM and used to fix default values and initialize fields
–
START-OF-SELECTION
This event is called after the Standard Screens are once processed and is used to write all the functional statements
–
GET node
These are used in reports associated with only logical database and are used to read events of logical database
Obsolete
END-OF-SELECTION
These are used in reports associated with only logical database and is raised when:
• When logical database has completed its work
• Just after START-OF-SELECTION
Obsolete
INITIALIZATION
As discussed above, this event is called just after LOAD-OF-PROGRAM and before any selection screen events; and it is used to fix default values and initialize fields.
Example
PARAMETERS: p_lan TYPE string.
INITIALIZATION.
p_lan = sy-langu.
***Note: In case a standard selection screen is there, multiple calls are made to the same program based upon user input and interaction. INITIALIZATION is ignored after the first call to the program and in this case to initialize the selection screen explicitly for each call we will have to use the event AT SELECTION-SCREEN OUTPUT.
START-OF-SELECTION
As discussed above, this event is called after the Standard Screens are once processed and it is used to write all the functional statements. By functional statements we mean the actual code/ business logic.
Example
REPORT ztest_report.
DATA: text TYPE string.
START-OF-SELECTION.
text = ‘Hello World!’.
Write: text.
*** Note: If I will not write START-OF-SELECTION in above program, still the program will construct a block of START-OF-SELECTION implicitly just before the actual code. Thus we can skip writing START-OF-SELECTION, but it is a good practise to use it as it
Preface – This post is part of the ABAP Beginner series.
In this article, we have discussed a type of ABAP Report Events i.e. List events. To learn all about ABAP Report Events click here.
Introduction
In ABAP Report List means ABAP table. Using List events we can manipulate or perform actions on a list. Interactive report uses list events to interact with a table output.
Types of List events
Following are the types of List events:
Event
Description
TOP-OF-PAGE
[DURING LINE-SELECTION]
It is used to write constants in the header of a page. The header remains fixed against scrolling.
If used without [DURING LINE-SELECTION], TOP-OF-PAGE is triggered as soon the list is created else it loads during particular line selection.
END-OF-PAGE
It is used to write constants in the header of a page. It appears at the end of a page and is generally used to print page number.
It only works in case of LINE-COUNT is defined (will be explained via example).
AT LINE-SELECTION
It is triggered whenever a line of a list is double clicked. The main purpose of this event is in Interactive report where on click of a line item creates details lists.
AT USER-COMMAND
It is triggered whenever a custom button is clicked on UI.
AT PF
It is triggered whenever a function key is pressed on a keyboard.
SET USER-COMMAND
It can be used to auto trigger a button key by setting an fcode to the USER-COMMAND. These fcodes are predefined and you can find them here.
Examples
*** Note: We will update examples for all the events very soon.
Preface – This post is part of the ABAP Beginner series.
Interactive Report in SAP ABAP is a report where user can interact with the output page of report. They can click on an item of a list to get its details. For example, On first page you have been provided basic details of employees and on click of a line item i.e. Employee ID, you are navigated to another page where you can see the employee Annual Salary. If you still want to know further, you again clicked on Employee ID here and now you are navigated to third page where you see employee’s salary structure. These all things are possible using Interactive Report in SAP ABAP.
Introduction
An Interactive Report uses a basic list [list number 0] to show basic information and uses secondary list [1 to 20] to show detailed information. Thus, there are total 21 lists. We use SY-LSIND [System Variable] to get the index number of the list.
Events in ABAP
Before, we learn about events of Interactive report, it is advisable to learn all the ABAP events, because it is common across all the programs. ABAP is an event driven Programming language. ABAP Report Events are used to handle different kinds of events during runtime. It starts with the event name, followed by the programming codes belonging to that event.
It is advisable to use Comment line to declare the end of an event, since Events do not have a closing Keyword and it ends as soon any other Event starts.
There are different kinds of events in ABAP, SAP has categorized these events together.
Categories of Events in ABAP:
There are four categories of Events in ABAP. Among them List Events are the one that helps us to make Interactive Reports:
These events occur during Classical List Processing [List can be a table or consecutive Write statements, etc.]
TOP-OF-PAGE
END-OF-PAGE
AT-LINE-SELECTION
AT USER-COMMAND
AT PFnn
SET USER-COMMAND
Events in Classical Report [Used in Interactive Reports too]:
Classical Reports have following events, these events are common for Interactive Reports:
LOAD-OF-PROGRAM : First event fired, loads program in memory
INITIALIZATION: Initialize variable
START-OF-SELECTION : Actual Business Logic (After START-OF-SELECTION)
END-OF-SELECTION : To end above
AT SELECTION-SCREEN : To validate Multiple Input fields (After Initialization and before START-OF-SELECTION) (After
AT SELECTION-SCREEN OUTPUT: To manipulate Dynamic screen
AT SELECTION-SCREEN ON
AT SELECTION-SCREEN ON END OF
AT SELECTION-SCREEN ON BLOCK
AT SELECTION-SCREEN ON RADIOBUTTON GROUP
AT SELECTION-SCREEN ON VALUE REQUEST
TOP-OF-PAGE : To print heading
END-OF-PAGE: To print footer
Events in Interactive Reports in SAP ABAP – Image Illustration
Events of Interactive Report in SAP ABAP:
TOP-OF-PAGE
END-OF-PAGE
AT-LINE-SELECTION
AT USER-COMMAND
AT PFnn
SET USER-COMMAND
Note: To know more about these events, click here.
Example of Interactive Report in SAP ABAP:
TABLES zBarry_emp.
TABLES zBarry_sal.
PARAMETERS: ip type char20.
DATA : it_emp1 TYPE TABLE OF zBarry_emp,
it_emp2 TYPE TABLE OF zBarry_sal,
wa_emp TYPE zBarry_emp,
wa_emp2 TYPE zBarry_sal,
it_emp3 TYPE TABLE OF zBarry_add,
wa_emp3 TYPE zBarry_add,
fnam TYPE char20,
fval TYPE char8,
fnam1 TYPE char20,
fval1 TYPE char8..
set PF-STATUS 'PFSTATUS'.
SELECT-OPTIONS : p_empid FOR zBarry_emp-empid.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'MAIN'.
sy-lsind = 1.
PERFORM display_data.
ENDCASE.
AT SELECTION-SCREEN.
PERFORM validate_input.
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
TOP-OF-PAGE.
FORMAT COLOR COL_HEADING INVERSE.
WRITE 'BASIC EMPLOYEE DETAILS'.
TOP-OF-PAGE DURING LINE-SELECTION.
IF sy-lsind = 1.
FORMAT COLOR COL_HEADING INVERSE.
WRITE 'EMPLOYEE SALARY DETAILS'.
ELSEIF sy-lsind = 2.
FORMAT COLOR COL_HEADING INVERSE.
WRITE 'EMPLOYEE ADDRESS DETAILS'.
ENDIF.
AT LINE-SELECTION.
PERFORM primary_list.
PERFORM secondary_list.
*&---------------------------------------------------------------------*
*& Form VALIDATE_INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validate_input . "validating input
IF p_empid IS INITIAL.
MESSAGE 'Please Enter Employee Number' TYPE 'E'. "if the employee id field is left blank
ELSE.
SELECT empid FROM zBarry_emp INTO TABLE it_emp1 WHERE empid IN p_empid.
IF sy-subrc <> 0.
MESSAGE 'Please Enter Correct Employee Number' TYPE 'E'. "if wrong employee id is entered
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data . "fetching basic employee details from table
SELECT * FROM zBarry_emp INTO TABLE it_emp1 WHERE empid IN p_empid.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data . "displaying data
FORMAT COLOR COL_NEGATIVE INVERSE.
WRITE:/,3 'Employee ID',
20 'First NAME',
35 'Last NAME'.
SKIP.
LOOP AT it_emp1 INTO wa_emp.
FORMAT COLOR COL_POSITIVE INVERSE.
WRITE : /3 wa_emp-empid,20 wa_emp-emp_fname,35 wa_emp-emp_lname.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PRIMARY_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM primary_list . "fetching employee salary details on list 1
IF sy-lsind = 1.
GET CURSOR FIELD fnam VALUE fval.
IF fnam = 'WA_EMP-EMPID'. "if employee id is selected
SELECT * FROM zBarry_sal INTO TABLE it_emp2 WHERE empid = fval .
FORMAT COLOR COL_NEGATIVE INVERSE.
WRITE:/,3 'Employee ID',
20 'Transaction ID',
35 'Month',
55 'Date Of Salary'.
SKIP.
LOOP AT it_emp2 INTO wa_emp2.
FORMAT COLOR COL_POSITIVE INVERSE.
WRITE : /3 wa_emp2-empid,20 wa_emp2-tid,35 wa_emp2-mon,55 wa_emp2-dos.
ENDLOOP.
ENDIF.
IF fnam = 'WA_EMP-EMP_FNAME'. "if employee name is selected
WRITE: / 'name'.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SECONDARY_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM secondary_list . "fetching employee address details on list 2
IF sy-lsind = 2.
GET CURSOR FIELD fnam1 VALUE fval1.
IF fnam = 'WA_EMP-EMPID'. "if employee id is selected
SELECT * FROM zBarry_add INTO TABLE it_emp3 WHERE empid = fval1 .
FORMAT COLOR COL_NEGATIVE INVERSE.
WRITE:/,3 'Employee ID',
20 'Flat No.',
35 'Street Name',
55 'City Name'.
SKIP.
LOOP AT it_emp3 INTO wa_emp3.
FORMAT COLOR COL_POSITIVE INVERSE.
WRITE : /3 wa_emp3-empid,20 wa_emp3-flat_no,35 wa_emp3-street_name,55 wa_emp3-city_name.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM.
Note: To learn more about how this program is functioning, click here.
Programming Guidelines:
Never use Selection Screen Events in Function Module
Use LOAD-OF-SCREEN to load default values for the type of Reports executed via SUBMIT or using a transaction code
Use INITIALIZATION to load default values for the executable type of Reports
It is advised not to specify an event more than once [Except AT-SELECTION-SCREEN & GET event, all other can be specified multiple times.]
If you are not specifying any event name, still specify START-OF-SELECTION to improve readability
After every execution of events NEW-LINE event is executed automatically.
Preface – This post is part of the ABAP Beginner series.
ABAP is an event driven Programming language. ABAP Report Events are used to handle different kinds of events during runtime. It starts with the event name, followed by the programming codes belonging to that event. Classical reports in SAP ABAP are the reports which contain both selection screens and output screens.
It is advisable to use Comment line to declare the end of an event, since Events do not have a closing Keyword and it ends as soon any other Event starts.
There are different kinds of events in ABAP; SAP has categorized these events together.
Categories of Classical Report Events in SAP ABAP:
Preface – This post is part of the ABAP Beginner series.
ABAP report is an old term for executable program in ABAP and it is a program that can be executed using the SUBMIT statement. This SUBMIT statement is always executed internally as we execute it using F8 user command or via a Transaction code.
Both these Reports are event driven. The only thing that divides them is the use of different events.
Classical Report
A classical report is a report which contains both selection screens and output screens.
Events in Classical Report
Classical Reports have following events:
LOAD-OF-PROGRAM : First event fired, loads program in memory
INITIALIZATION: Initialize variable
START-OF-SELECTION : Actual Business Logic (After START-OF-SELECTION)
END-OF-SELECTION : To end above
AT SELECTION-SCREEN : To validate Multiple Input fields (After Initialization and before START-OF-SELECTION) (After
AT SELECTION-SCREEN OUTPUT: To manipulate Dynamic screen
AT SELECTION-SCREEN ON
AT SELECTION-SCREEN ON END OF
AT SELECTION-SCREEN ON BLOCK
AT SELECTION-SCREEN ON RADIOBUTTON GROUP
AT SELECTION-SCREEN ON VALUE REQUEST
TOP-OF-PAGE : To print heading
END-OF-PAGE: To print footer
Events in Classical Report – Image Illustration
Interactive Report
An interactive report is a report in which the information are shown using basic and secondary lists. An interactive report has total 21 lists including the basic list. The first list is numbered as 0 and other are from 1 to 20.
To get the current page number, we can use system variable SY-LSIND.
Preface – This post is part of the ABAP Beginner series.
ABAP Report Events: Reporting Events
In ABAP Report Events after Program Constructor Event of ABAP, we have ABAP Reporting Events which occur in a predefined manner. These events are called in a predefined sequence (as mentioned later in this post). These events are only called in Executable reports.
Following are the types of Reporting Events:
Event
Description
Status
INITIALIZATION
This event is called just after LOAD-OF-PROGRAM and used to fix default values and initialize fields
–
START-OF-SELECTION
This event is called after the Standard Screens are once processed and is used to write all the functional statements
–
GET node
These are used in reports associated with only logical database and are used to read events of logical database
Obsolete
END-OF-SELECTION
These are used in reports associated with only logical database and is raised when:
· When logical database has completed its work
· Just after START-OF-SELECTION
Obsolete
INITIALIZATION
As discussed above, this event is called just after LOAD-OF-PROGRAM and before any selection screen events; and it is used to fix default values and initialize fields.
Example
PARAMETERS: p_lan TYPE string.
INITIALIZATION.
p_lan = sy-langu.
***Note: In case a standard selection screen is there, multiple calls are made to the same program based upon user input and interaction. INITIALIZATION is ignored after the first call to the program and in this case to initialize the selection screen explicitly for each call we will have to use the event AT SELECTION-SCREEN OUTPUT.
START-OF-SELECTION
As discussed above, this event is called after the Standard Screens are once processed and it is used to write all the functional statements. By functional statements we mean the actual code/ business logic.
Example
REPORT ztest_report.
DATA: text TYPE string.
START-OF-SELECTION.
text = ‘Hello World!’.
Write: text.
*** Note: If I will not write START-OF-SELECTION in above program, still the program will construct a block of START-OF-SELECTION implicitly just before the actual code. Thus we can skip writing START-OF-SELECTION, but it is a good practise to use it as it makes the code readable.