2020 Nov 22 7:21 AM
HI EXPERT
I want to make two of my exit columns blue,My Code Here
TYPE-POOLS SLIS.
TYPES : BEGIN OF TY_T023T ,
MATKL TYPE T023T-MATKL,
WGBEZ TYPE T023T-WGBEZ,
END OF TY_T023T.
DATA : IT_T023T TYPE STANDARD TABLE OF TY_T023T .
DATA : I_T023T TYPE TY_T023T .
TYPES : BEGIN OF TY_T001W ,
WERKS TYPE T001W-WERKS,
NAME1 TYPE T001W-NAME1,
END OF TY_T001W.
DATA : IT_T001W TYPE STANDARD TABLE OF TY_T001W .
DATA : I_T001W TYPE TY_T001W .
DATA : IT_MARAFINAL TYPE STANDARD TABLE OF ZSTR_MARAFINAL,
I_MARAFINAL TYPE ZSTR_MARAFINAL .
DATA : IDX TYPE I .
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA : WA_FCAT TYPE SLIS_FIELDCAT_ALV.
SELECT-OPTIONS : S_MATNR FOR I_MARAFINAL-MATNR.
SELECT-OPTIONS : S_WERKS FOR I_MARAFINAL-WERKS.
SELECT-OPTIONS : S_MATKL FOR I_MARAFINAL-MATKL.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM VALIDATE_FCAT.
END-OF-SELECTION.
PERFORM DISPLAY_ALV.
FORM GET_DATA.
SELECT MARA~MATNR MAKT~MAKTX
MARC~WERKS MARA~MATKL
INTO TABLE IT_MARAFINAL
FROM MARA
INNER JOIN MARC ON MARC~MATNR = MARA~MATNR
INNER JOIN MAKT ON MAKT~MATNR = MARA~MATNR
AND MAKT~MATNR = MARC~MATNR
WHERE MARA~MATNR IN S_MATNR
AND MARA~MATKL IN S_MATKL
AND MARC~WERKS IN S_WERKS
AND MAKT~SPRAS = 'E'.
SORT IT_MARAFINAL BY MATNR .
IF IT_MARAFINAL[] IS NOT INITIAL .
SELECT T001W~WERKS T001W~NAME1
INTO TABLE IT_T001W
FROM T001W
FOR ALL ENTRIES IN IT_MARAFINAL
WHERE WERKS = IT_MARAFINAL-WERKS AND SPRAS EQ 'E'.
SELECT T023T~MATKL T023T~WGBEZ
INTO TABLE IT_T023T
FROM T023T
FOR ALL ENTRIES IN IT_MARAFINAL
WHERE MATKL = IT_MARAFINAL-MATKL AND SPRAS EQ 'E'.
LOOP AT IT_MARAFINAL[] INTO I_MARAFINAL .
READ TABLE IT_T001W INTO I_T001W
WITH KEY WERKS = I_MARAFINAL-WERKS.
I_MARAFINAL-NAME1 = I_T001W-NAME1 .
READ TABLE IT_T023T INTO I_T023T
WITH KEY MATKL = I_MARAFINAL-MATKL .
I_MARAFINAL-WGBEZ = I_T023T-WGBEZ .
IDX = SY-TABIX.
MODIFY IT_MARAFINAL FROM I_MARAFINAL INDEX IDX .
ENDLOOP.
ENDIF.
ENDFORM.
FORM DISPLAY_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MARAFINAL.
ENDFORM.
FORM VALIDATE_FCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_structure_name = 'ZSTR_MARAFINAL'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = IT_FCAT[].
ENDFORM.
-ZSTR_MARAFINAL Is a structure that i create in se11
now when i add cellcolor TYPE lvc_t_scol in my output internal tabale وBy the following code :
types : begin of ty_marafinal,
matnr like ZSTR_MARAFINAL-matnr ,
maktx like ZSTR_MARAFINAL-maktx ,
werks like ZSTR_MARAFINAL-WERKS ,
matkl like ZSTR_MARAFINAL-MATKL ,
wgbez like ZSTR_MARAFINAL-WGBEZ ,
name1 like ZSTR_MARAFINAL-name1,
cellcolor TYPE lvc_t_scol ,
end of ty_marafinal.
DATA : IT_MARAFINAL TYPE STANDARD TABLE OF TY_MARAFINAL,
I_MARAFINAL TYPE TY_MARAFINAL .
i see error :
the work area (or internal table ) 'it_marafinal' is not flat or contains references or internal tables as components. or internal tables as components. as components.
can you help me ? how can color cell in alv grid display and REUSE_ALV_FIELDCATALOG_MERGE
2020 Nov 22 7:27 AM
Hello afsane_salehi
You need to define an additional field in your internal table with data. That field should hold information about columns' colors.
You can find an example here: https://answers.sap.com/answers/1301499/view.html
There is plenty more on the Internet.
Kind regards,
Mateusz2020 Nov 22 8:16 AM
hi thank you
I see example but i cant understand what you mean .
can explain with details or edit my code ?
I see https://www.saplearners.com/cell-color-in-abap-alv-grid-report/
I tried to write like this code
2020 Nov 22 8:28 AM
Your IT_MARAFINAL table should have additional column called TABCOLOR of type LVC_T_SCOL.
In this field you will provide information about colors of the cells. Example from the link:
FORM f_modify_color USING u_fieldname TYPE lvc_fname
CHANGING us_vbak TYPE ty_vbak.
DATA :
l_rnd_value TYPE integer2,
ls_tabcolor TYPE lvc_s_scol.
Random value
CALL FUNCTION 'RANDOM_I2'
EXPORTING
rnd_min = 0
rnd_max = 3
IMPORTING
rnd_value = l_rnd_value.
CLEAR ls_tabcolor.
ls_tabcolor-fname = u_fieldname.
CASE l_rnd_value.
WHEN 0.
ls_tabcolor-color-col = 1. " Blue.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
WHEN 1.
ls_tabcolor-color-col = 3. " Yellow.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
WHEN 2.
ls_tabcolor-color-col = 5. " Green.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
WHEN 3.
ls_tabcolor-color-col = 6. " Red.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
ENDCASE.
INSERT ls_tabcolor INTO TABLE us_vbak-tabcolor.
ENDFORM. " F_MODIFY_COLOR
2020 Nov 22 11:32 AM
Exactly it is my problem when i add LVC_T_SCOL in my internaltable it_marafinal
types : begin of ty_marafinal,
matnr like ZSTR_MARAFINAL-matnr ,
maktx like ZSTR_MARAFINAL-maktx ,
werks like ZSTR_MARAFINAL-WERKS ,
matkl like ZSTR_MARAFINAL-MATKL ,
wgbez like ZSTR_MARAFINAL-WGBEZ ,
name1 like ZSTR_MARAFINAL-name1,
cellcolor TYPE lvc_t_scol ,
end of ty_marafinal.
DATA : IT_MARAFINAL TYPE STANDARD TABLE OF TY_MARAFINAL,
I_MARAFINAL TYPE TY_MARAFINAL .
i sae below error : the work area (or internal table ) 'it_marafinal' is not flat or contains references or internal tables as components. or internal tables as components. as components.
2020 Nov 22 11:51 AM
Use INTO CORRESPONDING FIELDS OF TABLE in the below SELECT statement.
SELECT MARA~MATNR MAKT~MAKTX
MARC~WERKS MARA~MATKL
INTO TABLE IT_MARAFINAL " <-- change here
FROM MARA
INNER JOIN MARC ON MARC~MATNR = MARA~MATNR
INNER JOIN MAKT ON MAKT~MATNR = MARA~MATNR
AND MAKT~MATNR = MARC~MATNR
WHERE MARA~MATNR IN S_MATNR
AND MARA~MATKL IN S_MATKL
AND MARC~WERKS IN S_WERKS
AND MAKT~SPRAS = 'E'.
2020 Nov 22 12:49 PM
2020 Nov 22 12:51 PM
It makes me proud to be able to communicate with you on this link.
2020 Nov 23 10:24 AM
HI
Dear mateuszadamus
I made the changes and now my first 2 columns are displayed in blue, but unfortunately the two name1 and wgbez fields are displayed in the empty output I asked my questions in the following link, if you help me, I would be really grateful
https://answers.sap.com/questions/13195563/empty-result-1.html?childToView=13193795#comment-13193795
2020 Nov 23 10:24 AM
HI
Dear mateuszadamus
I made the changes and now my first 2 columns are displayed in blue, but unfortunately the two name1 and wgbez fields are displayed in the empty output I asked my questions in the following link, if you help me, I would be really grateful
https://answers.sap.com/questions/13195563/empty-result-1.html?childToView=13193795#comment-13193795