
Displaying Cells as Pushbuttons
Purpose
If you assign the style
mc_style_button
to cells, rows or columns, the ALV Grid Control displays the associated cells as pushbuttons. Users know immediately that they can obtain further information about the cell by clicking on the pushbutton. The ALV Grid Control then triggers the event
button_click.
Process Flow

To display all cells of a column as pushbuttons, you use the
field STYLE of the field catalog.
To display rows or individual cells as pushbuttons, proceed as follows:
- Define the
layout structure of type
LVC_S_LAYO
.
Add a row table of type
LVC_T_STYL
to your output table, as shown in the following example:
DATA: BEGIN OF GT_OUTTAB OCCURS 0.
INCLUDE STRUCTURE
<DDIC structure>
.
DATA: CT TYPE LVC_T_STYL. "Table buttons
DATA: END OF GT_OUTTAB.
Select your data and copy it into the output table.
Read one output table row at a time in a loop. One row of the row table has the fields
FIELDNAME
and
STYLE
. Assign values to these fields as follows:
- If you want to display all cells of a row as pushbuttons, assign the attribute
cl_gui_alv_grid=>mc_style_button
to the field
style
. In this case, field
fieldname
remains empty.
If you want to display only specific columns of the row as pushbuttons, append one row for each column to the cell table. Assign the name of the desired column to the field
fieldname
, and assign the attribute
cl_gui_alv_grid=>mc_style_button
to the field
style
.
- Assign the name of the internal table to the field
stylefname
of the layout structure (in our case
'CT',
see step 2).
Pass the layout structure and the output table using method
set_table_for_first_display.
Result
The ALV Grid Control displays all cells to which the attribute has been assigned as pushbuttons.