<?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 Issues in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904275#M55804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. I sometimes find another approach is better. Inside a loop, Use &amp;lt;b&amp;gt;READ TABLE itab&amp;lt;/b&amp;gt; first and then &amp;lt;b&amp;gt;SELECT SINGLE zzz APPENDING itab&amp;lt;/b&amp;gt; each time you don't find the record in the itab. Using this strategy, multiple calls for the same record are very fast and itab remains only as big as it has to be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Spend some time in SE11 making sure you understand which indexes are already defined for your table(s) of interest. Sometimes you can expand the WHERE clause using the IN and/or EXISTS operators to use existing indexes efficiently. I like to define RANGES objects with two or three values for use in WHERE clauses. Like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES: r_key2 FOR table-key2.

r_key2-sign = 'I'.
r_key2-option = 'EQ'.
r_key2-low = 'value1'. APPEND r_key2.
r_key2-low = 'value2'. APPEND r_key2.
r_key2-low = 'value3'. APPEND r_key2.

SELECT * FROM table
WHERE key1 EQ ' '
  AND key2 IN r_key2
  AND field IN S_SelectOption.
* Do stuff here
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, I happen to know that the first key field is always empty for my data of interest and the second key field could be any of three values. Because it uses the primary key index of the table to speed up the query, this code could be much faster than the standard approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table WHERE field IN S_SelectOption.
* Do stuff here
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These performance improvements can come without any index changes at all. Experiment a bit, it's worth it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Apr 2005 22:23:40 GMT</pubDate>
    <dc:creator>juan_suros</dc:creator>
    <dc:date>2005-04-27T22:23:40Z</dc:date>
    <item>
      <title>Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904273#M55802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have couple of questions regarding performance tuning of applications.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Which of the following is better from performance point of view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a) SELECT SINGLE ... inside a LOOP or&lt;/P&gt;&lt;P&gt;b) SELECT XXX. YYYY INTO TABLE ZZZ FROM table... and then READ TABLE zzz ... inside a LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I am planning to discuss with basis guys over creating a new index with all the fields used in the WHERE clause. Will creating a new index be productive????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And one more question. When I did ST05 on my program I got a trace list. I displayed the trace list by SQL statements. But it is not clear which SELECT on which TABLE is taking more time. I will appreciate if someone throw little insight on working with trace list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Somen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2005 20:55:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904273#M55802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-27T20:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904274#M55803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It really depends I think.  In your first case option b. is probably better, especially if you are going to end up getting just about all items in the main select that you would have gotten in the select single by the end of processing.  As long as it doesn't force you to have to read a bunch of extra data, one big select is more efficent than many single selects.  Now on your read table, you can get even better response if you sort by your reading keys and do a &amp;lt;i&amp;gt;read binary search&amp;lt;/i&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Item 2:  This really depends.  It depends upon the table layout, the number of fields, the size of the table, the amount of updating done to the table.  You really need to analyse each situation.  I have seen good indexes have a great positive effect.  I have also seen the opposite.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally from the SQL trace, I like to compress my trace to see the big hitters.  In 640 use menu option Trace List-&amp;gt;Summarize Trace by SQL Statement (or Shift+F8). This should give you a nice ranked list and point out any problems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2005 21:17:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904274#M55803</guid>
      <dc:creator>thomas_jung</dc:creator>
      <dc:date>2005-04-27T21:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904275#M55804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. I sometimes find another approach is better. Inside a loop, Use &amp;lt;b&amp;gt;READ TABLE itab&amp;lt;/b&amp;gt; first and then &amp;lt;b&amp;gt;SELECT SINGLE zzz APPENDING itab&amp;lt;/b&amp;gt; each time you don't find the record in the itab. Using this strategy, multiple calls for the same record are very fast and itab remains only as big as it has to be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Spend some time in SE11 making sure you understand which indexes are already defined for your table(s) of interest. Sometimes you can expand the WHERE clause using the IN and/or EXISTS operators to use existing indexes efficiently. I like to define RANGES objects with two or three values for use in WHERE clauses. Like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES: r_key2 FOR table-key2.

r_key2-sign = 'I'.
r_key2-option = 'EQ'.
r_key2-low = 'value1'. APPEND r_key2.
r_key2-low = 'value2'. APPEND r_key2.
r_key2-low = 'value3'. APPEND r_key2.

