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

is this correct procedure..?

Former Member
0 Likes
572

select vbap~vbeln

vbap~posnr

vbap~matnr

vbap~ps_psp_pnr

kna1~kunnr

kna1~land1

konh~kosrt

konh~knumh

into corresponding fields of

table itab1

from kna1 join vbak

on VBAKKUNNR = KNA1KUNNR join vbap

on vbapvbeln = vbakvbeln join a090

on a090vbeln = vbapvbeln

and

a090posnr = vbapposnr

and

a090matnr = vbapmatnr join konh

on a090knumh = konhknumh join konp

on konhknumh = konpknumh

where a090~kappl = 'V'

and a090~kschl = 'PR00'

and konh~kosrt in srchterm

and konp~loevm_ko = 'X' and

vbak~vbtyp = 'C' and

vbap~pstyv = 'TAO' and

vbak~erdat in date.

this coding procedure is correct or not..?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
504

HI,

Don't use more than two tables in a join. It will reduce performance.

Use first two tables in one join then use that internal table and FOR ALL ENTRIES to fetch entries from the thrid table.

Loop through first table, read the second table's matching entry, move all corresponding entries to a new final internal table.

Regards,

Subramanian

4 REPLIES 4
Read only

Former Member
0 Likes
505

HI,

Don't use more than two tables in a join. It will reduce performance.

Use first two tables in one join then use that internal table and FOR ALL ENTRIES to fetch entries from the thrid table.

Loop through first table, read the second table's matching entry, move all corresponding entries to a new final internal table.

Regards,

Subramanian

Read only

Former Member
0 Likes
504

hi,

1. Use FOR ALL ENTRIES statement instead of join.

2. Use INTO TABLE statement instead of INTO CORRESPONDING FIELDS OF TABLE statement

http://www.sap-img.com/abap/usage-of-for-all-entries-in-select-statement.htm

Regards,

Santosh

Read only

Former Member
0 Likes
504

Hi,

check the following points

1. do't use more then 2 tables in the joining.

2. if you are using join statement, check the joinning fields should be key fields only.

in your query,

1. first join VBAK and VBAP table using vbeln.

2. retrieve the additional data from kna1 based on kunnr

3. join knop and konh table.

3. retrieve the additional data from A090

Reward if found helpful.

Regards,

SB

Read only

Former Member
0 Likes
504

select vbap~vbeln

vbap~matnr

vbap~posnr

vbap~pstyv

vbap~ps_psp_pnr

vbak~erdat

vbak~vbtyp

vbak~kunnr

kna1~land1

a090~kappl

a090~kschl

a090~knumh

konh~kosrt

konp~loevm_ko

into corresponding fields of

table itab1

from vbap inner join vbak on vbapvbeln = vbakvbeln

inner join kna1 on VBAKKUNNR = KNA1KUNNR

inner join a090 on ( a090vbeln = vbapvbeln

and a090posnr = vbapposnr

and a090matnr = vbapmatnr )

inner join konh on a090knumh = konhknumh

inner join konp on konhknumh = konpknumh

where a090~kappl = 'V'

and a090~kschl = 'PR00'

and konh~kosrt in srchterm

and konp~loevm_ko = 'X' and

vbak~vbtyp = 'C' and

vbap~pstyv = 'TAO' and

vbak~erdat in date.

This code should work..

Better to avoid this kind of lenghy joins , since if there is no entries for any one of table the sy-subrc value will be 4.

Regards,

Sreeja