cancel
Showing results for 
Search instead for 
Did you mean: 

Faster loop?

0 Kudos

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.

Sandra_Rossi
Active Contributor
0 Kudos

Did you try a join?

0 Kudos

Yes I did

but unfortunaly listident and rqident are not the same type.

Sandra_Rossi
Active Contributor
0 Kudos

Andrea Clöß it's worth converting it into an answer!

p244500
Active Contributor
0 Kudos

Try to define your internal table as hashed table. try to do same, it will be fast

DATA IT_TAB TYPE HASHED TABLE OF scarr
WITH UNIQUE KEY carrid.

View Entire Topic
former_member182371
Active Contributor

maybe a JOIN like in the thread below?

Select Join problem

Best regards,

Pablo

0 Kudos

Yes I did try that

but unfortunaly listident and rqident are not the same type.

former_member182371
Active Contributor
0 Kudos

Hi,

instead of TSP01(Spool Requests) ,

would TBTC_SPOOLID(Background Processing Spool IDs Table) be a valid table?

(check report BTCAUX05)

BEst regards,

Pablo

Sandra_Rossi
Active Contributor

This works for me (ABAP >= 7.50 - CAST of type INT4 or NUMC):

DATA lv_email TYPE tsp01-rqposname.
SELECT s~rqident,                                       " <========== INT4
       j~listident,                                     " <========== NUMC (10)
       s~rqposname, j~jobname, j~progname, j~variant
    FROM tsp01 AS s
        INNER JOIN tbtcp AS j
            ON CAST( j~listident AS INT4 ) = s~rqident
    WHERE s~rqposname = @lv_email
      AND j~listident <> '0000000000'
INTO TABLE @DATA(t_output).
0 Kudos

I've just moved out my selects with an "for all entrys" that made it faster.