SAP ABAP Report Programming
⚡ Smart Summary
ABAP Report Programming builds executable programs that select, process, and display large volumes of SAP data. This page explains the report header additions, the selection screen, the event sequence, formatting commands, interactive lists, and logical databases.

What is ABAP Report Programming?
SAP-ABAP supports two types of Programs – Report Programs & Dialog Programs. Report Programs are used when large amounts of data needs to be displayed
Purpose/Use of Report Programs
- They are used when data from a number of tables have to be selected and processed before presenting
- Used when reports demand a special format
- Used when the report has to be downloaded from SAP to an Excel sheet to be distributed across.
- Used when the report has to be mailed to a particular person.
Important Points to Note About Report Program
- Report Programs are always Executable Programs. Program Type is always 1.
- Every Report program corresponds to a particular Application Type i.e. either with Sales & Distribution, FI – CO etc. It can also be Cross Application i.e. type ‘*’.
- Report Programming is an Event-driven programming.
- The first line of a report program is always Report <report-name>.
- To suppress the list heading or the name of the program the addition No Standard Page Heading is used.
- The line size for a particular report can be set by using the addition line-size <size>.
- The line count for a particular page can be set by using the addition line-count n(n1). N is the number of lines for the page and N1 is the number of lines reserved for the page footer.
- To display any information or error message we add a message class to the program using the addition: Message-id <message class name>. Message classes are maintained in SE91.
Therefore an ideal report program should start with:
Report <report name> no standard page heading line-size <size> line-count <n(n1)> message-id <message class>.
Report Program vs Dialog Program
Both program types run in the same system, yet they solve opposite problems. A report reads and displays data, while a dialog program lets a user maintain it through screens.
| Criteria | Report Program | Dialog Program |
|---|---|---|
| Program type | Type 1, executable | Type M, module pool |
| Started by | Program name or a transaction code | A transaction code only |
| Flow control | Events such as INITIALIZATION and START-OF-SELECTION | Screen flow logic with PBO and PAI modules |
| User input | A generated selection screen | Screens designed in the Screen Painter |
| Typical use | Displaying and downloading large data volumes | Creating and changing business data |
The selection screen is where a report collects its input, so it is described next.
Selection Screen
“Selection screen” is the screen where one specifies the input values for which the program should run.
The selection screen is normally generated from the
- Parameters
- Select-Options
Syntax
Selection-screen begin of screen <screen #> selection-screen begin of block <#> with frame title <text> ......... ......... selection-screen end of block <#> selection-screen end of screen <screen #>
Parameters
Parameters help one to do dynamic selection. They can accommodate only one value for one cycle of execution of the program.
Syntax
Defining parameters as a data type
Parameters p_id(30) type c.
Defining parameters like a table field.
Parameter p_id like <table name>-<field name>.
Parameters can be Checkboxes as well as Radiobuttons.
Parameters p_id as checkbox.Parameters p_id1 radiobutton group <group name>. Parameters p_id2 radiobutton group <group name>.
Parameters can be listbox.
Parameter p_id like <table name>-<field name> as listbox
Select Options
A Select-Option is used to input a range of values or a set of values to a program
Syntax
select-options s_vbeln for vbak-vbeln.
The screenshot shows the low and high input fields that a select option generates, together with the multiple selection button.
You can also define a select option like a variable
select-options s_vbeln for vbak-vbeln no intervals no-extension
Once the input is collected, the program reacts to a fixed sequence of events.
Events in an ABAP Report Program
ABAP report programs are event driven programs. The different events in a report Program are:
Load-of-program
- Triggers the associated event in an internal session after loading a program of type 1, M, F, or S.
- Also runs the associated processing block once and once only for each program and internal session.
- The processing block LOAD-OF-PROGRAM has roughly the same function for an ABAP program of type 1, M, F or S as a constructor has for classes in ABAP Objects
Initialization.
- This event is executed before the selection screen is displayed .
- Initialization of all the values.
- You can assign different values other than the values defaulted on the selection screen .
- You can fill your selection screen with some values at runtime.
At Selection-Screen.
- The event is processed when the selection screen has been processed (at the end of PAI ).
- Validation & Checks of inputted values happen here
Start-of-Selection.
- Here the program starts selecting values from tables.
End-of-selection.
- After all the data has been selected this event writes the data to the screen.
Interactive Events
- Used for interactive reporting. It is used to create a detailed list from a basic list.
💡 Tip: Statements written without any event keyword belong to START-OF-SELECTION by default, which is why a report still runs when the event is missing.
Example: A Simple ABAP Report Program
The program below joins the additions, the selection screen, and the events into one working report. It reads sales order headers from VBAK for the numbers entered on the selection screen and writes them as a list.
REPORT z_sales_order_list NO STANDARD PAGE HEADING LINE-SIZE 80 LINE-COUNT 65(3) MESSAGE-ID zsd. TABLES: vbak. DATA: lt_vbak TYPE STANDARD TABLE OF vbak, ls_vbak TYPE vbak. * Selection screen SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. PARAMETERS: p_erdat LIKE vbak-erdat. INITIALIZATION. p_erdat = sy-datum. AT SELECTION-SCREEN. IF p_erdat > sy-datum. MESSAGE e001(zsd). " Date must not lie in the future ENDIF. START-OF-SELECTION. SELECT * FROM vbak INTO TABLE lt_vbak WHERE vbeln IN s_vbeln AND erdat LE p_erdat. END-OF-SELECTION. LOOP AT lt_vbak INTO ls_vbak. WRITE: / ls_vbak-vbeln, ls_vbak-erdat, ls_vbak-netwr. HIDE ls_vbak-vbeln. ENDLOOP.
Three details are worth noting. INITIALIZATION fills the date parameter before the selection screen appears. AT SELECTION-SCREEN validates the entry and raises a message from class ZSD. HIDE stores the order number of each written row, so a double click can build a secondary list from it, which is the subject of the next section.
Formatting the report
ABAP allows the reports to be formatted as the user wants it to be. For example, “Alternate Lines” must appear in different colors and the “Totals” line should appear in Yellow.
Syntax
Format Color n Format Color n Intensified On
n may correspond to various numbers
Please note that there are other additions along with format as well
FORMAT COLOR OFF INTENSIFIED OFF INVERSE OFF HOTSPOT OFF INPUT OFF
Interactive Report Programming
- Using Interactive Programming users can actively control the data retrieval and display of data
- Used to create a detailed list from a very basic list
- The detailed data is written on a secondary list.
- The secondary list may either completely overlay the first screen or one can display it in a new screen
- The secondary lists can be themselves interactive.
- The first list may also call a transaction.
- There are different events associated with interactive programming.
Some commands used for interactive programming
Hotspot
If one drags the mouse over the data displayed in the report the cursor changes to a Hand with an Outstretched Index finger. An hotspot can be achieved using the FORMAT statement.
Syntax: Format Hotspot On (Off).
Hide
This command helps you to store the field names based on which one will be doing further processing to get a detailed list. It is written directly after the WRITE statement for a field. When a row is selected the values get automatically filled in the variables for further use.
Syntax: Hide <field-name>.
Reports that read many tables can replace their SELECT statements with a logical database, described below.
Logical Databases
- Instead of using “Select” queries you can use logical database to retrieve data for a program.
- Logical databases are created by transaction SE36
- The name of a logical database can be up to 20 characters long. It may begin with a namespace prefix.
- The data is selected by another program and one can access the data using GET <table-name> command which places the data in the work area <table-name>.
Advantages of a logical database over normal Select queries.
- It offers check conditions to see whether the input is correct, complete and plausible
- It contains central authorization checks for database access
- Enhancements such as improvement in performance immediately apply to all reports which use logical database.
Note: Due to the complexities involved, logical databases are not used in most of the cases
