You are on page 1of 4

ALV reporting using FMs

ALV Reporting using Function Modules:


Function Modules used for display:
REUSE_ALV_LIST_DISPLAY
REUSE_ALV_GRID_DISPLAY
Procedure for ALV reporting using function modules:
Declaration
Retrieve data
Field catalogue generation
Display
As part of the function module REUSE_ALV_GRID_DISPLAY there is only one mandatory parameter T_OUTTAB. This parameter holds the internal
table containing data.
If we pass only this parameter, it leads to Abort Error.
The reason for this error is we must specify the field catalog information.
This information can be specified in two ways.
By specifying the dictionary structure name.
By specifying the field catalog directly.

Field catalogue:
It is an object which contains the informations of the fields display in the ALV Grid.
This information includes name of the field, position, label, grid, appearance etc.
Note
To specify the field catalogue information using the dictionary structure we need to use the importing parameter
I_STRUCTURE_NAME as part of the function module REUSE_ALV_GRID_DISPLAY.
Whenever this parameter is specified all the properties of the field are taken from dictionary itself.
The structure name passed must match with the format of internal table i.e. the no of fields and sequence of fields in the structure and in the
internal table must match otherwise it leads to runtime error.
GENERATING FIELD CATALOGUE using std. F.M REUSE_ALV_FIELDCATALOG_MERGE.
This function module takes the dictionary structure as input, generates the field catalogue based on structure fields and returns the field catalogue
which is of type internal table SLIS_T_FIELDCAT_ALV.
Note: It is recommended to generate the Field catalog manually, as we have better flexibility and control of the fields. For this, we need to prepare
work area for each field and append the same to the internal table of type SLIS_T_FIELDCAT_ALV.
INTERACTIVE ALV REPORTING:-
This is generated based on the user interaction in the runtime.
To handle events in ALV reports developed using function module we need to consider the parameter IT_EVENTS as part of the F.M REUSE_ALV_GRID_DISPLAY.
This parameter is an internal table of type SLIS_T_EVENT.
This internal table holds the events information (refer to the document of the parameter IT_EVENTS to get the events list).
This internal table is associated with two fields.
Name and 2. Form
Name holds the name of the event.
Form holds the name of the user defined subroutine.
As part of this subroutine definition, we need to implement the business logic related to the event.
This subroutine will be called by SAP whenever event is Triggered.
By reading the documentation of the parameter IT_EVENTS we can understand what events are supported in ALV using F.Ms.
USER_COMMAND:-
This event is triggered when the user double clicks on ALV cell value (or) single click on hotspot cell value. This event contains two parameters.
Parameter of type sy-ucomm.
Parameter of type slis_selfield.
Note:
To handle the events we need to specify the parameter I_CALLBACK_PROGRAM as part of F.M REUSE_ALV_GRID_DISPLAY so that whenever the event is triggered SAP will search for
the corresponding event subroutine definition in the specified calling program.
Reuse_Alv_Commentary_Write is a function module used for Associating text and Logo to the TOP OF PAGE Area of ALV report developed using F.M. This F.M should be called as part
of user defined subroutine definition associated with the event TOP_OF_PAGE.
Displaying LOGO in ALV report using function module:
Upload the logo using the Transaction code OAER .
Step 1:
GOTO-> SE93->Enter Transaction-> OAER
Step 2:
In OAER Transaction -> enter the values in following below.
Class name -> pictures.
Class type -> OT.
Object key-> object name (any unique id).
And execute.

Step 3:
In the next screen , in the top pane, choose pictures, and in bottom pane, ->doctype->expand->standard doc types->double click on screen entry->choose filename (logo file) from
local drive->continue.
Blocked Alv:
It is used for displaying the data in the form of blocks.
As part of this we use following function modules.
Reuse_alv_block_list_init.
Reuse_alv_block_list_append.
Reuse_alv_block_list_display.
Procedure:
Step 1:
Initialize the ALV blocked list using the function module.
Reuse_alv_block_list_init.
Step 2:
Generate the field catalog for the block.
Step 3:
Retrieve the data for the block.
Append the field catalog and the data to the blocked list using the
function module Reuse_alv_block_list_append.
Note:
Repeat the steps 2,3 for each of the block.
Step 4:
Display the ALV blocked list using the function module
Reuse_alv_block_list_display.
Note: Reuse_alv_events_get is the function module which returns
list of events supported in ALV function modules.

You might also like