SELECT * FROM table
WHERE key1 EQ ' '
  AND key2 IN r_key2
  AND field IN S_SelectOption.
* Do stuff here
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, I happen to know that the first key field is always empty for my data of interest and the second key field could be any of three values. Because it uses the primary key index of the table to speed up the query, this code could be much faster than the standard approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table WHERE field IN S_SelectOption.
* Do stuff here
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These performance improvements can come without any index changes at all. Experiment a bit, it's worth it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2005 22:23:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904275#M55804</guid>
      <dc:creator>juan_suros</dc:creator>
      <dc:date>2005-04-27T22:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904276#M55805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here I am pasting some part of the code where the execution time is more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SELECT using JOIN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      &amp;lt;b&amp;gt;select a&lt;SUB&gt;vbeln c&lt;/SUB&gt;lifsk c&lt;SUB&gt;kunnr e&lt;/SUB&gt;kunnr c&lt;SUB&gt;vsbed c&lt;/SUB&gt;audat&lt;/P&gt;&lt;P&gt;             c&lt;SUB&gt;bstnk c&lt;/SUB&gt;submi c&lt;SUB&gt;waerk c&lt;/SUB&gt;knumv&lt;/P&gt;&lt;P&gt;             a&lt;SUB&gt;posnr a&lt;/SUB&gt;matnr a&lt;SUB&gt;kwmeng a&lt;/SUB&gt;vrkme&lt;/P&gt;&lt;P&gt;             a~kdmat&lt;/P&gt;&lt;P&gt;             d&lt;SUB&gt;edatu a&lt;/SUB&gt;vstel a&lt;SUB&gt;mfrgr a&lt;/SUB&gt;abgru a&lt;SUB&gt;pstyv a&lt;/SUB&gt;vkaus&lt;/P&gt;&lt;P&gt;             a~posex&lt;/P&gt;&lt;P&gt;        into table idocs&lt;/P&gt;&lt;P&gt;        from vbap as a join vbuk as b on&lt;/P&gt;&lt;P&gt;           ( a&lt;SUB&gt;vbeln = b&lt;/SUB&gt;vbeln )&lt;/P&gt;&lt;P&gt;                       join vbak as c on&lt;/P&gt;&lt;P&gt;           ( a&lt;SUB&gt;vbeln = c&lt;/SUB&gt;vbeln )&lt;/P&gt;&lt;P&gt;                       join vbep as d on&lt;/P&gt;&lt;P&gt;           ( a&lt;SUB&gt;vbeln = d&lt;/SUB&gt;vbeln and&lt;/P&gt;&lt;P&gt;             a&lt;SUB&gt;posnr = d&lt;/SUB&gt;posnr )&lt;/P&gt;&lt;P&gt;                       join vbpa as e on&lt;/P&gt;&lt;P&gt;           ( a&lt;SUB&gt;vbeln = e&lt;/SUB&gt;vbeln )&lt;/P&gt;&lt;P&gt;        where a~vbeln in so_vbeln&lt;/P&gt;&lt;P&gt;          and c~submi in so_submi&lt;/P&gt;&lt;P&gt;          and c~audat in so_audat&lt;/P&gt;&lt;P&gt;          and c~erdat in so_erdat&lt;/P&gt;&lt;P&gt;          and c~vbtyp = 'H'&lt;/P&gt;&lt;P&gt;          and c~bstnk in so_bstnk&lt;/P&gt;&lt;P&gt;          and c~lifsk in so_lifsk&lt;/P&gt;&lt;P&gt;          and c~auart in so_auart&lt;/P&gt;&lt;P&gt;          and c~kunnr in so_kunnr&lt;/P&gt;&lt;P&gt;          and e~posnr = '000000'&lt;/P&gt;&lt;P&gt;          and e~kunnr in so_ship2&lt;/P&gt;&lt;P&gt;          and e~parvw = 'WE'&lt;/P&gt;&lt;P&gt;          and a~matnr in so_matnr&lt;/P&gt;&lt;P&gt;          and a~route in so_route&lt;/P&gt;&lt;P&gt;          and d~etenr = '0001'.  " Always pick first schedule line entry&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And other part of the code where I am facing problem is here.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;  loop at isel into ssel.&lt;/P&gt;&lt;P&gt;    at new vbeln.&lt;/P&gt;&lt;P&gt;      clear:   header, headerx, new_kunnr, new_ship2, logsw, condup,&lt;/P&gt;&lt;P&gt;               head_err, con1_err, con2_err.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      clear int_num_assign.                "DM01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      refresh: ireturn, iitem, iitemx, isched, ischedx, icond, icondx.&lt;/P&gt;&lt;P&gt;      headerx-updateflag = 'U'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    If a header condition is being added, first see if it already&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    exists.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      if not check_condh is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      See if the condition exists on the header&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Get VBAK condition number.  We can't join because KONV is a&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      pooled table.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       select single knumv waerk into (knumv, waerk)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         from vbak&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         where vbeln = ssel-vbeln.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      See if the condition exists at the header in KONV.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        select single kschl into kschl&lt;/P&gt;&lt;P&gt;          from konv&lt;/P&gt;&lt;P&gt;          where knumv = ssel-knumv&lt;/P&gt;&lt;P&gt;            and kposn = '000000'&lt;/P&gt;&lt;P&gt;            and kschl = zmass_order-kschlh.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      If found, do not update.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;          head_err = 'X'.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        See if any items are delivered.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          select single vbeln into lips-vbeln&lt;/P&gt;&lt;P&gt;            from lips&lt;/P&gt;&lt;P&gt;            where vgbel = ssel-vbeln.&lt;/P&gt;&lt;P&gt;          if sy-subrc = 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;          See if all items are billed&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            select single c~fksta into fksta&lt;/P&gt;&lt;P&gt;              from lips as a join vbap as b on&lt;/P&gt;&lt;P&gt;                 ( a&lt;SUB&gt;vgbel = b&lt;/SUB&gt;vbeln and&lt;/P&gt;&lt;P&gt;                   a&lt;SUB&gt;vgpos = b&lt;/SUB&gt;posnr )&lt;/P&gt;&lt;P&gt;                             join vbup as c on&lt;/P&gt;&lt;P&gt;                 ( a&lt;SUB&gt;vbeln = c&lt;/SUB&gt;vbeln and&lt;/P&gt;&lt;P&gt;                   a&lt;SUB&gt;posnr = c&lt;/SUB&gt;posnr )&lt;/P&gt;&lt;P&gt;               where b~vbeln = ssel-vbeln&lt;/P&gt;&lt;P&gt;                 and c~fksta &amp;lt;&amp;gt; 'C'.&lt;/P&gt;&lt;P&gt;            if sy-subrc ne 0.&lt;/P&gt;&lt;P&gt;              head_err = 'Y'.&lt;/P&gt;&lt;P&gt;            endif.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      If both tests passed.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        if head_err is initial.&lt;/P&gt;&lt;P&gt;          kbetr_out = zmass_order-kbetrh.&lt;/P&gt;&lt;P&gt;          read table it685a with key kschl = zmass_order-kschlh.&lt;/P&gt;&lt;P&gt;          if it685a-krech ca 'AHI'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           multiply kbetr_out by 10.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            icond-currency  = waerk.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;          icond-itm_number  = '000000'.&lt;/P&gt;&lt;P&gt;          icond-cond_type   = zmass_order-kschlh.&lt;/P&gt;&lt;P&gt;          icond-cond_value  = kbetr_out.&lt;/P&gt;&lt;P&gt;          icond-applicatio  = 'V'.&lt;/P&gt;&lt;P&gt;          icondx-itm_number = '000000'.&lt;/P&gt;&lt;P&gt;          icondx-cond_type  = zmass_order-kschlh.&lt;/P&gt;&lt;P&gt;          icondx-cond_value = 'X'.&lt;/P&gt;&lt;P&gt;          icondx-currency   = 'X'.&lt;/P&gt;&lt;P&gt;          icondx-updateflag = 'I'.&lt;/P&gt;&lt;P&gt;          append: icond, icondx.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    clear:   ireturn, iitem, iitemx, isched, ischedx, icond, icondx,&lt;/P&gt;&lt;P&gt;             refresh_vas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Set fields for update&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_kunnr = 'X'.&lt;/P&gt;&lt;P&gt;      new_kunnr = ssel-kunnr.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    if check_ship2 = 'X'.&lt;/P&gt;&lt;P&gt;      new_ship2 = ssel-ship2.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    if ssel-revas = 'X'.&lt;/P&gt;&lt;P&gt;      refresh_vas = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to delivery block.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_lifsk = 'X'.&lt;/P&gt;&lt;P&gt;      header-dlv_block  = ssel-lifsk.&lt;/P&gt;&lt;P&gt;      headerx-dlv_block = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to pricing date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_prsdt = 'X'.&lt;/P&gt;&lt;P&gt;      header-price_date  = ssel-prsdt.&lt;/P&gt;&lt;P&gt;      headerx-price_date = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to shipping condition&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_vsbed = 'X'.&lt;/P&gt;&lt;P&gt;      header-ship_cond  = ssel-vsbed.&lt;/P&gt;&lt;P&gt;      headerx-ship_cond = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to document date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_audat = 'X'.&lt;/P&gt;&lt;P&gt;      header-doc_date  = ssel-audat.&lt;/P&gt;&lt;P&gt;      headerx-doc_date = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to purchase order&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_bstnk = 'X'.&lt;/P&gt;&lt;P&gt;      header-purch_no_c  = ssel-bstnk.&lt;/P&gt;&lt;P&gt;      headerx-purch_no_c = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if p_item eq 'X'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to material&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_matnr = 'X'.&lt;/P&gt;&lt;P&gt;*&amp;gt;&amp;gt;   Begin Insert                                    "DM02&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Get the Material on the SO Item being changed&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    If it is the same material as the one entered on the change&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    screen the item will be deleted and re-inserted. This is done&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    because it is assumed that the material master data has been&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    updated and that it needs to be refreshed on the order. The&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    only way to do this is to add the material as a new item&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      clear old_matnr.&lt;/P&gt;&lt;P&gt;      select single matnr into old_matnr&lt;/P&gt;&lt;P&gt;        from vbap&lt;/P&gt;&lt;P&gt;        where vbeln = ssel-vbeln&lt;/P&gt;&lt;P&gt;          and posnr = ssel-posnr.&lt;/P&gt;&lt;P&gt;*&amp;lt;&amp;lt;  End Insert                                        "DM02&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Check to see if either the original material or the new one is a&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    BOM header.  If so, delete the original and add a new one.  This&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    will prevent errors during the BOM explosion if the BOM has more&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    than 10 items.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      clear izsd17.&lt;/P&gt;&lt;P&gt;      read table izsd17 with key pstyv = ssel-pstyv.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Check for the new material in MAST (BOM header)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      clear mast.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     select single matnr into mast-matnr                   "DM01&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      select single matnr stlan                              "DM01&lt;/P&gt;&lt;P&gt;            into (mast-matnr, mast-stlan)                    "DM01&lt;/P&gt;&lt;P&gt;        from mast&lt;/P&gt;&lt;P&gt;        where matnr = ssel-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      if izsd17-mtype ne 'S' or not mast-matnr is initial. "DM01&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       if izsd17-mtype ne 'S' or                             "DM01&lt;/P&gt;&lt;P&gt;           mast-stlan = '5' or mast-stlan = '3'              "DM01&lt;/P&gt;&lt;P&gt;           or ssel-matnr = old_matnr.                        "DM02&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitem-material    = ssel-matnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitemx-updateflag = 'D'.&lt;/P&gt;&lt;P&gt;        append: iitemx, iitem.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       clear: iitem-itm_number, iitemx-itm_number.  "DM01&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr + 1.           "DM01&lt;/P&gt;&lt;P&gt;        iitem-material    = ssel-matnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = iitem-itm_number.         "DM01&lt;/P&gt;&lt;P&gt;        iitemx-updateflag = 'I'.&lt;/P&gt;&lt;P&gt;        iitemx-material   = 'X'.&lt;/P&gt;&lt;P&gt;        isched-itm_number  = iitem-itm_number.        "DM01&lt;/P&gt;&lt;P&gt;        isched-sched_line   = '0001'.&lt;/P&gt;&lt;P&gt;        isched-req_qty      = ssel-kwmeng.&lt;/P&gt;&lt;P&gt;        ischedx-itm_number  = isched-itm_number.      "DM01&lt;/P&gt;&lt;P&gt;        ischedx-sched_line  = '0001'.&lt;/P&gt;&lt;P&gt;        ischedx-req_qty     = 'X'.&lt;/P&gt;&lt;P&gt;        ischedx-updateflag  = 'I'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        int_num_assign = 'X'.                         "DM01&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitem-material    = ssel-matnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitemx-updateflag = 'U'.&lt;/P&gt;&lt;P&gt;        iitemx-material   = 'X'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to item category&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_pstyv = 'X'.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag = 'I'."                                 SM01+&lt;/P&gt;&lt;P&gt;        iitem-item_categ  = ssel-pstyv.&lt;/P&gt;&lt;P&gt;        iitemx-item_categ = 'X'.&lt;/P&gt;&lt;P&gt;      else."                                                       SM01+&lt;/P&gt;&lt;P&gt;        clear izsd17.&lt;/P&gt;&lt;P&gt;        read table izsd17 with key pstyv = ssel-pstyv.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Check for the new material in MAST (BOM header)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        clear mast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      select single matnr into mast-matnr                  "DM01&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        select single matnr stlan                            "DM01&lt;/P&gt;&lt;P&gt;           into (mast-matnr, mast-stlan)                     "DM01&lt;/P&gt;&lt;P&gt;          from mast&lt;/P&gt;&lt;P&gt;          where matnr = ssel-matnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      if izsd17-mtype ne 'S' or not mast-matnr is initial. "DM01&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        if izsd17-mtype ne 'S' or                            "DM01&lt;/P&gt;&lt;P&gt;            mast-stlan = '5' or mast-stlan = '3'.            "DM01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        Delete Item&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;          iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;          iitemx-updateflag = 'D'.&lt;/P&gt;&lt;P&gt;          append: iitem, iitemx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        Insert Item back with updated Item Category&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          iitem-itm_number    = ssel-posnr + 1.        "DM01&lt;/P&gt;&lt;P&gt;          iitem-material      = ssel-matnr.&lt;/P&gt;&lt;P&gt;          iitem-cust_mat35    = ssel-kdmat.            "DM01&lt;/P&gt;&lt;P&gt;          iitem-item_categ    = ssel-pstyv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          iitemx-itm_number   = iitem-itm_number.      "DM01&lt;/P&gt;&lt;P&gt;          iitemx-updateflag   = 'I'.&lt;/P&gt;&lt;P&gt;          iitemx-item_categ   = 'X'.&lt;/P&gt;&lt;P&gt;          iitemx-material     = 'X'.&lt;/P&gt;&lt;P&gt;          iitemx-cust_mat35   = 'X'.                   "DM01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          isched-itm_number   = iitem-itm_number.      "DM01&lt;/P&gt;&lt;P&gt;          isched-sched_line   = '0001'.&lt;/P&gt;&lt;P&gt;          isched-req_qty      = ssel-kwmeng.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          ischedx-itm_number  = isched-itm_number.     "DM01&lt;/P&gt;&lt;P&gt;          ischedx-sched_line  = isched-sched_line.&lt;/P&gt;&lt;P&gt;          ischedx-req_qty     = 'X'.&lt;/P&gt;&lt;P&gt;          ischedx-updateflag  = 'I'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          int_num_assign = 'X'.                        "DM01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;P&gt;          iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;          iitem-item_categ  = ssel-pstyv.&lt;/P&gt;&lt;P&gt;          iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;          if iitemx-updateflag is initial.&lt;/P&gt;&lt;P&gt;            iitemx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;          iitemx-item_categ = 'X'.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to item delivery date.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_edatu = 'X'.&lt;/P&gt;&lt;P&gt;      if ischedx-updateflag  &amp;lt;&amp;gt; 'I'."                              SM01+&lt;/P&gt;&lt;P&gt;        isched-itm_number   = ssel-posnr.&lt;/P&gt;&lt;P&gt;        ischedx-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;      isched-sched_line   = '0001'.&lt;/P&gt;&lt;P&gt;      isched-req_date     = ssel-edatu.&lt;/P&gt;&lt;P&gt;      ischedx-sched_line  = '0001'.&lt;/P&gt;&lt;P&gt;      ischedx-req_date    = 'X'.&lt;/P&gt;&lt;P&gt;      if ischedx-updateflag is initial.&lt;/P&gt;&lt;P&gt;        ischedx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to ship point&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_vstel = 'X'.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag &amp;lt;&amp;gt; 'I'."                                SM01+&lt;/P&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;      iitem-ship_point  = ssel-vstel.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag is initial.&lt;/P&gt;&lt;P&gt;        iitemx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      iitemx-ship_point = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to rejection reason&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_abgru = 'X'.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag &amp;lt;&amp;gt; 'I'."                                SM01+&lt;/P&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;      iitem-reason_rej  = ssel-abgru.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag is initial.&lt;/P&gt;&lt;P&gt;        iitemx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      iitemx-reason_rej = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to item usage&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_vkaus = 'X'.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag &amp;lt;&amp;gt; 'I'."                                SM01+&lt;/P&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;      iitem-usage_ind   = ssel-vkaus.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag is initial.&lt;/P&gt;&lt;P&gt;        iitemx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      iitemx-usage_ind  = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to item order reason&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_posex = 'X'.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag &amp;lt;&amp;gt; 'I'."                                SM01+&lt;/P&gt;&lt;P&gt;        iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;      iitem-po_itm_no   = ssel-posex.&lt;/P&gt;&lt;P&gt;      if iitemx-updateflag is initial.&lt;/P&gt;&lt;P&gt;        iitemx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      iitemx-po_itm_no  = 'X'.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Check change to qty.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if check_qty = 'X'.&lt;/P&gt;&lt;P&gt;      if ischedx-updateflag  &amp;lt;&amp;gt; 'I'."                              SM01+&lt;/P&gt;&lt;P&gt;        isched-itm_number   = ssel-posnr.&lt;/P&gt;&lt;P&gt;        ischedx-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;      endif."                                                      SM01+&lt;/P&gt;&lt;P&gt;      isched-sched_line   = '0001'.&lt;/P&gt;&lt;P&gt;      isched-req_qty      = ssel-kwmeng.&lt;/P&gt;&lt;P&gt;      ischedx-sched_line  = '0001'.&lt;/P&gt;&lt;P&gt;      ischedx-req_qty     = 'X'.&lt;/P&gt;&lt;P&gt;      if ischedx-updateflag is initial.&lt;/P&gt;&lt;P&gt;        ischedx-updateflag  = 'U'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Delete the item if marked.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if ssel-delet = 'X'.&lt;/P&gt;&lt;P&gt;      iitem-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;      iitemx-updateflag = 'D'.&lt;/P&gt;&lt;P&gt;      iitemx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Determine item billing status.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if not check_cond1 is initial or not check_cond2 is initial.&lt;/P&gt;&lt;P&gt;      clear fksta.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Look for any delivery of the item that has not been completely&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    billed.  There may be multiple deliveries, so we're looking for&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    anything that's not a 'C'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    See if the item has been delivered.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      select single vbeln into lips-vbeln&lt;/P&gt;&lt;P&gt;        from lips&lt;/P&gt;&lt;P&gt;        where vgbel = ssel-vbeln&lt;/P&gt;&lt;P&gt;          and vgpos = ssel-posnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    If delivered, check billing status.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;        select single c~fksta into fksta&lt;/P&gt;&lt;P&gt;          from lips as a join vbap as b on&lt;/P&gt;&lt;P&gt;             ( a&lt;SUB&gt;vgbel = b&lt;/SUB&gt;vbeln and&lt;/P&gt;&lt;P&gt;               a&lt;SUB&gt;vgpos = b&lt;/SUB&gt;posnr )&lt;/P&gt;&lt;P&gt;                         join vbup as c on&lt;/P&gt;&lt;P&gt;             ( a&lt;SUB&gt;vbeln = c&lt;/SUB&gt;vbeln and&lt;/P&gt;&lt;P&gt;               a&lt;SUB&gt;posnr = c&lt;/SUB&gt;posnr )&lt;/P&gt;&lt;P&gt;           where b~vbeln = ssel-vbeln&lt;/P&gt;&lt;P&gt;             and b~posnr = ssel-posnr&lt;/P&gt;&lt;P&gt;             and c~fksta &amp;lt;&amp;gt; 'C'.&lt;/P&gt;&lt;P&gt;        if sy-subrc ne 0.&lt;/P&gt;&lt;P&gt;          condup = 'X'.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      The document has no deliveries, so set the billing status to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      incomplete.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        fksta = 'A'.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Add condition types if specified.  For condition types with KRECH =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  A, H, or I, the condition type is a percentage.  The BAPI translates&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  these values incorrectly, so multiply the input by 10 to correct it.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if not check_cond1 is initial and not fksta is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    See if the condition exists on the item&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Get VBAK condition number.  We can't join because KONV is a&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    pooled table.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     select single knumv waerk into (knumv, waerk)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       from vbak&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       where vbeln = ssel-vbeln.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    See if the condition exists at the header in KONV.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      select single kschl into kschl&lt;/P&gt;&lt;P&gt;        from konv&lt;/P&gt;&lt;P&gt;        where knumv = ssel-knumv&lt;/P&gt;&lt;P&gt;          and kposn = ssel-posnr&lt;/P&gt;&lt;P&gt;          and kschl = zmass_order-kschl1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    If found, do not update.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;        con1_err = 'X'.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        kbetr_out = zmass_order-kbetr1.&lt;/P&gt;&lt;P&gt;        read table it685a with key kschl = zmass_order-kschl1.&lt;/P&gt;&lt;P&gt;        if it685a-krech ca 'AHI'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        multiply kbetr_out by 10.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;P&gt;          icond-currency    = ssel-waerk.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;        icond-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        icond-cond_type   = zmass_order-kschl1.&lt;/P&gt;&lt;P&gt;        icond-cond_value  = kbetr_out.&lt;/P&gt;&lt;P&gt;        icondx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;        icondx-cond_type  = zmass_order-kschl1.&lt;/P&gt;&lt;P&gt;        icondx-cond_value = 'X'.&lt;/P&gt;&lt;P&gt;        icondx-currency   = 'X'.&lt;/P&gt;&lt;P&gt;        icondx-updateflag = 'I'.&lt;/P&gt;&lt;P&gt;        append: icond, icondx.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if not check_cond2 is initial and not fksta is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    See if the condition exists on the item&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Get VBAK condition number.  We can't join because KONV is a&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    pooled table.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     select single knumv waerk into (knumv, waerk)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       from vbak&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       where vbeln = ssel-vbeln.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    See if the condition exists at the header in KONV.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      select single kschl into kschl&lt;/P&gt;&lt;P&gt;        from konv&lt;/P&gt;&lt;P&gt;        where knumv = ssel-knumv&lt;/P&gt;&lt;P&gt;          and kposn = ssel-posnr&lt;/P&gt;&lt;P&gt;          and kschl = zmass_order-kschl2.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    If found, do not update.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;        con2_err = 'X'.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        kbetr_out = zmass_order-kbetr2.&lt;/P&gt;&lt;P&gt;        read table it685a with key kschl = zmass_order-kschl2.&lt;/P&gt;&lt;P&gt;        if it685a-krech ca 'AHI'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       multiply kbetr_out by 10.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;P&gt;          icond-currency    = ssel-waerk.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;        icond-itm_number  = ssel-posnr.&lt;/P&gt;&lt;P&gt;        icond-cond_type   = zmass_order-kschl2.&lt;/P&gt;&lt;P&gt;        icond-cond_value  = kbetr_out.&lt;/P&gt;&lt;P&gt;        icondx-itm_number = ssel-posnr.&lt;/P&gt;&lt;P&gt;        icondx-cond_type  = zmass_order-kschl2.&lt;/P&gt;&lt;P&gt;        icondx-cond_value = 'X'.&lt;/P&gt;&lt;P&gt;        icondx-currency   = 'X'.&lt;/P&gt;&lt;P&gt;        icondx-updateflag = 'I'.&lt;/P&gt;&lt;P&gt;        append: icond, icondx.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;   endif.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  If the header rows have data for item and schedule line, append&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  to the tables.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    if not iitem is initial.&lt;/P&gt;&lt;P&gt;      append: iitem.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    if not iitemx is initial.&lt;/P&gt;&lt;P&gt;      append: iitemx.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    if not isched is initial.&lt;/P&gt;&lt;P&gt;      append: isched, ischedx.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  At the last line for the sales document, call the BAPI.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    at end of vbeln.&lt;/P&gt;&lt;P&gt;      call function 'BAPI_SALESORDER_CHANGE'&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          salesdocument    = ssel-vbeln&lt;/P&gt;&lt;P&gt;          order_header_in  = header&lt;/P&gt;&lt;P&gt;          order_header_inx = headerx&lt;/P&gt;&lt;P&gt;          logic_switch     = logsw&lt;/P&gt;&lt;P&gt;          INT_NUMBER_ASSIGNMENT = int_num_assign   "DM01&lt;/P&gt;&lt;P&gt;        tables&lt;/P&gt;&lt;P&gt;          return           = ireturn&lt;/P&gt;&lt;P&gt;          order_item_in    = iitem&lt;/P&gt;&lt;P&gt;          order_item_inx   = iitemx&lt;/P&gt;&lt;P&gt;          schedule_lines   = isched&lt;/P&gt;&lt;P&gt;          schedule_linesx  = ischedx&lt;/P&gt;&lt;P&gt;          conditions_in    = icond&lt;/P&gt;&lt;P&gt;          conditions_inx   = icondx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call function 'BAPI_TRANSACTION_COMMIT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Update the log from the BAPI call.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      perform c010_update_log_from_bapi tables ireturn&lt;/P&gt;&lt;P&gt;                                        using  ssel-vbeln.&lt;/P&gt;&lt;P&gt;      if condup = 'X'.&lt;/P&gt;&lt;P&gt;        ilog-status = 'Warning'.&lt;/P&gt;&lt;P&gt;        ilog-msg    =&lt;/P&gt;&lt;P&gt;        'Not all conditions were updated due to completed billings.'.&lt;/P&gt;&lt;P&gt;        append ilog.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      if head_err = 'X'.&lt;/P&gt;&lt;P&gt;        ilog-status = 'Warning'.&lt;/P&gt;&lt;P&gt;        ilog-msg    =&lt;/P&gt;&lt;P&gt;          'Header pricing condition not updated as it already exists.'.&lt;/P&gt;&lt;P&gt;        append ilog.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      if head_err = 'Y'.&lt;/P&gt;&lt;P&gt;        ilog-status = 'Warning'.&lt;/P&gt;&lt;P&gt;        ilog-msg    =&lt;/P&gt;&lt;P&gt;        'Header pricing condition not updated as all items are billed.'.&lt;/P&gt;&lt;P&gt;        append ilog.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      if con1_err = 'X'.&lt;/P&gt;&lt;P&gt;        ilog-status = 'Warning'.&lt;/P&gt;&lt;P&gt;        ilog-msg    =&lt;/P&gt;&lt;P&gt;        'Item pricing condition 1 not updated as it already exists.'.&lt;/P&gt;&lt;P&gt;        append ilog.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      if con2_err = 'X'.&lt;/P&gt;&lt;P&gt;        ilog-status = 'Warning'.&lt;/P&gt;&lt;P&gt;        ilog-msg    =&lt;/P&gt;&lt;P&gt;        'Item pricing condition 2 not updated as it already exists.'.&lt;/P&gt;&lt;P&gt;        append ilog.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      call function 'DEQUEUE_ALL'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endat.&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;endform.                    " b020_udpate_documents&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I did an SQL trace on this application the most time taking operations are &lt;/P&gt;&lt;P&gt;1. Dynpro entry&lt;/P&gt;&lt;P&gt;2. LDB processing&lt;/P&gt;&lt;P&gt;3. PAI module (2nd part of the code is part of PAI module)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can any one please explain me what Dynpro entry and LDB processing is??? It would be great if you point me to some documentation over this where I can find details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Somen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2005 00:29:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904276#M55805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-28T00:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904277#M55806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The above two parts are eating 90% of the execution time. Please suggest what changes can be still to those two parts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Somen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2005 00:33:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904277#M55806</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-28T00:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904278#M55807</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;SELECT XXX. YYYY INTO TABLE ZZZ FROM table... and then READ TABLE zzz ... inside a LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use this select query, this will reduce execution time, Using Select inside a loop is not recommended, Because it will hit the database as many times the loop gets executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope I have cleared ur first question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Judith&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2005 04:50:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904278#M55807</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-28T04:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904279#M55808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Naren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest you to change the order of the tables in the join condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vbak join vbap&lt;/P&gt;&lt;P&gt;on ( vbeln ... )&lt;/P&gt;&lt;P&gt;join vbep&lt;/P&gt;&lt;P&gt;join vbpa&lt;/P&gt;&lt;P&gt;join vbuk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erwan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2005 07:02:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/904279#M55808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-28T07:02:21Z</dc:date>
    </item>
  </channel>
</rss>

