Sei sulla pagina 1di 10

Procedure for Classical Reporting:

1. Generate a selection screen for reading user input


2. Retrieve data from database tables based on user input

3. Process the internal table for display (write)

--> displays the output in L.P.S

Procedure for developing ALV reports using classes:

1. Create a Module pool screen

2. Place custom control component on the module pool screen

3. Create the object for container class 'CL_GUI_CUSTOM_CONTAINER’


linking with custom control (physical control on module pool screen toolbox)

4. Create the object for grid class 'CL_GUI_ALV_GRID' linking with


container object

5. Retrieve the data to be displayed in the ALV grid

6. Generate the field catalog for the fields of ALV grid

7. Generate the layout for the ALV grid (optional)

8. Display the data in the ALV grid using the method


'SET_TABLE_FOR_FIRST_DISPLAY' of the grid class 'cl_gui_alv_grid'

Field catalog Generation:

Whenever we display the data in the form of ALV report, we need to provide field
catalog information; otherwise the report execution leads to ABORT error. In case
of ALV reporting using classes, we can generate field catalog in 2 ways.

1. Using the function module ‘LVC_FIELDCATALOG_MERGE’: As part of this


F.M call, we need to provide the dictionary structure containing the
required fields (fields provided as part of internal table) , based on this
dictionary structure fields SAP constructs the fieldcatalog internal table and
returns which is of type ‘LVC_T_FCAT’.

2. Manually

Note: In either of the above 2 process, once the fieldcatalog is generated, we


need to pass it as a value to the parameter ‘IT_FIELDCATALOG’ as part of the
method call ‘SET_TABLE_FOR_FIRST_DISPLAY’.

Excluding the standard ALV toolbar pushbuttons:

For this, we need to identify the function codes of the ALV toolbar buttons and
prepare an internal table with those function codes and pass the internal table as
a value to the parameter “IT_TOOLBAR_EXCLUDING” of the method
“SET_TABLE_FOR_FIRST_DISPLAY” of the class ‘CL_GUI_ALV_GRID’. All the ALV
toolbar buttons function codes exist in the form of constant public attributes with
the naming standard ‘MC_FC…’ of the class ‘CL_GUI_ALV_GRID’.

Note: For excluding entire ALV toolbar in the Report, set the field ‘NO_TOOLBAR’
to ‘X’ as part of Layout.

ALV Column as pushbutton:

For displaying the entire ALV column as pushbutton, set the field ‘STYLE’ as part of
field catalog. All the styles exist in the form of constant attributes with the
naming standard ‘MC_STYL’ as part of the class ‘CL_GUI_ALV_GRID’.

Displaying ALV cells as pushbutton:

Procedure:

Step1:

Take an additional column in the final internal table which is of table type
“LVC_T_STYL”.

Step 2:
Before displaying the final data in the ALV grid, loop the final internal table and
set the button style (MC_STYLE_BUTTON) to ALV cells based on the condition.

As part of layout generation, set the field “stylefname” whose value is name of
the additional field which holds the style.

ALV Column Coloring:

For coloring the entire ALV column, set the field ‘EMPHASIZE’ to a color coding as
part of field catalog.

ALV Row Coloring:

Procedure:

Step1:

Take an additional column in the final internal table which is of type char4.

Step 2:

Before displaying the final data in the ALV grid, loop the final internal table and
set the color coding for the additional field based on the condition.

As part of layout generation, set the field “info_fname” whose value is name
of the additional field which holds the row color coding.

ALV Cell Coloring:

Procedure:

Step1:

Take an additional column in the final internal table which is of type


‘LVC_T_SCOL’.

Step 2:

Before displaying the final data in the ALV grid, loop the final internal table and
set the color coding for the additional field based on the condition.
For this, we need to prepare work area of type ‘LVC_S_SCOL’ and append the
same to the additional field and update the internal table.

As part of layout generation, set the field “ctab_fname” whose value is name
of the additional field which holds the cell color coding.

ALV Traffic Light columns:

- Traffic light columns acts as indicators in the ALV reports.

- These traffic lights by default are displayed as First column of the ALV
report.

- Traffic light codes are 3 types (1-Red, 2-Yellow, 3-Green) and also we can
refer to the corresponding constant values in the ICON type-group.

Procedure:

Step 1:

Take an additional column in the final internal table which is of type character
of “One”.

Step 2:

Before displaying the final data in the ALV GRID, loop the internal table and set
the traffic light code for an additional column based on a condition.

Step 3:

As part of layout, set the field “EXCP_FNAME”, the value of the field should be
“Name of the additional column” containing traffic light code.

