‎2007 Apr 21 6:11 AM
Hi all,
i have following select statements. i had to get the out put as follows.
output:
pspid posid banfn ebeln lblni.
my select queries are:
select pspid werks from proj into table p_proj.
select posid werks from prps into table p_prps for all entries in p_proj where werks = p_proj-werks.
select banfn werks lblni from eban into table p_eban for all entries in p_prps where werks = p_prps-werks.
select lblni ebeln banfn from essr into table p_essr for all entries in p_eban where lblni = p_eban-lblni.
select ebeln from ekko into table p_ekko for all entries in p_essr where ebeln = p_essr-ebeln.
thing is i need to loop them to get output as mentioned above,can any body provide me code for this.
thanks in advance
siva
‎2007 Apr 21 10:25 AM
Hi..
try this..
<b>loop at p_proj.</b>
write: p_proj-pspid.
read table p_prps with key werks = p_proj-werks.
if sy-subrc eq 0.
write: p_prps-posid.
delete table p_prps index sy-tabix.
read table p_eban with key werks = p_prps-werks.
if sy-subrc eq 0.
write: p_eban-banfn.
delete table p_eban index sy-tabix.
read table p_essr with key lblni = p_eban-lblni.
if sy-subrc eq 0.
write: p_essr-lblni.
delete table p_essr index sy-tabix.
read table p_ekko with key ebeln = p_essr-ebeln.
if sy-subrc eq 0.
write: p_ekko-ebeln.
delete table p_ekko index sy-tabix.
endif.
endif.
endif.
endif.
write: /.
<b>endloop. </b>
Instead of multile selects write a <b>two Inner Join statements</b> which will make ur problem much easy....
select lblni ebeln banfn from essr into table p_essr for all entries in p_eban where lblni = p_eban-lblni.
select ebeln from ekko into table p_ekko for all entries in p_essr where ebeln = p_essr-ebeln.