<?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: problem in loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577812#M1272213</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not very sure of your requirement. You are taking EKPO-ematn in your final table but your are not appending your final table within the LOOP-ENDLOOP on EKPO table.&lt;/P&gt;&lt;P&gt;However you are doing it within the LOOP-ENDLOOP of BSEG table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the result why you are getting all entries on BSEG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i presume that you just need the sum of the quantities of EKPO and not the actual 5 entries then to achieve that do the following.&lt;/P&gt;&lt;P&gt;Immediately after the ENDLOOP on EKPO, do a sy-subrc check.&lt;/P&gt;&lt;P&gt;append only if the sy-subrc value is 0.&lt;/P&gt;&lt;P&gt;By this you will get the EBELN which is in BSEG and EKPO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want all the 5 entries on EKPO then do the append within the LOOP-ENDLOOP of EKPO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PLease remove the Delete adjacent duplicate statement on BSEG within the EKPO loop.&lt;/P&gt;&lt;P&gt;It does not make any sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 May 2009 07:33:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-09T07:33:40Z</dc:date>
    <item>
      <title>problem in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577810#M1272211</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 dont know wats wrong in my loop , the problem is in it_ekpo i have only 5 entries but &lt;/P&gt;&lt;P&gt;when it gets executed it checks for the condition &lt;/P&gt;&lt;P&gt;   where ebeln = wa_bseg-ebeln in it_ekpo loop and bring  all entries of it_bseg, but i want only&lt;/P&gt;&lt;P&gt;the 5 entries which is it_ekpo.....can u pls help me out ...where i have gone wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code &lt;/P&gt;&lt;P&gt;=====&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sort it_ekpo by ebeln.

sort it_bkpf by belnr.


loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.

        loop at it_bseg into wa_bseg where belnr = wa_bkpf-belnr.
             wa_final-ebeln =  wa_bseg-ebeln.

    read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
          if sy-subrc = 0.
              wa_final-name1 = wa_lfa1-name1.
            wa_final-ort01 = wa_lfa1-ort01.
          Endif.

    read table  it_J_1IMOVEND into  wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
           if sy-subrc = 0.
                wa_final-J_1ILSTNO =  wa_J_1IMOVEND-J_1ILSTNO.
           endif.

    loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln  .
        read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.

                  wa_final-ematn = wa_ekpo-ematn.
                  wa_final-txz01 = wa_ekpo-txz01.
                  wa_final-menge = wa_ekpo-menge.
                  wa_final-netwr = wa_ekpo-netwr.
        QTY =  QTY + WA_FINAL-MENGE.
        move qty to wa_final-qty.



*****FOR TAX CODE 45

If wa_ekpo-mwskz = '45' .
 wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
  tot2 = tot2 + wa_final-zbed.

   move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
   tot3 = tot3 + wa_Final-zex1.
   move tot3 to  wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
  tot4 = tot4 + wa_final-zex2.
  move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
  tot5 = tot5 + wa_final-jipc.
  move tot5 to wa_final-t5.
Endif.


sort it_bseg by ebeln.
delete adjacent duplicates from it_bseg comparing ebeln.

     Endloop.

     append wa_final to it_final.
     clear :wa_ekpo, wa_ekko.
Endloop.
 clear : wa_bseg.
Endloop.
Endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rachel Arun on May 9, 2009 12:36 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2009 07:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577810#M1272211</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-09T07:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: problem in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577811#M1272212</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;Technically the code is correct. Please explain your requirement in details. Also provide the data in the internal table, whicvh will help in detailed analysis.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2009 07:28:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577811#M1272212</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-09T07:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: problem in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577812#M1272213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not very sure of your requirement. You are taking EKPO-ematn in your final table but your are not appending your final table within the LOOP-ENDLOOP on EKPO table.&lt;/P&gt;&lt;P&gt;However you are doing it within the LOOP-ENDLOOP of BSEG table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the result why you are getting all entries on BSEG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i presume that you just need the sum of the quantities of EKPO and not the actual 5 entries then to achieve that do the following.&lt;/P&gt;&lt;P&gt;Immediately after the ENDLOOP on EKPO, do a sy-subrc check.&lt;/P&gt;&lt;P&gt;append only if the sy-subrc value is 0.&lt;/P&gt;&lt;P&gt;By this you will get the EBELN which is in BSEG and EKPO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want all the 5 entries on EKPO then do the append within the LOOP-ENDLOOP of EKPO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PLease remove the Delete adjacent duplicate statement on BSEG within the EKPO loop.&lt;/P&gt;&lt;P&gt;It does not make any sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2009 07:33:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577812#M1272213</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-09T07:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: problem in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577813#M1272214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rachel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have made small change in your code please check that --&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort it_ekpo by ebeln.
 
sort it_bkpf by belnr.
 
 
LOOP AT it_ekpo INTO wa_ekpo.   " Added
    loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.
 
        loop at it_bseg into wa_bseg where belnr = wa_bkpf-belnr.
             wa_final-ebeln =  wa_bseg-ebeln.
 
    read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
          if sy-subrc = 0.
              wa_final-name1 = wa_lfa1-name1.
            wa_final-ort01 = wa_lfa1-ort01.
          Endif.
 
    read table  it_J_1IMOVEND into  wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
           if sy-subrc = 0.
                wa_final-J_1ILSTNO =  wa_J_1IMOVEND-J_1ILSTNO.
           endif.
 
    loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln  .
        read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.
 
                  wa_final-ematn = wa_ekpo-ematn.
                  wa_final-txz01 = wa_ekpo-txz01.
                  wa_final-menge = wa_ekpo-menge.
                  wa_final-netwr = wa_ekpo-netwr.
        QTY =  QTY + WA_FINAL-MENGE.
        move qty to wa_final-qty.
 
 
 
*****FOR TAX CODE 45
 
If wa_ekpo-mwskz = '45' .
 wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
  tot2 = tot2 + wa_final-zbed.
 
   move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
   tot3 = tot3 + wa_Final-zex1.
   move tot3 to  wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
  tot4 = tot4 + wa_final-zex2.
  move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
  tot5 = tot5 + wa_final-jipc.
  move tot5 to wa_final-t5.
Endif.
 
 
sort it_bseg by ebeln.
delete adjacent duplicates from it_bseg comparing ebeln.
 
     Endloop.
    clear :wa_ekpo, wa_ekko.
Endloop.
     append wa_final to it_final. " Place changed
endloop.    "Added
 clear : wa_bseg.
Endloop.
Endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pinaki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2009 07:35:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-loop/m-p/5577813#M1272214</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-09T07:35:38Z</dc:date>
    </item>
  </channel>
</rss>

