<?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: performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316553#M508072</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;Try changing your code this way...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh it_vbfa.&lt;/P&gt;&lt;P&gt;clear it_vbfa..&lt;/P&gt;&lt;P&gt;if not i_vbep[] is initial.&lt;/P&gt;&lt;P&gt;select vbelv&lt;/P&gt;&lt;P&gt;posnv&lt;/P&gt;&lt;P&gt;vbeln&lt;/P&gt;&lt;P&gt;rfmng&lt;/P&gt;&lt;P&gt;from vbfa&lt;/P&gt;&lt;P&gt;into table it_vbfa&lt;/P&gt;&lt;P&gt;for all entries in i_vbep&lt;/P&gt;&lt;P&gt;where vbelv = i_vbep-vbeln and&lt;/P&gt;&lt;P&gt;posnv = i_vbep-posnr and&lt;/P&gt;&lt;P&gt;vbtyp_n = 'J'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh i_vbuk. clear i_vbuk.&lt;/P&gt;&lt;P&gt;If not it_vbfa[] is initial.&lt;/P&gt;&lt;P&gt;select vbeln&lt;/P&gt;&lt;P&gt;wbstk&lt;/P&gt;&lt;P&gt;into table i_vbuk from vbuk for all entries in it_vbfa&lt;/P&gt;&lt;P&gt;where vbeln = it_vbfa-vbeln.&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;sort i_vbuk by vbeln.&lt;/P&gt;&lt;P&gt;LOOP AT i_vbep.&lt;/P&gt;&lt;P&gt;CLEAR ig_tmatnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here Ig_tmatnr has all the materail with Materail type ne 'VERP'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table ig_tmatnr with key matnr = i_vbep-matnr.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;loop at it_vbfa where vbelv = i_vbep-vbeln&lt;/P&gt;&lt;P&gt;                       And   posnr = i_vbep-posnr.&lt;/P&gt;&lt;P&gt;clear : l_delete_rec.&lt;/P&gt;&lt;P&gt;read table i_vbuk with key vbeln = it_vbfa-vbeln.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;binary search.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;if i_vbuk-wbstk = 'C'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Must accumulate the Delivered QTYs - Use this Summed amount&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and deduct from initial Order Item QTY. This results in the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;actual OPEN ITEM QTY on the report; basically whats OPEN to be&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Delivered&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;w_deliv_cmp_rfmng = w_deliv_cmp_rfmng + it_vbfa-rfmng.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set the Delete flag because you don't need this delivery to show&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;on the report as its already been goods issued! But you still want to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Calculate its Delivered QTY for Outstanding QTYs&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;l_delete_rec = 'X'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;w_deliv_rfmng = w_deliv_rfmng + it_vbfa-rfmng.&lt;/P&gt;&lt;P&gt;if l_delete_rec is initial .&lt;/P&gt;&lt;P&gt;move-corresponding it_vbfa to i_vbfa.&lt;/P&gt;&lt;P&gt;append i_vbfa.&lt;/P&gt;&lt;P&gt;clear i_vbfa.&lt;/P&gt;&lt;P&gt;endif.&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;MOVE-CORRESPONDING i_vbep TO i_sales.&lt;/P&gt;&lt;P&gt;IF w_deliv_cmp_rfmng = 0.&lt;/P&gt;&lt;P&gt;i_sales-outstanding_qty = i_sales-kwmeng - w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The 'new' Open Order Qty is the Initial Order QTY less the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Delivered QTYS.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;i_sales-kwmeng = i_sales-kwmeng - w_deliv_cmp_rfmng.&lt;/P&gt;&lt;P&gt;i_sales-outstanding_qty = i_sales-kwmeng - w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ig_tmatnr WITH KEY matnr = i_vbep-matnr&lt;/P&gt;&lt;P&gt;werks = i_vbep-werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt;MOVE ig_tmatnr-dispo TO i_sales-dispo.&lt;/P&gt;&lt;P&gt;CHECK i_vbep-kunnr IN s_kunnr.&lt;/P&gt;&lt;P&gt;READ TABLE i_vbpa WITH KEY vbeln = i_vbep-vbeln BINARY SEARCH.&lt;/P&gt;&lt;P&gt;CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt;READ TABLE i_kunnr WITH KEY kunnr = i_vbpa-kunnr BINARY SEARCH.&lt;/P&gt;&lt;P&gt;MOVE i_vbpa-kunnr TO i_sales-kunnr.&lt;/P&gt;&lt;P&gt;MOVE i_kunnr-name1 TO i_sales-name1.&lt;/P&gt;&lt;P&gt;MOVE i_kunnr-land1 TO i_sales-land1.&lt;/P&gt;&lt;P&gt;READ TABLE i_mtxt1 WITH KEY matnr = i_vbep-matnr BINARY SEARCH.&lt;/P&gt;&lt;P&gt;MOVE i_mtxt1-maktx TO i_sales-maktx.&lt;/P&gt;&lt;P&gt;APPEND i_sales.&lt;/P&gt;&lt;P&gt;CLEAR i_sales.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;DELETE i_vbep.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;CLEAR w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;CLEAR w_deliv_cmp_rfmng.&lt;/P&gt;&lt;P&gt;ENDLOOP. " loop end for i_vbep&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vidya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 May 2007 08:38:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-23T08:38:59Z</dc:date>
    <item>
      <title>performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316549#M508068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;   I have given a program to reduce its perfromance, then i run that report in se30&lt;/P&gt;&lt;P&gt;it is showing the db hit at around 97%, then for this i have taken tables statement &lt;/P&gt;&lt;P&gt;and used types to declare internal tables, it  was having lot of inner joins i have &lt;/P&gt;&lt;P&gt;removed that and used for all entries, now i run the tranction se30 to this modified report but also it is showing the db hit is around 93 %. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Still in this report he is using lot of loops, inside loops he is using lot of select &lt;/P&gt;&lt;P&gt;queries, for this i used read insted of select inside loops but in runtime analysis&lt;/P&gt;&lt;P&gt;the db hit is incresed ie 98%. &lt;/P&gt;&lt;P&gt;     Can any one help me i am sending piece of loop pls suggest how to reduce&lt;/P&gt;&lt;P&gt;select inside loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT i_vbep.&lt;/P&gt;&lt;P&gt;    CLEAR ig_tmatnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here Ig_tmatnr has all the materail with Materail type ne 'VERP'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    read table ig_tmatnr with key matnr = i_vbep-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      refresh it_vbfa.&lt;/P&gt;&lt;P&gt;      clear it_vbfa.&lt;/P&gt;&lt;P&gt;      select vbelv&lt;/P&gt;&lt;P&gt;             posnv&lt;/P&gt;&lt;P&gt;             vbeln&lt;/P&gt;&lt;P&gt;             rfmng&lt;/P&gt;&lt;P&gt;         from vbfa&lt;/P&gt;&lt;P&gt;         into table it_vbfa&lt;/P&gt;&lt;P&gt;         where    vbfa~vbelv    = i_vbep-vbeln and&lt;/P&gt;&lt;P&gt;                  vbfa~posnv    = i_vbep-posnr and&lt;/P&gt;&lt;P&gt;                  vbfa~vbtyp_n  = 'J'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;        refresh i_vbuk. clear i_vbuk.&lt;/P&gt;&lt;P&gt;        select vbeln&lt;/P&gt;&lt;P&gt;               wbstk&lt;/P&gt;&lt;P&gt;            into table i_vbuk from vbuk for all entries in it_vbfa&lt;/P&gt;&lt;P&gt;            where vbeln = it_vbfa-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        sort i_vbuk by vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        loop at it_vbfa.&lt;/P&gt;&lt;P&gt;          clear : l_delete_rec.&lt;/P&gt;&lt;P&gt;         read table i_vbuk with key vbeln = it_vbfa-vbeln.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        binary search.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;            if i_vbuk-wbstk = 'C'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Must accumulate the Delivered QTYs - Use this Summed amount&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and deduct from initial Order Item QTY. This results in the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;actual OPEN ITEM QTY on the report; basically whats OPEN to be&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Delivered&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              w_deliv_cmp_rfmng = w_deliv_cmp_rfmng + it_vbfa-rfmng.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set the Delete flag because you don't need this delivery to show&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;on the report as its already been goods issued! But you still want to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Calculate its Delivered QTY for Outstanding QTYs&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              l_delete_rec      = 'X'.&lt;/P&gt;&lt;P&gt;            endif.&lt;/P&gt;&lt;P&gt;            w_deliv_rfmng     = w_deliv_rfmng + it_vbfa-rfmng.&lt;/P&gt;&lt;P&gt;            if l_delete_rec  is initial  .&lt;/P&gt;&lt;P&gt;              move-corresponding it_vbfa to i_vbfa.&lt;/P&gt;&lt;P&gt;              append i_vbfa.&lt;/P&gt;&lt;P&gt;              clear i_vbfa.&lt;/P&gt;&lt;P&gt;            endif.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        endloop.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      MOVE-CORRESPONDING i_vbep TO i_sales.&lt;/P&gt;&lt;P&gt;      IF w_deliv_cmp_rfmng = 0.&lt;/P&gt;&lt;P&gt;        i_sales-outstanding_qty = i_sales-kwmeng - w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The 'new' Open Order Qty is the Initial Order QTY less the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Delivered QTYS.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        i_sales-kwmeng = i_sales-kwmeng - w_deliv_cmp_rfmng.&lt;/P&gt;&lt;P&gt;        i_sales-outstanding_qty = i_sales-kwmeng - w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      READ TABLE ig_tmatnr WITH KEY matnr = i_vbep-matnr&lt;/P&gt;&lt;P&gt;                                   werks = i_vbep-werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      MOVE ig_tmatnr-dispo TO i_sales-dispo.&lt;/P&gt;&lt;P&gt;      CHECK i_vbep-kunnr IN s_kunnr.&lt;/P&gt;&lt;P&gt;      READ TABLE i_vbpa WITH KEY vbeln = i_vbep-vbeln BINARY SEARCH.&lt;/P&gt;&lt;P&gt;      CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      READ TABLE i_kunnr WITH KEY kunnr = i_vbpa-kunnr BINARY SEARCH.&lt;/P&gt;&lt;P&gt;      MOVE i_vbpa-kunnr TO i_sales-kunnr.&lt;/P&gt;&lt;P&gt;      MOVE i_kunnr-name1 TO i_sales-name1.&lt;/P&gt;&lt;P&gt;      MOVE i_kunnr-land1 TO i_sales-land1.&lt;/P&gt;&lt;P&gt;      READ TABLE i_mtxt1 WITH KEY matnr = i_vbep-matnr BINARY SEARCH.&lt;/P&gt;&lt;P&gt;      MOVE i_mtxt1-maktx TO i_sales-maktx.&lt;/P&gt;&lt;P&gt;      APPEND i_sales.&lt;/P&gt;&lt;P&gt;      CLEAR  i_sales.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      DELETE i_vbep.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    CLEAR w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;    CLEAR w_deliv_cmp_rfmng.&lt;/P&gt;&lt;P&gt;  ENDLOOP.   " loop end for i_vbep&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;desha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2007 07:59:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316549#M508068</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-22T07:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316550#M508069</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;Please remove all the select statements from the loop.&lt;/P&gt;&lt;P&gt;and then u can use read statements instead of select statements in loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let me know if u have any doubts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Suresh.D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2007 08:39:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316550#M508069</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-22T08:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316551#M508070</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;&lt;/P&gt;&lt;P&gt;Donot use loops at all which is having select statement inside!!!!&lt;/P&gt;&lt;P&gt;Instead select data into itabs with select statemetn and using joins (inner/outer)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To join different tables, it is easy for that refer following link which is having all details of link between tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/sap-download/sap-tables.zip" target="test_blank"&gt;http://www.sap-img.com/sap-download/sap-tables.zip&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help u, if u want more info revert back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jogdand M B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2007 09:23:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316551#M508070</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-22T09:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316552#M508071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please avoid using the select queries inside the loop. And instead use the read statements taking the help of the work area. For selecting all the required try using for all entries in the select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sharadendu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2007 10:28:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316552#M508071</guid>
      <dc:creator>sharadendu_agrawal</dc:creator>
      <dc:date>2007-05-22T10:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316553#M508072</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;Try changing your code this way...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh it_vbfa.&lt;/P&gt;&lt;P&gt;clear it_vbfa..&lt;/P&gt;&lt;P&gt;if not i_vbep[] is initial.&lt;/P&gt;&lt;P&gt;select vbelv&lt;/P&gt;&lt;P&gt;posnv&lt;/P&gt;&lt;P&gt;vbeln&lt;/P&gt;&lt;P&gt;rfmng&lt;/P&gt;&lt;P&gt;from vbfa&lt;/P&gt;&lt;P&gt;into table it_vbfa&lt;/P&gt;&lt;P&gt;for all entries in i_vbep&lt;/P&gt;&lt;P&gt;where vbelv = i_vbep-vbeln and&lt;/P&gt;&lt;P&gt;posnv = i_vbep-posnr and&lt;/P&gt;&lt;P&gt;vbtyp_n = 'J'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh i_vbuk. clear i_vbuk.&lt;/P&gt;&lt;P&gt;If not it_vbfa[] is initial.&lt;/P&gt;&lt;P&gt;select vbeln&lt;/P&gt;&lt;P&gt;wbstk&lt;/P&gt;&lt;P&gt;into table i_vbuk from vbuk for all entries in it_vbfa&lt;/P&gt;&lt;P&gt;where vbeln = it_vbfa-vbeln.&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;sort i_vbuk by vbeln.&lt;/P&gt;&lt;P&gt;LOOP AT i_vbep.&lt;/P&gt;&lt;P&gt;CLEAR ig_tmatnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here Ig_tmatnr has all the materail with Materail type ne 'VERP'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table ig_tmatnr with key matnr = i_vbep-matnr.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;loop at it_vbfa where vbelv = i_vbep-vbeln&lt;/P&gt;&lt;P&gt;                       And   posnr = i_vbep-posnr.&lt;/P&gt;&lt;P&gt;clear : l_delete_rec.&lt;/P&gt;&lt;P&gt;read table i_vbuk with key vbeln = it_vbfa-vbeln.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;binary search.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;if i_vbuk-wbstk = 'C'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Must accumulate the Delivered QTYs - Use this Summed amount&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and deduct from initial Order Item QTY. This results in the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;actual OPEN ITEM QTY on the report; basically whats OPEN to be&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Delivered&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;w_deliv_cmp_rfmng = w_deliv_cmp_rfmng + it_vbfa-rfmng.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set the Delete flag because you don't need this delivery to show&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;on the report as its already been goods issued! But you still want to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Calculate its Delivered QTY for Outstanding QTYs&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;l_delete_rec = 'X'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;w_deliv_rfmng = w_deliv_rfmng + it_vbfa-rfmng.&lt;/P&gt;&lt;P&gt;if l_delete_rec is initial .&lt;/P&gt;&lt;P&gt;move-corresponding it_vbfa to i_vbfa.&lt;/P&gt;&lt;P&gt;append i_vbfa.&lt;/P&gt;&lt;P&gt;clear i_vbfa.&lt;/P&gt;&lt;P&gt;endif.&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;MOVE-CORRESPONDING i_vbep TO i_sales.&lt;/P&gt;&lt;P&gt;IF w_deliv_cmp_rfmng = 0.&lt;/P&gt;&lt;P&gt;i_sales-outstanding_qty = i_sales-kwmeng - w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The 'new' Open Order Qty is the Initial Order QTY less the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Delivered QTYS.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;i_sales-kwmeng = i_sales-kwmeng - w_deliv_cmp_rfmng.&lt;/P&gt;&lt;P&gt;i_sales-outstanding_qty = i_sales-kwmeng - w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ig_tmatnr WITH KEY matnr = i_vbep-matnr&lt;/P&gt;&lt;P&gt;werks = i_vbep-werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt;MOVE ig_tmatnr-dispo TO i_sales-dispo.&lt;/P&gt;&lt;P&gt;CHECK i_vbep-kunnr IN s_kunnr.&lt;/P&gt;&lt;P&gt;READ TABLE i_vbpa WITH KEY vbeln = i_vbep-vbeln BINARY SEARCH.&lt;/P&gt;&lt;P&gt;CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt;READ TABLE i_kunnr WITH KEY kunnr = i_vbpa-kunnr BINARY SEARCH.&lt;/P&gt;&lt;P&gt;MOVE i_vbpa-kunnr TO i_sales-kunnr.&lt;/P&gt;&lt;P&gt;MOVE i_kunnr-name1 TO i_sales-name1.&lt;/P&gt;&lt;P&gt;MOVE i_kunnr-land1 TO i_sales-land1.&lt;/P&gt;&lt;P&gt;READ TABLE i_mtxt1 WITH KEY matnr = i_vbep-matnr BINARY SEARCH.&lt;/P&gt;&lt;P&gt;MOVE i_mtxt1-maktx TO i_sales-maktx.&lt;/P&gt;&lt;P&gt;APPEND i_sales.&lt;/P&gt;&lt;P&gt;CLEAR i_sales.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;DELETE i_vbep.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;CLEAR w_deliv_rfmng.&lt;/P&gt;&lt;P&gt;CLEAR w_deliv_cmp_rfmng.&lt;/P&gt;&lt;P&gt;ENDLOOP. " loop end for i_vbep&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vidya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2007 08:38:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316553#M508072</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-23T08:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316554#M508073</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;Try to remove SELECT queries with in the LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kishi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 May 2007 05:18:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/2316554#M508073</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-24T05:18:44Z</dc:date>
    </item>
  </channel>
</rss>

