Process documentationDisplaying Cells as Pushbuttons Locate this document in the navigation structure

 

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

Note Note

To display all cells of a column as pushbuttons, you use the field STYLE of the field catalog.

End of the note.

To display rows or individual cells as pushbuttons, proceed as follows:

  1. Define the layout structure of type LVC_S_LAYO.

  2. Add a row table of type LVC_T_STYL to your output table, as shown in the following example:

    Syntax Syntax

    1. DATA: BEGIN OF GT_OUTTAB OCCURS 0.
      	INCLUDE STRUCTURE <DDIC structure>.
      
      DATA: CT TYPE LVC_T_STYL.  "Table buttons
      
      DATA: END OF GT_OUTTAB.
    End of the code.
  3. Select your data and copy it into the output table.

  4. Read one row of the output table 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. Field fieldname does not receive a value in this case.

    • 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.

  5. Assign the name of the internal table to the field stylefname of the layout structure (in our case 'CT', see step 2).

  6. Pass the layout structure and the output table with method set_table_for_first_display.

Result

The ALV Grid Control displays all cells to which the attribute has been assigned as pushbuttons.