‎2020 May 15 7:19 AM
hi all,
please help me..
i am getting
If the addition "FOR ALL ENTRIES IN itab" is used, the fields "WERKS" and "ITMARC-WERKS" must have the same type and the same length. in
REPORT zmanoj.
TABLES : mara,marc,t001w.
TYPE-POOLS: slis.
TYPES : BEGIN OF ty_mara,
matnr TYPE matnr,
mtart TYPE mtart,
END OF ty_mara.
TYPES : BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks,
END OF ty_marc.
TYPES : BEGIN OF ty_t001w,
werks TYPE werks,
name1 TYPE name1,
END OF ty_t001w.
TYPES : BEGIN OF ty_final,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
werks TYPE marc-werks,
name1 TYPE t001w-name1,
END OF ty_final.
DATA : it TYPE TABLE OF ty_final,
wa TYPE ty_final.
DATA : itmara TYPE TABLE OF ty_mara,
wamara TYPE ty_mara.
DATA : itmarc TYPE TABLE OF ty_marc,
wamarc TYPE ty_marc.
DATA : itt001w TYPE TABLE OF ty_t001w,
wat001w TYPE ty_t001w.
DATA repid TYPE sy-repid.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
layout TYPE slis_layout_alv.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT matnr
mtart
FROM mara INTO TABLE itmara
WHERE matnr IN s_matnr.
IF itmara IS NOT INITIAL.
SELECT matnr
werks
FROM marc INTO TABLE itmarc
FOR ALL ENTRIES IN itmara
WHERE matnr = itmara-matnr.
ENDIF.
<--------- here i am getting error------->
IF itmarc IS NOT INITIAL.
SELECT name1
werks
FROM t001w INTO TABLE itt001w
FOR ALL ENTRIES IN itmarc
WHERE werks = itmarc-werks. ------ in this link !!!
ENDIF.
LOOP AT itmarc INTO wamarc.
wa-matnr = wamarc-matnr.
wa-werks = wamarc-werks.
READ TABLE itmara INTO wamara WITH KEY matnr = wamarc-matnr.
wa-mtart = wamara-mtart.
READ TABLE itt001w INTO wat001w WITH KEY werks = wamarc-werks.
wa-name1 = wat001w-name1.
APPEND wa TO it.
CLEAR : wa, wamara, wamarc, wat001w.
ENDLOOP.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-ref_tabname = 'MARA'.
wa_fieldcat-seltext_m = 'Accounting Document Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-ref_tabname = 'MARA'.
wa_fieldcat-seltext_m = 'Accounting'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-ref_tabname = 'MARC'.
wa_fieldcat-seltext_m = 'Accouncument Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-ref_tabname = 'T001W'.
wa_fieldcat-seltext_m = 'Accou'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
call FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
i_grid_title = 'ACCOUNTING DOCUMENT DETAILS'
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it.
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
‎2020 May 15 7:22 AM
Hi manoj16393
You have errors in your type definitions. Plant has a type of WERKS_D, not WERKS. You need to change it in TY_MARC and TY_T001W types. Then it should work.
regards,
Mateusz
‎2020 May 15 9:32 AM
‎2020 May 15 7:31 AM
Hi Manoj,
check types declaration, for all entries need exact domain element matches, instead for this you can try with inner join than All entries.
Regards
‎2020 May 15 9:32 AM
‎2020 May 15 7:40 AM
Please, try and phrase your title with more meaningful content
‎2020 May 15 8:02 AM
Hello manoj16393
Replace
TYPES : BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks,
END OF ty_marc.With
TYPES : BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.Also compare the definitions of WERKS and WERKS_D in SE11 and you'll see why - WERKS is a structure, where as WERKS_D is a data element.
I'd also suggest replacing other occurrences of TYPE WERKS with TYPE WERKS_D unless you really want to use structure WERKS in your declarations.
Best regards
Dominik Tylczynski
‎2020 May 15 9:27 AM
‎2020 May 15 8:50 AM
manoj16393,
All your data type declaration for the plant field (WERKS) is pointing out to Data Type WERKS which is wrong, the Data Type must refer to WERKS_D. You can see below the screen shots on the difference. WERKS is a structure and WERKS_D is a data element
WERKS is a Structure

WERKS_D is the Data Element

Regards!
‎2020 May 15 9:33 AM
‎2020 May 15 9:05 AM
Dear Manoj
Please change your code in the following section
TYPES : BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE t001w-werks, " change it from werks to t001w-werks
END OF ty_marc.
Because, the type werks - itself a structure - hence you got this error.
Regards,
Venkat
‎2020 May 15 9:34 AM
‎2020 May 15 9:51 AM
Dear Manoj
If this answer has solved your problem, accept the answer and close the thread. This will help other who search for the same solutions.
Thanks,
Venkat