Application Development and Automation 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: 
Read only

ALV

Former Member
0 Likes
1,153

Hi abapers...

I hav and ALV each cell color issue.

If anyone send me any idea regarding alv color then i can proceed.

Actually my report is to be done in normal alv function modules but not oops aabap.

Thnk u all ....

regards,

sanjay

Hi abapers...

I hav and ALV each cell color issue.

If anyone send me any idea regarding alv color then i can proceed.

Actually my report is to be done in normal alv function modules but not oops aabap.

Thnk u all ....

regards,

sanjay

8 REPLIES 8
Read only

Former Member
0 Likes
1,104

Hi Sanjay,

Plz try the following codes to color a cell in ALV.

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.

Regards,

Hendy

Read only

anversha_s
Active Contributor
0 Likes
1,104

hi,

chk this.

<b><u>Row wise coloring</u></b>

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

<u><b>Coloumn wise coloring</b></u>

Do as follows

1. declare one field say color in the output table of type SLIS_T_SPECIALCOL_ALV.

2. Also declare a table color like

DATA COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.

3. After you have filled the field catalog do like this,

LOOP AT IT_ALV_DATA.
IF SY-TABIX = 2.
COLOR-FIELDNAME = 'POSNR'.
COLOR-COLOR-COL = 6.
COLOR-COLOR-INT = 0.
APPEND COLOR.
IT_ALV_DATA-COLOR = COLOR[].
MODIFY IT_ALV_DATA.
ENDIF.
ENDLOOP.

***********************************************

chk this sample code.

report ztest_color no standard page heading. 
type-pools slis. 
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0, 
matnr type mara-matnr, 
mtart type mara-mtart, 
maktx type makt-maktx, 
color_line(4) type c, 
tcolor type slis_t_specialcol_alv. "cell end of imara.
 
data: xcolor type slis_specialcol_alv. 

start-of-selection. 

perform get_data. 

perform write_report.

********************** * Get_Data *********
form get_data. imara-matnr = 'ABC'.
 imara-mtart = 'ZCFG'. 
 imara-maktx = 'This is description for ABC'. 
 append imara. imara-matnr = 'DEF'.
 imara-mtart = 'ZCFG'. 
 imara-maktx = 'This is description for DEF'.
 append imara.

 imara-matnr = 'GHI'. 
imara-mtart = 'ZCFG'.
 imara-maktx = 'This is description for GHI'.
 append imara.
 loop at imara.
 if sy-tabix = 1.
 imara-color_line = 'C410'. " color line endif. 
if sy-tabix = 2. "color CELL clear xcolor.
 xcolor-fieldname = 'MTART'.
 xcolor-color-col = '3'. 
xcolor-color-int = '1'. "Intensified on/off 
xcolor-color-inv = '0'. 
append xcolor to imara-tcolor. 
endif. modify imara.
 endloop. 
endform. 

**************** * WRITE_REPORT *******
form write_report. 
data: layout type slis_layout_alv.
 layout-coltab_fieldname = 'TCOLOR'.
 layout-info_fieldname = 'COLOR_LINE'.
 perform build_field_catalog. 
* CALL ABAP LIST VIEWER (ALV) 
call function 'REUSE_ALV_GRID_DISPLAY' 
exporting 
is_layout = layout 
it_fieldcat = fieldcat 
tables t_outtab = imara.
 endform.

 **************BUILD_FIELD_CATALOG *************
form build_field_catalog. 
data: fc_tmp type slis_t_fieldcat_alv with header line. 
clear: fieldcat.
 refresh: fieldcat.
 clear: fc_tmp.
 fc_tmp-reptext_ddic = 'Material Number'. 
fc_tmp-fieldname = 'MATNR'. 
fc_tmp-tabname = 'IMARA'. 
fc_tmp-outputlen = '18'. 
append fc_tmp to fieldcat. 
clear: fc_tmp.
 fc_tmp-reptext_ddic = 'Material Type'.
 fc_tmp-fieldname = 'MTART'. 
fc_tmp-tabname = 'IMARA'. 
fc_tmp-outputlen = '4'. 
append fc_tmp to fieldcat.
 clear: fc_tmp.
 fc_tmp-reptext_ddic = 'Material'.
 fc_tmp-fieldname = 'MAKTX'.
 fc_tmp-tabname = 'IMARA'.
 fc_tmp-outputlen = '40'. 
fc_tmp-emphasize = 'C610'. " color column 
append fc_tmp to fieldcat. 
endform.

Rgds

Anver

Read only

Former Member
0 Likes
1,104

Hi Sanjay,

use emphasize and pass values like c2,c3,c4,c6,c8 etc for colouring the alv display

Cxyz

x:Colornumbers

y:1/0:inverseon/off

z:1/0:intensifiedon/off

Color numbers are:

x color intended for

1 gray-blue headers

2 light gray list bodies

3 yellow totals

4 blue-green key columns

5 green positive threshold value

6 red negative threshold value

7 orange Control levels

Coloring an Entire Row

Coloring a row is a bit (really a bit) more complicated. To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. Sample Declaration of our list data table “gt_list”.

DATA BEGIN OF gt_list OCCURS 0 .

INCLUDE STRUCTURE SFLIGHT .

DATA rowcolor(4) TYPE c .

DATA END OF gt_list .

As you guess, you should fill the color code to this field. Its format will be explained below But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field “INFO_FNAME” of the layout structure.

ps_layout-info_fname = <field_name_containing_color_codes>. “e.g. ‘ROWCOLOR’

You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.

You can color an entire row as described in the next section. However, this method is less time consuming.

Coloring Individual Cells

This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by “more” is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.

The structure that should be included must be of type “LVC_T_SCOL”. If you want to color the entire row, this inner table should contain only one row with field “fname” is set to space, some color value at field “col”, “0” or “1” at fields “int” (intensified) and “inv” (inverse).

If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field “fname”. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table. But, it is also obvious that, this will be more time consuming than the method at section C.6.1.

Again key field coloring will override your settings. That’s why, we have another field in this inner table called “nokeycol”. For each field represented in the inner table, set this field to ‘X’ to prevent overriding of key color settings.

In this procedure, again we must tell the control the name of the inner table containing color data. The field “CTAB_FNAME” of the layout structure is used for this purpose.

*--- Internal table holding list data

DATA BEGIN OF gt_list OCCURS 0 .

INCLUDE STRUCTURE SFLIGHT .

DATA rowcolor(4) TYPE c .

DATA cellcolors TYPE lvc_t_scol .

DATA END OF gt_list .

Code Part 15 – A sample code to make the cell at row 5 and column ‘SEATSOCC’ colored

DATA ls_cellcolor TYPE lvc_s_scol .

...

READ TABLE gt_list INDEX 5 .

ls_cellcolor-fname = 'SEATSOCC' .

ls_cellcolor-color-col = '7' .

ls_cellcolor-color-int = '1' .

APPEND ls_cellcolor TO gt_list-cellcolors .

MODIFY gt_list INDEX 5 .

Read only

Former Member
0 Likes
1,104

HI,

Most of them have already posted the code: Check this also.

REPORT ZTESTIN111 .

*****************************************************************

  • Use of colours in ALV grid (cell, line and column) *

*****************************************************************

  • Table

tables : mara.

  • Type

types : begin of ty_mara,

matnr like mara-matnr,

matkl like mara-matkl,

counter(4) type n,

free_text(15) type c,

color_line(4) type c, " Line color

color_cell type lvc_t_scol, " Cell color

end of ty_mara.

  • Structures

data : wa_mara type ty_mara,

wa_fieldcat type lvc_s_fcat,

is_layout type lvc_s_layo,

wa_color type lvc_s_scol.

  • Internal table

data : it_mara type standard table of ty_mara,

it_fieldcat type standard table of lvc_s_fcat,

it_color type table of lvc_s_scol.

  • Variables

data : okcode like sy-ucomm,

w_alv_grid type ref to cl_gui_alv_grid,

w_docking_container type ref to cl_gui_docking_container.

parameters : p_column as checkbox,

p_line as checkbox,

p_cell as checkbox.

at selection-screen output.

perform get_data.

perform fill_catalog.

if w_docking_container is initial.

perform create_objects.

endif.

&----


*& Form create_objects

&----


form create_objects.

create object w_docking_container

exporting

ratio = 60

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

create object w_alv_grid

exporting

i_parent = w_docking_container.

  • Field that identify color line in internal table

move 'COLOR_LINE' to is_layout-info_fname.

  • Field that identify cell color in inetrnal table

move 'COLOR_CELL' to is_layout-ctab_fname.

call method w_alv_grid->set_table_for_first_display

exporting

is_layout = is_layout

changing

it_outtab = it_mara

it_fieldcatalog = it_fieldcat

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

endform.

&----


*& Form get_data

&----


form get_data.

select * from mara up to 5 rows.

clear : wa_mara-color_line, wa_mara-color_cell.

move-corresponding mara to wa_mara.

add 1 to wa_mara-counter.

move 'Blabla' to wa_mara-free_text.

if wa_mara-counter = '0002'

and p_line = 'X'.

  • Color line

move 'C410' to wa_mara-color_line.

elseif wa_mara-counter = '0004'

and p_cell = 'X'.

  • Color cell

move 'FREE_TEXT' to wa_color-fname.

move '6' to wa_color-color-col.

move '1' to wa_color-color-int.

move '1' to wa_color-color-inv.

append wa_color to it_color.

wa_mara-color_cell[] = it_color[].

endif.

append wa_mara to it_mara.

endselect.

endform.

&----


*& Form fill_catalog

&----


form fill_catalog.

*****************************************************************

  • Colour code : *

  • Colour is a 4-char field where : *

  • - 1st char = C (color property) *

  • - 2nd char = color code (from 0 to 7) *

  • 0 = background color *

  • 1 = blue *

  • 2 = gray *

  • 3 = yellow *

  • 4 = blue/gray *

  • 5 = green *

  • 6 = red *

  • 7 = orange *

  • - 3rd char = intensified (0=off, 1=on) *

  • - 4th char = inverse display (0=off, 1=on) *

  • *

  • Colour overwriting priority : *

  • 1. Line *

  • 2. Cell *

  • 3. Column *

*****************************************************************

data : w_position type i value '1'.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'MATNR' to wa_fieldcat-fieldname.

move 'MARA' to wa_fieldcat-ref_table.

move 'MATNR' to wa_fieldcat-ref_field.

append wa_fieldcat to it_fieldcat.

add 1 to w_position.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'MATKL' to wa_fieldcat-fieldname.

move 'MARA' to wa_fieldcat-ref_table.

move 'MATKL' to wa_fieldcat-ref_field.

  • Color column

if p_column = 'X'.

move 'C610' to wa_fieldcat-emphasize.

endif.

append wa_fieldcat to it_fieldcat.

add 1 to w_position.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'COUNTER' to wa_fieldcat-fieldname.

move 'N' to wa_fieldcat-inttype.

move '4' to wa_fieldcat-intlen.

move 'Counter' to wa_fieldcat-coltext.

append wa_fieldcat to it_fieldcat.

add 1 to w_position.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'FREE_TEXT' to wa_fieldcat-fieldname.

move 'C' to wa_fieldcat-inttype.

move '20' to wa_fieldcat-intlen.

move 'Text' to wa_fieldcat-coltext.

append wa_fieldcat to it_fieldcat.

endform.

Regards

Subramanian

Read only

Former Member
0 Likes
1,104

HI,

Most of them have already posted the code: Check this also.

REPORT ZTESTIN111 .

*****************************************************************

  • Use of colours in ALV grid (cell, line and column) *

*****************************************************************

  • Table

tables : mara.

  • Type

types : begin of ty_mara,

matnr like mara-matnr,

matkl like mara-matkl,

counter(4) type n,

free_text(15) type c,

color_line(4) type c, " Line color

color_cell type lvc_t_scol, " Cell color

end of ty_mara.

  • Structures

data : wa_mara type ty_mara,

wa_fieldcat type lvc_s_fcat,

is_layout type lvc_s_layo,

wa_color type lvc_s_scol.

  • Internal table

data : it_mara type standard table of ty_mara,

it_fieldcat type standard table of lvc_s_fcat,

it_color type table of lvc_s_scol.

  • Variables

data : okcode like sy-ucomm,

w_alv_grid type ref to cl_gui_alv_grid,

w_docking_container type ref to cl_gui_docking_container.

parameters : p_column as checkbox,

p_line as checkbox,

p_cell as checkbox.

at selection-screen output.

perform get_data.

perform fill_catalog.

if w_docking_container is initial.

perform create_objects.

endif.

&----


*& Form create_objects

&----


form create_objects.

create object w_docking_container

exporting

ratio = 60

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

create object w_alv_grid

exporting

i_parent = w_docking_container.

  • Field that identify color line in internal table

move 'COLOR_LINE' to is_layout-info_fname.

  • Field that identify cell color in inetrnal table

