<?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: Slow process of ABAP code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464513#M1554316</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi, &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Point 1:&lt;/P&gt;&lt;P&gt;&amp;gt; Please check the code. You are reading RETURN table with TYPE = 'E' and if sy-subrc is not initial (i.e; BAPI fails) again you are calling the BAPI with the same data.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Point 2:&lt;/P&gt;&lt;P&gt;&amp;gt; In the loop you are updating the DB table which will impact the performance. Avoid update in loop.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Regards,&lt;/P&gt;&lt;P&gt;&amp;gt; Jaya krishna K&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding 1.: If it's not initial, then he didn't find a E message and thus it was ok. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding 2: update inside a loop is not per definition wrong. It's the inner select on MSEG that's causing a sequential read&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Dec 2010 12:43:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-12-08T12:43:40Z</dc:date>
    <item>
      <title>Slow process of ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464509#M1554312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear gurus&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My this codes take to much time to execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to resolve it ?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  call_bapi
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_GOODSMVT_HEADER  text
*      --&amp;gt;P_GOODSMVT_ITEM    text
*----------------------------------------------------------------------*
FORM call_bapi USING p_goodsmvt_header LIKE goodsmvt_header
                                  p_goodsmvt_item LIKE goodsmvt_item.

  DATA: materialdocument TYPE bapi2017_gm_head_ret-mat_doc,
        matdocumentyear TYPE bapi2017_gm_head_ret-doc_year,
        wa_return LIKE LINE OF return,
        goodsmvt_code LIKE  bapi2017_gm_code.

  goodsmvt_code-gm_code = '04'.

  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      goodsmvt_header               = p_goodsmvt_header
      goodsmvt_code                 = goodsmvt_code
      testrun                       = 'X'
   IMPORTING
     materialdocument              = materialdocument
     matdocumentyear               = matdocumentyear
    TABLES
      goodsmvt_item                 = p_goodsmvt_item
*     GOODSMVT_SERIALNUMBER         = GOODSMVT_SERIALNUMBER
      return                        = return
*     GOODSMVT_SERV_PART_DATA       = GOODSMVT_SERV_PART_DATA
*     EXTENSIONIN                   = EXTENSIONIN
            .

  READ TABLE return WITH KEY type = 'E' INTO wa_return.

  IF sy-subrc IS INITIAL.
    MESSAGE ID wa_return-id TYPE wa_return-type NUMBER wa_return-number
    WITH wa_return-message_v1 wa_return-message_v2 wa_return-message_v3 wa_return-message_v4.
  ELSE.

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      goodsmvt_header               = p_goodsmvt_header
      goodsmvt_code                 = goodsmvt_code
   IMPORTING
*     GOODSMVT_HEADRET              = GOODSMVT_HEADRET
     materialdocument              = materialdocument
     matdocumentyear               = matdocumentyear
    TABLES
      goodsmvt_item                 = p_goodsmvt_item
      return                        = return
            .

*    COMMIT WORK.

   call function 'BAPI_TRANSACTION_COMMIT'
       exporting
            wait = 'X'.



    SORT itab_final ASCENDING BY vbeln posnr.

    DATA wa_itab LIKE wa_itab_final.

    LOOP AT itab_final INTO wa_itab_final.

      UPDATE zpacking_list SET posted = 'X' WHERE vbeln = wa_itab_final-vbeln AND posnr = wa_itab_final-posnr
        AND mblnr IN ( SELECT mblnr FROM mseg WHERE werks = wa_itab_final-plant AND charg = wa_itab_final-charg ).

    ENDLOOP.

    MESSAGE i001 WITH materialdocument matdocumentyear.
    LEAVE PROGRAM.

  ENDIF.

ENDFORM.                    " call_bapi&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 10:37:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464509#M1554312</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-08T10:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Slow process of ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464510#M1554313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why 2 times CALL FUNCTION 'BAPI_GOODSMVT_CREATE' ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once is enough.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 10:41:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464510#M1554313</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-08T10:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Slow process of ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464511#M1554314</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;I find there is nothing to be done regarding the BAPI calls.&lt;/P&gt;&lt;P&gt;But, I think you should rewrite your UPDATE statement (especially because of the "nested SELECT"). I would rather process all entries in internal table using large SELECT (if required with working internal tables) and update the whole Z-table in one-pass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Guillaume&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 10:41:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464511#M1554314</guid>
      <dc:creator>guillaume-hrc</dc:creator>
      <dc:date>2010-12-08T10:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Slow process of ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464512#M1554315</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;Point 1:&lt;/P&gt;&lt;P&gt;Please check the code. You are reading RETURN table with TYPE = 'E' and if sy-subrc is not initial (i.e; BAPI fails) again you are calling the BAPI with the same data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Point 2:&lt;/P&gt;&lt;P&gt;In the loop you are updating the DB table which will impact the performance. Avoid update in loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jaya krishna K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 12:35:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464512#M1554315</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-08T12:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Slow process of ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464513#M1554316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi, &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Point 1:&lt;/P&gt;&lt;P&gt;&amp;gt; Please check the code. You are reading RETURN table with TYPE = 'E' and if sy-subrc is not initial (i.e; BAPI fails) again you are calling the BAPI with the same data.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Point 2:&lt;/P&gt;&lt;P&gt;&amp;gt; In the loop you are updating the DB table which will impact the performance. Avoid update in loop.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Regards,&lt;/P&gt;&lt;P&gt;&amp;gt; Jaya krishna K&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding 1.: If it's not initial, then he didn't find a E message and thus it was ok. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding 2: update inside a loop is not per definition wrong. It's the inner select on MSEG that's causing a sequential read&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 12:43:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464513#M1554316</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-08T12:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Slow process of ABAP code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464514#M1554317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) The first call with test flag is not actually required, perform the call without test, and use a BAPI_TRANSACTION_ROLLBACK when an error is raised.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)  Do you actually need the "IN ( select MBLNR from MSEG WHERE werks =&lt;/P&gt;&lt;P&gt;wa_itab_final-plant AND charg = wa_itab_final-charg )." clause, check for MSEG indexes and other code to perform. (use SE30, ST05) - only werks and charg can give huge result/cpu without MATNR field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 12:44:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-process-of-abap-code/m-p/7464514#M1554317</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2010-12-08T12:44:34Z</dc:date>
    </item>
  </channel>
</rss>

