What are Reports and their Types in SAP ABAP [With Examples]

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
  • Views

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.

EventsDescription
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-PageData is displayed on a new page as a result of the first WRITE statement.
End-of-PageIt 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
EventsDescription
AT-LINE SELECTIONThis 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-COMMANDThis event provides the user functions keys.
AT PFFor 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.

Step-1:

  • Open SAP ABAP and type the transaction code SE38 in the search bar and hit enter.
Classical report in SAP ABAP

Step-2:

  • Give the report name and click Create.
  • Here for my understanding purpose, I have given the name ZREPORT_C, C for the classical report.
Classical report in SAP ABAP SE38

Step-3:

  • 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.
Create classical report in SAP ABAP

Step-4:

  • After saving, the ABAP report page will open with the name we have declared by default.
Classical report in SAP ABAP

Step-5:

  • 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
SAP ABAP Classical report

Step-6:

  • 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.
Create Classical report from SAP ABAP

Step-7:

  • 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.
SAP ABAP Classical report creation

Step-8:

  • 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.
Create classical report in the SAP ABAP

Step-9:

  • Save the program by CTRL+S and activate the program by clicking the execute icon at the top or by clicking the F8 key.
Execute classical report in SAP ABAP

Step-10:

  • 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.
Output in SAP ABAP Classical Report

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

Classical Error report in SAP ABAP

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?

Activation Error in SAP ABAP

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.

Example-2 Output

Below is the output for the classical report for the second example.

Classical report example in SAP ABAP

You may also like:

Conclusion

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