‎2009 May 19 6:43 PM
Hi All,
I am using this inner Join Statement
SELECT *
FROM vbap AS a INNER JOIN vbak AS b
ON avbeln = bvbeln
AND amandt = bmandt
WHERE a~vbeln IN lr_vbeln AND
a~posnr IN lr_posnr AND
a~aedat IN lr_aedat AND
( b~vbtyp EQ 'A' OR
b~vbtyp EQ 'B' OR
b~vbtyp EQ 'G' ).
But when i see the Output, One of the field ERDAT is geeting picked up from VBAK table instead of VBAP table.
Any pointers on how can we select the ERDAT from VBAP using this inner Join.
I dont want to use 2 select stetements.
Regards,
Mayank
‎2009 May 20 5:08 AM
In Inner join, it is always advisable to put the header table as First table and secondly, it should be advisable to fetch only the requried fields. I believe that you might not required all the fields of VBAP table.
Select A~Vbeln
A~vbtyp
B~posnr
B~erdat
into table I_VBAP
from vbak as A innner Join VBAP as B
on a~vbeln = b~vbeln
where a~vbeln IN lr_vbeln AND
b~posnr IN lr_posnr AND
b~aedat IN lr_aedat AND
( a~vbtyp EQ 'A' OR
a~vbtyp EQ 'B' OR
a~vbtyp EQ 'G' ).
‎2009 May 19 6:51 PM
Hi Mayank,
try this way..
data : it_vbap type standard table of vbap with header line. "add this
SELECT *
FROM vbap AS a INNER JOIN vbak AS b
ON a~vbeln = b~vbeln
AND a~mandt = b~mandt
into corresponding field of it_vbap "add this
WHERE a~vbeln IN lr_vbeln AND
a~posnr IN lr_posnr AND
a~aedat IN lr_aedat AND
b~vbtyp in ( 'A' , 'B' , 'G' ). "add this
Regards,
Prabhudas
‎2009 May 20 12:02 AM
Hi Prabhu,
The Code which you have provided will not work.
Any other inputs on this issue.
‎2009 May 20 12:38 AM
Hi Mayank,
What ouput are you seeing in the above statement?
You can directly use VBAP-ERDAT or VBAK-ERDAT, as the data will be stored in the header line.
‎2009 May 19 7:07 PM
‎2009 May 20 3:38 AM
Hi,
you can select fields using syntax like a~erdat. So you need to write down all fields which you need from your query instead of using *.
Cheers
‎2009 May 20 4:18 AM
Hi,
During inner joins using Alias ('A' or 'B' and so on), we have to instruct, what field from which Alias need to be selected from the Query.
Regards,
RamaniN
‎2009 May 20 5:08 AM
In Inner join, it is always advisable to put the header table as First table and secondly, it should be advisable to fetch only the requried fields. I believe that you might not required all the fields of VBAP table.
Select A~Vbeln
A~vbtyp
B~posnr
B~erdat
into table I_VBAP
from vbak as A innner Join VBAP as B
on a~vbeln = b~vbeln
where a~vbeln IN lr_vbeln AND
b~posnr IN lr_posnr AND
b~aedat IN lr_aedat AND
( a~vbtyp EQ 'A' OR
a~vbtyp EQ 'B' OR
a~vbtyp EQ 'G' ).
‎2009 May 20 10:59 AM
hi,
please use into corresponding fields
select * into corresponding fields of table <itab>
from ( VBAK AS A INNER JOIN VBAP AS B ON
AVBELN = BVBELN )
WHERE a~vbeln IN lr_vbeln AND
b~posnr IN lr_posnr AND
b~aedat IN lr_aedat AND
( a~vbtyp EQ 'A' OR
a~vbtyp EQ 'B' OR
a~vbtyp EQ 'G' ).
‎2009 Jun 18 6:39 PM