move 'COLOR_CELL' to is_layout-ctab_fname.

call method w_alv_grid->set_table_for_first_display

exporting

is_layout = is_layout

changing

it_outtab = it_mara

it_fieldcatalog = it_fieldcat

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

endform.

&----


*& Form get_data

&----


form get_data.

select * from mara up to 5 rows.

clear : wa_mara-color_line, wa_mara-color_cell.

move-corresponding mara to wa_mara.

add 1 to wa_mara-counter.

move 'Blabla' to wa_mara-free_text.

if wa_mara-counter = '0002'

and p_line = 'X'.

  • Color line

move 'C410' to wa_mara-color_line.

elseif wa_mara-counter = '0004'

and p_cell = 'X'.

  • Color cell

move 'FREE_TEXT' to wa_color-fname.

move '6' to wa_color-color-col.

move '1' to wa_color-color-int.

move '1' to wa_color-color-inv.

append wa_color to it_color.

wa_mara-color_cell[] = it_color[].

endif.

append wa_mara to it_mara.

endselect.

endform.

&----


*& Form fill_catalog

&----


form fill_catalog.

*****************************************************************

  • Colour code : *

  • Colour is a 4-char field where : *

  • - 1st char = C (color property) *

  • - 2nd char = color code (from 0 to 7) *

  • 0 = background color *

  • 1 = blue *

  • 2 = gray *

  • 3 = yellow *

  • 4 = blue/gray *

  • 5 = green *

  • 6 = red *

  • 7 = orange *

  • - 3rd char = intensified (0=off, 1=on) *

  • - 4th char = inverse display (0=off, 1=on) *

  • *

  • Colour overwriting priority : *

  • 1. Line *

  • 2. Cell *

  • 3. Column *

*****************************************************************

data : w_position type i value '1'.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'MATNR' to wa_fieldcat-fieldname.

move 'MARA' to wa_fieldcat-ref_table.

move 'MATNR' to wa_fieldcat-ref_field.

append wa_fieldcat to it_fieldcat.

add 1 to w_position.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'MATKL' to wa_fieldcat-fieldname.

move 'MARA' to wa_fieldcat-ref_table.

move 'MATKL' to wa_fieldcat-ref_field.

  • Color column

if p_column = 'X'.

move 'C610' to wa_fieldcat-emphasize.

endif.

append wa_fieldcat to it_fieldcat.

add 1 to w_position.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'COUNTER' to wa_fieldcat-fieldname.

move 'N' to wa_fieldcat-inttype.

move '4' to wa_fieldcat-intlen.

move 'Counter' to wa_fieldcat-coltext.

append wa_fieldcat to it_fieldcat.

add 1 to w_position.

clear wa_fieldcat.

move w_position to wa_fieldcat-col_pos.

move 'FREE_TEXT' to wa_fieldcat-fieldname.

move 'C' to wa_fieldcat-inttype.

move '20' to wa_fieldcat-intlen.

move 'Text' to wa_fieldcat-coltext.

append wa_fieldcat to it_fieldcat.

endform.

Regards

Subramanian

Read only

Former Member
0 Likes
1,104

Hi Sanjay,

see given example

REPORT zrnp_alv_so MESSAGE-ID znew .

************************************************************************

TABLE DECLARATION

************************************************************************

TABLES: vbak , "Sales Document: Header Data

vbap , "Sales Document: Item Data

makt , "Material Descriptions

lips . "SD document: Delivery: Item data

************************************************************************

DECLARATION OF TYPE-POOL

*THIS TYPE-POOL CONTAINS THE EVENTS,

************************************************************************

TYPE-POOLS : slis.

************************************************************************

DECLARATION OF EVENTS

************************************************************************

DATA: i_event TYPE slis_t_event.

DATA: t_event TYPE slis_alv_event.

************************************************************************

DECLARATION OF LIST HEADER

************************************************************************

DATA: i_listheader TYPE slis_t_listheader.

************************************************************************

DECLARATION OF FIELD CATALOG FOR SCREEN 1

************************************************************************

DATA: i_fldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

************************************************************************

DECLARATION OF FIELD CATALOG FOR SCREEN 2

************************************************************************

DATA: i_fldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE.

************************************************************************

DECLARATION OF FIELD LAYOUT

************************************************************************

DATA: i_layout TYPE slis_layout_alv.

