<?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: Selecting single value using for all entries. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363924#M1400882</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bestin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can achieve it by using another key field of VBAP Table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try with below coding..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF IT_VBAK[] IS NOT INITIAL.

SELECT * FROM VBAP
INTO TABLE IT_VBAP
for all entries in it_vbak 
where vbeln = it_vbak-vbeln AND
POSNR = '000010'. " First Line item for particular sale order 

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope it will solve your problem..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;ilesh 24x7&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ilesh Nandaniya&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Nov 2009 12:49:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-11-17T12:49:15Z</dc:date>
    <item>
      <title>Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363921#M1400879</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;I want to know that is it possible to fetch only the first record for a particular condition while using for all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For ex:&lt;/P&gt;&lt;P&gt;Suppose i got 10 different vbeln from vbak table into my internal table it_vbak. For a particular vbeln there can be multiple records in vbap table.&lt;/P&gt;&lt;P&gt;Now i need to fetch only the first record which is getting from vbap table for different vbeln while using &lt;STRONG&gt;'for all entries in it_vbak where vbeln = it_vbak-vbeln'&lt;/STRONG&gt;. Is it possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Be$t!N&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Moved to the correct forum&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Nov 17, 2009 9:38 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 12:27:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363921#M1400879</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-17T12:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363922#M1400880</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;I dont think this is possible using for all entries.&lt;/P&gt;&lt;P&gt;You can select the data into an internal table, sort by vbeln and delete adjacent duplicates by comparing vbeln.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 12:32:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363922#M1400880</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-17T12:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363923#M1400881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can not use for all entries to retrive first entry from database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;only way is looping the itab and fetch using select up to 1 row&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nandha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 12:34:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363923#M1400881</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-17T12:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363924#M1400882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bestin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can achieve it by using another key field of VBAP Table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try with below coding..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF IT_VBAK[] IS NOT INITIAL.

SELECT * FROM VBAP
INTO TABLE IT_VBAP
for all entries in it_vbak 
where vbeln = it_vbak-vbeln AND
POSNR = '000010'. " First Line item for particular sale order 

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope it will solve your problem..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;ilesh 24x7&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ilesh Nandaniya&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 12:49:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363924#M1400882</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-17T12:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363925#M1400883</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; &lt;/P&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;CODE&gt;&amp;gt; POSNR = '000010'. " First Line item for particular sale order &lt;/CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;Not sure if this will work since the first item could have been deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since FOR ALL ENTRIES removed duplicate items from the selection set, the OP might be able to do this by only SELECCTing VBELN from VBAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 14:38:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363925#M1400883</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-17T14:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363926#M1400884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob Burbank,&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;You are correct.. If that is the scenario in their company... Again it depends on the configuration and business process.. But it's possible that they may need to delete first on any line item after creation of sale order.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that case below solution will work..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF IT_VBAK[] IS NOT INITIAL.
 
SELECT * FROM VBAP
INTO TABLE IT_VBAP
for all entries in it_vbak 
where vbeln = it_vbak-vbeln. 
ENDIF.
SORT IT_VBAP BY VBELN POSNR.
LOOP AT IT_VBAK INTO WA_VBAK.
READ TABLE IT_VBAP INTO WA_VBAP WITH KEY VBELN = WA_VBAK-VBELN.
IF SY-SUBRC = 0.
APPEND WA_VBAP TO IT_VBAP2. " Another Internal table which stores only first record
ENDIF.
CLEAR : WA_VBAP.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IT_VBAP3[] = IT_VBAP[].

SORT IT_VBAP3 BY VBELN POSNR.

DELETE ADJACENT DUPLICATES FROM IT_VBAP3 COMPARING VBELN.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now Table IT_VBAP2 and IT_VBAP3 will be having only first line items for all sales orders..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do some little changes in the code as per your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope it will solve your problem..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;ilesh 24x7&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ilesh Nandaniya&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2009 04:20:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363926#M1400884</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-18T04:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting single value using for all entries.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363927#M1400885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think we need to do delete adjacent after the fetching.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 13:33:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-single-value-using-for-all-entries/m-p/6363927#M1400885</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-10T13:33:35Z</dc:date>
    </item>
  </channel>
</rss>

