Application Development 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: 

How to handle Loop within Select For all entries

Former Member
0 Kudos

hi all,

i have a requirement where I need to include 2 country code .

so in selection screen s_bukrs has AU00 - AU99 & NZ00 -NZ99

select countrycode

from ZCTYCOD

into table lt_zctycod

where ( land1 ge s_bukrs-low(02) AND

land1 Le s_bukrs-HIGH(02).

SO countrycode entries r in table lt_zctycod.

Now I need to loop into this SELECT ...FOR ALL ENTRIES....

LOOP AT LT_ZCTCOD.

SELECT * FROM zbase

APPENDING TABLE ts_base

FOR ALL ENTRIES IN ts_zdocket

WHERE zzumicur = ts_docket-zzumicur AND

( status = c_rej OR

status = c_sus ) AND

CTYCOD = LT_ZCTCOD-Ctycod.

ENDIF.

Is there any best approach to AVOID LOOP INSIDE FOR ALL ENTRIES...any alternative approach to have good performance

APPRECIATE UR HELP

THANKS

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try to use inner join operation instead of select in loop statement...

problem for me i don't know the relation between LT_ZCTCOD and ts_zdocket.

Edited by: subas Bose on Feb 18, 2010 1:09 AM

3 REPLIES 3

Former Member
0 Kudos

try to use inner join operation instead of select in loop statement...

problem for me i don't know the relation between LT_ZCTCOD and ts_zdocket.

Edited by: subas Bose on Feb 18, 2010 1:09 AM

0 Kudos

Hi,

You can create ranges for your ZCTYCOD

DATA: R_ZTYCODE TYPE RANGE OF ...

so your program flow will be like this

1. select ZTYCOD into LT_ZTYCOD

2. loop at LT_ZTYCOD, assign each value to R_ZTYCODE

3. select form zbase ..... where CTYCOD in R_ZTYCODE

hope it helps

Former Member
0 Kudos

answered