************************************************************************

SORTING OF OUTPUT

************************************************************************

DATA: i_sort TYPE slis_t_sortinfo_alv.

************************************************************************

*DATA DECLARATION

************************************************************************

DATA: v_auart TYPE tvak-auart,

v_vkorg TYPE tvko-vkorg,

v_kunnr TYPE kna1-kunnr,

v_matnr TYPE mara-matnr ,

v_spart TYPE tvta-spart .

TYPES: BEGIN OF it_so ,

vbeln TYPE vbeln_va , "SALES ORDER NO.

auart TYPE auart , "SALES DOC. TYPE

vkorg TYPE vkorg , "SALES ORG.

spart TYPE spart , "DIVISION

kunnr TYPE kunag , "SOLD TO PARTY

posnr TYPE posnr_va , "SALES DOC. ITEM

matnr TYPE matnr , "MATERIAL NO

maktx TYPE maktx , "DESCRIPTION

kwmeng TYPE kwmeng , "QUANTITY

vrkme TYPE vrkme , "SALES UNIT

line_color(4) TYPE c ,

END OF it_so .

TYPES: BEGIN OF it_del ,

vbeln TYPE vbeln_vl , "SALES ORDER NO.

posnr TYPE posnr_vl , "SALES DOC. ITEM

matnr TYPE matnr , "MATERIAL NO

werks TYPE werks_d , "PLANT

lgort TYPE lgort_d , "STORAGE LOCATION

charg TYPE charg_d , "BATCH NO.

lfimg TYPE lfimg , "ACTUAL DELIVERY QTY.

vrkme TYPE vrkme , "SALES UNIT

END OF it_del .

TYPES: BEGIN OF type_vbfa ,

vbelv TYPE vbeln_von , "Preceding sales and distribution document

posnv TYPE posnr_von , "Preceding item of an SD document

vbeln TYPE vbeln_nach, "Subsequent sales and distribution document

posnn TYPE posnr_nach, "Document category of subsequent document

vbtyp_n TYPE vbtyp_n ,

END OF type_vbfa .

DATA: it_so1 TYPE STANDARD TABLE OF it_so ,

it_del1 TYPE STANDARD TABLE OF it_del ,

it_vbfa TYPE STANDARD TABLE OF type_vbfa,

it_del_ful TYPE STANDARD TABLE OF it_del.

DATA: wa_so TYPE it_so ,

wa_del TYPE it_del ,

wa_vbfa TYPE type_vbfa,

wa_it_del_ful TYPE it_del.

DATA: i_title_vbfa TYPE lvc_title VALUE 'SALES ORDER LIST DISPLAYED'.

DATA: i_title_vbpa TYPE lvc_title VALUE

'DELIVERY DETAILS DISPLAYED AGAINST GIVEN SALES ORDER'.

************************************************************************

*SELECTION SCREEN *

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-004 .

SELECT-OPTIONS: s_vbeln FOR vbak-vbeln ,

s_auart FOR v_auart ,

s_vkorg FOR v_vkorg ,

s_spart FOR v_spart ,

s_kunnr FOR v_kunnr ,

s_matnr FOR v_matnr .

SELECTION-SCREEN END OF BLOCK blk1 .

************************************************************************

*AT SELECTION SCREEN *

************************************************************************

AT SELECTION-SCREEN.

SELECT SINGLE vbeln

FROM vbak INTO vbak-vbeln

WHERE vbeln IN s_vbeln.

IF sy-subrc <> 0.

MESSAGE e202.

ENDIF.

************************************************************************

*START OF SELECTION *

************************************************************************

START-OF-SELECTION .

PERFORM data_select.

PERFORM t_sort USING i_sort .

PERFORM event_cat USING i_event .

PERFORM fld_cat USING i_fldcat[] .

PERFORM t_layout USING i_layout .

PERFORM fld_cat2 USING i_fldcat2[] .

PERFORM call_alv.

************************************************************************

  • DATA SELECT *

************************************************************************

&----


*& Form DATA_SELECT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_select .

REFRESH: it_vbfa, it_so1, it_del_ful ,it_del1 .

BREAK-POINT.

SELECT

a~vbeln

a~auart

a~vkorg

a~spart

a~kunnr

b~posnr

b~matnr

c~maktx

b~kwmeng

b~vrkme

INTO TABLE it_so1 FROM vbak AS a

