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: 

Coloring ALV text

Former Member
0 Kudos
753

Can anyone tell me how to color the text in the cell of an ALV report? I know how to color a particular cell or the a row or a column, but i want to change the color of the text. IS it possible? The reason i am asking this is when i am sub totalling a column in AALV grid, the text color at the sub total row is black, which is fine. But the color of the text in the other rows (rows with actual data)is white and which is almost invisible. So i want to change that color from white to black or some other dark color.

11 REPLIES 11

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
185

To be honest, I've not seen this done in an ALV before. So, I don't know if it can be done or not.

Regards,

Rich Heilman

0 Kudos
185

Yes, it is possible in a LIST. I've never seen it in a GRID.

Regards,

Rich HEilman

Former Member
0 Kudos
185

Yes it is possible see below example

REPORT Z_REPT

LINE-SIZE 180

LINE-COUNT 55

NO STANDARD PAGE HEADING

MESSAGE-ID Z2.

TABLES: MCH1,

MCHB,

MVKE,

LIPS,

LFA1,

VBUP,

MARA,

MAKT,

EINA,

MARC,

MBEW,

T001W,

T001L,

T134.

TYPE-POOLS: slis, imrep.

Data : Begin of it_header occurs 0,

MATNR LIKE MVKE-MATNR, "Material

MAKTX LIKE MAKT-MAKTX, "Description

MTART LIKE MARA-MTART, "material type

WERKS LIKE MCHB-WERKS, "Plant

NAME1 LIKE T001W-NAME1, "PLANT NAME

LGORT LIKE MCHB-LGORT, "Storage Location

LSDYS LIKE MARA-MHDRZ, "days in material Group 2

End of it_header.

  • Data for listviewer

DATA: repid LIKE sy-repid.

DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA: keyinfo TYPE slis_keyinfo_alv.

DATA: color TYPE slis_t_specialcol_alv WITH HEADER LINE.

DATA: layout TYPE slis_layout_alv.

DATA: print TYPE slis_print_alv.

DATA: sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.

DATA: excluding TYPE slis_t_extab WITH HEADER LINE.

  • Variants

DATA: variante LIKE disvariant,

def_variante LIKE disvariant,

variant_exit(1) TYPE c.

Data : v_sydatum type sy-datum.

types: slis_t_event type slis_alv_event occurs 0.

CONSTANTS : C_CCODE TYPE T001-BUKRS VALUE '1000'.

DATA : BEGIN OF IT_T001 OCCURS 1,

BUKRS LIKE T001-BUKRS,

WAERS LIKE T001-WAERS,

END OF IT_T001.

DATA : BEGIN OF IT_T001W OCCURS 0,

WERKS LIKE T001W-WERKS,

NAME1 LIKE T001W-NAME1,

END OF IT_T001W.

**Structure for Events.

DATA : X_EVENTS TYPE SLIS_ALV_EVENT.

**Internal table to hold events.

DATA : IT_EVENTS TYPE SLIS_T_EVENT.

DATA : R_UCOMM LIKE SY-UCOMM.

DATA : RS_SELFIELD TYPE SLIS_SELFIELD.

DATA: BEGIN OF ITAB OCCURS 10,

MATNR LIKE MVKE-MATNR, "Material

MAKTX LIKE MAKT-MAKTX, "Description

MTART LIKE MARA-MTART, "material type

WERKS LIKE MCHB-WERKS, "Plant

LGORT LIKE MCHB-LGORT, "Storage Location

LIFNR LIKE EINA-LIFNR, "Vendor

DISPO LIKE MARC-DISPO, "MRP controller

EKGRP LIKE MARC-EKGRP, "Purchasing Group

LSDAY LIKE MARA-MHDRZ, "days in material Group 2

CHARG LIKE MCH1-CHARG, "Batch

VFDAT LIKE MCH1-VFDAT, "Expiration Date

LSDYS LIKE MARA-MHDRZ, "last ship days (expdate - mvgr2)

LSHDT LIKE MCH1-VFDAT, "last ship date

QNDAT LIKE MCH1-QNDAT, "Retest Date

BFDAT LIKE MCH1-VFDAT, "last shp date - buffer days

RSHLF LIKE MARA-MHDRZ, "Remaining shelf life

CLABS LIKE MCHB-CLABS, "U/R Stock.

MEINS LIKE MARA-MEINS,

VALCL LIKE MBEW-STPRS, "Value U/R

WAERS LIKE T001-WAERS,

CINSM LIKE MCHB-CINSM, "Q stock

