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

replacing selects with join

Former Member
0 Likes
815

SELECT vbeln

kunnr

FROM vbpa

INTO TABLE l_i_vbpa

FOR ALL ENTRIES IN i_kna1

WHERE kunnr EQ i_kna1-kunnr.

IF NOT l_i_vbpa[] IS INITIAL.

  • Fetch the Credit checks.

SELECT vbeln

gbstk

cmgst

FROM vbuk

INTO TABLE l_i_vbuk

FOR ALL ENTRIES IN l_i_vbpa

WHERE vbeln EQ l_i_vbpa-vbeln.

with

SELECT a~vbeln

a~kunnr

b~gbstk

b~cmgst

from vbpa as a inner join vbuk as b

on avbeln eq bvbeln

INTO TABLE ITAB

FOR ALL ENTRIES IN i_kna1

WHERE kunnr EQ i_kna1-kunnr.

Is this a correct statement.

Pl let me know if any changes req.

Thanks

Kiran

8 REPLIES 8
Read only

Former Member
0 Likes
793

hi,

Check if the table is empty or not for each select ...It is always better to use for all entries as two different selects as yours than using joins ...

if not i_kna1[] is initial.

SELECT a~vbeln

a~kunnr

b~gbstk

b~cmgst

from vbpa as a inner join vbuk as b

on avbeln eq bvbeln

INTO TABLE ITAB

FOR ALL ENTRIES IN i_kna1

WHERE kunnr EQ i_kna1-kunnr.

endif.

Read only

0 Likes
793

Hi Santhosh,

Thanks for that advise.

But am tuning a report that is running for almost 130hrs in background.Hence am replacing lot many selects with joins.

Is it a good way 2 replace selects in view of tuning by replacing those couple of selects which i posted.

Thanks

Kiran

Read only

0 Likes
793

in some cases Selects on Views will be useful. your select is combination of join and for all entries. so it will not be that performance.

Read only

0 Likes
793

hi,

Here i would advise you to make use of the entire key in both the separate selects than using joins as joins always affect performance .... when using the individual select you can even sort the table and delete the adjacent duplicate entries comparing fields....

Regards,

Santosh

Read only

0 Likes
793

No - your problem is not with JOINs. It is because the first SELECT does not use an index.

Rob

Read only

0 Likes
793

Exactly.

I was worrying about that only.

And I am also thinking, if my i replace them with a join, am i going to worsen the situation?

Thanks

Kiran

Read only

Former Member
0 Likes
793

SELECT a~vbeln

a~kunnr

b~gbstk

b~cmgst

from vbpa as a inner join vbuk as b

on avbeln eq bvbeln

INTO TABLE ITAB

FOR ALL ENTRIES IN i_kna1

WHERE a~kunnr EQ i_kna1-kunnr.

Read only

Former Member
0 Likes
793

WHERE a~kunnr EQ i_kna1-kunnr.