<?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 loop issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041454#M1350913</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;in my report program i need to calculate the total amount based on the Customer number and Invoice number. But problem is that some time one customer having three invoice. if i give in condition for customer or invoice its taking only one Invoice or one customer. My requirement is based on the customer i need both Invoice Amount calculation. For that what logic i want to write in my program. If any one having any idea plz inform me.&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;bab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Aug 2009 05:47:31 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-06T05:47:31Z</dc:date>
    <item>
      <title>loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041454#M1350913</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;in my report program i need to calculate the total amount based on the Customer number and Invoice number. But problem is that some time one customer having three invoice. if i give in condition for customer or invoice its taking only one Invoice or one customer. My requirement is based on the customer i need both Invoice Amount calculation. For that what logic i want to write in my program. If any one having any idea plz inform me.&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;bab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 05:47:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041454#M1350913</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T05:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041455#M1350914</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;Please post the code snippet you are trying for so that we can suggest some changes in it as per your requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 05:51:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041455#M1350914</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T05:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041456#M1350915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Babu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare another internal table and clear all fields except customer, invoice , amt field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in loop collect .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 and itab2 shuld be same.&lt;/P&gt;&lt;P&gt;Loop at itab1.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;clear all fields except customer, invoice , amt field.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;collect itab1 into itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 05:52:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041456#M1350915</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T05:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041457#M1350916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a temp internal table with customer no, invoice no and amt field. first fill only cust no and invoice no..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at customet no.. and check if looped record EQ previous record.. if yes add the sum to a variable.. do this until the cust no is not equal to the previous record. if the condition is not satisfied then move the value in variable to teh thir field in the interna table.  so by the end of the loop processing u have customer no, inv no and sum of all teh amounts for a particular customer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Method 2 :  Read the customer no.  loop at the internal table from sy-tabix.&lt;/P&gt;&lt;P&gt;                   Sum up all the amounts for the same cust no..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 05:54:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041457#M1350916</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T05:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041458#M1350917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Do something like this.&lt;/P&gt;&lt;P&gt;1. Create an internal table with the customer number as the first field, invoice number as the second and invoice item as the third and rest of the fields of the invoice ( like amount etc ).&lt;/P&gt;&lt;P&gt;2. Populate this table and sort it by customer number invoice number and invoice item.&lt;/P&gt;&lt;P&gt;3. Loop at this sorted internal table&lt;/P&gt;&lt;P&gt;4. use control break statements ( at new, at end of etc ) on customer number and invoice number sum invoice amount in a varaible lets call them as cust_amount , invoice_amount.&lt;/P&gt;&lt;P&gt;5 End loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will give you an idea of how to proceed, please make your attempt if you have further difficulties , don't hesitate to ask.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 05:54:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041458#M1350917</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T05:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041459#M1350918</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;my select query for mat is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT  CNO CDATE MINVNO  SUM( REAMOUNT1 )&lt;/P&gt;&lt;P&gt;        INTO (L_CNO2, L_CDATE2, L_MINVNO2, L_AMOUNT2)&lt;/P&gt;&lt;P&gt;        FROM ZPAYMENT&lt;/P&gt;&lt;P&gt;        WHERE ( CDATE = WA_PAY-CDATE AND  CNO = WA_PAY-CNO AND      &lt;/P&gt;&lt;P&gt;         MINVNO = WA_PAY-MINVNO  AND VCODE = WA_PAY-VCODE&lt;/P&gt;&lt;P&gt;         AND QTY &amp;gt; 0 AND REAMOUNT1 &amp;gt; 0 )&lt;/P&gt;&lt;P&gt;in these query its fetching what are the invoice available in that corresponding customer number that much invoice amount will take and give total amount.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i give condition like &lt;/P&gt;&lt;P&gt; SELECT  CNO CDATE MINVNO  SUM( REAMOUNT1 )&lt;/P&gt;&lt;P&gt;        INTO (L_CNO2, L_CDATE2, L_MINVNO2, L_AMOUNT2)&lt;/P&gt;&lt;P&gt;        FROM ZPAYMENT&lt;/P&gt;&lt;P&gt;        WHERE ( CDATE = WA_PAY-CDATE AND  CNO = WA_PAY-CNO AND      &lt;/P&gt;&lt;P&gt;         MINVNO = WA_PAY-MINVNO  AND VCODE = WA_PAY-VCODE AND CUSTMAT = T_CUSTMAT&lt;/P&gt;&lt;P&gt;         AND QTY &amp;gt; 0 AND REAMOUNT1 &amp;gt; 0 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this condition it takes only one invoice based on the customer number.&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;bab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 05:59:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041459#M1350918</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T05:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041460#M1350919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi vikred ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;have you see the select query.... for these what i want logic i want to write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 06:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041460#M1350919</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T06:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041461#M1350920</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 first select query you have mentioned, youi will get the total ammount for each customer number based on the number of invoices present for the customer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the second select query you have added the condition CUSTMAT = T_CUSTMAT. What does CUSTMAT stand for and what is the requirement now?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 06:15:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041461#M1350920</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T06:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041462#M1350921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To me your query looks fine, however, it is obvious that the additional criteria ( CUSTMAT = T_CUSTMAT) is affecting your data selection and that is where you need to see in se16 if there are more than 1 records in the table for that condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 06:23:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041462#M1350921</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T06:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041463#M1350922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;forget about the second query... in first query what logic i want to apply for getting base on one customer (CUSTMAT) in need to get the corresponding invoice total....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 06:27:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041463#M1350922</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T06:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: loop issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041464#M1350923</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;Then try like this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT CNO CDATE MINVNO  REAMOUNT1 
INTO  itab
FROM ZPAYMENT
WHERE ( CDATE = WA_PAY-CDATE AND CNO = WA_PAY-CNO AND 
MINVNO = WA_PAY-MINVNO AND VCODE = WA_PAY-VCODE AND CUSTMAT = T_CUSTMAT
AND QTY &amp;gt; 0 AND REAMOUNT1 &amp;gt; 0 ).

loop at itab.
v_ind = sy-tabix+1.
if sy-tabix = 1.
read table itab into wa_tab index v_ind.
if itab-CUSTMAT = wa_tab- CUSTMAT and itab-MINVNO = wa_tab-MINVNO.
total = itab-REAMOUNT1 + wa_tab-REAMOUNT1.
clear wa_tab.
endif.
else.
read table itab into wa_tab index v_ind.
if itab-CUSTMAT = wa_tab- CUSTMAT and itab-MINVNO = wa_tab-MINVNO.
total = total + wa_tab-REAMOUNT1.
clear wa_tab.
endif.

itab2-CUSTMAT= itab-CUSTMAT.
itab2-reamount1 = total.
append itab2.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now itab2 will hold the customer and the total amount calculated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 06:49:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-issue/m-p/6041464#M1350923</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T06:49:48Z</dc:date>
    </item>
  </channel>
</rss>

