<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Faster loop? in Spend Management Q&amp;A</title>
    <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105617#M173459</link>
    <description>&lt;P&gt;maybe a JOIN like in the thread below?&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/3970824/select-join-problem.html" target="_blank"&gt;Select Join problem&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Pablo&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2019 10:43:15 GMT</pubDate>
    <dc:creator>former_member182371</dc:creator>
    <dc:date>2019-11-27T10:43:15Z</dc:date>
    <item>
      <title>Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaq-p/12105616</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;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?&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;SELECT rqposname RQIDENT
INTO TABLE t_output
FROM tsp01
WHERE rqposname EQ lv_email.

LOOP AT t_output ASSIGNING FIELD-SYMBOL(&amp;lt;fs2&amp;gt;).
SELECT SINGLE jobname progname variant listident
INTO ( &amp;lt;fs2&amp;gt;-jobname, &amp;lt;fs2&amp;gt;-progname, &amp;lt;fs2&amp;gt;-variant, &amp;lt;fs2&amp;gt;-listident )
FROM tbtcp
WHERE listident EQ &amp;lt;fs2&amp;gt;-rqident
AND listident NE '0'.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This takes a few minutes even though there are "only" 1300 rows in t_output.&lt;/P&gt;
  &lt;P&gt;Any Tips?&lt;/P&gt;
  &lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:31:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaq-p/12105616</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-27T10:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105617#M173459</link>
      <description>&lt;P&gt;maybe a JOIN like in the thread below?&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/3970824/select-join-problem.html" target="_blank"&gt;Select Join problem&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Pablo&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:43:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105617#M173459</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2019-11-27T10:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105618#M173460</link>
      <description>&lt;P&gt;Did you try a join?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:44:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105618#M173460</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-27T10:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105619#M173461</link>
      <description>&lt;P&gt;SELECT inside LOOP is generally bad for performance! Always try to SELECT your data in one DB fetch if possible.&lt;/P&gt;&lt;P&gt;In this case I would suggest simple SELECT with JOIN of the two tables.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:51:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105619#M173461</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2019-11-27T10:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105620#M173462</link>
      <description>&lt;P&gt;Hi ! &lt;/P&gt;&lt;P&gt;Do make a Database View joining both tables with your desire condition and then use it appropriatly in you programe.&lt;/P&gt;&lt;P&gt;Hope it helps,&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Shakir.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:26:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105620#M173462</guid>
      <dc:creator>shakirali7</dc:creator>
      <dc:date>2019-11-27T11:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105621#M173463</link>
      <description>&lt;P&gt;Yes I did&lt;/P&gt;&lt;P&gt;but unfortunaly listident and rqident are not the same type.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:52:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105621#M173463</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-27T11:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105622#M173464</link>
      <description>&lt;P&gt;Yes I did try that&lt;/P&gt;&lt;P&gt;but unfortunaly listident and rqident are not the same type.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:53:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105622#M173464</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-27T11:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105623#M173465</link>
      <description>&lt;P&gt;Yes I did try that&lt;/P&gt;&lt;P&gt;but unfortunaly listident and rqident are not the same type.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:53:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105623#M173465</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-27T11:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105624#M173466</link>
      <description>&lt;P&gt;&lt;EM&gt;I know of 'for all entries' but what if the two fields aren't compatible?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Why not type the internal table so they are compatible?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 12:07:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105624#M173466</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-11-27T12:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105625#M173467</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;teaman&lt;/SPAN&gt;  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. &lt;/P&gt;&lt;P&gt;But now I see another and bigger problem - your both conditions (only the one you are using) are not index nor key fields: &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;TBTCP-LISTIDENT &lt;/LI&gt;&lt;LI&gt;TSP01-RQPOSNAME&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 27 Nov 2019 12:19:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105625#M173467</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2019-11-27T12:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105626#M173468</link>
      <description>&lt;P&gt;Two CDS!&lt;/P&gt;&lt;P&gt;First:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;define view ztbtcp 
  as select from tbtcp
{
  cast ( listident as abap.int4 ) as listident,
  variant,
  progname,
  jobname
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Second:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;define view zoutput
   as select from tsp01
    left outer join ztbtcp
    on tsp01.rqident = ztbtcp.listident 
{
rqposname,
listident,
variant,
progname,
jobname
}
where listident &amp;lt;&amp;gt; 0
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you need more fields in the output-structure, define them in the second CDS.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 12:58:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105626#M173468</guid>
      <dc:creator>ascm</dc:creator>
      <dc:date>2019-11-27T12:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105627#M173469</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;instead of TSP01(Spool Requests) ,&lt;/P&gt;&lt;P&gt;would TBTC_SPOOLID(Background Processing Spool IDs Table) be a valid table?&lt;/P&gt;&lt;P&gt;(check report BTCAUX05)&lt;/P&gt;&lt;P&gt;BEst regards,&lt;/P&gt;&lt;P&gt;Pablo&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:03:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105627#M173469</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2019-11-27T13:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105628#M173470</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/240332/ascm.html"&gt;Andrea Clöß&lt;/A&gt; it's worth converting it into an answer!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:12:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105628#M173470</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-27T13:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105629#M173471</link>
      <description>&lt;P&gt;This works for me (ABAP &amp;gt;= 7.50 - &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm?file=abensql_cast.htm"&gt;CAST&lt;/A&gt; of type INT4 or NUMC):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA lv_email TYPE tsp01-rqposname.
SELECT s~rqident,                                       " &amp;lt;========== INT4
       j~listident,                                     " &amp;lt;========== 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 &amp;lt;&amp;gt; '0000000000'
INTO TABLE @DATA(t_output).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:23:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105629#M173471</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-27T13:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105630#M173472</link>
      <description>&lt;P&gt;Hello &lt;A href="https://answers.sap.com/users/856727/teaman.html"&gt;Nils Bla&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;if not CDS views, you can use the below code as a solution. This should work fine.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 14:03:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105630#M173472</guid>
      <dc:creator>former_member1716</dc:creator>
      <dc:date>2019-11-27T14:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105631#M173473</link>
      <description>&lt;P&gt;Try to define your internal table as hashed table. try to do same, it will be fast &lt;/P&gt;&lt;P&gt;DATA IT_TAB  TYPE HASHED TABLE OF scarr&lt;BR /&gt;  WITH UNIQUE KEY carrid.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 15:44:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105631#M173473</guid>
      <dc:creator>Nawanandana</dc:creator>
      <dc:date>2019-11-27T15:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Faster loop?</title>
      <link>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105632#M173474</link>
      <description>&lt;P&gt;I've just moved out my selects with an "for all entrys" that made it faster.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 10:37:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/spend-management-q-a/faster-loop/qaa-p/12105632#M173474</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-12-04T10:37:46Z</dc:date>
    </item>
  </channel>
</rss>

