REPORT z_vtest13.
TABLES :
marc,
mast,
mapl.
SELECT-OPTIONS : s_matnr FOR marc-matnr,
s_werks FOR marc-werks.
TYPES : BEGIN OF ty_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
lvorm TYPE marc-lvorm,
ekgrp TYPE marc-ekgrp,
dismm TYPE marc-dismm,
dispo TYPE marc-dispo,
END OF ty_marc.
DATA : it_marc TYPE TABLE OF marc,
wa_marc TYPE ty_marc.
TYPES : BEGIN OF ty_mast,
matnr TYPE mast-matnr,
werks TYPE mast-werks,
stlan TYPE mast-stlan,
stlnr TYPE mast-stlnr,
stlal TYPE mast-stlal,
END OF ty_mast.
DATA : it_mast TYPE TABLE OF mast,
wa_mast TYPE ty_mast.
DATA : BEGIN OF it_table1 OCCURS 0,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
lvorm TYPE marc-lvorm,
ekgrp TYPE marc-ekgrp,
dismm TYPE marc-dismm,
dispo TYPE marc-dispo,
stlan TYPE mast-stlan,
stlnr TYPE mast-stlnr,
stlal TYPE mast-stlal,
END OF it_table1.
TYPES : BEGIN OF ty_table2.
INCLUDE TYPE ty_marc.
TYPES : stlan TYPE mast-stlan,
stlnr TYPE mast-stlnr,
stlal TYPE mast-stlal.
TYPES : END OF ty_table2.
SELECT matnr werks lvorm ekgrp dismm dispo
FROM marc
INTO CORRESPONDING FIELDS OF TABLE it_marc WHERE matnr IN s_matnr AND werks IN s_werks.
IF sy-subrc = 0.
SELECT matnr werks stlan stlnr stlal
FROM mast
INTO CORRESPONDING FIELDS OF TABLE it_mast
FOR ALL ENTRIES IN it_marc
WHERE matnr = it_marc-matnr AND
werks = it_marc-werks.
ENDIF.
WRITE :/.
SKIP 1.
LOOP AT it_mast INTO wa_mast.
WRITE : / sy-vline,
wa_mast-matnr, sy-vline,
wa_mast-werks, sy-vline,
wa_mast-stlan, sy-vline,
wa_mast-stlnr, sy-vline,
wa_mast-stlal, sy-vline.
ENDLOOP.
TABLES :
marc,
mast,
mapl.
SELECT-OPTIONS : s_matnr FOR marc-matnr,
s_werks FOR marc-werks.
TYPES : BEGIN OF ty_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
lvorm TYPE marc-lvorm,
ekgrp TYPE marc-ekgrp,
dismm TYPE marc-dismm,
dispo TYPE marc-dispo,
END OF ty_marc.
DATA : it_marc TYPE TABLE OF marc,
wa_marc TYPE ty_marc.
TYPES : BEGIN OF ty_mast,
matnr TYPE mast-matnr,
werks TYPE mast-werks,
stlan TYPE mast-stlan,
stlnr TYPE mast-stlnr,
stlal TYPE mast-stlal,
END OF ty_mast.
DATA : it_mast TYPE TABLE OF mast,
wa_mast TYPE ty_mast.
DATA : BEGIN OF it_table1 OCCURS 0,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
lvorm TYPE marc-lvorm,
ekgrp TYPE marc-ekgrp,
dismm TYPE marc-dismm,
dispo TYPE marc-dispo,
stlan TYPE mast-stlan,
stlnr TYPE mast-stlnr,
stlal TYPE mast-stlal,
END OF it_table1.
TYPES : BEGIN OF ty_table2.
INCLUDE TYPE ty_marc.
TYPES : stlan TYPE mast-stlan,
stlnr TYPE mast-stlnr,
stlal TYPE mast-stlal.
TYPES : END OF ty_table2.
SELECT matnr werks lvorm ekgrp dismm dispo
FROM marc
INTO CORRESPONDING FIELDS OF TABLE it_marc WHERE matnr IN s_matnr AND werks IN s_werks.
IF sy-subrc = 0.
SELECT matnr werks stlan stlnr stlal
FROM mast
INTO CORRESPONDING FIELDS OF TABLE it_mast
FOR ALL ENTRIES IN it_marc
WHERE matnr = it_marc-matnr AND
werks = it_marc-werks.
ENDIF.
WRITE :/.
SKIP 1.
LOOP AT it_mast INTO wa_mast.
WRITE : / sy-vline,
wa_mast-matnr, sy-vline,
wa_mast-werks, sy-vline,
wa_mast-stlan, sy-vline,
wa_mast-stlnr, sy-vline,
wa_mast-stlal, sy-vline.
ENDLOOP.