01-24-2007 7:30 AM
Hello all,
How to create a self join using ABAP Query?
Say, I have this table EKBE with belnr (materials doc num) and lfbnr (reference material doc num). I have to pick the PO's from EKBE whose belnr doesnt have any lfbnr.
Regards
Madhumathi A
01-24-2007 8:04 AM
Hi,
Use the below select -
select *
from ekbe as a
into table itab
where not exists ( select * from ekbe
where ifbnr eq a~belnr ).
Hope it works..
Reward points if found useful...!
Cheers
Abhishek
01-24-2007 7:35 AM
Hi
in select option mention the condition that lfbnr = 0 and belnr <> 0.
this will fecth only the required
thanks
Shiva
01-24-2007 7:53 AM
Hi ,
My requirement is that,
I have to pick the PO's with movement type 103, which does not have a corresponding 104 document (which are not rejected) using ABAP query.
So, in this case I think a different logic should be used altogether.
Regards
Madhumathi A
01-24-2007 7:48 AM
hi madhu,
tables : ekbe.
data itab like standard table of ekbe with header line.
select * from ekbe into table itab where belnr >< 0 and lfbnr = ' '.
loop at itab.
write 😕 itab-belnr,itab-lfbnr.
endloop.
check this code this works to select the orders whose belnr doesnt have any lfbnr
reward points if useful.
01-24-2007 8:04 AM
Hi,
Use the below select -
select *
from ekbe as a
into table itab
where not exists ( select * from ekbe
where ifbnr eq a~belnr ).
Hope it works..
Reward points if found useful...!
Cheers
Abhishek
01-24-2007 8:15 AM
Hi
Try out this code.
select-options:
s_belnr for ekbe-belnr.
data : begin of it_ekbe occurs 0,
ebeln like ekbe-ebeln,
belnr like ekbe-belnr,
end of it_ekbe.
select distinct aebeln abelnr
into corresponding fields of table it_ekbe
from ekbe as a inner join ekbe as b
on abelnr <> blfbnr
where a~belnr in s_belnr and
b~belnr in s_belnr.
HOPE THIS WILL HELP YOU.
Regs
Nimesh.
01-24-2007 9:44 AM
09-19-2016 10:45 AM
It would be helpful for me, if you post your solution that you found for your problem.