cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

is there a way to make a loop faster or to replace it by something faster? I know of 'for all entries' but what if the two fields aren't compatible?

SELECT rqposname RQIDENT
INTO TABLE t_output
FROM tsp01
WHERE rqposname EQ lv_email.

LOOP AT t_output ASSIGNING FIELD-SYMBOL(<fs2>).
SELECT SINGLE jobname progname variant listident
INTO ( <fs2>-jobname, <fs2>-progname, <fs2>-variant, <fs2>-listident )
FROM tbtcp
WHERE listident EQ <fs2>-rqident
AND listident NE '0'.
ENDLOOP.

This takes a few minutes even though there are "only" 1300 rows in t_output.

Any Tips?

Thanks in advance.

0 Likes
View Entire Topic
Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes

SELECT inside LOOP is generally bad for performance! Always try to SELECT your data in one DB fetch if possible.

In this case I would suggest simple SELECT with JOIN of the two tables.

Former Member

Yes I did try that

but unfortunaly listident and rqident are not the same type.

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes

teaman I see, in this case you can either create a table for FOR ALL ENTRIES or range table. And you will have to retype the rqident to listident.

But now I see another and bigger problem - your both conditions (only the one you are using) are not index nor key fields:

  • TBTCP-LISTIDENT
  • TSP01-RQPOSNAME