VALCI LIKE MBEW-STPRS, "Value Q

CEINM LIKE MCHB-CEINM, "Restricted

VALCE LIKE MBEW-STPRS, "Value restricted

CSPEM LIKE MCHB-CSPEM, "Blocked

VALCS LIKE MBEW-STPRS, "Value blocked

CRETM LIKE MCHB-CRETM, "Returns

VALCR LIKE MBEW-STPRS, "Value Returns

ONDEL LIKE LIPS-LFIMG, "Qty on Delivery

RSLDAYS(10) TYPE C, "Exp.Date - System date

END OF ITAB.

DATA: ITAB1 LIKE ITAB OCCURS 10 WITH HEADER LINE.

Data : begin of it_ALV occurs 10.

include structure itab.

data : farbe type slis_t_specialcol_alv,

  • MEINS LIKE MARA-MEINS,

End of it_ALV.

DATA: BEGIN OF IT_MARA OCCURS 10,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MEINS LIKE MARA-MEINS,

END OF IT_MARA.

DATA: V_FIELD(20),

V_TEMP(20),

W_STRING(40) TYPE C,

V_LSHDT TYPE NUMC3,

V_LSDYS TYPE NUMC3.

W_STRING = 'LIST OF BATCHES WITH LAST SHIP DATE'.

SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_MATNR FOR MVKE-MATNR,

S_WERKS FOR MCHB-WERKS,

S_LGORT FOR MCHB-LGORT,

S_CHARG FOR MCH1-CHARG,

S_LIFNR FOR EINA-LIFNR.

SELECTION-SCREEN END OF BLOCK A.

SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-002.

SELECT-OPTIONS: S_MTART FOR MARA-MTART,

S_DISPO FOR MARC-DISPO,

S_EKGRP FOR MARC-EKGRP.

SELECTION-SCREEN END OF BLOCK B.

SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-003.

SELECT-OPTIONS: S_VFDAT FOR MCH1-VFDAT,

S_LSHDT FOR MCH1-VFDAT.

SELECTION-SCREEN END OF BLOCK C.

SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-004.

PARAMETERS: p_vari LIKE disvariant-variant.

PARAMETERS: P_NOVAL AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK D.

*****

  • F4-Help for variant

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

PERFORM f4_for_variant.

----


Initialisierung -

INITIALIZATION.

PERFORM initialisierung.

*----


AT SELECTION-SCREEN.

*----


  • Material Number

IF NOT s_matnr-low IS INITIAL OR NOT s_matnr-high IS INITIAL.

SELECT SINGLE * FROM mara WHERE matnr IN s_matnr

and mtart in s_mtart.

IF SY-SUBRC NE 0.

MESSAGE E060 WITH S_MATNR-LOW S_MATNR-HIGH.

ENDIF.

SELECT SINGLE * FROM marc WHERE matnr IN s_matnr

and werks in s_werks.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Material Plant combination is not valid'.

ENDIF.

ENDIF.

  • Plant

IF NOT s_werks-low IS INITIAL OR NOT s_werks-high IS INITIAL.

SELECT SINGLE * FROM t001w WHERE werks IN s_werks.

IF SY-SUBRC NE 0.

MESSAGE E054 WITH S_WERKS-LOW S_WERKS-HIGH.

ENDIF.

ENDIF.

  • Storage Location

IF NOT s_lgort-low IS INITIAL OR NOT s_lgort-high IS INITIAL.

SELECT SINGLE * FROM t001l WHERE werks in s_werks

AND lgort IN s_lgort.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Invalid Storage Location'.

ENDIF.

ENDIF.

  • Batch Number

IF NOT S_CHARG-low IS INITIAL OR NOT S_CHARG-high IS INITIAL.

SELECT SINGLE * FROM MCHB WHERE CHARG IN S_CHARG AND

MATNR IN S_MATNR AND

WERKS IN S_WERKS.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Invalid Batch Number'.

ENDIF.

ENDIF.

  • Vendor

IF NOT s_lifnr-low IS INITIAL OR NOT s_lifnr-high IS INITIAL.

SELECT SINGLE * FROM LFA1 WHERE LIFNR IN S_LIFNR.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Invalid Vendor Number'.

ENDIF.

ENDIF.

  • Material type

IF NOT s_mtart-low IS INITIAL OR NOT s_mtart-high IS INITIAL.

SELECT SINGLE * FROM t134 WHERE mtart IN s_mtart.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Invalid Material Type'.

ENDIF.

ENDIF.

  • MRP Controller

