<?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 fine tune the program for performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954172#M1155048</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moved to correct forum by moderator.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hello gurus please give me suggestions to  performance the code in a good way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD if_ex_mb_migo_badi~post_document . 
**********************************************************************
*The delivery note number provided by vendor should be unique  in migo
Importing it_mseg and is_mkpf 
**********************************************************************
  DATA : itab_mkpf TYPE TABLE OF mkpf.
  DATA : work_mseg TYPE mseg.
  DATA : itab1t_mseg TYPE TABLE OF mseg. 
  DATA : itab1_mseg TYPE TABLE OF mseg.

  LOOP AT it_mseg INTO work_mseg.

*  Fetching the delivery note if already exists
      SELECT mblnr mjahr xblnr FROM mkpf
                INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                WHERE xblnr = is_mkpf-xblnr.

      IF sy-subrc EQ 0.

        IF work_mseg-bwart EQ '103' . 
          
          SELECT mblnr lifnr FROM mseg INTO  TABLE itab1_mseg
                             FOR ALL ENTRIES IN itab_mkpf
                                WHERE mblnr = itab_mkpf-mblnr
                                  AND mjahr = itab_mkpf-mjahr
                                  AND lifnr = work_mseg-lifnr.
          IF sy-subrc EQ 0.
            MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
          ENDIF.

        ELSEIF work_mseg-bwart EQ '105'.

          SELECT mblnr mjahr lifnr  ebeln ebelp FROM mseg
                     INTO CORRESPONDING FIELDS OF TABLE itab1t_mseg
                                       WHERE ebeln = work_mseg-ebeln
                                         AND ebelp = work_mseg-ebelp.

          SELECT mblnr mjahr xblnr FROM mkpf
                     INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                    FOR ALL ENTRIES IN itab1t_mseg
                                   WHERE mblnr = itab1t_mseg-mblnr
                                   AND   mjahr = itab1t_mseg-mjahr
                                   AND   xblnr = is_mkpf-xblnr.

          IF sy-subrc = 0.

            IF sy-subrc = 0. 
              SELECT mblnr lifnr  ebeln FROM mseg
                    INTO CORRESPONDING FIELDS OF TABLE  itab1_mseg
                                     FOR ALL ENTRIES IN itab_mkpf
                                    WHERE mblnr = itab_mkpf-mblnr
                                      AND mjahr = itab_mkpf-mjahr
                                      AND bwart &amp;lt;&amp;gt; '103'
                                      AND lifnr = work_mseg-lifnr.

              IF sy-subrc EQ 0.
                MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
              ENDIF.
            ENDIF. 
          ELSE.
            MESSAGE 'Maintain the same delivery note number as maintained for 103 mvt type'              TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.

  ENDLOOP.
ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Dec 24, 2008 7:33 PM - added  tags&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Dec 2008 09:00:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-12-24T09:00:07Z</dc:date>
    <item>
      <title>fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954172#M1155048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moved to correct forum by moderator.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hello gurus please give me suggestions to  performance the code in a good way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD if_ex_mb_migo_badi~post_document . 
**********************************************************************
*The delivery note number provided by vendor should be unique  in migo
Importing it_mseg and is_mkpf 
**********************************************************************
  DATA : itab_mkpf TYPE TABLE OF mkpf.
  DATA : work_mseg TYPE mseg.
  DATA : itab1t_mseg TYPE TABLE OF mseg. 
  DATA : itab1_mseg TYPE TABLE OF mseg.

  LOOP AT it_mseg INTO work_mseg.