Note: By default, Traffic light column is displayed in first column position. To


display traffic light in a specific column position, declare an additional column
of type character with some length, generate field catalog for this column
including required column position and assign traffic light code to its column
value along with static text. In this case, we should not set the field
‘EXCP_FNAME’ in layout.
Splitter control
It is used for splitting the container in to “N” no of partitions.

Each partition is called as a “PANE”.

Each “PANE” should be associated with a container to hold an object. The object
can be ALV Grid, Image and Tree.

Procedure for displaying images in ALV Reporting using classes

Step 1:

Upload the picture by using t-code ‘SMW0’.

In SMW0, choose the radio button ‘binary data for webrfc applications’, click on
‘FIND’ (appl.toolbar)  provide package name(any package), object name (any
name, unique id) description(…), click on execute  click on ‘create’ button
(appl.toolbar),provide object name (ZBT), description(…), click on ‘import button’
(status bar of dialog box)

Step 2:

Call the function module “dp_publish_www_url”.

This function module takes an image object id as input and returns the “URL” of
picture which is of type “cndp_url”.

Note:

“cndp_url” is a types declaration declared in the type group “CNDP”.

Step 3: Create the object of picture class ‘CL_GUI_PICTURE’ linking with a


container.
Step 4: call the instance method “load_picture_from_url” of the class
“cl_gui_picture”. This method takes URL of the picture as input and displays the
picture in the container.

Procedure for tree control:

A tree control is collection of nodes.

A node can be a folder / it can be an action item.

We can add the nodes to the tree control by using the instance method
“add_nodes” of the class “cl_gui_simple_tree”.

This method contains two mandatory parameters.

1. Structure representing the nodes.

2. Internal table containing the nodes information.

Note: “ABDEMONODE” is one of the standard structure given by SAP which


represents simple tree (or) we can create custom dictionary structure by including
std.structure ‘TREEV_NODE’ and a character field ‘text’ of any length

Displaying ALV columns as Dropdown:


Generally we display ALV column as drop down when we have fixed set of values
to be shown to the user as a drop down so that the user can select the value in
the runtime.

Procedure:

Step 1:

Take an additional column in the final internal table, this additional column
needs to be displayed as dropdown.

Step 2:

Generate the field catalog for the additional column.


As part of the field catalog, set the field “DRDN_HNDL” to some Numeric value
and also set the edit field to ‘X’ as the column should be editable, so that user
can choose value from the drop down in the runtime.

Step 3:

Prepare an internal table of type ‘LVC_T_DROP’ with drop down handle and
dropdown values and pass this internal table as a parameter to the method
‘SET_DROP_DOWN_TABLE’ of the class ‘CL_GUI_ALV_GRID’.

Custom event handling process:


1. Needs to be declared in custom class definition

2. Event Business logic needs to be implemented as part of custom class


implementation(inside event handler method)

3. Raised in custom class methods

4. Register the handlers for execution of event handler methods

Standard Event handling process in ALV Reports using classes:


1. They are declared by SAP itself as part of standard SAP classes

2. Event Business logic needs to implemented as part of custom class


implementation (inside event handler method)

3. Raised by SAP itself depending on user actions (from. The std. methods)

4. Register the handlers for execution of event handler methods

Note:
1. To Display ALV column values as link, we need to set the field ‘HOTSPOT’ as
part of field catalog for that particular field.
2. ‘HOTSPOT_CLICK’ is the instance event of the class ‘CL_GUI_ALV_GRID’
which is triggered by SAP whenever the user clicks on ALV Cell value in the
runtime.

3. ‘BUTTON_CLICK’ is the instance event of the class ‘CL_GUI_ALV_GRID’


which is triggered by SAP whenever the user clicks on ALV Cell displayed as
pushbutton

4. ‘DOUBLE_CLICK’ is the instance event of the class ‘CL_GUI_ALV_GRID’


which is triggered by SAP whenever the user double clicks on ALV Cell value
in the runtime.

5. As part of interactive ALV reporting using classes, when the user interacts
and navigates from one screen to another screen, we need to refresh the
grid with the corresponding internal table data using the method
‘REFRESH_TABLE_DISPLAY’ of the class ‘CL_GUI_ALV_GRID’.

TOOLBAR Event: is the instance event of the class ‘CL_GUI_ALV_GRID’ which is


triggered when the ALV grid is displayed. This event can be used to manage the
ALV Toolbar for Enabling/Disabling standard ALV Toolbar buttons, Adding custom
buttons.

USER_COMMAND event: is the instance event of the class ‘CL_GUI_ALV_GRID’


