Professional Documents
Culture Documents
CLASSICAL REPORTS
CLASSICAL REPORTS
A report with single input screen (selection screen) and single output screen (list
screen) is called a 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
At Selection-screen
At Selection-screen
At Selection-screen
At Selection-screen
Start of selection
End of selection
Top of page
output
on field
on value request
on Help Request
End of page
Load of Program: - This event is used to load the program into memory for
execution. This is internal event, which we cannot see.
Initialization: - This event is used to initialize the default values to program variables
and selection-screen variables.
Examples: v_land1 = IN
v_bukrs = 1001
p_werks = US
p_mtart = FERT
AT Selection-screen output: - This event is used to modify the selection screen
dynamically based on user actions on the selection screen.
This event is triggered (or) executed for every action on the selection screen.
AT Selection-screen on field: - This event is used to validate a single input field on
the selection-screen.
AT Selection-screen on value request: - This event is used to provide a search help
for an input field. This event is triggered whenever the user click on search help
button.
Start of selection: - This event is used to write the original business logic statements i.e all
select statements. It is also used to indicate the starting point of a program.
It is the default event.
End of selection: - It is used to indicate the start of selection has been ended. It is
mainly used with logical database, which are absolute in ABAP (LDBs are used in old
version of ABAP). But LDBs are stilled used in HR-ABAP, so end of selection is mainly
used in HR-ABAP. It doesnt have much importance in ABAP, it is used to indicate the
start of selection has been ended .
Top of page: - This event is use to display constant page heading for all the pages in
the output screen. This event is triggered after the first WRITE statement.
End of page: - This event is used to provide constant footer information across the
all pages of the list-screen. To display end of page (or) footer information we have
to reserve some lines as footer lines using the statement.
Report <Report Name> Line Count Total Lines(Footer Lines)
At Selection-Screen
1. It is used to validate multiple
Fields.
2. Whenever there is an error
On a field the entire screen
Will be enabled.
INTERACTIVE REPORTS
INTERACTIVE REPORTS
Display the basic information on the basic list and the detailed information in
the Secondary list is called Interactive report.
The remaining lists are called as secondary lists and the number start from 1
to 20. So totally there are 21 lists.
If you select any line, then the selected line data is stored in SY-LISEL.
We can generate interactive report based on field name and field value which
is not possible with HIDE statement.
The other difference between hide and get cursor is, with the hide statement
the system uses line no and gets the value into hide variable without knowing
what is the fieldname.
Whereas the get cursor will get the exact field name and field value with
which we can generate various interactive reports based on filed names.
ALV REPORT
ALV ( ABAP List Viewer ) is per-defined report format in SAP. Advantages of
ALV Reports
Structure Name
Program Name
Itab Name
FieldCatelog: It is an int.Table which contains the list of the fields to be displayed in
ALV Report
It is also used to set various properties for each field.
The properties/options are:
1. COL_POS = 1.
2. FIELD NAME Specifies the name of the field
3. TABLE NAME Specifies the name of the internal table
4.
SELTEXT_S Specifies short
SELTEXT_L
Specifies Long
C Indicates color
X Color Numbers
Y Backgroundcolor 1 On BG color
0 off BG color
Z Font color
1 OnFont color
1) Manually
2) Automatically by using FM
WA_FCAT-REF_FIELDNAME = 'KUNNR'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO I_FCAT.
CLEAR WA_FCAT.
Call the function module and Export the field catalog in internal table as exporting
parameters to IT_FCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= 'SY-REPID'
IT_FIELDCAT
= I_FCAT
TABLES
T_OUTTAB
= I_KNA1.
ALV with Layout
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
The properties are,
1. ZEEBRA
= X. Displays ALV with alternative colors
SUBTOT = X in FCAT.
WA_SORT-FIELDNAME = 'VBELN'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT.
Steps :
Declare the internal table and work area for the sorting
DATA : I_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA : WA_SORT TYPE SLIS_SORTINFO_ALV.
Specify the field and subtot = X .
WA_SORT-FIELDNAME = 'VBELN'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT.
.
Call the function module and send the SORT internal table as exporting parameters to
IT_SORT
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-REPID
IT_FIELDCAT
= I_FCAT
IT_SORT
= I_SORT
TABLES
T_OUTTAB
= I_VBAP.
ALV with field catalog merge
We can create a field catalog either manually or by automatically
REUSE_ALV_FIELDCATELOG_MERGE is the function module which is used to create field
catalog automatically
But this is obsolete because, the function module uses the old syntax for declaring
internal tables
I.e. the internal table should be created as below and all the fields in the internal
table must be declared using LIKE statement not the TYPE statement.
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
END OF I_MARA.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE
EXPORTING
I_PROGRAM_NAME
= SY-REPID
I_INTERNAL_TABNAME
= 'I_MARA'
I_INCLNAME
= SY-REPID
CHANGING
CT_FIELDCAT
= I_FCAT.
LOOP AT I_FCAT INTO WA_FCAT.
IF WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-NO_OUT = 'X'. "For hiding the field
ELSEIF WA_FCAT-FIELDNAME = 'MTART'.
WA_FCAT-KEY = 'X.
ENDIF.
MODIFY I_FCAT FROM WA_FCAT INDEX SY-TABIX.
ENDLOOP.
ALV Reports with top of page/ Events
There are totally 17 events available for ALV reporting
The function module REUSE_ALV_EVENTS_GET will display all the list of ALV events
Below are some events
Top-Of-Page
End-Of-List
At User command
Set PF status
ALV with LOGO:
For Logos in the ALV , We have two steps.
1. Upload the Logo from our system into SAP.
2. Call the FM Reuse_Alv_Commentary_Write and Export the Logo
name.
STEP1: OAER is the T-Code for upload the Logos into SAP.
=> Go to OAER Tcode.
ClassName Pictures
ClassType OT
ObjectKey ARJUN
Exporting
I_LOGO
= ARJUN.
TOP-OF-PAGE
Call the function module REUSE_ALV_EVENTS_GET
Provide the sub routine name for top-of-page event
Write below down the code in sub routine
Call the function module REUSE_ALV_COMMENTARY_WRITE to display top-of-page in
ALV
Finally export the events into internal table to the REUSE_ALV_GRID_DISPLAY
STEP1:Data Declarations for TOP-OF-PAGE.
TYPE-POOLS: SLIS.
Data: I_EVENTS type SLIS_T_EVENT.
Data: WA_EVENTS like line of I_EVENTS.
Data: I_HEADING type SLIS_T_LISTHEADER.
Data: WA_HEADING like line of I_HEADING.
STEP2:
Call Function REUSE_ALV_EVENTS_GET
Importing
ET_EVENTS = I_EVENTS.
Read Table I_EVENTS into WA_EVENTS
Exporting
IT_LIST_COMMENTARY = I_HEADING.
EndForm.
STEP4:
Call Function REUSE_ALV_GRID_DISPLAY
Exporting
I_Callback_Programme = SY REPID
IT_Events
= I_EVENTS
Tables
T_OutTab
= I_MARA.
END -OF-LIST:
Call the function module REUSE_ALV_EVENTS_GET
Provide the sub routine name for End-of-List event
Write below down the code in sub routine
Exporting
IT_LIST_COMMENTARY = I_HEADING
I_END_OF_LIST_GRID
= X.
EndForm.
STEP4:
Call Function REUSE_ALV_GRID_DISPLAY
Exporting
I_Callback_Programme = SY REPID
IT_Events
= I_EVENTS
Tables
T_OutTab
= I_MARA.
INTERACTIVE ALVs:
Call the function module REUSE_ALV_EVENTS_GET
Provide the sub routine name for USER_COMMAND
Write below down the code in sub routine
In the Sub routine Call the function module REUSE_ALV_GRID_DISPLAY to display
Secondary ALV
Finally export the events into internal table to the REUSE_ALV_GRID_DISPLAY
STEP1:Data Declarations .
Type-Pools: SLIS.
Data: I_Events type SLIS_T_EVENT.
Data: WA_Events like line of I_Events.
Data: V_VBELN type VBAK VBELN.
STEP2:
Call Function REUSE_ALV_EVENTS_GET
Importing
ET_EVENTS
= I_EVENTS.
Read Table I_EVENTS into WA_EVENTS with key NAME = USER_COMMAND.
WA_EVENTS-FORM = FORM_USER_COMMAND.
I_CALLBACK_PROGRAME = SY-REPID
I_STRUCTURE_NAME
= VBAP
Tables
T_OUTTAB
= I_VBAP.
STEP4:
Call Function REUSE_ALV_GRID_DISPLAY
Exporting
I_Callback_Programme = SY REPID
I_StructureName
= VBAK
IT_Events
= I_EVENTS
Tables
T_OutTab
= I_VBAK.
HIERARCHIAL ALVs:
Create User-Defined Types for Header Data and Item Data.
Write the code in Subroutines for Header data and Item Data.
Create the Fieldcatalog .
Create subroutine for Hierarchy.
Form Create_Hierarchy.
Key Item01
= VBELN.
EndForm.
Finally,For Display Exports Header Data, Item Data, and Fieldcatalog to the function
module REUSE_ALV_HIERSEQ_LIST_DISPLAY.
Call Function REUSE_ALV_HIERSEQ_LIST_DISPLAY
Exporting
I_Callback_Program
= SY REPID
IT_Fieldcat
= I_FCAT
I_Tabname_Header
= I_VBAK
I_Tabname_Item
= I_VBAP
Is_KeyInfo
= KEY
Tables
T_Outtab_Header
= I_VBAK
T_Outtab_Item
= I_VBAP.