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: 

REUSE_ALV_FIELDCATALOG_MERGE missing fields

former_member713390
Participant
0 Kudos
515

Hi experts, I'm using FM REUSE_ALV_FIELDCATALOG_MERGE

but two fields are missing when displaying the ALV list. The two fields existing in the data dictionary, so I can't understand why is it.


TYPE-POOLS SLIS.


TABLES :MARA,MARC,MAKT,T001W,T023T.


DATA : BEGIN OF IT_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
MAKTX LIKE MAKT-MAKTX,
SPRAS LIKE MAKT-SPRAS,
WGBEZ LIKE T023T-WGBEZ ,
END OF IT_MARA .
DATA : BEGIN OF I_MARC ,
MATNR LIKE MARA-MATNR,
WERKS LIKE MARC-WERKS,
NAME1 LIKE T001W-NAME1,
SPRAS LIKE T001W-SPRAS,
END OF I_MARC.
DATA : IT_MARC LIKE STANDARD TABLE OF I_MARC .

DATA: BEGIN OF IT_MARAFINAL OCCURS 0,
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE MARC-WERKS,
NAME1 LIKE T001W-NAME1,
MATKL TYPE MARA-MATKL,
WGBEZ TYPE T023T-WGBEZ,
END OF IT_MARAFINAL.

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


SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
SELECT-OPTIONS : S_WERKS FOR MARC-WERKS.
SELECT-OPTIONS : S_MATKL FOR MARA-MATKL.


START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM VALIDATE_FCAT.

END-OF-SELECTION.
PERFORM DISPLAY_ALV.


FORM GET_DATA.

SELECT MARA~MATNR MARA~MATKL
MAKT~MAKTX MAKT~SPRAS
T023T~WGBEZ
INTO TABLE IT_MARA
FROM MARA
INNER JOIN MAKT ON MARA~MATNR = MAKT~MATNR
INNER JOIN T023T ON MARA~MATKL = T023T~MATKL
AND MAKT~SPRAS = T023T~SPRAS
WHERE MARA~MATNR IN S_MATNR
AND MARA~MATKL IN S_MATKL .

SELECT MARC~MATNR MARC~WERKS
T001W~NAME1 T001W~SPRAS
INTO TABLE IT_MARC
FROM MARC
INNER JOIN T001W ON MARC~WERKS = T001W~WERKS
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR = IT_MARA-MATNR
AND SPRAS = IT_MARA-SPRAS
AND MARC~WERKS IN S_WERKS .



LOOP AT IT_MARC INTO I_MARC .
READ TABLE IT_MARA WITH KEY MATNR = I_MARC-MATNR
SPRAS = I_MARC-SPRAS .

IF sy-subrc = 0.

IT_MARAFINAL-MATNR = IT_MARA-MATNR.
IT_MARAFINAL-MAKTX = IT_MARA-MAKTX.
IT_MARAFINAL-WERKS = I_MARC-WERKS.
IT_MARAFINAL-NAME1 = I_MARC-NAME1.
IT_MARAFINAL-MATKL = IT_MARA-MATKL.
IT_MARAFINAL-WGBEZ = IT_MARA-WGBEZ.
APPEND IT_MARAFINAL.

ENDIF.
CLEAR IT_MARAFINAL.

ENDLOOP.

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_INTERNAL_TABNAME = 'IT_MARAFINAL'
I_INCLNAME = SY-REPID
I_BYPASSING_BUFFER = 'X'

CHANGING
CT_FIELDCAT = IT_FCAT[].

ENDFORM.

1 ACCEPTED SOLUTION

abo
Active Contributor
358

Let me guess: the two missing fields are MATKL and WGBEZ in IT_MARAFINAL, right?

You need to use "LIKE" for all type declarations when you use automatic catalog generation through

REUSE_ALV_FIELDCATALOG_MERGE.

Save your time, fix the declaration and it will work.

7 REPLIES 7

moshenaveh
Community Manager
Community Manager
0 Kudos
358
Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful). The more details you provide, the more likely it is that members will be able to assist you. You should also make sure you're using all the appropriate tags, so the right experts can find your question. Should you wish, you can revise your question by selecting Actions, then Edit. Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Abinathsiva
Active Contributor
358

Hi,

Find the value of it_fcat through debug mode and find all the relevant information loaded properly...

In some cases where domain has similar properties that could result like this... in such cases loop it_fcat and modify the required values accordingly

abo
Active Contributor
359

Let me guess: the two missing fields are MATKL and WGBEZ in IT_MARAFINAL, right?

You need to use "LIKE" for all type declarations when you use automatic catalog generation through

REUSE_ALV_FIELDCATALOG_MERGE.

Save your time, fix the declaration and it will work.

0 Kudos
358

Hi

Thank you Alot,

I merge the tables mar Marc and mark into a internal table

