Reports
Reports
Report is the combination of given inputs to the selection-screen retrieving the data from data base
based on the given input & display the output in a predefined format.
Types of reports:
Classical reports
Interactive reports
ALV reports
a) Classical report
A report with single input screen (selection screen) and single output screen (list screen) is called
Classical report.
Events in Classical Reports: - All the ABAP programs are developed using events because ABAP is
“EVENT DRIVEN PROGRAMMING LANGUAGE” i.e., the entire ABAP program execution is based on order
of events.
LOAD-OF-PROGRAM
INITIALIZATION
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN ON FIELD
AT SELECTION-SCREEN ON VALUE REQUEST
AT SELECTION-SCREEN ON HELP REQUEST
AT SELECTION-SCREEN
START OF SELECTION
END OF SELECTION
TOP-OF-PAGE
END-OF-PAGE
Load of program:
This event is used to load the program into the memory for execution.
Initialization:
At selection-screen output:
It’s an event which is triggered at the selection-screen based on the user action.
This is used to modify the selection-screen.
At selection-screen on field:
It’s an event which is triggered at the selection-screen based on particular input field.
At selection-screen on value-request:
It’s an event which is triggered at the time of click on F4 button. This is used to provide the list of
possible values to the input variables.
At selection-screen on help-request:
It’s an event which is triggered at the time of click on F1 button. This is used to provide the help
document to the input variable
At selection-screen:
It’s an event which is triggered after provide the input to the screen & before leaving the selection-
screen.
Start-of-selection: It’s an event which is triggered after leaving the selection-screen & before display
the output. This is used to fetch the data from data base & place into internal table.
End-of-selection:
INITIALIZATION.
p_vkorg = 1710.
AT SELECTION-SCREEN.
SELECT SINGLE vkorg INTO gv_Vkorg FROM vbak WHERE vkorg = p_vkorg.
IF sy-subrc NE 0.
MESSAGE 'Please provide correct value of sales organization' TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
** AT SELECTION-SCREEN ON FIELD.
** AT SELECTION-SCREEN ON VALUE-REQUEST FOR FIELD.
** AT SELECTION-SCREEN ON HELP-REQUEST FOR FIELD.
START-OF-SELECTION.
SELECT * FROM Vbak INTO TABLE gt_vbak WHERE vkorg = p_vkorg.
END-OF-SELECTION.
LOOP AT gt_vbak INTO gs_Vbak.
WRITE:/ gs_Vbak-vbeln,
gs_Vbak-erdat,
gs_Vbak-ernam,
gs_Vbak-auart,
gs_Vbak-vkorg.
HIDE gs_Vbak-vbeln.
ENDLOOP.
TOP-OF-PAGE.
ULINE.
WRITE: 'Sales order' , ' created date' , 'created by' , 'Sales order type
', 'Sales organization'.
ULINE.
END-OF-PAGE.
ULINE.
WRITE: 'continue' , sy-pagno.
ULINE.
OUTPUT
b) Interactive Report
It’s nothing but to display the summarized information in the first list & detailed information in the
secondary list.
The remaining lists are called secondary lists and the number starts from 1 to 20.
So, there are total 21 lists. We can view multiple lists simultaneously.
If you select any line, then the selected line data is stored in SY-LISEL.
1. At line selection
2. At user-command.
4. At PF <Function Key>
At line selection:
It’s an event which is triggered at the time of user clicks on any record of any list. To know the
selected contents, we have two Key words.
HIDE
GET CURSOR
Hide is a key word which is used to hide the data temporarily memory is called as HIDE area for
further processing.
We use the HIDE statement with in the LOOP……END LOOP, so that the hide key word will hide the
values into hide area.
Functionality of HIDE: Whenever the user double clicks on any list line, the event at line selection
will be triggered.
The system automatically identifies the line number where the user has double clicked and reads
the corresponding record into hide variable.
GET-CURSOR: Get-cursor technique writes the field name as well as field value which is clicked by
the user.
It’s an event which is triggered at the time of user clicks on any menu item.
At PF <Functional Key> : It’s an event which is triggered at the time of user clicks on F1 to F12
function keys.
ALV Reports are mainly used to display the data in the form of either Grid or List Format with good
look and feel.
2. Pre defined options given by SAP like Asc, Desc, Filtering, Downloading, Changing Layout, sending
Mail.... etc.
REUSE_ALV_BLOCKED_LIST_DISPLAY--Display blocked
Hierarchical ALV
Blocked ALV
STEPS:
Click on Create.
Select Local Object.
Source Code:
*&---------------------------------------------------------------------*
*& Report ZALV
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALV.
Output
ALV WITH FIELD CATALOG:
Field Catalog:
It is an internal table which contains the list of the fields along with the field properties to be displayed
in ALV Report
1. COL_POS = 1
10. EMPHASIZE ='CXYZ' --> Specifies the color to the fields C--> Indicates color X--> Color Numbers Y-->
Background color---- 1 on BG color 0 off BG color Z--> Font color---1 On Font color 0 Off Font color
11. REFERENCE TABLENAME REFERENCE FIELDNAME -->To copy all the properties from data dictionary
to a field catalog field.
1) Manually
2) Automatically by using FM
Program using ALV with MANUAL FIELD CATALOG
For single field
*&---------------------------------------------------------------------*
*& Report ZALV_WITH_FIELD_CAT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALV_WITH_FIELD_CAT.
type-pools slis.
data : gt_vbak type table of vbak,
gt_Fcat type slis_t_fieldcat_alv,
gs_fcat type slis_fieldcat_alv.
gs_fcat-col_pos = 1.
gs_fcat-fieldname = 'VBELN'.
gs_fcat-seltext_m = 'sales order'.
append gs_fcat to gt_fcat.
OUTPUT
***field catalog for multiple records
TYPE-POOLS slis.
DATA : gt_vbak TYPE TABLE OF vbak,
gt_Fcat TYPE slis_t_fieldcat_alv,
gs_fcat TYPE slis_fieldcat_alv.
SELECT * FROM vbak INTO TABLE gt_vbak.
gs_fcat-col_pos = 1.
gs_fcat-fieldname = 'VBELN'.
gs_fcat-seltext_m = 'sales order'.
gs_Fcat-key = 'X '.
* it will show different color ******
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = 2.
gs_fcat-fieldname = 'ERDAT'.
gs_fcat-seltext_m = 'CREATED DATE'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = 3.
gs_fcat-fieldname = 'ERNAM'.
gs_fcat-seltext_m = 'CREATED BY'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = 4.
gs_fcat-fieldname = 'AUART'.
gs_fcat-seltext_m = 'SO DOC TYPE'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = 5.
gs_fcat-fieldname = 'VKORG'.
gs_fcat-seltext_m = 'sales organization'.
APPEND gs_fcat TO gt_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = gt_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* O_PREVIOUS_SRAL_HANDLER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_vbak
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Output
Program using ALV with FIELD CATALOG MERGE.
*&---------------------------------------------------------------------*
*& Report ZALV6
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALV6.
DATA: GT_EKKO TYPE TABLE OF EKKO,
GT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_FCAT TYPE SLIS_FIELDCAT_ALV.
Layout:
It is a structure or work area which is used to decorate or embellish the output of ALV report. Layout
contains the few properties to decorate the ALV output.
2. COLWIDTH-OPTIMIZE='X'. Each column in ALV o/p displayed with maximum length, to display the
entire data.
OUTPUT
ALV with GRAND TOTALS:
The totals can be calculated in two ways By clicking on ∑ALV output field. By programmatically setting
the option DO_SUM='X', for a currency/quantity field in FCAT.