Tuesday, April 9, 2013

SAP INNER JOIN WITH 4 Tables

SAP Program to Inner Join Between 4 Tables

Example 


REPORT  zgo7.
TABLES: mara , mkpf, mseg.
DATA:   BEGIN OF it  OCCURS 0,
        matnr LIKE mara-matnr, "Material
        meins LIKE mara-meins, "Base Unit of Measure
        menge LIKE mseg-menge, "Quantity /  Price per base unit of measure
        lifnr LIKE mseg-lifnr, "VENDOR
        bldat LIKE mkpf-bldat, "Document Date
        mjahr LIKE mkpf-mjahr, "Material Doc. Year
        makt LIKE makt-maktx, "Material Description
        END OF it.


SELECT a~matnr a~meins b~menge b~lifnr c~bldat c~mjahr d~maktx
  INTO TABLE it
  FROM  mara AS a
  INNER JOIN mseg AS b ON a~matnr EQ b~matnr
  INNER JOIN mkpf AS c ON c~mblnr EQ b~mblnr
  INNER JOIN makt AS d ON d~matnr EQ a~matnr.


WRITE: / 'Material', 25 'Quantity', 35 'Base Unit of Measure', 45 'VENDOR', 55 'Document Date', 65 'Material Doc Year', 75 'Material Description'.

LOOP AT it.
  WRITE: / it-matnr, it-menge, it-meins, it-lifnr, it-bldat, it-mjahr, it-makt.
ENDLOOP.

7 comments:

  1. a good details information..thankyou for that

    ReplyDelete
  2. The information provided here is of great use as I got to learn new things. Keep blogging.
    SAP ABAP TRAINING IN HYDERABAD

    ReplyDelete
  3. Great Post. The information provided is of great use as I got to learn new things. Keep Blogging.
    SAP ABAP TRAINING IN HYDERABAD

    ReplyDelete
  4. The coding that you provided here helped solved my INNER JOIN problem. Thank you so much!

    ReplyDelete