How to create Simple Report in SAP ABAP
Classical Reports
These are the most simple reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop.
Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.
Events In Classical Reports.
INTIALIZATION: This event triggers before selection screen display.
AT-SELECTION-SCREEN: This event triggers after proccesing user input still selection screen is in active mode.
START OF SELECTION: Start of selection screen triggers after proceesing selection screen.
END-OF-SELECTION : It is for Logical Database Reporting.
Events in Classical Reports.
The following are the list of Events in Classical Reports.
1. Load-of-program
The Load-of-program event loads the program into memory for execution. Always, Load-of-program is the first event in execution sequence.
2. Initialization
Initialization is an event that is used for initialize variables, screen values and other default actions.
3. At Selection-Screen output
One of the selection screen events is used to manipulate dynamic selection-screen changes.
4. At Selection-Screen on field
It is used to validates the screen input parameter.
5. At Selection-Screen on value request
This selection screen event allows for a value help or field help for an input field.
6. At Selection-Screen on help request
This selection screen event enables function key F1 help for a input field.
7. At Selection-Screen
Selection screen validates various input fields.
8. Start-of-Selection
This is the default event in any ABAP program and is activated whether we use it explicitly or not .
9. End-of-Selection
This event signals that event of what has been initiated by the start-of-selection event.
10. Top-of-Page
This event is used to print the same heading for all pages.
11. End-of-Page
This event is used to print the same footer for all pages.
*&---------------------------------------------------------------------*
*& Report ZDEMO_PROGRAM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDEMO_PROGRAM.
*report program started
TYPES: BEGIN OF ZVBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERZET TYPE VBAK-ERZET,
ERNAM TYPE VBAK-ERNAM,
END OF ZVBAK.
data : it_vbak type table of zvbak,
wa_vbak type zvbak.
select-options : s_vbeln for wa_vbak-vbeln.
initialization.
s_vbeln-low = '4969'.
s_vbeln-HIGH = '4986'.
s_vbeln-SIGN = 'I'.
s_vbeln-OPTION = 'BT'.
APPEND S_vbeln.
START-OF-SELECTION.
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE IT_vbak.
TOP-OF-PAGE.
WRITE :/50 'Sales Document: Header Data'.
ULINE.
END-OF-PAGE.
WRITE :/50 ' THANK U VISIT AGAIN'.
ULINE.
END-OF-SELECTION.
LOOP AT IT_vbak into WA_vbak.
WRITE :WA_vbak-vbeln,
WA_vbak-erdat,
WA_vbak-erzet,
WA_vbak-ernam.
ENDLOOP.
Check,activate and Execute the Program.
You can get the output like in the below Image.
These are the most simple reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop.
Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.
Events In Classical Reports.
INTIALIZATION: This event triggers before selection screen display.
AT-SELECTION-SCREEN: This event triggers after proccesing user input still selection screen is in active mode.
START OF SELECTION: Start of selection screen triggers after proceesing selection screen.
END-OF-SELECTION : It is for Logical Database Reporting.
Events in Classical Reports.
The following are the list of Events in Classical Reports.
1. Load-of-program
The Load-of-program event loads the program into memory for execution. Always, Load-of-program is the first event in execution sequence.
2. Initialization
Initialization is an event that is used for initialize variables, screen values and other default actions.
3. At Selection-Screen output
One of the selection screen events is used to manipulate dynamic selection-screen changes.
4. At Selection-Screen on field
It is used to validates the screen input parameter.
5. At Selection-Screen on value request
This selection screen event allows for a value help or field help for an input field.
6. At Selection-Screen on help request
This selection screen event enables function key F1 help for a input field.
7. At Selection-Screen
Selection screen validates various input fields.
8. Start-of-Selection
This is the default event in any ABAP program and is activated whether we use it explicitly or not .
9. End-of-Selection
This event signals that event of what has been initiated by the start-of-selection event.
10. Top-of-Page
This event is used to print the same heading for all pages.
11. End-of-Page
This event is used to print the same footer for all pages.
Creating Simple Report in SAP ABAP
*&---------------------------------------------------------------------*
*& Report ZDEMO_PROGRAM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDEMO_PROGRAM.
*report program started
TYPES: BEGIN OF ZVBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERZET TYPE VBAK-ERZET,
ERNAM TYPE VBAK-ERNAM,
END OF ZVBAK.
data : it_vbak type table of zvbak,
wa_vbak type zvbak.
select-options : s_vbeln for wa_vbak-vbeln.
initialization.
s_vbeln-low = '4969'.
s_vbeln-HIGH = '4986'.
s_vbeln-SIGN = 'I'.
s_vbeln-OPTION = 'BT'.
APPEND S_vbeln.
START-OF-SELECTION.
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE IT_vbak.
TOP-OF-PAGE.
WRITE :/50 'Sales Document: Header Data'.
ULINE.
END-OF-PAGE.
WRITE :/50 ' THANK U VISIT AGAIN'.
ULINE.
END-OF-SELECTION.
LOOP AT IT_vbak into WA_vbak.
WRITE :WA_vbak-vbeln,
WA_vbak-erdat,
WA_vbak-erzet,
WA_vbak-ernam.
ENDLOOP.
Check,activate and Execute the Program.
You can get the output like in the below Image.