<?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>topic Re: Better alternative for the following code... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355786#M520498</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I beleive no need to use collect for the range tables as there are no amount fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change to this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lr_vbeln             LIKE RANGE OF wa_vbfa-vbeln,&lt;/P&gt;&lt;P&gt;        la_vbeln             LIKE LINE OF lr_vbeln.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;consolidate all document number for selection criteria&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;billing documents&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT it_vbrk INTO wa_vbrk.&lt;/P&gt;&lt;P&gt;    la_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;    la_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;    la_vbeln-low    = wa_vbrk-vbeln.&lt;/P&gt;&lt;P&gt;    la_vbeln-high   = space.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   &amp;lt;b&amp;gt; APPEND la_vbeln INTO lr_vbeln.&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;delivery documents&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT it_likp INTO wa_likp.&lt;/P&gt;&lt;P&gt;    la_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;    la_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;    la_vbeln-low    = wa_likp-vbeln.&lt;/P&gt;&lt;P&gt;    la_vbeln-high   = space.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    &amp;lt;b&amp;gt;APPEND la_vbeln INTO lr_vbeln.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF NOT lr_vbeln[] IS INITIAL.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  get on the document flow for the corresponding billing and&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  delivery document to get corresponding sales orders&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE it_vbfa&lt;/P&gt;&lt;P&gt;      FROM vbfa&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN lr_vbeln&lt;/P&gt;&lt;P&gt;     WHERE vbeln EQ lr_vbeln-low&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    WHERE vbeln IN lr_vbeln-low&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       AND vbtyp_n IN ('M', 'J')                "billing/delivery&lt;/P&gt;&lt;P&gt;       AND vbtyp_v EQ 'C'.                      "order&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v&lt;/P&gt;&lt;P&gt;      APPENDING CORRESPONDING FIELDS OF TABLE it_vbfa&lt;/P&gt;&lt;P&gt;      FROM vbfa&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN lr_vbeln&lt;/P&gt;&lt;P&gt;     WHERE vbeln EQ lr_vbeln-low&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    WHERE vbeln IN lr_vbeln-low&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       AND vbtyp_n IN ('T', 'O')                "returns billing/delivery&lt;/P&gt;&lt;P&gt;       AND vbtyp_v EQ 'H'.                      "returns&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt; Better remove INTO CORRESPONDING FIELDS OF &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt; when you are equating vbeln EQ lr_vbeln-low , then there is no need to build a range table , instead just declare one internal table with field vbeln , and append the values to it , and then use in FOR ALL ENTRIES&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2007 02:40:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-01T02:40:54Z</dc:date>
    <item>
      <title>Better alternative for the following code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355784#M520496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently debugging a report which is in PRD server and users complain that&lt;/P&gt;&lt;P&gt;it always result in time limit error. I am currently checking the report and I found some&lt;/P&gt;&lt;P&gt;code that I think can be optimized. Below is one of the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lr_vbeln             LIKE RANGE OF wa_vbfa-vbeln,
        la_vbeln             LIKE LINE OF lr_vbeln.

* consolidate all document number for selection criteria
* billing documents
  LOOP AT it_vbrk INTO wa_vbrk.
    la_vbeln-sign   = 'I'.
    la_vbeln-option = 'EQ'.
    la_vbeln-low    = wa_vbrk-vbeln.
    la_vbeln-high   = space.

    COLLECT la_vbeln INTO lr_vbeln.

  ENDLOOP.

* delivery documents
  LOOP AT it_likp INTO wa_likp.
    la_vbeln-sign   = 'I'.
    la_vbeln-option = 'EQ'.
    la_vbeln-low    = wa_likp-vbeln.
    la_vbeln-high   = space.

    COLLECT la_vbeln INTO lr_vbeln.

  ENDLOOP.

  IF NOT lr_vbeln[] IS INITIAL.
*   get on the document flow for the corresponding billing and
*   delivery document to get corresponding sales orders
    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v
      INTO CORRESPONDING FIELDS OF TABLE it_vbfa
      FROM vbfa
     FOR ALL ENTRIES IN lr_vbeln
     WHERE vbeln EQ lr_vbeln-low
*     WHERE vbeln IN lr_vbeln-low
       AND vbtyp_n IN ('M', 'J')                "billing/delivery
       AND vbtyp_v EQ 'C'.                      "order

    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v
      APPENDING CORRESPONDING FIELDS OF TABLE it_vbfa
      FROM vbfa
     FOR ALL ENTRIES IN lr_vbeln
     WHERE vbeln EQ lr_vbeln-low
*     WHERE vbeln IN lr_vbeln-low
       AND vbtyp_n IN ('T', 'O')                "returns billing/delivery
       AND vbtyp_v EQ 'H'.                      "returns