which is triggered when the user clicks on custom normal buttons on ALV toolbar.
Before this event, SAP Triggers ‘BEFORE_USER_COMMAND’ and then
‘USER_COMMAND’ and after this it triggers ‘AFTER_USER_COMMAND’. These
events are also triggered when the user clicks on Menu items of Menu Buttons of
ALV toolbar.

MENU_BUTTON event: is the instance event of the class ‘CL_GUI_ALV_GRID’


which is triggered when the user clicks on custom MENU buttons on ALV toolbar.

Note:

1. To enable multiple selection of rows on ALV grid, we need to set the field
‘SEL_MODE’ TO ‘A’ as part of layout
2. To identify the selected rows on the ALV grid, we need to use the instance
method ‘GET_SELECTED_ROWS’ of the class ‘CL_GUI_ALV_GRID’. This
method returns the internal tables containing the indexes of selected rows.

Editing ALV Cells in runtime and updating to database:

Procedure:
1. For the ALV column to be editable, set the field edit to ‘X’ As part of field
catalog,
2. Handle the event ‘DATA_CHANGED’ of the class ‘CL_GUI_ALV_GRID’. This
event is not triggered by default as it is a system event, it requires explicit
registration and it is done by calling the instance method
‘REGISTER_EDIT_EVENT’ of the class ‘CL_GUI_ALV_GRID’. This method
takes event id as a mandatory input parameter. These event ids exist in the
form of constant attributes of the grid class and we can use any of the
following attribute event ids.
a) Mc_evt_modified  Allows only single cell editing, in this case the event
‘DATA_CHANGED’ is triggered when the user shifts the focus from the
first modified cell or when the user presses enter key in the first
modified cell.
b) Mc_evt_enter -> Allows multi cell editing, in this case the event is
triggered when the user presses enter key in the last modified cell.
3. As part of the event handler method, we need to import the event
parameter ‘ER_DATA_CHANGED’ and using this event parameter (object)
access the instance attribute (internal table) ‘MT_MODIFIED_CELLS’ which
keeps track about the information of the modified cells which includes
row_id and modified value. Based on this, update the grid internal table as
well as corresponding database table.

Tree Control Events:


1. ‘NODE_DOUBLE_CLICK’: is the instance event of the class
‘CL_GUI_SIMPLE_TREE’ which is triggered when the user double clicks
on the tree node of the tree control. This event is not triggered by
default; it needs to be registered explicitly by using the instance method
‘SET_REGISTERED_EVENTS’ of the class ‘CL_GUI_SIMPLE_TREE’.
2. ‘NODE_CONTEXT_MENU_REQUEST’: is the instance event of the class
‘CL_GUI_SIMPLE_TREE’ which is triggered when the user right clicks on
the tree node of the tree control. This event can be handled to associate
the context menu with the tree node. This event is not triggered by
default; it needs to be registered explicitly by using the instance method
‘SET_REGISTERED_EVENTS’ of the class ‘CL_GUI_SIMPLE_TREE’.

3. ‘NODE_KEYPRESS’: is the instance event of the class


‘CL_GUI_SIMPLE_TREE’ which is triggered when the user presses a key
on the tree node of the tree control. For this, we need to register the
keys for triggering this event. The keys can be registered by calling the
method ‘ADD_KEY_STROKE’ of the class ‘CL_GUI_SIMPLE_TREE’. All the
keys exist in the form of constant attributes with the naming standard
‘KEY_....’ of the class ‘CL_GUI_SIMPLE_TREE’. This event is not triggered
by default; it needs to be registered explicitly by using the instance
method ‘SET_REGISTERED_EVENTS’ of the class ‘CL_GUI_SIMPLE_TREE’.

4. ‘NODE_CONTEXT_MENU_SELECT’: is the instance event of the class


‘CL_GUI_SIMPLE_TREE’ which is triggered when the user selects a
context menu item from the context menu of the node.

Note: For the method ‘SET_REGISTERED_EVENTS’, we need to pass


event id as a parameter. All the event ids exist in the form of constant
attributes with the naming standard ‘EVENTID_.....’ of the class
‘CL_GUI_SIMPLE_TREE’.

Generating TOP OF PAGE content for ALV Grid:


For this, we need to handle the event ‘TOP_OF_PAGE’. It is the instance event of
the class ‘CL_GUI_ALV_GRID’ used for generating content in the TOP OF PAGE
area of ALV Grid. This event is not triggered by default; it should be registered
explicitly by calling the instance method ‘LIST_PROCESSING_EVENTS’ of the class
‘CL_GUI_ALV_GRID’.

Potrebbero piacerti anche