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: 

colour for a Paticular row in alv grid,based on condition

Former Member
0 Kudos

Hi Master's.

I want to display a paticular row in my alv_grid based on my condition a diffrent colour.

The Entire row ?

Regards,

Abhisek

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can have a new field in your OUTPUT Table structure which is of 4 characters.

Lets say ROWCL is the field name.

While filling each row in your output table, you can also fill value for this field based on condition.

Contents of this field would be "CXYZ".

C - hardcode

X - 1,2,3,4,5,6,7 - Each number gives different color

Y - 1/0 - Intensified

Z - 1/0 - for some other property.

Now you have to mention this field name as the INFO field for the ALV GRID LAYOUT Structure.

GS_LAYOUT-info_fieldname = 'ROWCL'.

and pass this GS_LAYOUT to REUSE_ALV_GRID_DISPLAY.

Thanks,

Sai Ramesh P

5 REPLIES 5

Former Member
0 Kudos

You can have a new field in your OUTPUT Table structure which is of 4 characters.

Lets say ROWCL is the field name.

While filling each row in your output table, you can also fill value for this field based on condition.

Contents of this field would be "CXYZ".

C - hardcode

X - 1,2,3,4,5,6,7 - Each number gives different color

Y - 1/0 - Intensified

Z - 1/0 - for some other property.

Now you have to mention this field name as the INFO field for the ALV GRID LAYOUT Structure.

GS_LAYOUT-info_fieldname = 'ROWCL'.

and pass this GS_LAYOUT to REUSE_ALV_GRID_DISPLAY.

Thanks,

Sai Ramesh P

0 Kudos

Hi Ramesh,

How about just one row based on the condition ?

Regards,

Abhisek.

0 Kudos

Pass value (CXYZ) into ROWCL only for that particular row and dont pass anything to other rows.

Thanks

Sai Ramesh P

0 Kudos

Thanks alots

Regards,

Abhisek

naimesh_patel
Active Contributor
0 Kudos

If you are using the SALV model you can use class



*   Final output table
    TYPES: BEGIN OF ty_vbak,
           vbeln     TYPE vbak-vbeln,
           erdat     TYPE erdat,
           auart     TYPE auart,
           kunnr     TYPE kunnr,
           t_color   TYPE lvc_t_scol,   " << for color
           END   OF ty_vbak.
    DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak.

    DATA: lt_s_color TYPE lvc_t_scol,
          ls_s_color TYPE lvc_s_scol.

          ls_s_color-color-col = col_positive.
          ls_s_color-color-int = 0.
          ls_s_color-color-inv = 0.
          APPEND ls_s_color TO lt_s_color.
          CLEAR  ls_s_color.

*     Modify that data back to the output table
      la_vbak-t_color = lt_s_color.
      MODIFY ct_vbak FROM la_vbak.
      CLEAR  la_vbak.

You can check the entire code at: [SALV Table 9 u2013 Apply Colors|http://help-abap.zevolving.com/2008/10/salv-table-9-apply-colors/]

Regards,

Naimesh Patel