<?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: abap select query problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668635#M1289121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;join on cluster table with no proper indexing or unsfficient "where" condition; is never advisable .. &lt;/P&gt;&lt;P&gt;join on more then 4 .. even 4 are more ... can really effect the processing time .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so to avoid it ..&lt;/P&gt;&lt;P&gt;we usually fetch all the recorrds in the itab and do a read statement on it,cause operation on itab is any time faster ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i suggest u understand first the tables u are using and then approach accordingly .. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Renu .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Jun 2009 18:22:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-08T18:22:25Z</dc:date>
    <item>
      <title>abap select query problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668634#M1289120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This report will take delivery document number and delivery date from user and fetches details from delivery table and fetches&lt;/P&gt;&lt;P&gt;corresponding sales order details and billing details  and displays sales order details with ALV list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt; Please only post the relevant portions of your code &amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i just want to know that is this way of fetching the data into internal table okay ?are there any better ways of fetching the data into the internal table ? why  is it looping in work area of lips, why not in likp? &lt;/P&gt;&lt;P&gt;(plz dont use field-symbols or oo abap or macros) I WANT TO USE PLAIN AND SIMPLE ABAP STATEMENTS LIKE ABOVE..&lt;/P&gt;&lt;P&gt;By using "vbeln type lips-vbeln" are we refering to the field or data element? plz suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.           [my approach was to inner join likp and lips into itab(my internal table).&lt;/P&gt;&lt;P&gt;select data from kna1, vbak,vbap,vbrp into respective internal tables like it_kna1,it_vbak etc.&lt;/P&gt;&lt;P&gt;then using individual loops into the tables, i would use read table to insert data into itab(my final internal table) plz suggest which method wud be more efficient? ]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Jun 8, 2009 11:54 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jun 2009 15:52:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668634#M1289120</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-08T15:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: abap select query problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668635#M1289121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;join on cluster table with no proper indexing or unsfficient "where" condition; is never advisable .. &lt;/P&gt;&lt;P&gt;join on more then 4 .. even 4 are more ... can really effect the processing time .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so to avoid it ..&lt;/P&gt;&lt;P&gt;we usually fetch all the recorrds in the itab and do a read statement on it,cause operation on itab is any time faster ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i suggest u understand first the tables u are using and then approach accordingly .. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Renu .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jun 2009 18:22:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668635#M1289121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-08T18:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: abap select query problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668636#M1289122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok i am posting the select queries once again.&lt;/P&gt;&lt;P&gt; i want to know why are we looping in t_lips and why not t_likp? bcoz &lt;U&gt;t&lt;/U&gt;likp is the header table, if we loop thru it and then read the rest tables then what will be the problem? plz clarify with examples._&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[my idea was to loop at t_likp then read t_lips.append the lips data into t_order(main internal table).then do read table on t_kna1,t_vbap etc indexing t_order. so plz suggest whether my approach was write or wrong?if wrong why?plz site any other ways of doing this query.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------------" /&gt;&lt;P&gt;types: begin of ty_vbap,&lt;/P&gt;&lt;P&gt;       vbeln type vbap-vbeln,&lt;/P&gt;&lt;P&gt;       posnr type vbap-posnr, .....&lt;/P&gt;&lt;P&gt;does the declaration statement in types refer to tables or data elements? what is the difference if we declare it like: &lt;/P&gt;&lt;P&gt;   types: begin of ty_vbap,&lt;/P&gt;&lt;P&gt;       vbeln type vbeln,&lt;/P&gt;&lt;P&gt;       posnr type posnr, .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**********************************************&lt;/P&gt;&lt;P&gt;select-options:&lt;/P&gt;&lt;P&gt;s_deldoc FOR likp-vbeln, " Delivery&lt;/P&gt;&lt;P&gt;s_dldate FOR likp-lfdat. " Delivery Date&lt;/P&gt;&lt;P&gt;*************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get delivery document number,delivery date,customer number from&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;delivery header table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln " Delivery&lt;/P&gt;&lt;P&gt;lfdat " Delivery Date&lt;/P&gt;&lt;P&gt;kunnr " Customer Number 1&lt;/P&gt;&lt;P&gt;FROM likp&lt;/P&gt;&lt;P&gt;INTO TABLE t_likp&lt;/P&gt;&lt;P&gt;WHERE vbeln IN s_deldoc&lt;/P&gt;&lt;P&gt;AND lfdat IN s_dldate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get Customer name for customer numbers from Customer master table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT kunnr " Customer Number 1&lt;/P&gt;&lt;P&gt;name1 " Name 1&lt;/P&gt;&lt;P&gt;FROM kna1&lt;/P&gt;&lt;P&gt;INTO TABLE t_kna1&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN t_likp&lt;/P&gt;&lt;P&gt;WHERE kunnr EQ t_likp-kunnr.&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get delivery item number,sales document number,sales item number,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;delivery quantity from delivery item table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln " Delivery&lt;/P&gt;&lt;P&gt;posnr " Delivery Item&lt;/P&gt;&lt;P&gt;vgbel " Document number of&lt;/P&gt;&lt;P&gt;" reference document&lt;/P&gt;&lt;P&gt;vgpos " Item number of reference item&lt;/P&gt;&lt;P&gt;lfimg " Actual quantity delivered&lt;/P&gt;&lt;P&gt;vrkme " Sales unit&lt;/P&gt;&lt;P&gt;FROM lips&lt;/P&gt;&lt;P&gt;INTO TABLE t_lips&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN t_likp&lt;/P&gt;&lt;P&gt;WHERE vbeln EQ t_likp-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get sales document number,item number,material,material description,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ordered quantity from sales item table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln " Sales Document&lt;/P&gt;&lt;P&gt;posnr " Sales Document Item&lt;/P&gt;&lt;P&gt;matnr " Material Number&lt;/P&gt;&lt;P&gt;arktx " Short text for sales order&lt;/P&gt;&lt;P&gt;" item&lt;/P&gt;&lt;P&gt;kwmeng " Cumulative Order Quantity&lt;/P&gt;&lt;P&gt;vrkme " Sales unit&lt;/P&gt;&lt;P&gt;FROM vbap&lt;/P&gt;&lt;P&gt;INTO TABLE t_vbap&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN t_lips&lt;/P&gt;&lt;P&gt;WHERE vbeln EQ t_lips-vgbel&lt;/P&gt;&lt;P&gt;AND posnr EQ t_lips-vgpos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get sales document number ,created date,purchase order number from&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;sales header table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln " Sales Document&lt;/P&gt;&lt;P&gt;erdat " Date on Which Record Was" Created&lt;/P&gt;&lt;P&gt;aufnr " Order Number&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;INTO TABLE t_vbak&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN t_lips&lt;/P&gt;&lt;P&gt;WHERE vbeln EQ t_lips-vgbel.&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.* Get billing document number,billing item,reference delivery document&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;number,delivery item number,billing item from billing item table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT vbeln " Billing Document&lt;/P&gt;&lt;P&gt;posnr " Billing item&lt;/P&gt;&lt;P&gt;vgbel " Document number of the&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" reference document&lt;/P&gt;&lt;P&gt;vgpos " Item number of the" reference" item&lt;/P&gt;&lt;P&gt;fklmg " Billing quantity in" stockkeeping unit&lt;/P&gt;&lt;P&gt;vrkme " Sales unit&lt;/P&gt;&lt;P&gt;FROM vbrp&lt;/P&gt;&lt;P&gt;INTO TABLE t_vbrp&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN t_lips&lt;/P&gt;&lt;P&gt;WHERE vgbel EQ t_lips-vbeln&lt;/P&gt;&lt;P&gt;AND vgpos EQ t_lips-posnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Display message if records are not found for entered values&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;MESSAGE S000.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Looping Delivery item internal table to assign values to order&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_lips INTO fs_lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get delivery date and customer number for delivery document number&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;from delivery header internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE t_likp WITH KEY vbeln = fs_lips-vbeln&lt;/P&gt;&lt;P&gt;INTO fs_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get customer name for customer number from customer master internal&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;READ TABLE t_kna1 WITH KEY kunnr = fs_likp-kunnr&lt;/P&gt;&lt;P&gt;INTO fs_kna1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get sales document number,item number,ordered quantity for delivery&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;document number,item number from sales item internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;READ TABLE t_vbap WITH KEY vbeln = fs_lips-vgbel&lt;/P&gt;&lt;P&gt;posnr = fs_lips-vgpos INTO fs_vbap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get goods issue date and purchase order number for sales document&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;number from sales header internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;READ TABLE t_vbak WITH KEY vbeln = fs_vbap-vbeln INTO fs_vbak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get billing document number,billing item,billing quantity for delivery&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;document number,delivery item number from billing item internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE t_vbrp WITH KEY vgbel = fs_lips-vbeln&lt;/P&gt;&lt;P&gt;vgpos = fs_lips-posnr INTO fs_vbrp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Assign sales,delivery,billing fields into respective fields of sales&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;order internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fs_order-vbeln = fs_vbap-vbeln.&lt;/P&gt;&lt;P&gt;fs_order-posnr = fs_vbap-posnr.&lt;/P&gt;&lt;P&gt;fs_order-erdat = fs_vbak-erdat.&lt;/P&gt;&lt;P&gt;fs_order-kunnr = fs_likp-kunnr.&lt;/P&gt;&lt;P&gt;fs_order-name1 = fs_kna1-name1.&lt;/P&gt;&lt;P&gt;fs_order-aufnr = fs_vbak-aufnr.&lt;/P&gt;&lt;P&gt;fs_order-matnr = fs_vbap-matnr.&lt;/P&gt;&lt;P&gt;fs_order-arktx = fs_vbap-arktx.&lt;/P&gt;&lt;P&gt;fs_order-kwmeng = fs_vbap-kwmeng.&lt;/P&gt;&lt;P&gt;fs_order-vrkme = fs_vbap-vrkme.&lt;/P&gt;&lt;P&gt;fs_order-vbeln1 = fs_lips-vbeln.&lt;/P&gt;&lt;P&gt;fs_order-posnr1 = fs_lips-posnr.&lt;/P&gt;&lt;P&gt;fs_order-lfimg = fs_lips-lfimg.&lt;/P&gt;&lt;P&gt;fs_order-vrkme1 = fs_lips-vrkme.&lt;/P&gt;&lt;P&gt;fs_order-vbeln2 = fs_vbrp-vbeln.&lt;/P&gt;&lt;P&gt;fs_order-posnr2 = fs_vbrp-posnr.&lt;/P&gt;&lt;P&gt;fs_order-fklmg = fs_vbrp-fklmg.&lt;/P&gt;&lt;P&gt;fs_order-vrkme2 = fs_vbrp-vrkme.&lt;/P&gt;&lt;P&gt;APPEND fs_order TO t_order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR fs_order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;ENDIF. " IF SY-SUBRC EQ 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP. " LOOP AT T_LIPS INTO FS_LIPS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2009 09:09:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-select-query-problem/m-p/5668636#M1289122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-09T09:09:44Z</dc:date>
    </item>
  </channel>
</rss>

