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.
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hello Nils Bla,
if not CDS views, you can use the below code as a solution. This should work fine.
TYPES: BEGIN OF ty_tsp01,
rqposname TYPE tsp01-rqposname,
rqident TYPE tbtcp-listident,
END OF ty_tsp01.
DATA: lv_email TYPE tsp01-rqposname,
ls_tsp01 TYPE ty_tsp01,
lt_tsp01 TYPE STANDARD TABLE OF ty_tsp01.
SELECT rqposname, rqident
FROM tsp01
WHERE rqposname EQ @lv_email
INTO TABLE @DATA(t_tsp01).
IF sy-subrc EQ 0.
SORT t_tsp01 BY rqident.
LOOP AT t_tsp01 INTO DATA(ls_temp).
CLEAR: ls_tsp01.
ls_tsp01-rqposname = ls_temp-rqposname.
ls_tsp01-rqident = ls_temp-rqident.
APPEND ls_tsp01 TO lt_tsp01.
ENDLOOP.
ENDIF.
SELECT jobname,
progname,
variant,
listident
FROM tbtcp
FOR ALL ENTRIES IN @lt_tsp01
WHERE listident = @lt_tsp01-rqident AND
listident NE 0
INTO TABLE @DATA(t_tbtcp).
IF sy-subrc EQ 0.
SORT t_tbtcp BY listident.
ENDIF.Regards!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.