*  Fetching the delivery note if already exists
      SELECT mblnr mjahr xblnr FROM mkpf
                INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                WHERE xblnr = is_mkpf-xblnr.

      IF sy-subrc EQ 0.

        IF work_mseg-bwart EQ '103' . 
          
          SELECT mblnr lifnr FROM mseg INTO  TABLE itab1_mseg
                             FOR ALL ENTRIES IN itab_mkpf
                                WHERE mblnr = itab_mkpf-mblnr
                                  AND mjahr = itab_mkpf-mjahr
                                  AND lifnr = work_mseg-lifnr.
          IF sy-subrc EQ 0.
            MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
          ENDIF.

        ELSEIF work_mseg-bwart EQ '105'.

          SELECT mblnr mjahr lifnr  ebeln ebelp FROM mseg
                     INTO CORRESPONDING FIELDS OF TABLE itab1t_mseg
                                       WHERE ebeln = work_mseg-ebeln
                                         AND ebelp = work_mseg-ebelp.

          SELECT mblnr mjahr xblnr FROM mkpf
                     INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                    FOR ALL ENTRIES IN itab1t_mseg
                                   WHERE mblnr = itab1t_mseg-mblnr
                                   AND   mjahr = itab1t_mseg-mjahr
                                   AND   xblnr = is_mkpf-xblnr.

          IF sy-subrc = 0.

            IF sy-subrc = 0. 
              SELECT mblnr lifnr  ebeln FROM mseg
                    INTO CORRESPONDING FIELDS OF TABLE  itab1_mseg
                                     FOR ALL ENTRIES IN itab_mkpf
                                    WHERE mblnr = itab_mkpf-mblnr
                                      AND mjahr = itab_mkpf-mjahr
                                      AND bwart &amp;lt;&amp;gt; '103'
                                      AND lifnr = work_mseg-lifnr.

              IF sy-subrc EQ 0.
                MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
              ENDIF.
            ENDIF. 
          ELSE.
            MESSAGE 'Maintain the same delivery note number as maintained for 103 mvt type'              TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.

  ENDLOOP.
ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Dec 24, 2008 7:33 PM - added  tags&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:00:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954172#M1155048</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954173#M1155049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove your selects from loop.. endloop ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:01:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954173#M1155049</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954174#M1155050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Few basic things...&lt;/P&gt;&lt;P&gt; - Dont use selects inside the loop, if possible try and populate your table outside the loop and use the   READ statement with Binary search in the loop.&lt;/P&gt;&lt;P&gt; - Instead of INTO CORRESPONDING FIELDS key in the actual field names.&lt;/P&gt;&lt;P&gt;- Also Use key fields in the where condition if available&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Narendra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:03:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954174#M1155050</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954175#M1155051</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;don't use the select statements inside the loop...endloop.&lt;/P&gt;&lt;P&gt;select all the data from database and use read statement or loop on the internal tables.&lt;/P&gt;&lt;P&gt;then u can reduce the perfomance issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:03:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954175#M1155051</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954176#M1155052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove INTO CORRESPONDING FIELDS &lt;/P&gt;&lt;P&gt;while selecting for all entries take all the key fields in select statment whether u need it or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avoid hitting one table multiple times rather select in one go and use read to filter the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bikas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:06:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954176#M1155052</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954177#M1155053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry in my code i msissed one statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD if_ex_mb_migo_badi~post_document . 
**********************************************************************
*The delivery note number provided by vendor should be unique  in migo
Importing it_mseg and is_mkpf 
Work = wa
Itab1 = itt
Itab1t = ittt
Itab = ist
**********************************************************************
  DATA : itab_mkpf TYPE TABLE OF mkpf.
  DATA : work_mseg TYPE mseg.
  DATA : itab1t_mseg TYPE TABLE OF mseg. 
  DATA : itab1_mseg TYPE TABLE OF mseg.

  LOOP AT it_mseg INTO work_mseg.
if work_mseg-bukrs = '2122'."here i am checking for only one company code ,if it satisfies then only the rest of the code will execute.so I think using loop here wont degrade the performance