IF NOT S_DISPO-low IS INITIAL OR NOT S_DISPO-high IS INITIAL.

SELECT SINGLE * FROM MARC WHERE MATNR IN S_MATNR AND

WERKS IN S_WERKS AND

DISPO IN S_DISPO.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Invalid MRP Controller'.

ENDIF.

ENDIF.

  • Purchasing Group

IF NOT S_EKGRP-low IS INITIAL OR NOT S_EKGRP-high IS INITIAL.

SELECT SINGLE * FROM MARC WHERE MATNR IN S_MATNR AND

WERKS IN S_WERKS AND

EKGRP IN S_EKGRP.

IF SY-SUBRC NE 0.

MESSAGE E999 WITH 'Invalid Purchasing Group'.

ENDIF.

ENDIF.

  • Display variant

IF NOT p_vari IS INITIAL.

MOVE variante TO def_variante.

MOVE p_vari TO def_variante-variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

i_save = 'A'

CHANGING

cs_variant = def_variante.

variante = def_variante.

ELSE.

CLEAR variante.

variante-report = repid.

ENDIF.

*----


START-OF-SELECTION.

*----


SET PF-STATUS 'STANDARD'.

PERFORM GET_BATCHES.

****

PERFORM GET_CURRENCY.

PERFORM GET_PLANTS.

PERFORM PREPARE_FIELDCATALOG.

PERFORM LIST_OUTPUT.

PERFORM USERCOMMAND USING R_UCOMM

RS_SELFIELD.

  • PERFORM WRITE_REPORT.

*----


*AT LINE-SELECTION.

  • GET CURSOR FIELD V_TEMP.

  • IF V_TEMP = 'ITAB1-CHARG'.

  • IF SY-SUBRC = 0.

  • PERFORM DISPLAY_BATCH.

  • ENDIF.

  • ENDIF.

*AT USER-COMMAND.

  • GET CURSOR FIELD V_TEMP.

  • R_UCOMM = SY-UCOMM.

  • RS_SELFIELD-TABNAME = 'IT_ALV'.

  • RS_SELFIELD-FIELDNAME = V_TEMP.

TOP-OF-PAGE.

ULINE.

WRITE: /1 'Requester:', 12 SY-UNAME, 40 W_STRING, 116 'Date:',

SY-DATUM.

ULINE.

WRITE: /1 'BATCH', 12 'EXP DATE', 23 'LS MTHs', 33 'LAST SHPDT', 45

'REM LIFE', 58 'PLANT', 64 'SLOC', 80 'U/R', 90 'QUALITY', 108

'RESTRICTED', 123 'BLOCKED', 140 'RETURNS'.

ULINE.

END-OF-PAGE.

&----


*& Form get_batches

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_BATCHES.

SELECT MATNR MTART MEINS FROM MARA INTO TABLE IT_MARA WHERE

MTART IN S_MTART AND

MATNR IN S_MATNR.

IF SY-SUBRC = 0.

LOOP AT IT_MARA.

SELECT * FROM MCHB INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE

MATNR EQ IT_MARA-MATNR AND

WERKS IN S_WERKS AND

LGORT IN S_LGORT AND

CHARG IN S_CHARG AND

( CLABS GT 0 OR CINSM GT 0 OR CEINM GT 0 OR CSPEM GT 0 OR

CRETM GT 0 ).

IF SY-SUBRC = 0.

CLEAR ITAB.

PERFORM GET_DESCRIPTION.

PERFORM GET_STKVAL.

PERFORM GET_MTART.

PERFORM CHECK_MARC.

LOOP AT ITAB.

SELECT * FROM MCH1 INTO MCH1 WHERE

MATNR = ITAB-MATNR AND

CHARG = ITAB-CHARG.

IF SY-SUBRC = 0.

ITAB-VFDAT = MCH1-VFDAT.

ITAB-QNDAT = MCH1-QNDAT.

ITAB-LIFNR = MCH1-LIFNR.

IF ( ITAB-MTART EQ 'FERT' OR ITAB-MTART EQ 'HALB' OR

ITAB-MTART = 'ZSFG' OR ITAB-MTART EQ 'HAWA' ) AND

ITAB-VFDAT NE'00000000'.

IF NOT ITAB-VFDAT IS INITIAL.

ITAB-RSHLF = ITAB-VFDAT - SY-DATUM.

ENDIF.

PERFORM GET_LAST_SHIPDATE.

ENDIF.

MODIFY ITAB.

ENDIF.

ENDSELECT.

ENDLOOP.

