‎2007 Jan 08 4:12 PM
Hi
Say i am retrieving data from VBAK
select * from vbak
retrieving data from vbap
select * from vbap
retreiving from likp
select * from likp
retrieving from lips
select * from lips
retrieving from kna1
select * from kna1...
i want to pass all data to final internal table..
which table we loop first ....why is that so..
How read works on these tables??
Thanks in advance
‎2007 Jan 08 4:21 PM
First u have to loop at VBAK because it is the header table.Then within that loop u need to read the other internal tables.
READ can hold only one record at any point of time.
Like
loop at it_vbak.
.........
read table it_vbap with key vbeln = it_vbak-vbeln.
move corresponding fields to ur final internal table
...........
append it_final.
endloop.
‎2007 Jan 08 4:21 PM
First u have to loop at VBAK because it is the header table.Then within that loop u need to read the other internal tables.
READ can hold only one record at any point of time.
Like
loop at it_vbak.
.........
read table it_vbap with key vbeln = it_vbak-vbeln.
move corresponding fields to ur final internal table
...........
append it_final.
endloop.
‎2007 Jan 08 4:22 PM
hi RK,
u can use inner join for vbak, vbap, lips, likp with vbeln key.
select vbakfield vbapfields lipsfields likpfields into corresponding fields of itab from vbak inner join vbap on vbakvbeln = vbapvbeln inner join lips on vbakvbeln = lipsvbeln inner join likp on vbakvbeln = likpvbeln where ( ur conditions).
try to relate ur fields with KNA1 table fields and populate the final itab.
Regards
CNu
‎2007 Jan 08 4:24 PM
‎2007 Jan 08 4:25 PM
I know about joins,i dont want that.
My doubt is if you loop the KNA1 table instead of VBAK first or LIKP
or other table,how read works here?
I can also use Select single inside the loop,but why do we prefer Read??is it performance issue??
Thanks
‎2007 Jan 08 4:27 PM
Hi,
Whats your requirement, depends upon your requirement u have to join the table.
‎2007 Jan 08 4:27 PM
I know about joins,i dont want that.
My doubt is if you loop the KNA1 table instead of VBAK first or LIKP
or other table,how read works here?
I can also use Select single inside the loop,but why do we prefer Read??is it performance issue??
The way you write select statements order,do we write in read also same as selects order?
Thanks
‎2007 Jan 08 4:37 PM
1) Yes. READ with binary search (sort the internal table before) will improve the performance. Select single - it has to read the database each loop so slows down the performance.
2) You can loop through KNA1 but disadvantage is, it is not key and one customer will have multiple VBAK records so again you have to loop for VBAK. Inner loops should be avoided and again reason is performance.
3) Probably, you may need inner loops as same sales document, may have multiple deliveries and line items (LIPS). DO... READ....Enddo statements may be useful to avoid inner loops.
4) Though you don't want to use inner joins, it will reduce the development effort and improve the performance. Instead of joining all tables, you can atleast joins VBAK and VBAP, LIKP and LIPS.
Thanks
Viswa