Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV fieldcatalog change

Former Member
0 Kudos
1,022

Hello,

I have a colored ALV grid using the emphasize field from fieldcatalog table. When I change to edit mode I want to change the color of the row, so I change the color code from the fieldcatalog, and then call refresh_table_display, but the color of the grid is not changed. Does refresh_table_display take into account fieldcatalog changes?

4 REPLIES 4

Former Member
0 Kudos
129

hi

Coloring Rows

You can change the color of rows in the grid control to highlight data in the list.

The column color can be set using field EMPHASIZE of the field catalog (see: Output Options of Columns).

Process Flow

Define the layout structure of type LVC_S_LAYO .

Add a four-digit character field to your output table, as shown in the example below:

DATA: BEGIN OF GT_OUTTAB OCCURS 0.

INCLUDE STRUCTURE <DDIC-Struktur>.

DATA: linecolor(4) type c. "Color for corresponding line

DATA: END OF GT_OUTTAB.

Select your data and copy it into the output table.

Read one row of the output table at a time in a loop. To change the color of a row, assign a four-digit color code to the character field.

For more information on color codes, see field EMPHASIZE of the field catalog (see Output Options of Columns).

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

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

If you do not want to color the cells for the first display, postpone step 4 and refresh the output table with method refresh_table_display.

just go thro this process flow also hopen it helps

Process Flow

Define the layout structure of type LVC_S_LAYO .

Add a color table of type LVC_T_SCOL to your output table, as shown in the example below:

DATA: BEGIN OF GT_OUTTAB OCCURS 0.

INCLUDE STRUCTURE <DDIC-Struktur>.

DATA: CT TYPE LVC_T_SCOL. "Table for colors

DATA: END OF GT_OUTTAB.

Select your data and copy it into the output table.

Read one row of the output table at a time in the loop. One row of the color table has three fields. If field NOKEYCOL is set, you can change the color of key fields. Assign values to the remaining fields as follows:

If you want to color the entire row, assign the corresponding values to the fields of structure COLOR . Field fname does not receive a value in this case.

If you want to color specific columns of the row only, you must append one row for each column to the color table. Assign the name of the desired column to field fname , and the corresponding values to the fields of structure COLOR .

For information on the meaning of the color settings, see F1 help on the format command. Class CL_GUI_RESOURCES contains constant attributes for fields INT and INV of structure COLOR .

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

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

If you do not want to color the cells for the first display, postpone step 4 and refresh your output table with method refresh_table_display.

regards

navjot

reward accordingly

Message was edited by:

navjot sharma

p291102
Active Contributor
0 Kudos
129

Hi,

Herewith i am sending the sample coding for colour cell alv report.

REPORT YMS_COLOURCELLALV.

TYPE-POOLS : slis.

DATA : BEGIN OF t5 OCCURS 0.

INCLUDE STRUCTURE t005t.

DATA : color(4) TYPE c,

coltab TYPE slis_t_specialcol_alv,

target TYPE p,

END OF t5.

DATA fcat TYPE slis_t_fieldcat_alv.

DATA scol TYPE slis_specialcol_alv.

DATA cs_layo TYPE slis_layout_alv.

PARAMETER : p_row TYPE i DEFAULT 2.

START-OF-SELECTION.

SELECT * INTO CORRESPONDING FIELDS OF TABLE t5 FROM t005t

WHERE spras = sy-langu.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'T005T'

CHANGING

ct_fieldcat = fcat.

DELETE fcat WHERE fieldname NE 'LANDX'.

CLEAR cs_layo.

cs_layo-window_titlebar = 'Test ALV with color'.

cs_layo-colwidth_optimize = 'X'.

cs_layo-edit = 'X'.

cs_layo-edit_mode = space.

MOVE 'COLOR' TO cs_layo-info_fieldname.

MOVE 'COLTAB' TO cs_layo-coltab_fieldname.

READ TABLE t5 INDEX p_row.

IF sy-subrc = 0.

scol-fieldname = 'LANDX'.

scol-color-col = 6.

scol-color-int = 1.

scol-color-inv = 0.

APPEND scol TO t5-coltab.

MODIFY t5 INDEX p_row.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

is_layout = cs_layo

it_fieldcat = fcat

TABLES

t_outtab = t5.

Thanks,

Sankar M

Former Member
0 Kudos
129

refresh_table_display shld consider the changes done. Can u paste a part of ur code ?

Former Member
0 Kudos
129

I have solved the problem by using set_frontend_fieldcatalog method of the ALV grid, together with refresh_table_display.