There are multiple types of reports in SAP ABAP language like Classical Report, Interactive Report and ALV Report. In this article, we will be knowing about Classical Report.
Classical Report
Classical Reports are used in scenario where you want to display the entire output in a single list called basic list. There are multiple events used in Classical Report -
1) INITIALIZATION.
This is the first event to trigger in ABAP report. This allows the user to maintain default values in the selection-screen.
Syntax:
INITIALIZATION. |
|---|
2) AT SELECTION-SCREEN.
This event works only if you have added selection-screen in your program. It triggers once the selection-screen is displayed and used for validation for the pre-defined values in the selection-screen.
Syntax :
AT SELECTION-SCREEN ON <FIELDNAME>. |
|---|
3) START-OF-SELECTION.
This event is default in any ABAP program. But if you have used INITIALIZATION and AT SELECTION-SCREEN in your program you need to declared it manually. This event is used to extract data from the database and thus is an important event.
START-OF-SELECTION. |
|---|
4) END-OF-SELECTION.
This event triggers after the data is being is extracted and after that the first record in the output list is displayed.
Syntax :
END-OF-SELECTION. |
|---|
5) TOP-OF-PAGE.
This event helps in giving heading to the report.
Syntax :
TOP-OF-PAGE. |
|---|
6) END-OF-PAGE.
This event helps in maintaining the footer.
Syntax :
END-OF-PAGE. |
|---|
To understand more about classical report let's take a requirement and display the output.
REQUIREMENT: From the LFA1 table, display the fields - LIFNR, NAME1, ORT01 and PSTLZ.
Every report in SAP ABAP start with REPORT keyword. Here YCLASSICAL_LFA1 is the name of the program.
REPORT YCLASSICAL_LFA1 NO STANDARD PAGE HEADING. |
|---|
Name of the table or tables you want in the program.
TABLES: LFA1. |
|---|
Select-Options is used to define a range.
L_LIFNR is the variable to store the range.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000. |
|---|
Creating structure for LFA1 table with the name TY_STR.
TYPES: BEGIN OF TY_STR, |
|---|
Creating Internal Table with name "IT" and Work Area with "WA".
DATA: IT TYPE TABLE OF TY_STR, |
|---|
Performing Initialization.
INITIALIZATION. |
|---|
At selection-screen for Validation.
AT SELECTION-SCREEN ON L_LIFNR. |
|---|
To get data from the database.
START-OF-SELECTION.
END-OF-SELECTION. |
|---|
Displaying the data.
WRITE:/ 'LIFNR' COLOR 5, 10 'NAME1' COLOR 5, 40 'ORT01' COLOR 5, 60 'PSTLZ' COLOR 5. |
|---|
To give the heading at the top of page.
TOP-OF-PAGE. |
|---|
The whole program should look like the following-
REPORT YCLASSICAL_LFA1 NO STANDARD PAGE HEADING. WRITE:/ 'LIFNR' COLOR 5,
WRITE:/ WA-LIFNR,
|
|---|
Comments
Post a Comment