Mentor SAP

Line Colors

To change the color of a line in the ALV Grid, add an extra field to your data table that contains a code representing the color of the line. This is a character field with length 4. Add the field at the end of the line type of your internal table. If you are using a global structure type to describe the contents of the internal table, the color column will not be displayed. Instead, the ALV uses it to format the line accordingly.

 

The INCLUDE TYPE or INCLUDE STRUCTURE statement provides a simple way of defining the necessary line type for the data table, locally in the program.

 

 

Color Options

Components of the Color Field Value

 

 

Cell Colors

To highlight individual cells using colors, extend the line type of the output data table, adding an internal table of lvc_t_scol type. The contents of the internal table are not displayed; they contain information that controls the output.

 

 

 

Changing of the Cell Color

The steps to change the cell color are as follows:

  1. Loop through the gt_sbook internal table into the gs_sbook structure. Different cells can be colored for each data record. If you want colored cells only in one data record, use the READ TABLE statement instead.
  2. Fill the gs_colfield help field that contains two fields, fname and color. The fname field is the name of the field to be colored. The color field is a structure containing the different parts of the color code to be used. It is made up of the col, int, and inv
  3. Append the gs_colfield help field to the gs_sbook-it_colfields internal table. The gs_sbook-it_colfields internal table contains information about the cell color combinations.
  4. Write the gs_sbooking work area back into the internal data table using the MODIFY command. Complete steps 2 and 3 for each field to be colored.

 

 

To extend the output data table, add an internal table of lvc_t_scol type.

 

The contents of the internal table are not the output, but are included only for the layout.

 

 

You must assign the name of the column containing the internal table with the color field information to the ctab_fname field of the layout structure. Transfer the layout structure and the output table using the set_table_for_first_display method.

 

 

Hiding of Standard Functions

The possible function codes are defined as constants of the cl_gui_alv_grid class. The constants for function codes have the MC_FC_ prefix. The MC_MB_ prefix represents an entire menu in the toolbar.

 

Pass the table to the standard functions when you call the set_table_for_first_display method. To deactivate all functions on the application toolbar, you can use the MC_FC_EXCL_ALL constant.

 

To hide the entire toolbar, set the no_toolbar parameter of the layout structure to X and pass the layout structure to set_table_for_first_display.