PERFORM CHECK_DATES.

APPEND LINES OF ITAB TO ITAB1.

ELSE.

CONTINUE.

ENDIF.

APPEND ITAB.

ENDLOOP.

ENDIF.

ENDFORM. " get_batches

&----


*& Form get_last_shipdate

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_LAST_SHIPDATE.

CLEAR V_LSDYS.

SELECT MVGR2 FROM MVKE INTO MVKE-MVGR2 WHERE

MATNR = ITAB-MATNR.

IF MVKE-MVGR2 NE 'NA'.

V_LSDYS = MVKE-MVGR2.

ELSE.

V_LSDYS = 0.

ENDIF.

ITAB-LSDYS = V_LSDYS.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

CURRDATE = ITAB-VFDAT

BACKMONTHS = V_LSDYS

IMPORTING

NEWDATE = ITAB-LSHDT.

IF ITAB-LSHDT CS '0229'.

IF SY-SUBRC = 0.

CONCATENATE ITAB-LSHDT(4) '0301' INTO ITAB-LSHDT.

ITAB-LSHDT = ITAB-LSHDT - 1.

ENDIF.

ENDIF.

IF ( ITAB-LSHDT4(2) EQ '04' OR ITAB-LSHDT4(2) EQ '06' OR

ITAB-LSHDT4(2) EQ '09' OR ITAB-LSHDT4(2) EQ '11' )

AND ITAB-LSHDT+6(2) EQ '31'.

CONCATENATE ITAB-LSHDT(6) '30' INTO ITAB-LSHDT.

ENDIF.

  • ITAB-BFDAT = ITAB-LSHDT - V_ADDDAY.

ENDSELECT.

ENDFORM. " get_last_shipdate

&----


*& Form write_report

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM WRITE_REPORT.

CLEAR ITAB1.

SORT ITAB1 BY MATNR.

LOOP AT ITAB1.

AT NEW MATNR.

READ TABLE ITAB1 INDEX SY-TABIX.

FORMAT COLOR 4 INTENSIFIED ON.

WRITE: /10 'MATERIAL:', ITAB1-MATNR, ITAB1-MAKTX.

FORMAT COLOR OFF.

ENDAT.

WRITE: /1 ITAB1-CHARG, 12 ITAB1-VFDAT, 23 ITAB1-LSDYS,

33 ITAB1-LSHDT, 45 ITAB1-RSHLF, 58 ITAB1-WERKS, 64

ITAB1-LGORT, 70 ITAB1-CLABS, 85 ITAB1-CINSM, 100 ITAB1-CEINM,

115 ITAB1-CSPEM, 130 ITAB1-CRETM.

HIDE: ITAB1-WERKS, ITAB1-LGORT, ITAB1-MATNR, ITAB1-CHARG.

ENDLOOP.

CLEAR ITAB1.

ULINE.

ENDFORM. " write_report

&----


*& Form display_batch

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_BATCH.

SET PARAMETER ID 'MAT' FIELD IT_ALV-MATNR.

SET PARAMETER ID 'CHA' FIELD IT_ALV-CHARG.

SET PARAMETER ID 'WRK' FIELD IT_ALV-WERKS.

SET PARAMETER ID 'LAG' FIELD IT_ALV-LGORT.

CALL TRANSACTION 'MSC3N' AND SKIP FIRST SCREEN.

ENDFORM. " display_batch

&----


*& Form stock_overview

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM STOCK_OVERVIEW.

DATA : L_CHARG LIKE IT_ALV-CHARG.

SET PARAMETER ID 'MAT' FIELD IT_HEADER-MATNR.

SET PARAMETER ID 'CHA' FIELD L_CHARG.

SET PARAMETER ID 'WRK' FIELD IT_HEADER-WERKS.

  • SET PARAMETER ID 'LAG' FIELD IT_HEADER-LGORT.

CALL TRANSACTION 'MMBE' AND SKIP FIRST SCREEN.

ENDFORM. " stock_overview

&----


*& Form DISPLAY_REQLIST

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_REQLIST.

SET PARAMETER ID 'MAT' FIELD IT_HEADER-MATNR.

SET PARAMETER ID 'WRK' FIELD IT_HEADER-WERKS.

CALL TRANSACTION 'MD04' AND SKIP FIRST SCREEN.

ENDFORM. " DISPLAY_REQLIST

&----


*& Form check_marc

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CHECK_MARC.

LOOP AT ITAB.

SELECT SINGLE * FROM MARC INTO MARC WHERE

