<?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 problem in summing up inside loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611402#M1278721</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;The below is my loop code , &lt;STRONG&gt;the problem is suppose if i have 2 line items for one purchase order&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;i need to sum up the quantity amount etc, displaying the purchase order number only ones,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;in order i have made a loop at ekpo where i have the line  items , but still i am not able to &lt;/P&gt;&lt;P&gt;sum up , instead all the line items appearing , &lt;/P&gt;&lt;P&gt;if i give the statmt &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;delete adjacent duplicates from it_ekpo comparing ebeln.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;only first line item is displayed...pls help me out in this issue&lt;/P&gt;&lt;P&gt;&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_ekpo into wa_ekpo  .
    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 46 for

If wa_ekpo-mwskz = '46'.
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.

              loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.

        loop at it_bseg into wa_bseg where ebeln = wa_ekpo-ebeln."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.

     Endloop.

  Endloop.

 append wa_final to it_final.
 clear :wa_bkpf, wa_ekpo,wa_ekko,qty, wa_final.

delete adjacent duplicates from it_ekpo comparing ebeln.

Endloop.
Endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;/P&gt;&lt;P&gt;Rachel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 May 2009 12:32:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-20T12:32:22Z</dc:date>
    <item>
      <title>problem in summing up inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611402#M1278721</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;The below is my loop code , &lt;STRONG&gt;the problem is suppose if i have 2 line items for one purchase order&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;i need to sum up the quantity amount etc, displaying the purchase order number only ones,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;in order i have made a loop at ekpo where i have the line  items , but still i am not able to &lt;/P&gt;&lt;P&gt;sum up , instead all the line items appearing , &lt;/P&gt;&lt;P&gt;if i give the statmt &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;delete adjacent duplicates from it_ekpo comparing ebeln.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;only first line item is displayed...pls help me out in this issue&lt;/P&gt;&lt;P&gt;&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_ekpo into wa_ekpo  .
    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 46 for

If wa_ekpo-mwskz = '46'.
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.

              loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.

        loop at it_bseg into wa_bseg where ebeln = wa_ekpo-ebeln."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.

     Endloop.

  Endloop.

 append wa_final to it_final.
 clear :wa_bkpf, wa_ekpo,wa_ekko,qty, wa_final.

delete adjacent duplicates from it_ekpo comparing ebeln.

Endloop.
Endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;/P&gt;&lt;P&gt;Rachel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2009 12:32:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611402#M1278721</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-20T12:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: problem in summing up inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611403#M1278722</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;write the code delete adjacent duplicate outside the loop endloop.... it should not be within the loop.&lt;/P&gt;&lt;P&gt;this will resolve your issue&lt;/P&gt;&lt;P&gt;something like the code given below....&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_ekpo into wa_ekpo  .
    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 46 for
 
If wa_ekpo-mwskz = '46'.
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.
 
              loop at it_bkpf into wa_bkpf .
            wa_final-budat = wa_bkpf-budat.
 
        loop at it_bseg into wa_bseg where ebeln = wa_ekpo-ebeln."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.
 
     Endloop.
 
  Endloop.
 
 append wa_final to it_final.
 clear :wa_bkpf, wa_ekpo,wa_ekko,qty, wa_final.
 
Endloop.
delete adjacent duplicates from it_ekpo comparing ebeln.
Endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Siddarth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2009 12:35:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611403#M1278722</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-20T12:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: problem in summing up inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611404#M1278723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry still i face the same problem.......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2009 12:43:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611404#M1278723</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-20T12:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: problem in summing up inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611405#M1278724</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;create anothere internal table of the same structure..pass the values this inernal table using statement&lt;/P&gt;&lt;P&gt;itab1[] = itab2[].&lt;/P&gt;&lt;P&gt;sort the table itab1 by ebeln&lt;/P&gt;&lt;P&gt;then delete adjacent dupicate from itab1 comparing ebeln, &lt;/P&gt;&lt;P&gt;then loop the internal table itab1 and loop the other internal table itab2 inside it has below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    loop at itab2 where ebeln = itab1-ebeln.&lt;/P&gt;&lt;P&gt;    .....add the quantity.&lt;/P&gt;&lt;P&gt;    endloop.&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;Regrds&lt;/P&gt;&lt;P&gt;Yogi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2009 12:46:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611405#M1278724</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-20T12:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: problem in summing up inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611406#M1278725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt; as per my understanding.. assume 3 same order number with diffrent line item ..and you have to add the qntity of the three line item .. and make it single row aganis order numner rt?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1 into wa_itab1.&lt;/P&gt;&lt;P&gt;  loop at itab2 into wa_itan2 with key ordernumbr  = wa_itab1-ordernumber lineitem = wa_itab1-lineitem.&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    wa_final = add the qntity .&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;other conditions A  " according to your req inside loop &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;     endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;other conditions A   " according to your req  outside loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use key word COLLECT in final itable but dont insert line item in this table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt; read table itab1 into wa2 with key ordernumbr = itab-ordernumber line-item =itab-line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_final-qnty = itan1 0r itab-qnty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append wa_final to finaltab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; COLLECT FINALITAB.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2009 12:49:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-summing-up-inside-loop/m-p/5611406#M1278725</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-20T12:49:44Z</dc:date>
    </item>
  </channel>
</rss>

