简体   繁体   中英

How do I join two tables in SAP ABAP based on two columns?

I have two tables ACDOCA and BKPF. The two columns are GJAHR and BUKRS. I want to join these two tables based on these two columns. What will be the code for the select statement?

I did this:

 FROM acdoca AS a
   LEFT OUTER JOIN bkpf AS b
     ON a~rbukrs = b~bukrs
     ON a~gjahr = b~gjahr

Upon activating, it is showing the error, " "ON" is invalid here (due to grammar). "

Please help.

The second "ON" has to be replaced by "AND":

FROM acdoca AS a 
     LEFT OUTER JOIN bkpf AS b 
     ON a~rbukrs = b~bukrs AND " => here
        a~gjahr = b~gjahr

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/de-DE/abapselect_join.htm#!ABAP_ONE_ADD@1@

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM