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.
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.
thanx dude.
ReplyDeleteVery nice information given by you sir thank you
ReplyDeletea good details information..thankyou for that
ReplyDeleteThe information provided here is of great use as I got to learn new things. Keep blogging.
ReplyDeleteSAP ABAP TRAINING IN HYDERABAD
Great Post. The information provided is of great use as I got to learn new things. Keep Blogging.
ReplyDeleteSAP ABAP TRAINING IN HYDERABAD
The coding that you provided here helped solved my INNER JOIN problem. Thank you so much!
ReplyDeletehelpful information
ReplyDelete