JOIN vbap AS b ON bvbeln = avbeln

JOIN makt AS c ON cmatnr = bmatnr

AND c~spras = sy-langu

WHERE a~vbeln IN s_vbeln .

<b>************************************************************************

  • COLURING DISPLAY *

************************************************************************

DATA: ld_color(1) TYPE c .

LOOP AT it_so1 INTO wa_so.

  • Populate color variable with colour properties

  • Char 1 = C (This is a color property)

  • Char 2 = 3 (Color codes: 1 - 7)

  • Char 3 = Intensified on/off ( 1 or 0 )

  • Char 4 = Inverse display on/off ( 1 or 0 )

  • i.e. wa_ekko-line_color = 'C410'

ld_color = ld_color + 1.

  • Only 7 colours so need to reset color value

IF ld_color = 8.

ld_color = 1.

ENDIF.

CONCATENATE 'C' ld_color '10' INTO wa_so-line_color.

  • wa_ekko-line_color = 'C410'.

MODIFY it_so1 FROM wa_so.

ENDLOOP .</b>

IF sy-subrc = 0.

SELECT vbelv

posnv

vbeln

posnn

vbtyp_n

INTO TABLE it_vbfa

FROM vbfa

FOR ALL ENTRIES IN it_so1

WHERE vbelv = it_so1-vbeln

AND posnn = it_so1-posnr

AND vbtyp_n ='J' .

IF sy-subrc = 0.

SELECT vbeln

posnr

matnr

werks

lgort

charg

lfimg

vrkme

FROM lips INTO TABLE it_del_ful

FOR ALL ENTRIES IN it_vbfa

WHERE vbeln = it_vbfa-vbeln

AND posnr = it_vbfa-posnn.

ENDIF.

ENDIF.

ENDFORM. " DATA_SELECT

***********************************************************************

                                • EVENT CATALOG ****************************************

***********************************************************************

&----


*& Form EVENT_CAT

&----


  • text

----


  • -->P_I_EVENT text

----


FORM event_cat USING p_i_event TYPE slis_t_event .

REFRESH p_i_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

et_events = p_i_event

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

.

  • IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

READ TABLE p_i_event WITH KEY name = slis_ev_top_of_page INTO t_event.

IF sy-subrc = 0.

MOVE 'TOP_OF_PAGE' TO t_event-form.

MODIFY p_i_event FROM t_event INDEX sy-tabix TRANSPORTING form.

ENDIF.

CLEAR t_event .

ENDFORM. " EVENT_CAT

**********************************************************************

*********FORM FOR EVENT TOP_OF_PAGE*********************************

**********************************************************************

FORM top_of_page .

REFRESH i_listheader.

DATA: t_header TYPE slis_listheader.

DATA: v_text(50).

WRITE sy-datum TO v_text.

CLEAR t_header.

t_header-typ = 'S'.

t_header-key = 'Date'.

t_header-info = v_text.

APPEND t_header TO i_listheader.

CLEAR t_header.

CLEAR v_text.

  • WRITE: 'SALES ORDER REPORT ' TO v_text .

  • t_header-typ = 'S'.

  • t_header-key = 'TITLE'.

  • t_header-info = v_text.

  • APPEND t_header TO i_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_listheader.

  • I_LOGO = 'ALV_BACKGROUND'.

  • I_END_OF_LIST_GRID =

ENDFORM. "TOP_OF_PAGE

************************************************************************

                • FIRST ALV GRID DISPLAY ***************************************

************************************************************************

&----


*& Form CALL_ALV

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM call_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND1'

i_callback_top_of_page = 'TOP_OF_PAGE'

I_BACKGROUND_ID = 'ALV_BACKGROUND'

i_grid_title = i_title_vbfa

is_layout = i_layout

it_fieldcat = i_fldcat[]

it_sort = i_sort

it_events = i_event

TABLES

t_outtab = it_so1

.

  • IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

ENDFORM. " CALL_ALV

***********************************************************************

                            • FIRST FIELDCATALOG *************************************

***********************************************************************

&----


*& Form FLD_CAT

&----


  • text

----


  • -->P_I_FLDCAT[] text

----


FORM fld_cat USING p_i_fldcat TYPE slis_t_fieldcat_alv.

CLEAR i_fldcat.

i_fldcat-fieldname = 'VBELN'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'."TABLE NAME

i_fldcat-seltext_m = 'SALES ORDER NO.'.

