REPORT ZJH_SAL_3_INNER_JOIN.

TABLES: VBAK,VBAP , MARA.

TYPES: BEGIN OF ST_SAL,
         VBELN TYPE VBELN_VA,
         ERDAT TYPE ERDAT,
         ERNAM TYPE ERNAM,
         POSNR TYPE POSNR,
         MATNR TYPE MATNR,
         MTART TYPE MTART,
         MATKL TYPE MATKL,
       END OF ST_SAL.

DATA: IT_SAL TYPE STANDARD TABLE OF ST_SAL,
      W_SAL TYPE ST_SAL.

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.

SELECT VBAK~VBELN
       VBAK~ERDAT
       VBAK~ERNAM
       VBAP~POSNR
       VBAP~MATNR
       MARA~MTART
       MARA~MATKL INTO TABLE IT_SAL
  FROM VBAK INNER JOIN VBAP
    ON VBAK~VBELN = VBAP~VBELN
 INNER JOIN MARA
    ON VBAP~MATNR = MARA~MATNR
  WHERE VBAK~VBELN = S_VBELN.

LOOP AT IT_SAL INTO W_SAL.
    WRITE: / W_SAL-VBELN,
             W_SAL-ERNAM,
             W_SAL-ERDAT,
             W_SAL-POSNR,
             W_SAL-MATNR,
             W_SAL-MTART,
             W_SAL-MATKL.
ENDLOOP.



Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com