Skip to Content
-4
Jul 12, 2019 at 05:12 AM

syntax err:cannot use an internal table as work area

97 Views

hii experts,

REPORT ZMM_BUSINESS_BASE.
TABLES : ZMM_BUSINESS,T001W,T001L,CEPC.
SELECT-OPTIONS : WERKS FOR ZMM_BUSINESS-WERKS.
* PRCTR FOR ZMM_BUSINESS-PRCTR.

TYPES : BEGIN OF TY_FINAL,
WERKS TYPE T001W-WERKS,
NAME1 TYPE T001W-NAME1,
LGORT TYPE T001L-LGORT,
LIFNR TYPE T001L-LIFNR,
PRCTR TYPE CEPC-PRCTR,


END OF TY_FINAL.
DATA : WA_FINAL TYPE TY_FINAL,
IT_FINAL TYPE TABLE OF TY_FINAL.

TYPES : BEGIN OF TY_ZMM_BUSINESS,

WERKS TYPE ZMM_BUSINESS-WERKS,
LGORT TYPE ZMM_BUSINESS-LGORT,
PRCTR TYPE ZMM_BUSINESS-PRCTR,
END OF TY_ZMM_BUSINESS.
DATA : WA_ZMM_BUSINESS TYPE TY_ZMM_BUSINESS,
IT_ZMM_BUSINESS TYPE TABLE OF TY_ZMM_BUSINESS.

TYPES : BEGIN OF TY_T001L,
IGORT TYPE T001L-LGORT,
WERKS TYPE T001L-WERKS,
LIFNR TYPE T001L-LIFNR,
END OF TY_T001L.
DATA : WA_T001L TYPE TY_T001L,
IT_T001L TYPE TABLE OF TY_T001L.

TYPES : BEGIN OF TY_T001W,
WERKS TYPE T001W-WERKS,
NAME1 TYPE T001W-WERKS,
LIFNR TYPE T001W-LIFNR,
END OF TY_T001W.
DATA : WA_T001W TYPE TY_T001W,
IT_T001W TYPE TABLE OF TY_T001W.



TYPES : BEGIN OF TY_CEPC,
PRCTR TYPE CEPC-PRCTR,
NAME1 TYPE CEPC-NAME1,
END OF TY_CEPC.
DATA : WA_CEPC TYPE TY_CEPC,
IT_CEPC TYPE TABLE OF TY_CEPC.


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

SELECT-OPTIONS : S_WERKS FOR T001W-WERKS,
S_LGORT FOR T001L-LGORT,
S_PRCTR FOR CEPC-PRCTR.

SELECTION-SCREEN END OF BLOCK A.

SELECT WERKS LGORT PRCTR FROM ZMM_BUSINESS INTO TABLE IT_ZMM_BUSINESS WHERE WERKS IN S_WERKS.

IF IT_ZMM_BUSINESS IS NOT INITIAL.
SELECT LGORT WERKS LIFNR FROM T001L INTO IT_T001L FOR ALL ENTRIES IN IT_ZMM_BUSINESS WHERE WERKS = IT_ZMM_BUSINESS-WERKS.
ENDIF.

IF IT_T001L IS NOT INITIAL.
SELECT WERKS NAME1 LIFNR FROM T001W INTO IT_T001W FOR ALL ENTRIES IN IT_T001L WHERE LIFNR = IT_T001L-LIFNR.
ENDIF.

IF IT_T001W IS NOT INITIAL.
SELECT PRCTR NAME1 FROM CEPC INTO IT_CEPC FOR ALL ENTRIES IN IT_T001W WHERE NAME1 = IT_T001L-NAME1.
ENDIF.

LOOP AT IT_ZMM_BUSINESS INTO WA_ZMM_BUSINESS.
WA_FINAL-WERKS = WA_ZMM_BUSINESS-WERKS.
WA_FINAL-LGORT = WA_ZMM_BUSINESS-LGORT.
WA_FINAL-PRCTR = WA_ZMM_BUSINESS-PRCTR.
ENDLOOP.

LOOP AT IT_T001L INTO WA_T001L.

WA_FINAL-LIFNR = WA_T001L-LIFNR.
ENDLOOP.

LOOP AT IT_CEPC INTO WA_CEPC.
WA_FINAL-NAME1 = WA_CEPC-NAME1.

READ TABLE IT_T001W INTO WA_T001W WITH KEY WERKS = WA_T001L-WERKS.
* WA_FINAL-NAME1 = WA_T001L-NAME1.

APPEND WA_FINAL TO IT_FINAL.

CLEAR : WA_ZMM_BUSINESS,
WA_T001W,
WA_T001L,
WA_CEPC.
ENDLOOP.



LOOP AI IT_FINAL INTO WA_FINAL.

WRITE :/ WA_FINAL-WERKS,
WA_FINAL-LGORT,
WA_FINAL-PRCTR,
WA_FINAL_NAME1,
WA_FINAL_LIFNR.

ENDLOOP.

This program gives an error on select statement(we cannot use an internal table as workarea)