Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Flow

Former Member
0 Likes
783

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
741

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.

7 REPLIES 7
Read only

Former Member
0 Likes
742

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.

Read only

Former Member
0 Likes
741

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

Read only

0 Likes
741

Instead of inner joins u can use FOR ALL ENTRIES.

Read only

0 Likes
741

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

Read only

0 Likes
741

Hi,

Whats your requirement, depends upon your requirement u have to join the table.

Read only

0 Likes
741

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

Read only

0 Likes
741

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