MATNR EQ ITAB-MATNR AND

WERKS IN S_WERKS AND

DISPO IN S_DISPO AND

EKGRP IN S_EKGRP.

IF SY-SUBRC NE 0.

DELETE ITAB.

ELSE.

ITAB-DISPO = MARC-DISPO.

ITAB-EKGRP = MARC-EKGRP.

MODIFY ITAB.

ENDIF.

  • MODIFY ITAB.

ENDLOOP.

ENDFORM. " check_marc

&----


*& Form get_description

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DESCRIPTION.

LOOP AT ITAB.

SELECT * FROM MAKT INTO MAKT WHERE MATNR EQ ITAB-MATNR.

IF SY-SUBRC = 0.

ITAB-MAKTX = MAKT-MAKTX.

ENDIF.

MODIFY ITAB.

ENDSELECT.

ENDLOOP.

ENDFORM. " get_description

&----


*& Form get_mtart

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_MTART.

CLEAR ITAB.

LOOP AT ITAB.

SELECT * FROM MARA INTO MARA WHERE

MATNR = ITAB-MATNR.

IF SY-SUBRC = 0.

ITAB-MTART = MARA-MTART.

ENDIF.

MODIFY ITAB.

ENDSELECT.

ENDLOOP.

ENDFORM. " get_mtart

&----


*& Form check_dates

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CHECK_DATES.

CLEAR ITAB.

LOOP AT ITAB.

IF ITAB-VFDAT IN S_VFDAT AND

ITAB-LSHDT IN S_LSHDT AND

ITAB-LIFNR IN S_LIFNR.

CONTINUE.

ELSE.

DELETE ITAB.

ENDIF.

  • modify itab.

ENDLOOP.

ENDFORM. " check_dates

&----


*& Form get_stkval

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_STKVAL.

CLEAR ITAB.

LOOP AT ITAB.

SELECT * FROM MBEW INTO MBEW WHERE

MATNR = ITAB-MATNR AND

BWKEY = ITAB-WERKS.

IF SY-SUBRC = 0.

ITAB-VALCL = ( ITAB-CLABS * MBEW-STPRS ) / MBEW-PEINH.

ITAB-VALCI = ( ITAB-CINSM * MBEW-STPRS ) / MBEW-PEINH.

ITAB-VALCE = ( ITAB-CEINM * MBEW-STPRS ) / MBEW-PEINH.

ITAB-VALCS = ( ITAB-CSPEM * MBEW-STPRS ) / MBEW-PEINH.

ITAB-VALCR = ( ITAB-CRETM * MBEW-STPRS ) / MBEW-PEINH.

ENDIF.

MODIFY ITAB.

ENDSELECT.

ENDLOOP.

ENDFORM. " get_stkval

&----


*& Form PREPARE_FIELDCATALOG

&----


  • text

----


FORM PREPARE_FIELDCATALOG.

  • Header fields

CLEAR fieldcat.

fieldcat-fieldname = 'MATNR'.

fieldcat-tabname = 'IT_HEADER'.

fieldcat-ref_tabname = 'MARA'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'MAKTX'.

fieldcat-tabname = 'IT_HEADER'.

fieldcat-ref_tabname = 'MAKT'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'WERKS'.

fieldcat-tabname = 'IT_HEADER'.

fieldcat-ref_tabname = 'T001W'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'NAME1'.

fieldcat-tabname = 'IT_HEADER'.

fieldcat-ref_tabname = 'T001W'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'LSDYS'.

fieldcat-tabname = 'IT_HEADER'.

fieldcat-seltext_s = text-023.

fieldcat-seltext_l = text-023.

fieldcat-seltext_m = text-023.

fieldcat-outputlen = '13'.

APPEND fieldcat.

CLEAR fieldcat.

  • Detail Fields

fieldcat-fieldname = 'LGORT'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MARD'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'CHARG'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MCHB'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'VFDAT'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MCH1'.

fieldcat-outputlen = '12'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'LSHDT'.

fieldcat-tabname = 'ITAB1'.

fieldcat-seltext_s = text-022.

fieldcat-seltext_l = text-022.

fieldcat-seltext_m = text-022.

fieldcat-outputlen = '12'.

fieldcat-ref_tabname = 'MCH1-VFDAT'.

APPEND fieldcat.

CLEAR fieldcat.

  • fieldcat-fieldname = 'RSLDAYS'.

fieldcat-fieldname = 'RSHLF'.

fieldcat-tabname = 'ITAB1'.

fieldcat-seltext_s = text-021.

