Tuesday, July 30, 2019

Inner Join

Inner join is used to join two or more than two tables which are having common fields. Inner join actually joins with the data which are common in both table. In the following example one purchase order is having the unique entry in EKKO table and it has 24 items in the EKPO table based on the different items. Since we have selected EKPO table as INNER JOIN we are having all records of that PO in item table EKPO. In this way we have joined further two tables MAKT & MARA.

PARAMETERS p_ebeln TYPE ekko-ebeln.

SELECT a~ebelna~bukrsa~bsart,
       b~ebelpb~matnrb~menge,
       c~maktx,
       d~mtart
  FROM       ekko AS a
  INNER JOIN ekpo AS ON b~ebeln a~ebeln
  INNER JOIN makt AS ON c~matnr b~matnr AND
                          c~spras @sy-langu
  INNER JOIN mara AS ON d~matnr b~matnr

  INTO TABLE @DATA(itab)
  WHERE a~ebeln @p_ebeln.

cl_demo_output=>displayitab ).


No comments: