Are you confused about reports in SAP ABAP? Check out this SAP tutorial, here I will discuss what are reports and their types in SAP ABAP.
Also, I will explain the events in the classical reports for the ABAP Editor and will show how to create classical reports with two examples.
What are Reports in SAP ABAP
A report is a collection of data presented in a structured manner. SAP ABAP programs are written as reports. When a larger volume of data is presented, we need SAP ABAP programming. We will see briefly about reports in this tutorial.
Types of Reports in SAP ABAP
In SAP ABAP, we have 7 types of reports namely,
- Classical Report
- Interactive Report
- Logical Database
- ABAP Query
- ABAP List Viewer Reports(ALV)
- Report Writer/ Report Painter
Check out: How to Create a Foreign Key in SAP ABAP
Classical Report in SAP ABAP
Classical reports are the simple and basic reports in SAP ABAP. Developers will start with the classical reports.
We can take the output by using the WRITE statement. In this report, we don’t have any other functionalities like sorting, arranging, or filtering data.
Events in Classical Report in SAP ABAP
Below is the sequential order of events in the classical report.
|Initialization||This is the first step in the classical report. This will be activated before displaying the selection screen.|
|AT Selection Screen||Started activating after the user’s input in the selection screen. This event checks the user input before the execution of the program. Once the user input is processed, the selection screen will be in active mode.|
|Start-of-Selection||Activated once after the processing of the selection screen that is when the user tries to execute on the selection screen.|
|End-of-Selection||It will start activating after the last statement in Start-of-Selection is executed.|
|Top-of-Page||Data is displayed on a new page as a result of the first WRITE statement.|
|End-of-Page||It will display the text at the end of the page. This is the last event in creating the classical report in SAP ABAP.|
Interactive Reports in SAP ABAP
In the interactive report, the user can interact with the report. If the user wants specific information about a particular employee, but the column shows all the employee details then we can hide that data under employee details.
When the user clicks the employee details, the subreport which has particular employee details will be displayed.
Events in Interactive Report
Events in the interactive reports are as follows:
- AT-LINE SELECTION
- AT USER-COMMAND
- At Predefined Function (PF)
- Top of Page during Line Selection
|AT-LINE SELECTION||This will initiate when we double-click on the list when the event is initiated, then a new sublist will be generated. In this event, if the statements have been returned and we can be seen in the newly generated sublist.|
|AT USER-COMMAND||This event provides the user functions keys.|
|AT PF||For predefined function keys.|
|Top of Page during Line Selection||Top event for the secondary list.|
Logical Database Report in SAP ABAP
It is another tool for the ABAP report. We have some additional features on ABAP reports if we are using logical database reports (LDB). No need to declare parameters while using LDB. The selection screen will be automatically generated. We should use the statement Nodes in the ABAP report.
ABAP Query Reports in SAP ABAP
This is also another tool for ABAP reports. This report has high accuracy and efficiency in the SAP ABAP.
ABAP List Viewer (ALV)
The easiest way to reuse the library (transaction se83). It has two modes in the ALV such as list and grid. The list has some standard functionalities and it is an old process whereas grid mode is following a new OCX object displaying grids.
Report Writer/ Report Painter
Rather than using ABAP code to write a report in financial (FI) and controlling (CO), many users use a Report Painter/ Report Writer library using transaction MC27.
However, this also has some disadvantages. The use of the GRCT transaction code will solve the issues and it makes avoiding the use of the MC27 transaction code.
How to Create Classical Reports in SAP ABAP
Here we will see step by step how to create a classical report in SAP ABAP.
Example – 1: [Without Structure]
Here we will see how to create classical reports in SAP ABAP without structure.
- Open SAP ABAP and type the transaction code SE38 in the search bar and hit enter.
- Give the report name and click Create.
- Here for my understanding purpose, I have given the name ZREPORT_C, C for the classical report.
- Now program attribute page will open.
- Give a short description of the Demo for the classical report and give the type as Executable program and click Save.
- After saving, the ABAP report page will open with the name we have declared by default.
- Before declaring the table name, give the line size and line count and No standard page heading. Then give the table name.
- Line count: It denotes the total number of lines that can fit into a page, if the number of lines in the report exceeds, then a new page is automatically created.
- Line size: It declares the number of letters that can be occupied in a particular row. if the number of characters goes beyond than this then a new line is automatically created.
Report zreport_c line-size 125 line-count 10(2) No standard heading. Tables zcomp_employer
- Now declare the internal table and work area for the table.
DATA : IT_ZCOMP_EMPLOYER TYPE TABLE OF ZCOMP_EMPLOYER, WA_ZCOMP_EMPLOYER TYPE ZCOMP_EMPLOYER.
- In this step, we have to declare the selection statement. Here I want to show all the fields in the table so I am using * in the selection statement.
START-OF-SELECTION. SELECT * FROM ZCOMP_EMPLOYER INTO TABLE ZCOMP_EMPLOYER. END-OF-SELECTION.
- The next step is to declare a loop statement. We are looping the internal table into the work area for the table.
Loop AT IT_ZCOMP_EMPLOYER into WA_ZCOMP_EMPLOYER. WRITE : / WA_ZCOMP_EMPLOYER-EMID, WA_ZCOMP_EMPLOYER-EMNAME, WA_ZCOMP_EMPLOYER-EMPHN, WA_ZCOMP_EMPLOYER-EMCON. ENDLOOP.
- Save the program by CTRL+S and activate the program by clicking the execute icon at the top or by clicking the F8 key.
- We can see the below output for the classical report. We can see the exact output of the table here. And sometimes it will change depending upon our requirements.
This is one example of the classical report in SAP ABAP.
Example – 2: [With Structure]
Here we will see how to create classical reports in SAP ABAP with structure.
Follow the above steps(steps 1- step-10) to write in the se38 ABAP Dictionary. Here I have declared the structure for the table, the rest are the same in the declaration.
TABLES: ZCOMP_EMPLOYER2. TYPES: BEGIN OF ST, EMID TYPE EMID, EMPFN TYPE EMPFN, EMCN TYPE EMCN, END OF ST. DATA: IT_ZCOMP_EMPLOYER2 TYPE TABLE OF ZCOMP_EMPLOYER2, DATA: WA_ZCOMP_EMPLOYER2 TYPE ZCOMP_EMPLOYER2. START-OF-SELECTION. SELECT * FROM ZCOMP_EMPLOYER2 into table IT_ZCOMP_EMPLOYER2. END-OF-SELECTION. LOOP AT IT_ IT_ZCOMP_EMPLOYER2 INTO WA_IT_ZCOMP_EMPLOYER2. WRITE: / WA_ZCOMP_EMPLOYER2-EMID, WA_ZCOMP_EMPLOYER2-ENAME, WA_ZCOMP_EMPLOYER2-EMPFN, WA_ZCOMP_EMPLOYER2-EMCN. ENDLOOP.
This is the second example classical report where we declared structure here.
Error Message for Wrong End Statement
Check the below error to avoid in the program in SAP ABAP.
The beginning and end statements should be in the correct way. If it is given wrong, it will throw an error.
I have declared start-of-selection in the program, but while finishing instead of end-of-selection, I have given end-select. So the below error appears.
What Happens if it shows the Period is Missing?
Note – Make sure you have given commas and that a full stop was given properly. Else it will show an error period is missing.
In this way, we have to debug the error for the classical report in SAP ABAP.
Below is the output for the classical report for the second example.
You may also like:
- How to Logon to SAP System
- How to Configure SAP Business Application Studio Development for SAP HANA
- How to Use Select Statement in SAP HANA Cloud
I hope this tutorial helps you out with what are reports and their types with the events as well. I also explained the simple classical report with two examples and an error message as well in SAP ABAP. Below are the topics covered in this tutorial.
- Classical reports and their events
- Interactive reports and their events
- Logical Database
- ABAP Query
- ABAP List View
- Report writer/ Painter
- How to create a Classical report with an example
- Error message in the classical report
I am Chris Waldron, working as a Senior SAP HANA Consultant at Halliburton, Houston, Texas, United States. I have been working in SAP for more than 15 years, especially in SAP IT consulting and business consulting. I worked in various industries in Sales & Distribution, Customer Relationship Management, banking, Risk Management, etc. And I am an SAP Certified Development Specialist – ABAP for SAP HANA 2.0 and SAP HANA Modeling Certified consultant. Read more