*  Fetching the delivery note if already exists
      SELECT mblnr mjahr xblnr FROM mkpf
                INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                WHERE xblnr = is_mkpf-xblnr.

      IF sy-subrc EQ 0.

        IF work_mseg-bwart EQ '103' . 
          
          SELECT mblnr lifnr FROM mseg INTO  TABLE itab1_mseg
                             FOR ALL ENTRIES IN itab_mkpf
                                WHERE mblnr = itab_mkpf-mblnr
                                  AND mjahr = itab_mkpf-mjahr
                                  AND lifnr = work_mseg-lifnr.
          IF sy-subrc EQ 0.
            MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
          ENDIF.

        ELSEIF work_mseg-bwart EQ '105'.

          SELECT mblnr mjahr lifnr  ebeln ebelp FROM mseg
                     INTO CORRESPONDING FIELDS OF TABLE itab1t_mseg
                                       WHERE ebeln = work_mseg-ebeln
                                         AND ebelp = work_mseg-ebelp.

          SELECT mblnr mjahr xblnr FROM mkpf
                     INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                    FOR ALL ENTRIES IN itab1t_mseg
                                   WHERE mblnr = itab1t_mseg-mblnr
                                   AND   mjahr = itab1t_mseg-mjahr
                                   AND   xblnr = is_mkpf-xblnr.

          IF sy-subrc = 0.

            IF sy-subrc = 0. 
              SELECT mblnr lifnr  ebeln FROM mseg
                    INTO CORRESPONDING FIELDS OF TABLE  itab1_mseg
                                     FOR ALL ENTRIES IN itab_mkpf
                                    WHERE mblnr = itab_mkpf-mblnr
                                      AND mjahr = itab_mkpf-mjahr
                                      AND bwart &amp;lt;&amp;gt; '103'
                                      AND lifnr = work_mseg-lifnr.

              IF sy-subrc EQ 0.
                MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
              ENDIF.
            ENDIF. 
          ELSE.
            MESSAGE 'Maintain the same delivery note number as maintained for 103 mvt type'              TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.
Endif.
  ENDLOOP.
ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Dec 24, 2008 7:34 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:08:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954177#M1155053</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954178#M1155054</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;all the code what u wrote inside the badi MB_MIGO_BADI is not required....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;all the required fields are available in the parameter it_mseg and is_mkpf..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using this 2 parameter's, u can validate and acheive your requirement..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because u wrote soo many codes inside the BADI, this is not neccessary because u can use the parameter directly..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:16:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954178#M1155054</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954179#M1155055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;gurus could anyone please guide me further where exactly i can make the improvements.&lt;/P&gt;&lt;P&gt;Thank you for all the replies&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 09:49:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954179#M1155055</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T09:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954180#M1155056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you write DB queries inside the loop it will affect the performance.&lt;/P&gt;&lt;P&gt;What you can do is create ranges for fields like&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;work_mseg-ebeln, work_mseg-ebelp etc&lt;/STRONG&gt; then use those ranges in select statement.&lt;/P&gt;&lt;P&gt;Also instead of into corresponding give the field name in the same order as your internal table,&lt;/P&gt;&lt;P&gt;in case ur int tab  is same as db tab structure dont use corresponding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES: r_lifnr FOR mkpf-lifnr.

LOOP AT it_mseg INTO work_mseg.
"your conditions
    r_lifnr-sign = 'I'.
    r_lifnr-option = 'EQ'.
    r_lifnr-low = work_mseg-lifnr.
    APPEND lr_cust.
"You can fill other ranges here 
  ENDLOOP.