i_fldcat-col_pos = 1. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'AUART'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'."TABLE NAME

i_fldcat-seltext_m = 'SALES DOC. TYPE'.

i_fldcat-col_pos = 2. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 15. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'VKORG'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'SALES ORG.'.

i_fldcat-col_pos = 3. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 12. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'SPART'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'DIVISION'.

i_fldcat-col_pos = 4. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'KUNNR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'SOLD TO PARTY'.

i_fldcat-col_pos = 5. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 15. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'POSNR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'SALES DOC. ITEM'.

i_fldcat-col_pos = 6. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 17. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'MATNR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'MATERIAL NO.'.

i_fldcat-col_pos = 7. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'MAKTX'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'DESCRIPTION'.

i_fldcat-col_pos = 8. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'KWMENG'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'QUANTITY'.

i_fldcat-col_pos = 9. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 15. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-do_sum = 'X'. " For doing "SUM"

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'VRKME'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_SO1'.

i_fldcat-seltext_m = 'SALES UNIT'.

i_fldcat-col_pos = 10. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'C'.

APPEND i_fldcat.

ENDFORM. " FLD_CAT

***********************************************************************

                                    • ALV SORTING ***************************************

***********************************************************************

&----


*& Form SORT

&----


  • text

----


  • -->P_I_SORT text

----


FORM t_sort USING p_i_sort TYPE slis_t_sortinfo_alv .

DATA: i_sort TYPE slis_sortinfo_alv .

REFRESH p_i_sort .

CLEAR i_sort.

i_sort-spos = 1.

i_sort-tabname = 'IT_SO1'.

i_sort-fieldname = 'VBELN'.

i_sort-up = 'X'.

i_sort-subtot = 'X'.

i_sort-group = '*'.

APPEND i_sort TO p_i_sort.

ENDFORM. " SORT

*FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.

  • SET PF-STATUS 'ZSTANDARD'.

*ENDFORM. "Set_pf_status

***********************************************************************

**********FORM FOR EVENT USER_COMMAND1*******************************

***********************************************************************

FORM user_command1 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

*CASE R_UCOMM .

  • WHEN '&IC1' .

*

  • IF rs_selfield-FIELDNAME = 'VBELN' .

*

  • ENDIF .

*

  • WHEN OTHERS .

*

  • ENDCASE .

CLEAR wa_so.

REFRESH: it_del1 .

IF r_ucomm = '&IC1' AND rs_selfield-fieldname = 'VBELN' AND

rs_selfield-value IS NOT INITIAL.

READ TABLE it_so1 INTO wa_so INDEX rs_selfield-tabindex.

IF sy-subrc = 0.

LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = wa_so-vbeln

AND posnv = wa_so-posnr.

READ TABLE it_del_ful INTO wa_it_del_ful

WITH KEY vbeln = wa_vbfa-vbelv

posnr = wa_vbfa-posnn.

IF sy-subrc = 0.

CLEAR wa_del.

MOVE wa_it_del_ful TO wa_del.

APPEND wa_del TO it_del1.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

*********************************************************************

                  • SECOND ALV GRID DISPLAY ***********************************

*********************************************************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND2'

i_callback_top_of_page = 'TOP_OF_PAGE'

I_BACKGROUND_ID = 'ALV_BACKGROUND'

i_grid_title = i_title_vbpa

it_fieldcat = i_fldcat2[]

it_sort = i_sort

TABLES

t_outtab = it_del_ful

.

  • IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

ENDFORM . "USER_COMMAND1

***********************************************************************

                    • FORM FOR EVENT USER_COMMAND 2 ******************************

***********************************************************************

FORM user_command2 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CLEAR wa_so.

REFRESH: it_del1 .

IF r_ucomm = '&IC1' AND rs_selfield-fieldname = 'VBELN' AND

rs_selfield-value IS NOT INITIAL.

READ TABLE it_so1 INTO wa_so INDEX rs_selfield-tabindex.

  • IF SY-SUBRC = 0.

*

  • LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = WA_SO-vbeln

  • AND posnv = WA_SO-posnr.

READ TABLE it_del_ful INTO wa_it_del_ful

WITH KEY vbeln = rs_selfield-value

posnr = wa_vbfa-posnn.

IF rs_selfield-fieldname = 'VBELN'.

SET PARAMETER ID 'VL' FIELD wa_vbfa-vbeln .

CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN.

ENDIF .

  • ENDLOOP.

  • ENDIF.

ENDIF.

ENDFORM . "USER_COMMAND2

************************************************************************

                  • SECOND FIELDCATALOG ******************************************

************************************************************************

&----


*& Form FLD_CAT2

&----


  • text

----


  • -->P_I_FLDCAT2[] text

----


FORM fld_cat2 USING p_i_fldcat2 TYPE slis_t_fieldcat_alv .

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'VBELN'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-tabname = 'IT_DEL_FUL'."TABLE NAME

i_fldcat2-seltext_m = 'DELIVERY NO.'.

i_fldcat2-col_pos = 1. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-hotspot = 'X'.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'POSNR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'DELIVERY ITEM'.

i_fldcat2-col_pos = 2. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'MATNR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'MATERIAL NO.'.

i_fldcat2-col_pos = 3. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'WERKS'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'PLANT.'.

i_fldcat2-col_pos = 4. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'LGORT'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'ST. LOCATION'.

i_fldcat2-col_pos = 5. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'CHARG'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'BATCH NO.'.

i_fldcat2-col_pos = 6. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'LFIMG'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'ACT. DEL. QTY.'.

i_fldcat2-col_pos = 7. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

CLEAR i_fldcat2.

i_fldcat2-fieldname = 'VRKME'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat2-seltext_m = 'SALES UNIT.'.

i_fldcat2-col_pos = 8. " POSITION OF THE COLUMN.

i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.

i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.

i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT

"SCROLLABLE AND HIDDABLE.

i_fldcat2-just(1) = 'C'.

APPEND i_fldcat2.

ENDFORM. " FLD_CAT2

************************************************************************

                                  • ALV LAYOUT *******************************************

************************************************************************

&----


*& Form LAYOUT

&----


  • text

----


  • -->P_I_LAYOUT text

----


FORM t_layout USING p_i_layout TYPE slis_layout_alv .

p_i_layout-zebra = 'X'.

p_i_layout-totals_text = 'GRAND TOTAL ='.

  • p_i_layout-CONFIRMATION_PROMPT = 'X'.

  • p_i_layout-DEF_STATUS = ' '.

p_i_layout-info_fieldname = 'LINE_COLOR'.

ENDFORM. " LAYOUT

Please reward point if useful answer.

Read only

Former Member
0 Likes
1,104

Hi,

<b>Coloring Individual Cells</b>

The procedure is similar to coloring an entire row. However, since an

individual cell can be addressed with two parameters we will need something

more. What is meant by “more” is a table type structure to be

included into the structure of the list data table. It seems strange,

because including it will make our list data structure deep. But anyhow ALV

Grid control handles this.

The structure that should be included must be of type “LVC_T_SCOL”.

If you want to color the entire row, this inner table should contain

only one row with field “fname” is set to space, some color value at

field “col”, “0” or “1” at fields “int” (intensified)

and “inv” (inverse).

If you want to color individual cells, then for each cell column,

append a line to this inner table which also contains the column name at

field “fname”. It is obvious that you can color an entire column by

filling this inner table with a row for that column for each row in the

list data table. But, it is also obvious that, this will be more time

consuming than the method at section C.6.1.

Again key field coloring will override your settings. That’s why, we

have another field in this inner table called “nokeycol”. For each

field represented in the inner table, set this field to ‘X’ to

prevent overriding of key color settings.

In this procedure, again we must tell the control the name of the inner

table containing color data. The field “CTAB_FNAME” of the layout

structure is used for this purpose.

<i><b>*--- Internal table holding list data

DATA BEGIN OF gt_list OCCURS 0 .

INCLUDE STRUCTURE SFLIGHT .

DATA rowcolor(4) TYPE c .

DATA cellcolors TYPE lvc_t_scol .

DATA END OF gt_list .

Code Part 15 – A sample code to make the cell at row 5 and column

‘SEATSOCC’ colored

DATA ls_cellcolor TYPE lvc_s_scol .

...

READ TABLE gt_list INDEX 5 .

ls_cellcolor-fname = 'SEATSOCC' .

ls_cellcolor-color-col = '7' .

ls_cellcolor-color-int = '1' .

APPEND ls_cellcolor TO gt_list-cellcolors .

MODIFY gt_list INDEX 5 .</b></i>

Hope this helps.

Reward if helpful.

Regards,

Sipra