Thursday 8 December 2011

Change layout format in ALV

Layout format in ALV defined in structure IS_LAYOUT as importing structure of ALV REUSE_ALV_LIST_DISPLAY.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
......
is_layout = wa_layout
......
EXCEPTIONS
program_error = 1
OTHERS = 2.


Commonly used field:

- IS_LAYOUT-ZEBRA: X=striped (zebra) pattern
- IS_LAYOUT-BOX_FIELDNAME: insert column checkbox for each row to select row.
How to inset checkbox:
1. insert new field with type C in internal table ALV data to record selection indicator (X:selected).
Example:

DATA: BEGIN OF t_alv OCCURS 1,
field1,
field2,
...
BOX,
END Of T_alv.

2. set IS_LAYOUT-BOX_FIELDNAME = fieldname in internal table ALV data.
Example:

IS_LAYOUT-BOX_FIELDNAME = 'BOX'.

3. At run time, t_alv-box will filled with 'X' for selected data.

CheckBox can be initiated in these ways:
1: selected, can not be changed
0: not selected, can not be changed
X: selected, can be changed
SPACE (blank):not selected, can be changed
-: disable check box

- IS_LAYOUT-COL_FIELDNAME
Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell.
Assign the name of the field to this parameter.
The internal output table field must be of type SLIS_T_SPECIALCOL_ALV.
Principle: the color code field is entered for the record containing the cells to be colored. The field contains an internal table with the above structure, containing the field names of the cells to be colored and the color code. The cell coordinates are determined by the record position containing the color code and the column information in the color table.
The record structure of the internal color table of type SLIS_T_SPECIALCOL_ALV is as follows:
Color table-FIELDNAME = field name of the cell to be colored
Color table-COLOR-COL = color number (1 - 9)
Color table-COLOR-INT = bold (0 = off, 1 = on)
Color table-COLOR-INV = inverse (0 = off, 1 = on)
Color table-NOKEYCOL = ignore key coloring ('X' = yes, ' ' = no)
If the parameter color table-FIELDNAME is not filled, the coloring applies to all fields, so the entire record is colored.

No comments:

Post a Comment