Please help me optimize the code above. Thank you guys and take care!

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 02:24:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355784#M520496</guid>
      <dc:creator>aris_hidalgo</dc:creator>
      <dc:date>2007-06-01T02:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Better alternative for the following code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355785#M520497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if it retrieves too much data, i suggest you put in a batch process..or put COMMIT WORK in every select statement..to free the memory and make the retrieval faster&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        leonard chomi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 02:31:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355785#M520497</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T02:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Better alternative for the following code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355786#M520498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I beleive no need to use collect for the range tables as there are no amount fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change to this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lr_vbeln             LIKE RANGE OF wa_vbfa-vbeln,&lt;/P&gt;&lt;P&gt;        la_vbeln             LIKE LINE OF lr_vbeln.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;consolidate all document number for selection criteria&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;billing documents&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT it_vbrk INTO wa_vbrk.&lt;/P&gt;&lt;P&gt;    la_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;    la_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;    la_vbeln-low    = wa_vbrk-vbeln.&lt;/P&gt;&lt;P&gt;    la_vbeln-high   = space.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   &amp;lt;b&amp;gt; APPEND la_vbeln INTO lr_vbeln.&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;delivery documents&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT it_likp INTO wa_likp.&lt;/P&gt;&lt;P&gt;    la_vbeln-sign   = 'I'.&lt;/P&gt;&lt;P&gt;    la_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;    la_vbeln-low    = wa_likp-vbeln.&lt;/P&gt;&lt;P&gt;    la_vbeln-high   = space.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    &amp;lt;b&amp;gt;APPEND la_vbeln INTO lr_vbeln.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF NOT lr_vbeln[] IS INITIAL.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  get on the document flow for the corresponding billing and&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  delivery document to get corresponding sales orders&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE it_vbfa&lt;/P&gt;&lt;P&gt;      FROM vbfa&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN lr_vbeln&lt;/P&gt;&lt;P&gt;     WHERE vbeln EQ lr_vbeln-low&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    WHERE vbeln IN lr_vbeln-low&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       AND vbtyp_n IN ('M', 'J')                "billing/delivery&lt;/P&gt;&lt;P&gt;       AND vbtyp_v EQ 'C'.                      "order&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v&lt;/P&gt;&lt;P&gt;      APPENDING CORRESPONDING FIELDS OF TABLE it_vbfa&lt;/P&gt;&lt;P&gt;      FROM vbfa&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN lr_vbeln&lt;/P&gt;&lt;P&gt;     WHERE vbeln EQ lr_vbeln-low&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    WHERE vbeln IN lr_vbeln-low&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       AND vbtyp_n IN ('T', 'O')                "returns billing/delivery&lt;/P&gt;&lt;P&gt;       AND vbtyp_v EQ 'H'.                      "returns&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt; Better remove INTO CORRESPONDING FIELDS OF &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt; when you are equating vbeln EQ lr_vbeln-low , then there is no need to build a range table , instead just declare one internal table with field vbeln , and append the values to it , and then use in FOR ALL ENTRIES&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 02:40:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355786#M520498</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T02:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Better alternative for the following code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355787#M520499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just check the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: LT_VBRK   LIKE TABLE OF IT_VBRK,&lt;/P&gt;&lt;P&gt;            LT_LIKP     LIKE TABLE OF IT_LIKP.&lt;/P&gt;&lt;P&gt;         &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;consolidate all document number for selection criteria&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;billing documents&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LT_VBRK[] = IT_VBRK[].&lt;/P&gt;&lt;P&gt; Sort lt_vbrk by vbeln.&lt;/P&gt;&lt;P&gt; delete adjacent duplicates from lt_vbrk comparing vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; LT_LIKP[] = IT_LIKP[].  &lt;/P&gt;&lt;P&gt; Sort lt_likp by vbeln.&lt;/P&gt;&lt;P&gt; delete adjacent duplicates from lt_likp comparing vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  get on the document flow for the corresponding billing and&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  delivery document to get corresponding sales orders&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE it_vbfa&lt;/P&gt;&lt;P&gt;      FROM vbfa&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN LT_VBRK&lt;/P&gt;&lt;P&gt;     WHERE vbeln EQ LT_VBRK-VBELN&lt;/P&gt;&lt;P&gt;       AND vbtyp_n IN ('M', 'J')                "billing/delivery&lt;/P&gt;&lt;P&gt;       AND vbtyp_v EQ 'C'.                      "order&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;***Call FM  SAPGUI_PROGRESS_INDICATOR, This will reset the time and will not give time limit error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v&lt;/P&gt;&lt;P&gt;      APPENDING CORRESPONDING FIELDS OF TABLE it_vbfa&lt;/P&gt;&lt;P&gt;      FROM vbfa&lt;/P&gt;&lt;P&gt;     FOR ALL ENTRIES IN LT_LIKP&lt;/P&gt;&lt;P&gt;     WHERE vbeln EQ LT_LIKP-VBELN&lt;/P&gt;&lt;P&gt;       AND vbtyp_n IN ('T', 'O')                "returns billing/delivery&lt;/P&gt;&lt;P&gt;       AND vbtyp_v EQ 'H'.                      "returns&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Looping takes considerable amount of time and this will help in optimizing to large extent.&lt;/P&gt;&lt;P&gt;2) If possible declare it_vbfa with fields vbelv posnv vbeln posnn vbtyp_n vbtyp_v in the same order and remove corresponding fields of. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Navneet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Navneet Saraogi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 02:51:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355787#M520499</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T02:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Better alternative for the following code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355788#M520500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Viraylab , &lt;/P&gt;&lt;P&gt;  Here are few of my observations&lt;/P&gt;&lt;P&gt;1. Do not use into corresponding feilds of table , design your IT such that feilds are in the order you select from the database.&lt;/P&gt;&lt;P&gt;2. Combine the two SQL into 1 statement&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v
      into TABLE it_vbfa
      FROM vbfa
     FOR ALL ENTRIES IN lr_vbeln
     WHERE vbeln IN lr_vbeln-low  " Check Change
       AND vbtyp_n IN ('T', 'O' , 'M', 'J' )                "returns billing/delivery
       AND vbtyp_v in ( 'H' , 'C' 0.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 02:57:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-alternative-for-the-following-code/m-p/2355788#M520500</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T02:57:02Z</dc:date>
    </item>
  </channel>
</rss>

