Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Color particular cell :ALV

Hello Experts.

In my ALV report, I want to color particular cell where qty is less than zero.

Plz suggest where do i call this code.

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

  • DATA SELECTION AND DISPLAY LOGIC.

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

  • Data fetching, filtering and arranging.

START-OF-SELECTION.

PERFORM get_data.

PERFORM arrange_data.

  • Displaying the Data fetched.

END-OF-SELECTION.

PERFORM build_catlog.

PERFORM eventtab_field USING gt_events.

PERFORM set_cell_colours. <--- Help required

PERFORM comment_build USING gt_list_top_of_page[].

PERFORM display_alv.

&----


*

*& Form SET_CELL_COLOURS

&----


  • Set colour of individual ALV cell, field

----


FORM SET_CELL_COLOURS .

DATA: WA_CELLCOLOR TYPE LVC_S_SCOL.

DATA: ld_index TYPE SY-TABIX.

LOOP AT gt_final into gw_final.

LD_INDEX = SY-TABIX.

  • Set colour of QTY_6 field to color 6 if less than 0

if gw_final-QTY_6 LT 0.

WA_CELLCOLOR-FNAME = 'QTY_6'.

WA_CELLCOLOR-COLOR-COL = 6 . "color code 1-7, if outside rage defaults to 7

WA_CELLCOLOR-COLOR-INT = '0'. "1 = Intensified on, 0 = Intensified off

WA_CELLCOLOR-COLOR-INV = '0'. "1 = text colour, 0 = background colour

APPEND WA_CELLCOLOR TO gw_final-CELLCOLOR.

MODIFY gt_final from gw_final INDEX ld_index TRANSPORTING CELLCOLOR.

endif.

ENDLOOP.

ENDFORM. " SET_CELL_COLOURS

Thanks in advance .

Ravi.

Former Member
Former Member replied

Hi.. follow the steps...

Declare


DATA :  ISO_CELL_COLOR TYPE LVC_T_SCOL,               "Sorted table for cell coloring purpose
       W_CELL_COLOR TYPE LVC_S_SCOL.                 "work area for cell coloring purpose.

  • Add following column in your internal table which u are using for fieldcatalog...


       ISO_CELL_COLOR TYPE LVC_T_SCOL

Then Add following code....when filling the record in field catalog internal table...


 LOOP AT ITAB_FINAL INTO WA_FINAL.

            IF WA_FINAL-SKALAB EQ 0.

                CLEAR W_CELL_COLOR.
                W_CELL_COLOR-FNAME = 'SKALAB'.
                W_CELL_COLOR-COLOR-COL = '6'.
                W_CELL_COLOR-COLOR-INT = '1'.
                W_CELL_COLOR-COLOR-INV = '1'.
                APPEND W_CELL_COLOR TO ISO_CELL_COLOR.

                WA_FINAL-ISO_CELL_COLOR = ISO_CELL_COLOR.

             ENDIF.

             MODIFY ITAB_FINAL FROM WA_FINAL TRANSPORTING ISO_CELL_COLOR SKALAB.
             REFRESH ISO_CELL_COLOR.

     ENDLOOP.

here Loop is for your internal table which u are using for field catalog...

WA_FINAL-SKALAB is ur field for which u want to put "0" value condition....

here red color will be displayed...

This will surly helpful to u....

Regards,

Chintan

Edited by: Chintan_SAP on Apr 20, 2009 3:40 PM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question