SELECT mblnr lifnr FROM mseg INTO TABLE itab1_mseg
FOR ALL ENTRIES IN itab_mkpf
WHERE mblnr = itab_mkpf-mblnr
AND mjahr = itab_mkpf-mjahr
AND lifnr IN r_lifnr. "&amp;lt;=use your range here&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manoj Kumar P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 10:08:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954180#M1155056</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-24T10:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954181#M1155057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Madan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see that in the code you have 2 selects from MKPF using XBLNR. I had a look @ MKPF &amp;amp; there is no default INDEX on XBLNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My suggestion is to check if you have an index on XBLNR, if not create one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 10:53:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954181#M1155057</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2008-12-24T10:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954182#M1155058</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; sorry in my code i msissed one statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also missed  tags around your code.  I've put them in for you.  Doesn't it look nicer!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2008 18:36:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954182#M1155058</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-12-24T18:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954183#M1155059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you Matt , now my code looks good so that anyone can understand and help me to change the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gurus please guide where further cahnges are required.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Dec 2008 05:28:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954183#M1155059</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-25T05:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954184#M1155060</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; thank you Matt , now my code looks good so that anyone can understand and help me to change the code.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Gurus please guide where further cahnges are required.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you adjust your code based on people advises in here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abraham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 04:59:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954184#M1155060</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T04:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954185#M1155061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;any other replys please&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2008 08:42:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954185#M1155061</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-29T08:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954186#M1155062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Madan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) hitting the BSEG with in the loop leads to  bad performance. instead select the data from the BSEG and process the records based on your requirement.&lt;/P&gt;&lt;P&gt;2)Don't use the "INTO CORRESPONDING FIELDS " instead take the actual fields.&lt;/P&gt;&lt;P&gt;3) as BSEG is the cluster table u need to use the &lt;STRONG&gt;all the primary key values in the where conditon&lt;/STRONG&gt;. other wise data will not select properly.&lt;/P&gt;&lt;P&gt;   for the BSEG primary key fields are BUKRS,BELNR,GJAHR,BUZEI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope these tips are useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2008 10:27:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954186#M1155062</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-29T10:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954187#M1155063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think following three points you need to take care of:&lt;/P&gt;&lt;P&gt;1. Try to remove move-corresponding &lt;/P&gt;&lt;P&gt;2. Select query shouldnt be used in any loop...endloop.&lt;/P&gt;&lt;P&gt;3. If you nned to process for bukrs = '2122' then insted of looping every records use&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; LOOP AT it_mseg  where bukrs = '2122'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2008 10:43:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954187#M1155063</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-29T10:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954188#M1155064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your whole logic is quite strange, please revise completely!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use a sorted table for it_mseg! otherwise you will always loop the full table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then divide into logic for the branches, and be aware that the first select is independent&lt;/P&gt;&lt;P&gt;of the loop. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
      SELECT mblnr mjahr xblnr FROM mkpf
                INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                WHERE xblnr = is_mkpf-xblnr.

  LOOP AT it_mseg INTO work_mseg where work_mseg-bwart EQ '103' . 
    IF NOT itab_mkbf IS INOITIAL.
          SELECT mblnr lifnr FROM mseg INTO  TABLE itab1_mseg
                       FOR ALL ENTRIES IN itab_mkpf
                       WHERE mblnr = itab_mkpf-mblnr
                        AND mjahr = itab_mkpf-mjahr
                       AND lifnr = work_mseg-lifnr.
          IF sy-subrc EQ 0.
            MESSAGE 'Delivery note already there for this Vendor' TYPE 'E'.
          ENDIF.


    ENDIF.
  ENDLOOP
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  LOOP AT it_mseg INTO work_mseg where work_mseg-bwart EQ '105' . 

   see below
....

    ENDIF.
  ENDLOOP
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check whether you can change this into a join!&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
          SELECT mblnr mjahr lifnr  ebeln ebelp FROM mseg
                     INTO CORRESPONDING FIELDS OF TABLE itab1t_mseg
                                       WHERE ebeln = work_mseg-ebeln
                                         AND ebelp = work_mseg-ebelp.
 
          SELECT mblnr mjahr xblnr FROM mkpf
                     INTO CORRESPONDING FIELDS OF TABLE itab_mkpf
                                    FOR ALL ENTRIES IN itab1t_mseg
                                   WHERE mblnr = itab1t_mseg-mblnr
                                   AND   mjahr = itab1t_mseg-mjahr
                                   AND   xblnr = is_mkpf-xblnr.
 
          
            IF sy-subrc = 0. 
              SELECT mblnr lifnr  ebeln FROM mseg
                    INTO CORRESPONDING FIELDS OF TABLE  itab1_mseg
                                     FOR ALL ENTRIES IN itab_mkpf
                                    WHERE mblnr = itab_mkpf-mblnr
                                      AND mjahr = itab_mkpf-mjahr
                                      AND bwart  '103'
                                      AND lifnr = work_mseg-lifnr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2008 11:18:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954188#M1155064</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-29T11:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: fine tune the program for performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954189#M1155065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2009 12:26:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fine-tune-the-program-for-performance/m-p/4954189#M1155065</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-02T12:26:07Z</dc:date>
    </item>
  </channel>
</rss>

