<?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: is this code correct - logic wise and performance wise in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534100#M243777</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. BKPF will generally have a lot of entries, its better if you can make use of any of the secondary indexes. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One of the index is combination of fields &lt;/P&gt;&lt;P&gt;BUKRS, BSTAT, BUDAT. So if you can populate some values to BUKRS and BSTAT then your select can improve a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I wouldnt suggest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BKPF &lt;/P&gt;&lt;P&gt;SELECT BSEG.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead:&lt;/P&gt;&lt;P&gt;SELECT BKPF into &amp;lt;interal table1&amp;gt;&lt;/P&gt;&lt;P&gt;SELECT BSEG into &amp;lt;internal table2&amp;gt; for all entries in BKPF where &amp;lt;all the common fields&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Jul 2006 07:25:38 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-07-28T07:25:38Z</dc:date>
    <item>
      <title>is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534097#M243774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;scenario:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; iterating through bkpf to get all the document within a selected range of dates and document type 'KZ' . Then iterating through bseg(where belnr = belnr of the retrieved records from bkpf). Then looping through the selected bseg records and picking out the line items. In this loop i have to display the vendor line item's WRBTR(KOART = 'K') and other line item's WRBTR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;The code is sumthing lyke:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select single * from bseg into wa_bseg where belnr  = t_bkpf-belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  append wa_bseg to t_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_bseg into wa_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// is this following also correct or wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up vendor's WRBTR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up other line item's WRBTR  ( how ?? )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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;&lt;/P&gt;&lt;P&gt;I know this will comsume yur time, but if anyone is kind enuf to help me out or guide me through.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2006 20:16:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534097#M243774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-27T20:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534098#M243775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are issues with the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Performance can be improved for the program. Instead of select * from bkpf you can use select belnr from bkpf as &lt;/P&gt;&lt;P&gt;you are using only that field and instead of select,endselect and calling bseg inside it you change it as select all the belnr into an internal table and then do a for all entries query on bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// is this following also correct or wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up vendor's WRBTR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up other line item's WRBTR ( how ?? )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code will not work becuase when you do a at new belnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the remaining all the fields in the work are will have ***&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead you can write it like this .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : v_flag type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_bseg into wa_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;  v_flag = 'X'.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if v_flag eq 'X'.&lt;/P&gt;&lt;P&gt;if wa_bseg-KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;//Your logic&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;//Your logic&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;clear v_flag.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2006 21:01:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534098#M243775</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-27T21:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534099#M243776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank Sudir.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refreshing the thread to get more view on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 07:19:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534099#M243776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T07:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534100#M243777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. BKPF will generally have a lot of entries, its better if you can make use of any of the secondary indexes. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One of the index is combination of fields &lt;/P&gt;&lt;P&gt;BUKRS, BSTAT, BUDAT. So if you can populate some values to BUKRS and BSTAT then your select can improve a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I wouldnt suggest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BKPF &lt;/P&gt;&lt;P&gt;SELECT BSEG.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead:&lt;/P&gt;&lt;P&gt;SELECT BKPF into &amp;lt;interal table1&amp;gt;&lt;/P&gt;&lt;P&gt;SELECT BSEG into &amp;lt;internal table2&amp;gt; for all entries in BKPF where &amp;lt;all the common fields&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 07:25:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534100#M243777</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T07:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534101#M243778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sharath, what abt the 'loop at' and 'at new'  logic ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 07:54:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534101#M243778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T07:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534102#M243779</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;If there are existing secondary indices for BKPF, use that. Also, try to avoid select * since it will consume more time. Its much better to specify the fields explicitly. In your loop, you can use field-symbols to improve performance. Please look at the code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_equz ASSIGNING &amp;lt;fs_equz&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   get functional location and put in it_finaltab&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      READ TABLE it_iloa WITH TABLE KEY iloan = &amp;lt;fs_equz&amp;gt;-iloan&lt;/P&gt;&lt;P&gt;                                                INTO wa_iloa.&lt;/P&gt;&lt;P&gt;      IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;        wa_finaltab-funcloc = wa_iloa-tplnr.&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 value is present in s_anln1, continue.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      IF s_anln1[] IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;--&lt;/STRONG&gt;&lt;DEL&gt;&lt;STRONG&gt;-FOR RECORDS IN IT_EQUZ WITH A VALUE IN HEQUI&lt;/STRONG&gt;&lt;/DEL&gt;---&lt;/P&gt;&lt;P&gt;        IF NOT &amp;lt;fs_equz&amp;gt;-hequi IS INITIAL.&lt;/P&gt;&lt;P&gt;          v_flag = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        check whether current hequi has already been processed&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          READ TABLE it_equz_dum WITH TABLE KEY hequi = &amp;lt;fs_equz&amp;gt;-hequi&lt;/P&gt;&lt;P&gt;                                                       INTO wa_equz_dum.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        if not found, continue processing&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;            wa_equz_dum = &amp;lt;fs_equz&amp;gt;-hequi.&lt;/P&gt;&lt;P&gt;            INSERT wa_equz_dum INTO TABLE it_equz_dum.&lt;/P&gt;&lt;P&gt;            CALL METHOD me-&amp;gt;get_asset&lt;/P&gt;&lt;P&gt;                             EXPORTING equip_num = &amp;lt;fs_equz&amp;gt;-hequi&lt;/P&gt;&lt;P&gt;                             IMPORTING check     = lv_check.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            IF lv_check &amp;lt;&amp;gt; 'N'.&lt;/P&gt;&lt;P&gt;              wa_finaltab-asset_dum   = iloa-anlnr.&lt;/P&gt;&lt;P&gt;              wa_finaltab-asset       = iloa-anlnr.&lt;/P&gt;&lt;P&gt;              wa_finaltab-description = eqkt-eqktx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           check whether current asset exists in ANLA&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              SELECT SINGLE anln1 anln2 ord42&lt;/P&gt;&lt;P&gt;                FROM anla&lt;/P&gt;&lt;P&gt;                INTO (wa_anla-anln1, wa_anla-anln2, wa_anla-ord42)&lt;/P&gt;&lt;P&gt;               WHERE anln1 EQ wa_finaltab-asset&lt;/P&gt;&lt;P&gt;                 AND bukrs IN r_iwerk&lt;/P&gt;&lt;P&gt;                 AND deakt EQ '00000000'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           if not found, delete current record. Else, continue&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;                wa_finaltab-asset_sub = wa_anla-ord42.&lt;/P&gt;&lt;P&gt;                CONCATENATE: wa_anla-anln1 '-' wa_anla-anln2&lt;/P&gt;&lt;P&gt;                             INTO wa_finaltab-asset_subnum.&lt;/P&gt;&lt;P&gt;              ELSE.&lt;/P&gt;&lt;P&gt;                DELETE it_equz WHERE equnr = &amp;lt;fs_equz&amp;gt;-equnr.&lt;/P&gt;&lt;P&gt;                CLEAR: v_flag, wa_finaltab.&lt;/P&gt;&lt;P&gt;                CONTINUE.&lt;/P&gt;&lt;P&gt;              ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              READ TABLE it_t499s WITH TABLE KEY werks = wa_iloa-swerk&lt;/P&gt;&lt;P&gt;                                                 stand = wa_iloa-stort&lt;/P&gt;&lt;P&gt;                                                 INTO wa_t499s.&lt;/P&gt;&lt;P&gt;              IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;                wa_finaltab-location = wa_t499s-ktext.&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;            get records from ANLC based from current asset&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              SELECT gjahr kansw knafa kaafa answl nafav&lt;/P&gt;&lt;P&gt;                     nafag nafal aafav aafag nafap aafap&lt;/P&gt;&lt;P&gt;              FROM anlc UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;              INTO (wa_anlc-gjahr, wa_anlc-kansw, wa_anlc-knafa,&lt;/P&gt;&lt;P&gt;                    wa_anlc-kaafa, wa_anlc-answl, wa_anlc-nafav,&lt;/P&gt;&lt;P&gt;                    wa_anlc-nafag, wa_anlc-nafal, wa_anlc-aafav,&lt;/P&gt;&lt;P&gt;                    wa_anlc-aafag, wa_anlc-nafap, wa_anlc-aafap)&lt;/P&gt;&lt;P&gt;              WHERE anln1 = wa_anla-anln1&lt;/P&gt;&lt;P&gt;                AND anln2 = wa_anla-anln2&lt;/P&gt;&lt;P&gt;                AND bukrs IN r_iwerk&lt;/P&gt;&lt;P&gt;                AND afabe = '01'&lt;/P&gt;&lt;P&gt;              ORDER BY gjahr DESCENDING.&lt;/P&gt;&lt;P&gt;              ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              wa_finaltab-accq_cost = wa_anlc-kansw + wa_anlc-answl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              IF p_posdep = 'X'.&lt;/P&gt;&lt;P&gt;                wa_finaltab-acc_dep = wa_anlc-knafa +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-nafav +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-nafag +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-kaafa +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-aafav +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-aafag +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-nafal.&lt;/P&gt;&lt;P&gt;              ELSE.&lt;/P&gt;&lt;P&gt;                wa_finaltab-acc_dep = wa_anlc-knafa +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-nafav +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-kaafa +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-aafav +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-nafap +&lt;/P&gt;&lt;P&gt;                                      wa_anlc-aafap.&lt;/P&gt;&lt;P&gt;              ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              wa_finaltab-asset_book_val = wa_finaltab-accq_cost +&lt;/P&gt;&lt;P&gt;                                           wa_finaltab-acc_dep.&lt;/P&gt;&lt;P&gt;            ELSE.&lt;/P&gt;&lt;P&gt;              lv_check = 'Y'.&lt;/P&gt;&lt;P&gt;            ENDIF.&lt;/P&gt;&lt;P&gt;            APPEND wa_finaltab TO it_finaltab.&lt;/P&gt;&lt;P&gt;            CLEAR: wa_finaltab, wa_anla, wa_anlc, wa_iloa, eqkt, equz.&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;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. Please award points for useful answers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 07:59:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534102#M243779</guid>
      <dc:creator>aris_hidalgo</dc:creator>
      <dc:date>2006-07-28T07:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534103#M243780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you can even use the below to simplify the code and efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT {list of fields required in your report from BKPF and BSEG}&lt;/P&gt;&lt;P&gt;INTO ITAB.&lt;/P&gt;&lt;P&gt;FROM BKPF AS A INNER JOIN BSEG AS B&lt;/P&gt;&lt;P&gt;ON A&lt;SUB&gt;BUKRS = B&lt;/SUB&gt;BUKRS AND &lt;/P&gt;&lt;P&gt;   A&lt;SUB&gt;BELNR = B&lt;/SUB&gt;BELNR AND&lt;/P&gt;&lt;P&gt;   A&lt;SUB&gt;GJAHR = B&lt;/SUB&gt;GJAHR&lt;/P&gt;&lt;P&gt;WHERE A&lt;SUB&gt;BLART = 'KZ' AND A&lt;/SUB&gt;BLDAT IN S_BLDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U would need to initialise a variable for KOART as it would starred(*) during the AT NEW EVENT.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;l_koart = itab-koart.&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;if L_KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;// pick up vendor's WRBTR&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;// pick up other line item's WRBTR ( how ?? )&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anurag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 08:26:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534103#M243780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T08:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534104#M243781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sharath, can u demonstrate how to achieve the following(u told) with a example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BKPF into &amp;lt;interal table1&amp;gt;&lt;/P&gt;&lt;P&gt;SELECT BSEG into &amp;lt;internal table2&amp;gt; for all entries in BKPF where &amp;lt;all the common fields&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what will be types n all..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 10:40:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534104#M243781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T10:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534105#M243782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anurag,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I aint getting anything when i give the condition for KOART = 'K'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;l_koart = itab-koart.&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;if L_KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;// pick up vendor's WRBTR&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;// pick up other line item's WRBTR ( how ?? )&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endat.&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;why and how ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 11:22:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534105#M243782</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T11:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534106#M243783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;refreshing thread. can someone query the above problem ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanking in anticipation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 12:26:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534106#M243783</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T12:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534107#M243784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check couple of things..first you have selected the B~koart field in the select. Secondly, you have defined ITAB with header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If yes, to above questions than pls paste you code and I can check it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anurag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 14:32:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534107#M243784</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T14:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534108#M243785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anurag,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the code is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elect * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single * from bseg into wa_bseg where belnr = t_bkpf-belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append wa_bseg to t_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_bseg into wa_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// is this following also correct or wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up vendor's WRBTR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up other line item's WRBTR ( how ?? )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;basically what i wanna do is, iterate through bkpf whose bldat lies in the selected range and document type = 'KZ' , then iterate thru bseg for all entries(retrieved  from bkpf). then loop thru these items(from bseg) and select vendor line item and other line items separately(cuz i have to show them in different columns).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but when i do,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AT NEW BELNR.&lt;/P&gt;&lt;P&gt;   IF bseg-KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;     //&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;&lt;/P&gt;&lt;P&gt;i am getting no value, whereas i get value when i remove the 'AT NEW BELNR' condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 20:27:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534108#M243785</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T20:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: is this code correct - logic wise and performance wise</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534109#M243786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Shehryar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would still advice you to use the SELECT statement with join. U can check the run time analysis or SQL Trace to understand which is efficient (My bet would be on the below as it is usually better to use one statement than nesting of loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT {list of fields required in your report from BKPF and BSEG}&lt;/P&gt;&lt;P&gt;INTO T_BSEG.&lt;/P&gt;&lt;P&gt;FROM BKPF AS A INNER JOIN BSEG AS B&lt;/P&gt;&lt;P&gt;ON A&lt;SUB&gt;BUKRS = B&lt;/SUB&gt;BUKRS AND &lt;/P&gt;&lt;P&gt;A&lt;SUB&gt;BELNR = B&lt;/SUB&gt;BELNR AND&lt;/P&gt;&lt;P&gt;A&lt;SUB&gt;GJAHR = B&lt;/SUB&gt;GJAHR&lt;/P&gt;&lt;P&gt;WHERE A&lt;SUB&gt;BLART = 'KZ' AND A&lt;/SUB&gt;BLDAT IN S_BLDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok as far as the Loop condition is concerned, it should as follows ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_bseg into wa_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;L_KOART = WA_BSEG-KOART.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// is this following also correct or wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if L_KOART EQ 'K'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up vendor's WRBTR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// pick up other line item's WRBTR ( how ?? )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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;I feel the reason you are not able to see the value is due to the fact that KOART gets started out on AT NEW event and also you can use BSEG-KOART since you are looping the T_BSEG internal table(while BSEG-KOART would be indicating the last record value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anurag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2006 08:13:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-code-correct-logic-wise-and-performance-wise/m-p/1534109#M243786</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-31T08:13:13Z</dc:date>
    </item>
  </channel>
</rss>

