<?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: select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661749#M882012</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;The question is not very much clear as u've not specified whether u r using any selction criteria for selecting the records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can select the line items from the header data and vice versa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example I'm taking EKKO(PO header data) and EKPO(PO Item data).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: ekko, ekpo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: it_ekko like table of ekko,&lt;/P&gt;&lt;P&gt;      it_ekpo like table of ekpo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_ekko type ekko,&lt;/P&gt;&lt;P&gt;      wa_ekpo type ekpo.&lt;/P&gt;&lt;P&gt;select-options: po for ekko-ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_ekko is initial.&lt;/P&gt;&lt;P&gt;    select * from ekpo into table it_ekpo for all entries in it_ekko where ebeln = it_ekko-ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if not it_ekpo is initial.&lt;/P&gt;&lt;P&gt;      loop at it_ekpo into wa_ekpo.&lt;/P&gt;&lt;P&gt;        write:/ wa_ekpo-ebeln, wa_ekpo-ebelp.&lt;/P&gt;&lt;P&gt;      endloop.&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 u want select header data based on line items data just reverse the table names, internal tables and work areas in the select statement mentioned in the above example. While selecting the header data from the line items data, sort and  delete the duplicate PO from the internal table which is storing line items records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can select the item data based on header data and vice versa based on the KEY field of the header data table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward this solves ur problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;ChandraK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Apr 2008 11:08:31 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-03T11:08:31Z</dc:date>
    <item>
      <title>select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661743#M882006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how can we select line item  from item table and on the basis of that line item we can fetch header data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or vise versa&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can i have proper answer for that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Rahul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 10:04:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661743#M882006</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T10:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661744#M882007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in the line item there will also be a reference to the header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Header: document 1000&lt;/P&gt;&lt;P&gt;item: document 100 item 10&lt;/P&gt;&lt;P&gt;        document 100 item 20&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 10:06:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661744#M882007</guid>
      <dc:creator>Sm1tje</dc:creator>
      <dc:date>2008-04-03T10:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661745#M882008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See for any thing to select you should have some condition.&lt;/P&gt;&lt;P&gt;if there is no condition that means you are selecting all the records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now go to header table and get the Records from Header using the Item and header realtion fields in where condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use for all entries to get the data from header using item,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 10:08:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661745#M882008</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T10:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661746#M882009</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 you know the line items then you get multiple POs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example same line items exists in many documents like POs, SOs etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select the line items from item table and for those documents (the item table also contains the document number) get the header data by passing the document number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 10:13:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661746#M882009</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T10:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661747#M882010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can either use INNER JOIN to select  data from both header table and item table or u can select data from header table  and using the staement FOR ALL ENTRIES u can selct data from item table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For eg:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select VBAK&lt;SUB&gt;VBELN   VBAK&lt;/SUB&gt;ERDAT VBAP~POSNR&lt;/P&gt;&lt;P&gt;into corresponding fields of table ITAB&lt;/P&gt;&lt;P&gt;from VBAK inner join VBAP &lt;/P&gt;&lt;P&gt;on VBAK&lt;SUB&gt;VBELN eq VBAP&lt;/SUB&gt;VBELN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;OR&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln from vbak&lt;/P&gt;&lt;P&gt;into corresponding fields of table ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select POSNR from vbap &lt;/P&gt;&lt;P&gt;into corresponding fields of table ITAB1&lt;/P&gt;&lt;P&gt;for all entries in ITAB&lt;/P&gt;&lt;P&gt;where vbeln eq ITAB-vbeln.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 10:22:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661747#M882010</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T10:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661748#M882011</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;suppose &amp;lt;f1&amp;gt; is the common field between &amp;lt;header_table &amp;gt; and &amp;lt;item_table&amp;gt;..&lt;/P&gt;&lt;P&gt;then use this query:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select &amp;lt;f1&amp;gt;&amp;lt;f2&amp;gt; from &amp;lt;header_table&amp;gt; into &amp;lt;it_header_table&amp;gt;&lt;/P&gt;&lt;P&gt;where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;select &amp;lt;f1&amp;gt;&amp;lt;f3&amp;gt; &amp;lt;f4&amp;gt;....&lt;/P&gt;&lt;P&gt;         from &amp;lt;item_table&amp;gt; into &amp;lt;it_item_table&amp;gt; for all entries in &amp;lt;it_header_table&amp;gt;&lt;/P&gt;&lt;P&gt;        where &amp;lt;f1&amp;gt; = &amp;lt;it_header_table&amp;gt;-&amp;lt;f1&amp;gt;.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 10:27:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661748#M882011</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T10:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661749#M882012</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;The question is not very much clear as u've not specified whether u r using any selction criteria for selecting the records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can select the line items from the header data and vice versa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example I'm taking EKKO(PO header data) and EKPO(PO Item data).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: ekko, ekpo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: it_ekko like table of ekko,&lt;/P&gt;&lt;P&gt;      it_ekpo like table of ekpo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_ekko type ekko,&lt;/P&gt;&lt;P&gt;      wa_ekpo type ekpo.&lt;/P&gt;&lt;P&gt;select-options: po for ekko-ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_ekko is initial.&lt;/P&gt;&lt;P&gt;    select * from ekpo into table it_ekpo for all entries in it_ekko where ebeln = it_ekko-ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if not it_ekpo is initial.&lt;/P&gt;&lt;P&gt;      loop at it_ekpo into wa_ekpo.&lt;/P&gt;&lt;P&gt;        write:/ wa_ekpo-ebeln, wa_ekpo-ebelp.&lt;/P&gt;&lt;P&gt;      endloop.&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 u want select header data based on line items data just reverse the table names, internal tables and work areas in the select statement mentioned in the above example. While selecting the header data from the line items data, sort and  delete the duplicate PO from the internal table which is storing line items records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can select the item data based on header data and vice versa based on the KEY field of the header data table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward this solves ur problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;ChandraK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 11:08:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3661749#M882012</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T11:08:31Z</dc:date>
    </item>
  </channel>
</rss>