fieldcat-seltext_l = text-021.

fieldcat-seltext_m = text-021.

fieldcat-outputlen = '10'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'CLABS'.

fieldcat-tabname = 'ITAB1'.

fieldcat-qfieldname = 'MEINS'.

fieldcat-seltext_s = text-010.

fieldcat-seltext_l = text-010.

fieldcat-seltext_m = text-010.

fieldcat-do_sum = 'X'.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'MEINS'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MARA'.

fieldcat-qfieldname = 'MEINS'.

fieldcat-outputlen = '4'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'CEINM'.

fieldcat-tabname = 'ITAB1'.

fieldcat-qfieldname = 'MEINS'.

fieldcat-do_sum = 'X'.

fieldcat-seltext_s = text-011.

fieldcat-seltext_l = text-011.

fieldcat-seltext_m = text-011.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'CINSM'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MCHB'.

fieldcat-qfieldname = 'MEINS'.

fieldcat-do_sum = 'X'.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'CSPEM'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MCHB'.

fieldcat-qfieldname = 'MEINS'.

fieldcat-do_sum = 'X'.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'CRETM'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'MCHB'.

fieldcat-qfieldname = 'MEINS'.

fieldcat-do_sum = 'X'.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

*****Second Row

if p_noval = ' '.

fieldcat-fieldname = 'DUMMY'.

fieldcat-tabname = 'ITAB1'.

  • fieldcat-ref_tabname = 'MCHB'.

fieldcat-row_pos = '2'.

fieldcat-outputlen = 52.

APPEND fieldcat.

CLEAR fieldcat.

  • fieldcat-fieldname = 'DUMMY_LGORT'.

  • fieldcat-tabname = 'ITAB1'.

  • fieldcat-ref_tabname = 'MARD'.

  • fieldcat-row_pos = '2'.

  • fieldcat-outputlen = '4'.

  • APPEND fieldcat.

  • CLEAR fieldcat.

  • fieldcat-fieldname = 'DUMMY_CHARG'.

  • fieldcat-tabname = 'ITAB1'.

    • fieldcat-ref_tabname = 'MCHB'.

  • fieldcat-row_pos = '2'.

  • fieldcat-outputlen = '10'.

  • APPEND fieldcat.

  • CLEAR fieldcat.

*

  • fieldcat-fieldname = 'DUMMY_VFDAT'.

  • fieldcat-tabname = 'ITAB1'.

    • fieldcat-ref_tabname = 'MCH1'.

  • fieldcat-row_pos = '2'.

  • fieldcat-outputlen = '12'.

  • APPEND fieldcat.

  • CLEAR fieldcat.

*

  • fieldcat-fieldname = 'DUMMY_LSHDT'.

  • fieldcat-tabname = 'ITAB1'.

  • fieldcat-row_pos = '2'.

  • fieldcat-outputlen = '12'.

  • APPEND fieldcat.

  • CLEAR fieldcat.

*

  • fieldcat-fieldname = 'DUMMY_RSLDAYS'.

  • fieldcat-tabname = 'ITAB1'.

  • fieldcat-row_pos = '2'.

  • fieldcat-outputlen = '5'.

  • APPEND fieldcat.

  • CLEAR fieldcat.

fieldcat-fieldname = 'VALCL'.

fieldcat-tabname = 'ITAB1'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-do_sum = 'X'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_l = text-020.

fieldcat-seltext_m = text-020.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'WAERS'.

fieldcat-tabname = 'ITAB1'.

fieldcat-ref_tabname = 'T001'.

fieldcat-Cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-outputlen = 4.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'VALCE'.

fieldcat-tabname = 'ITAB1'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-do_sum = 'X'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_l = text-020.

fieldcat-seltext_m = text-020.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'VALCI'.

fieldcat-tabname = 'ITAB1'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-do_sum = 'X'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_l = text-020.

fieldcat-seltext_m = text-020.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'VALCS'.

fieldcat-tabname = 'ITAB1'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-do_sum = 'X'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_l = text-020.

fieldcat-seltext_m = text-020.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'VALCR'.

fieldcat-tabname = 'ITAB1'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-do_sum = 'X'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_l = text-020.

fieldcat-seltext_m = text-020.

fieldcat-outputlen = '15'.

APPEND fieldcat.

CLEAR fieldcat.

endif.

ENDFORM. " PREPARE_FIELDCATALOG

&----


*& Form LIST_OUTPUT

&----


  • text

----


FORM LIST_OUTPUT.

DATA : LV_TABIX LIKE SY-TABIX.

DEFINE colourize.

clear color.

color-fieldname = &1.

color-color-int = '0'.

IF &2 <> 0.

if &3 = '8888' or &3 = '9999'.

color-color-col = '6'.

ELSE.

COLOR-COLOR-COL = '5'.

ENDIF.

endif.

append color.

case &1.

when 'CLABS'.

color-fieldname = 'MEINS'.

append color.

when 'VALCL'.

color-fieldname = 'WAERS'.

append color.

endcase.

END-OF-DEFINITION.

keyinfo-header01 = 'MATNR'.

keyinfo-item01 = 'MATNR'.

v_sydatum = sy-datum.

SORT ITAB1 BY MATNR.

SORT IT_MARA BY MATNR.

LOOP AT ITAB1.

CLEAR LV_TABIX.

LV_TABIX = SY-TABIX.

MOVE-CORRESPONDING ITAB1 TO IT_ALV.

  • it_alv-rsldays = itab1-vfdat - v_sydatum .

it_alv-rsldays = itab1-rshlf.

CLEAR IT_MARA.

READ TABLE IT_MARA WITH KEY MATNR = ITAB1-MATNR BINARY SEARCH.

IT_ALV-MEINS = IT_MARA-MEINS.

CLEAR IT_T001.

READ TABLE IT_T001 WITH KEY BUKRS = C_CCODE BINARY SEARCH.

IT_ALV-WAERS = IT_T001-WAERS.

AT NEW MATNR.

READ TABLE ITAB1 INDEX LV_TABIX.

MOVE-CORRESPONDING ITAB1 TO IT_HEADER.

READ TABLE IT_T001W WITH KEY WERKS = ITAB1-WERKS BINARY SEARCH.

IT_HEADER-NAME1 = IT_T001W-NAME1.

APPEND IT_HEADER.

ENDAT.

REFRESH color.

colourize 'CLABS' ITAB1-CLABS ITAB1-LGORT.

colourize 'CINSM' ITAB1-CINSM ITAB1-LGORT.

colourize 'CEINM' ITAB1-CEINM ITAB1-LGORT.

colourize 'CSPEM' ITAB1-CSPEM ITAB1-LGORT.

colourize 'CRETM' ITAB1-CRETM ITAB1-LGORT.

colourize 'VALCL' ITAB1-VALCL ITAB1-LGORT.

colourize 'VALCI' ITAB1-VALCI ITAB1-LGORT.

colourize 'VALCE' ITAB1-VALCE ITAB1-LGORT.

colourize 'VALCS' ITAB1-VALCS ITAB1-LGORT.

colourize 'VALCR' ITAB1-VALCR ITAB1-LGORT.

IT_ALV-farbe = color[].

APPEND IT_ALV.

CLEAR : ITAB1, IT_HEADER, IT_ALV.

ENDLOOP.

repid = sy-repid.

layout-coltab_fieldname = 'FARBE'.

layout-group_change_edit = 'X'.

print-no_print_listinfos = 'X'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = repid

IS_LAYOUT = layout

I_CALLBACK_PF_STATUS_SET = 'STANDARD'

I_CALLBACK_USER_COMMAND = 'USERCOMMAND'

IT_FIELDCAT = fieldcat[]

I_DEFAULT = 'X'

i_save = 'A'

is_variant = variante

I_TABNAME_HEADER = 'IT_HEADER'

I_TABNAME_ITEM = 'ITAB1'

IS_KEYINFO = keyinfo

TABLES

T_OUTTAB_HEADER = IT_HEADER

T_OUTTAB_ITEM = IT_ALV.

ENDFORM. " LIST_OUTPUT

&----


*& Form GET_CURRENCY

&----


  • GETING THE CURRENCY

----


FORM GET_CURRENCY.

SELECT SINGLE BUKRS

WAERS

FROM T001

INTO (IT_T001-BUKRS, IT_T001-WAERS)

WHERE BUKRS = C_CCODE.

APPEND IT_T001.

ENDFORM. " GET_CURRENCY

&----


*& Form USERCOMMAND

&----


  • text

----


FORM USERCOMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

IF RS_SELFIELD-FIELDNAME = 'CHARG'.

READ TABLE IT_ALV INDEX RS_SELFIELD-TABINDEX.

ELSEIF RS_SELFIELD-FIELDNAME = 'MATNR'.

READ TABLE IT_HEADER INDEX RS_SELFIELD-TABINDEX.

ENDIF.

CASE R_UCOMM.

WHEN 'BATH'.

