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: 

EMPTY RESULT

former_member713390
Participant
0 Kudos
354

Hi Expert

Although I got the value of name1 and wgbez from the relevant table, but These values are not displayed in the report output These values were OK before I displayed the two fields MATNR and MAKTX in blue

Where is my mistake?


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 .


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 .


DATA : IDX TYPE I .
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA : WA_FCAT TYPE SLIS_FIELDCAT_ALV.


DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA :IT_CELLCOLOR TYPE LVC_S_SCOL.

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.
PERFORM VALIDATE_LAYOUT .


END-OF-SELECTION.
PERFORM DISPLAY_ALV.


FORM GET_DATA.


SELECT MARA~MATNR MAKT~MAKTX
MARC~WERKS MARA~MATKL
INTO CORRESPONDING FIELDS OF 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 .

IT_cellcolor-fname = 'MATNR'.
IT_cellcolor-color-col = 4.
IT_cellcolor-color-int = '1'.
IT_cellcolor-color-inv = '0'.
APPEND IT_cellcolor TO I_MARAFINAL-cellcolor.
CLEAR: IT_cellcolor.


IT_cellcolor-fname = 'MAKTX'.
IT_cellcolor-color-col = 4.
IT_cellcolor-color-int = '1'.
IT_cellcolor-color-inv = '0'.
APPEND IT_cellcolor TO I_MARAFINAL-cellcolor.
CLEAR: IT_cellcolor.


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 TRANSPORTING cellcolor.

ENDLOOP.



ENDIF.


ENDFORM.

FORM DISPLAY_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
is_layout = IT_layout
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_INTERNAL_TABNAME = 'IT_MARAFINAL'
I_structure_name = 'ZSTR_MARAFINAL'
I_INCLNAME = SY-REPID

CHANGING
CT_FIELDCAT = IT_FCAT.
ENDFORM.

FORM VALIDATE_LAYOUT .
CLEAR IT_layout.
IT_layout-colwidth_optimize = 'X'. " Optimization of Col width
IT_layout-coltab_fieldname = 'CELLCOLOR'.
ENDFORM.

9 REPLIES 9

former_member1716
Active Contributor
0 Kudos
187

afsane_salehi,

Before getting onto solution part, kindly post your code using CODE option for better readability and formatting.

You have constructed Field Catalog only for MATNR and MAKTX, for fields to be displayed in your output all the fields as part of the table must have relevant entry in field catalog table.

Regards!

0 Kudos
187

hi thank you

With this part, am I not finalizing the information of the other two tables?

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 TRANSPORTING cellcolor.

187

afsane_salehi Please use the CODE button please, thank you!

0 Kudos
187

DEAR satishkumarbalasubramanian

I am a beginner and I have no idea about the word code .

can you explain with details and Can you tell me where my problem is?

187

When you typed your question, the little editor has a number of buttons. One of them has the word "code" written on it. When you want to post code, use this button as it preserves formatting and makes it far easier for people to read your code. Of course, make sure that your code is pretty printed before posting it.

...
      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 TRANSPORTING cellcolor. ENDLOOP. ENDIF. ENDFORM.

is far easier to read and understand than

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 TRANSPORTING cellcolor.
ENDLOOP.
ENDIF.
ENDFORM.

Wouldn't you agree?

Sandra_Rossi
Active Contributor
0 Kudos
187

Please use the CODE button so that your code keeps indented, keywords are highlighted and it remains legible. Sorry, I won't do the effort of reading something not legible and so do many other volunteers.

nmirandaghn
Participant
0 Kudos
187

Seems to me that problem is that variable IDX takes the wrong SY-TABIX. When you read table I_T023T then SY-TABIX receives the index of that table and not from it_marafinal.

Put IDX = SY-TABIX at the beginning of the LOOP.

...
idx = sy-tabix. " <-- This line should be after 'loop at ...'
                " <-- The IDX takes value of SY-TABIX from table it_t023t'. 

modify it_marafinal[] from i_marafinal index idx transporting cellcolor.

raymond_giuseppi
Active Contributor
0 Kudos
187

Replace

LOOP AT IT_MARAFINAL[] INTO I_MARAFINAL .

with

LOOP AT IT_MARAFINAL[] ASSIGNING <MARAFINAL>.

and forget about MODIFY statement (and index)

187

And forget about the []. There's no ambiguity since there is a) no header line and b) it's a LOOP AT statement.

I use this nowadays:

DATA mara_final_record TYPE REF TO ty_mara_final_record.
LOOP AT it_marafinal REFERENCE INTO mara_final_record.
mara_final_record->some_field = new_value. ENDLOOP.