and Now I want to do for all entries for this internal table and t001w or t023t But it doesn't give me the Expected

results


DATA : BEGIN OF I_MARA ,
MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE MARC-WERKS,
SPRAS LIKE MAKT-SPRAS,
END OF I_MARA .
DATA : IT_MARA LIKE STANDARD TABLE OF I_MARA .
DATA : BEGIN OF I_T023T ,
MATKL LIKE MARA-MATKL,
WGBEZ LIKE T023T-WGBEZ ,
SPRAS LIKE T023T-SPRAS,
END OF I_T023T.
DATA : IT_T023T LIKE STANDARD TABLE OF I_T023T .
*
DATA : BEGIN OF I_T001W ,
WERKS LIKE MARC-WERKS,
NAME1 LIKE T001W-NAME1,
SPRAS LIKE T001W-SPRAS,
END OF I_T001W.
DATA : IT_T001W LIKE STANDARD TABLE OF I_T001W .



DATA: BEGIN OF IT_MARAFINAL OCCURS 0,
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE T001W-WERKS,
NAME1 LIKE T001W-NAME1,
MATKL LIKE MARA-MATKL,
WGBEZ LIKE T023T-WGBEZ,
END OF IT_MARAFINAL.
*DATA : IT_MARAFINAL LIKE STANDARD TABLE OF I_MARAFINAL .

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

SELECT-OPTIONS : S_MATNR FOR I_MARA-MATNR.
SELECT-OPTIONS : S_WERKS FOR I_MARA-WERKS.
SELECT-OPTIONS : S_MATKL FOR I_MARA-MATKL.

START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM VALIDATE_FCAT.

END-OF-SELECTION.
PERFORM DISPLAY_ALV.
FORM GET_DATA.
CLEAR IT_MARAFINAL.
SELECT MARA~MATNR MARA~MATKL
MAKT~MAKTX MARC~WERKS
MAKT~SPRAS

INTO TABLE IT_MARA
FROM MARA
INNER JOIN MARC ON MARA~MATNR = MARC~MATNR
INNER JOIN MAKT ON MARA~MATNR = MAKT~MATNR
WHERE MARA~MATNR IN S_MATNR
AND MARA~MATKL IN S_MATKL
AND MARC~WERKS IN S_WERKS.

IF IT_MARA IS NOT INITIAL .

SELECT T001W~WERKS T001W~NAME1 T001W~SPRAS
INTO TABLE IT_T001W
FROM T001W
FOR ALL ENTRIES IN IT_MARA
WHERE WERKS = IT_MARA-WERKS AND SPRAS = IT_MARA-SPRAS .

SELECT T023T~MATKL T023T~WGBEZ
T023T~SPRAS
INTO TABLE IT_T023T
FROM T023T
FOR ALL ENTRIES IN IT_MARA
WHERE MATKL = IT_MARA-MATKL AND SPRAS = IT_MARA-SPRAS .

ENDIF.
SORT IT_MARA BY MATNR SPRAS .
LOOP AT IT_T023T INTO I_T023T .
LOOP AT IT_T001W INTO I_T001W .

READ TABLE IT_MARA INTO I_MARA WITH KEY MATKL = I_T023T-MATKL
SPRAS = I_T001W-SPRAS
WERKS = I_T001W-WERKS
BINARY SEARCH.

IF sy-subrc = 0.

IT_MARAFINAL-MATNR = I_MARA-MATNR.
IT_MARAFINAL-MAKTX = I_MARA-MAKTX.
IT_MARAFINAL-WERKS = I_T001W-WERKS.
IT_MARAFINAL-NAME1 = I_T001W-NAME1.
IT_MARAFINAL-MATKL = I_MARA-MATKL.
IT_MARAFINAL-WGBEZ = I_T023T-WGBEZ.
APPEND IT_MARAFINAL ."TO IT_MARAFINAL.

ENDIF.

ENDLOOP.
ENDLOOP.

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_INTERNAL_TABNAME = 'IT_MARAFINAL'
I_INCLNAME = SY-REPID
* I_BYPASSING_BUFFER = 'X'

CHANGING
CT_FIELDCAT = IT_FCAT[].
ENDFORM.

And my Select-option Is Empty

Although I did not enter any input in (select-option) But only 10 records are displayed in the output Where is my mistake?

Sandra_Rossi
Active Contributor
358

For information, you wouldn't have this issue at all if you had used CL_SALV_TABLE. REUSE_ALV_GRID_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE are completely obsolete.

abo
Active Contributor
358

afsane_salehi one post, one question and no questions in comments, if possible. It helps in keeping posts readable.

0 Kudos
358

Hi

Ok ,Sure

I Have Ask My question In This Link

https://answers.sap.com/questions/13188717/wrong-result.html?childToView=13190453#

If Possible Please Answer My Question.

Thank You .