IF RS_SELFIELD-SEL_TAB_FIELD = 'IT_ALV-CHARG'.

PERFORM DISPLAY_BATCH.

ELSE.

MESSAGE I002(SY) WITH 'Place the Cursor on the Batch Number'.

ENDIF.

WHEN 'STOC'.

IF RS_SELFIELD-SEL_TAB_FIELD = 'IT_HEADER-MATNR'.

PERFORM STOCK_OVERVIEW.

ELSE.

MESSAGE I002(SY) WITH 'Place the Cursor on the Material Number'.

ENDIF.

WHEN 'STRQ'.

IF RS_SELFIELD-SEL_TAB_FIELD = 'IT_HEADER-MATNR'.

PERFORM DISPLAY_REQLIST.

ELSE.

MESSAGE I002(SY) WITH 'Place the Cursor on the Material Number'.

ENDIF.

ENDCASE.

ENDFORM. " USERCOMMAND

&----


*& Form GET_PLANTS

&----


  • GETTING PLANT NAMES

----


FORM GET_PLANTS.

SELECT WERKS

NAME1

FROM T001W

INTO TABLE IT_T001W

FOR ALL ENTRIES IN ITAB1

WHERE WERKS = ITAB1-WERKS.

SORT IT_T001W BY WERKS.

ENDFORM. " GET_PLANTS

&----


*& Form f4_for_variant

&----


  • text

----


FORM f4_for_variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = variante

i_save = 'A'

  • it_default_fieldcat =

IMPORTING

e_exit = variant_exit

es_variant = def_variante

EXCEPTIONS

not_found = 2.

IF sy-subrc = 2.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

IF variant_exit = space.

p_vari = def_variante-variant.

ENDIF.

ENDIF.

ENDFORM. " f4_for_variant

&----


*& Form initialisierung

&----


  • text

----


FORM initialisierung.

repid = sy-repid.

CLEAR variante.

variante-report = repid.

  • Get default variant

def_variante = variante.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = 'A'

CHANGING

cs_variant = def_variante

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_vari = def_variante-variant.

ENDIF.

ENDFORM. " initialisierung

Cheers,

Satya

0 Kudos
185

Hi Venkat,

I think entire part of your code was not copied. Some important which subrputines are missing which can give me the clue.

Former Member
0 Kudos
185

The following link provides the information how to color the entire row in ALV grid.

http://help.sap.com/saphelp_46c/helpdata/en/fa/efb529f8a611d2b48d006094192fe3/frameset.htm

Former Member
0 Kudos
185

Hi,

I assume that you know how to give color to a Row in an ALV Grid (by specfifying layout-info_fname = 'ROWCOLOR' where rowcolor is a CHAR4 field in the internal table that you pass to the ALV Grid.

Now when you give colors to each line, normally we give colors as follows,

itab-rowcolor = 'C510'. "Green Intensified background

If you want to give colors to letters then simply give the following,

itab-rowcolor = 'C501'. "Green letters & not background

Hope this helps..

Sri

0 Kudos
185

Thanks Sri.....it worked perfectly and it is coloring the texts. But i still have one problem, it will be great if u have any solution for that.

Suppose the report has sub-totalling on first two columns. When i am trying to apply the text color to the entire report, the texts are being colored for all the columns except those two sub totalling color. And SAP is by default displaying the text of those subtotalling columns as white, which is almost invisible. To change the color of the text of those sub-totalling columns is my actual requirement. But i cant change the background color nor the text color for them. DO u have any solution for that?

Thanks again for your help....

Sayantan

0 Kudos
185

hi Sayantan,

when we use sub_total u will get only that field in that row, and the entire row will be in yellow color with sub_total value black and bold format,

i think we can't change it because yellow color represents total.

i also doubt on seeing other fields in that row.

regards,

manohar

0 Kudos
185

Hi Sayantan,

I think we cannot change background color or text color of the subtotal columns but if you mark NO_MERGING = 'X' in the field catalog of the column then it retains the normal row color that we give for even subtotal columns.

The only issue is that the subtotal column values will stay populated on all rows even if they are same.

If that is OK then I think you can mark NO_MERGING = 'X' in the field catalog lines of subtotal columns.

Hope this helps..

Sri

0 Kudos
185

Hi Sri,

We cannot unmerge those when they are same. That is also the requirement. But anyway, thanks a lot for your help.

Regards

Sayantan

Former Member
0 Kudos
185

Hi,

You try with 'Style' field in the field catalog structure of ALV. I think it is possible if U familiar with ALV control style.