on 07-27-2005 8:20 AM
I am a fresher in SAP_ABAP.Can any one pls tell me how to join 3 tables.If u have code pls share with me.
hi..
we generally use join statements to retrieve data from more than one table. by using join statements we can avoid nested select statemnts, which are resticted to use in real time environment as they work as looping statemnts in database.
here i am giving you one example join statement with which you can get data from 3 tables....
hope it will help you.
SELECT A~EBELN
A~LIFNR
A~AEDAT
B~EBELP
B~MATNR
B~NETPR
C~ETENR
C~MENGE
C~WEMNG
FROM ( EKKO AS A INNER JOIN EKPO AS B
ON AEBELN = BEBELN )
INNER JOIN EKET AS C
ON AEBELN = CEBELN
AND BEBELP = CEBELP
INTO TABLE ITAB
WHERE A~EBELN IN PNO.
rgards...
prasad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mavreck,
give some more details of your problem.
Do you want to join internal tables declared by DATA, or do you want to join Database tables defined in the data dictionary?
Do the 3 tables share the same structure and you want to join the lines conjunctive/disjunctive, or do the tables have different structures and you want to join them using foreign keys ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Check out this link ( Online documentation 😞
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm
And here is the sample code on INNER JOIN on multiple tables:
select resb~matnr
resb~rsnum
resb~baugr
resb~lifnr
resb~werks
resb~bdart
resb~rsnum
resb~bdter
resb~ebeln
resb~ebelp
resb~ebele
resb~charg
resb~bdmng
resb~enmng
resb~meins
ekko~bstyp
eket~eindt
into corresponding fields of table xelem
from resb
inner join ekko on
resb~ebeln = ekko~ebeln and
resb~lifnr = ekko~lifnr
inner join eket on
resb~rsnum = eket~rsnum and
resb~ebeln = eket~ebeln and
resb~ebelp = eket~ebelp and
resb~ebele = eket~etenr
inner join ekpo on
eket~ebeln = ekpo~ebeln and
eket~ebelp = ekpo~ebelp
inner join marc on
resb~matnr = marc~matnr and
resb~werks = marc~werks
WHERE
resb~baugr in s_baugr and " SelOpt for Assembly
resb~lifnr in s_lifnr and " SelOpt for Vendor
resb~matnr in s_matnr and " SelOpt for Component
resb~werks in s_werks and " SelOpt for Plant
resb~bdter in s_bdter and " SelOPt for Reqmts. Date
resb~bdart EQ 'BB' and " Reqmts Type = 'BB'
resb~KZEAR EQ '' and " Final Iss. for Res. is ' '
eket~menge GT 0 and " Scheduled Qty GT zero
ekko~loekz eq '' and " Item NOT deleted
marc~dispo in s_dispo and " SelOpt for MRP Controller
ekpo~loekz eq ''. " Del. indicator in Pur. doc.
Plz. let me know if you have any specific question.
Hope this helps you.
Best Regards, Murugesh AS
Message was edited by: Murugesh Arcot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.