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

Colours in report programming!

former_member1716
Active Contributor
0 Likes
1,074

Hello Experts,

My requirment is have to display different colours in diffetent rows in an alv report display, For this i selected to display seven set of colours, that is every seven rows will have differents colours, that is first and 8th row will be of same colours, then 2nd and 9th and so on.

I have coded like this as below, BUT STILL AM NOT ABLE SEE THE COLOUR IN MY OUTPUT REPORT WINDOW, PLEASE HELP ME ON THIS.PLEASE NOTE THAT I HAVE CODED FOR BUILDING FIELD CATALOGUE ALSO WHICH I HAVE NOT PASTED HERE.

IN TOP,

   TABLES MARA.
TYPE-POOLS SLIS.
TYPES:BEGIN OF TY_ALV,
      MATNR TYPE MARA-MATNR,
      ERSDA TYPE MARA-ERSDA,
      ERNAM TYPE MARA-ERNAM,
      LAEDA TYPE MARA-LAEDA,
      AENAM TYPE MARA-AENAM,
      VPSTA TYPE MARA-VPSTA,
      PSTAT TYPE MARA-PSTAT,
      LVORM TYPE MARA-LVORM,
      MTART TYPE MARA-MTART,
      MBRSH TYPE MARA-MBRSH,
      MATKL TYPE MARA-MATKL,
      BISMT TYPE MARA-BISMT,
      MEINS TYPE MARA-MEINS,
      LINECOLOUR(4) TYPE C,
  END OF TY_ALV.

DATA:IT_ALV type STANDARD TABLE OF TY_ALV,

     WA_ALV type TY_ALV.

DATA MATNR TYPE MARA-MATNR.
DATA US1 TYPE SY-UCOMM.
DATA V_FLAG TYPE I.
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

DATA: gd_layout    type slis_layout_alv.

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

   START-OF-SELECTION.
PERFORM FETCH_DATA.                                 "FETCHING DATA.
PERFORM FIELDCATALOG.                               "CATALOG CONTENT.
PERFORM BUILD_LAYOUT.
PERFORM ALVSELECTION.                               "ALV SELECTION.

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

   FORM FETCH_DATA .
data: id_colour(1) type c.

SELECT
  MATNR
  ERSDA
  ERNAM
  LAEDA
  AENAM
  VPSTA
  PSTAT
  LVORM
  MTART
  MBRSH
  MATKL
  BISMT
  MEINS
  FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_ALV.

  LOOP AT IT_ALV INTO WA_ALV.
  ID_COLOUR = ID_COLOUR + 1.
  IF ID_COLOUR = 8.
    ID_COLOUR = 1.
  ENDIF.
  CONCATENATE 'C' ID_COLOUR '10' INTO WA_ALV-LINECOLOUR.
  MODIFY IT_ALV FROM WA_ALV.
  ENDLOOP.
ENDFORM.        

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

   FORM BUILD_LAYOUT .

gd_layout-no_input          = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text       = 'Totals'(201).
gd_layout-info_fieldname    = 'LINE_COLOR'.


ENDFORM.  

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

   FORM ALVSELECTION .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
     I_CALLBACK_PROGRAM                = SY-REPID
     IS_LAYOUT                         = GD_LAYOUT
     IT_FIELDCAT                       = FIELDCATALOG[]
     I_SAVE                            = 'X'
    TABLES
      T_OUTTAB                          = IT_ALV
   EXCEPTIONS
     PROGRAM_ERROR                     = 1
     OTHERS                            = 2.
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.
ENDFORM.

1 ACCEPTED SOLUTION
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,036

You need to pass this LINECOLUR field in field catalg also.

gd_layout-info_fieldname    = 'LINECOLOUR'.

6 REPLIES 6
Read only

former_member209120
Active Contributor
0 Likes
1,036

This message was moderated.

Read only

0 Likes
1,036

Thanks Ramesh,

It was very helpful. Nabheet found out the mistake where i made and it worked.

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,037

You need to pass this LINECOLUR field in field catalg also.

gd_layout-info_fieldname    = 'LINECOLOUR'.

Read only

0 Likes
1,036

Yup Nabheet,

It worked, Thanks for your help. Did not note this error. Thanks for your quick resolution.

Read only

davis_raja
Active Participant
0 Likes
1,036

For adding colors to individual cells you can add a deep structure to your table IT_ALV.

DATA : BEGIN OF it_final OCCURS 0.
          INCLUDE STRUCTURE zpmsp_dpr_detail.
DATA : cellcolor   TYPE lvc_t_scol.
DATA : END OF it_final.

Then while appending the data to IT_FINAL you can add the color to each cell.

    wa_cellcolor-fname = 'I1_ACT'.
     wa_cellcolor-color-col = '7'.
     wa_cellcolor-color-int = '1'.
     APPEND wa_cellcolor TO wa_final-cellcolor.
     CLEAR : wa_cellcolor.

Try like this. It will work.

Read only

0 Likes
1,036

Thanks for the info raja.