<?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: ABAP code help for adding amount fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224564#M1207976</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at itab.

itab-f4 = itab-f3 + itab-f2 + itab-f1 .

modify table itab with f4.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a pseudo code .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Feb 2009 05:19:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-23T05:19:09Z</dc:date>
    <item>
      <title>ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224562#M1207974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Abapers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code which seems to like below, in  which i need to add amount fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

TYPES: BEGIN OF TY_FINAL,
         KDGRP LIKE KNVV-KDGRP,
         KTEXT LIKE T151T-KTEXT,
         KUNNR LIKE BSID-KUNNR,
         NAME1 LIKE KNA1-NAME1,
         ORT01 LIKE KNA1-ORT01,
         TSO   LIKE BSID-ZUONR,
         VNAMC LIKE PA0002-VNAMC,
         BELNR LIKE BSID-BELNR,
         BLDAT LIKE BSID-BLDAT,
         REFER LIKE BSID-VBELN,
         DMBTR LIKE BSID-DMBTR,
         ZTERM LIKE BSID-ZTERM,
         VTEXT LIKE TVZBT-VTEXT,
         BLART LIKE BSID-BLART,
         DIFF1 LIKE BSID-DMBTR,          " Amount field
         DIFF2 LIKE BSID-DMBTR,          " Amount field
         DIFF3 LIKE BSID-DMBTR,          " Amount field
         DIFF4 LIKE BSID-DMBTR,          " Amount field
         DIFF5 LIKE BSID-DMBTR,          " Amount field
         DIFF6 LIKE BSID-DMBTR,          " Amount field
         DIFF7 LIKE BSID-DMBTR,          " Amount field
         TOTAL LIKE BSID-DMBTR,         " Amount field ( diff1 + diff2 +... + diff7)
         SCHEM TYPE CHAR15,
         POSTD LIKE BSID-BUDAT,
         BSTKD LIKE VBKD-BSTKD, 
         BSTDK LIKE VBKD-BSTDK, 
         ZCS1  TYPE CHAR40,
         ZCS2  TYPE CHAR40,
         ZCS3  TYPE CHAR40,
         ZCS4  TYPE CHAR40,

       END OF TY_FINAL.
 
Data:  
         IT_FINTSO         TYPE   STANDARD TABLE OF TY_FINAL    INITIAL SIZE 0,
        WA_FINTSO        TYPE   TY_FINAL.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I had all the data in IT_FINTSO ( FINAL INTERNAL TABLE ) based on customer number, i want to add the amounts based on customer number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i think collect statement will not work because there are few fields which &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please provide sample code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hari priya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:08:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224562#M1207974</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224563#M1207975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;use calculate or add the individual fields too &lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shashi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:11:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224563#M1207975</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224564#M1207976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at itab.

itab-f4 = itab-f3 + itab-f2 + itab-f1 .

modify table itab with f4.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a pseudo code .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:19:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224564#M1207976</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224565#M1207977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;move the customer number and fields that r to be added (ie.DIFF1 ,..DIFF7) to a separate internal table.&lt;/P&gt;&lt;P&gt;SORT table based on customer num.then LOOP that table.&lt;/P&gt;&lt;P&gt;Use COLLECT.&lt;/P&gt;&lt;P&gt;Then use READ stmt with Key as Customer Number and get the added amount.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:22:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224565#M1207977</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224566#M1207978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Hari&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Total Questions:   	 58 (35 unresolved)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;First of all you have many open questions please close these.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Test the following Sample Code hope will solve out your problem, i am using collect and think that it will work for you too. in fact collect will add up you all amount fields with grouping all Char Fields. i think it is the best solution of your problem,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF t_it ,
  name1(2),
  name2(2),
  amount1 TYPE p DECIMALS 0,
  amount2 TYPE p DECIMALS 0,
  amount3 TYPE p DECIMALS 0,
  amount4 TYPE p DECIMALS 0,
  amount5 TYPE p DECIMALS 0,
  END OF t_it.

DATA: it1 TYPE STANDARD TABLE OF t_it WITH HEADER LINE,
      it2 TYPE STANDARD TABLE OF t_it WITH HEADER LINE.


it1-name1 = 'A1'.
it1-name2 = 'B1'.
DO 9 TIMES.
  it1-amount1 = '100'.
  it1-amount2 = '200'.
  it1-amount3 = '300'.
  it1-amount4 = '400'.
  it1-amount5 = '500'.
  APPEND it1 TO it1.
add 1 to : it1-name1+1(1),
           it1-name2+1(1).
ENDDO.
it1-name1 = 'A1'.
it1-name2 = 'B1'.
DO 9 TIMES.
  it1-amount1 = '100'.
  it1-amount2 = '200'.
  it1-amount3 = '300'.
  it1-amount4 = '400'.
  it1-amount5 = '500'.
  APPEND it1 TO it1.
add 1 to : it1-name1+1(1),
           it1-name2+1(1).
ENDDO.

LOOP AT it1 into it1.
  it2 = it1.
  COLLECT it2 into it2.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please Reply if else Requirements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Faisal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:23:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224566#M1207978</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-02-23T05:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224567#M1207979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;u can do like this&lt;/P&gt;&lt;P&gt;1.if for each customer only sinlge record is there,perform this&lt;/P&gt;&lt;P&gt;loop at internal table.&lt;/P&gt;&lt;P&gt;for each record u add the amount fields and put into total field which is to be declared within the internal table so that the resuly will be against each record.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;2.if each cutomer multiple records are there,then use at end of statement and perform the above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:27:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224567#M1207979</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224568#M1207980</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;Use this logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT IT_FINTSO BY KUNNR.
LOOP AT IT_FINTSO.

AT END OF KUNNR.
SUM.
IT_FINTSO-TOTAL = IT_FINTSO-DIFF1 + IT_FINTSO-DIFF2 + IT_FINTSO-DIFF3. " add ur itab-fields
MODIFY IT_FINTSO TRANSPORTING TOTAL.
CLEAR IT_FINTSO.
ENDAT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:27:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224568#M1207980</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-02-23T05:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224569#M1207981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. copy paste the code and hope u will have Kunnr(customer total) at end of every customer.&lt;/P&gt;&lt;P&gt;but i have made ur KUNNR the ist field.&lt;/P&gt;&lt;P&gt;And after selectin in it_fintso make it sort as&lt;/P&gt;&lt;P&gt;sort it_fintso by kunnr. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF TY_FINAL,
KUNNR LIKE BSID-KUNNR,          
KDGRP LIKE KNVV-KDGRP,
         KTEXT LIKE T151T-KTEXT,
          NAME1 LIKE KNA1-NAME1,
         ORT01 LIKE KNA1-ORT01,
         TSO   LIKE BSID-ZUONR,
         VNAMC LIKE PA0002-VNAMC,
         BELNR LIKE BSID-BELNR,
         BLDAT LIKE BSID-BLDAT,
         REFER LIKE BSID-VBELN,
         DMBTR LIKE BSID-DMBTR,
         ZTERM LIKE BSID-ZTERM,
         VTEXT LIKE TVZBT-VTEXT,
         BLART LIKE BSID-BLART,
         DIFF1 LIKE BSID-DMBTR,          " Amount field
         DIFF2 LIKE BSID-DMBTR,          " Amount field
         DIFF3 LIKE BSID-DMBTR,          " Amount field
         DIFF4 LIKE BSID-DMBTR,          " Amount field
         DIFF5 LIKE BSID-DMBTR,          " Amount field
         DIFF6 LIKE BSID-DMBTR,          " Amount field
         DIFF7 LIKE BSID-DMBTR,          " Amount field
         TOTAL LIKE BSID-DMBTR,         " Amount field ( diff1 + diff2 +... + diff7)
         SCHEM TYPE CHAR15,
         POSTD LIKE BSID-BUDAT,
         BSTKD LIKE VBKD-BSTKD, 
         BSTDK LIKE VBKD-BSTDK, 
         ZCS1  TYPE CHAR40,
         ZCS2  TYPE CHAR40,
         ZCS3  TYPE CHAR40,
         ZCS4  TYPE CHAR40,
 
       END OF TY_FINAL.
 
Data:  
         IT_FINTSO         TYPE   STANDARD TABLE OF TY_FINAL    INITIAL SIZE 0,
        WA_FINTSO        TYPE   TY_FINAL.
        data: it_fintso2  TYPE   STANDARD TABLE OF TY_FINAL    INITIAL SIZE 0,
                wa_it_fintso2 like wa_fintso.
data: ckunnr(1).
loop at it_fintso into wa_fintso.
 wa_fintso2 = wa_fintso.
   at new kunnr.
        ckunnr = 'X'.
        append wa_finsto to it_fintso2.
    endat.

   if ckunnr = 'X'.
      clear ckunnr.
    else.
      wa_fintso-kunnr = ''.
    endif.

  append wa_fintso to it_fintso2.
at end of kunnr.
  sum.
    wa_fintso-name1 = 'Kunnr Total'.
    
    append wa_fintso to it_fintso2.
endat.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:41:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224569#M1207981</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code help for adding amount fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224570#M1207982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;    Please try using this with appropriate fields, I have not used the proper fields that u have used so please replace with the required fields,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_fintso INTO wa_fintso.&lt;/P&gt;&lt;P&gt;  AT NEW "CUSTOMER NUMBER".&lt;/P&gt;&lt;P&gt;    sum.&lt;/P&gt;&lt;P&gt;    WRITE:/128 sy-vline, wa_fintso-diff1.&lt;/P&gt;&lt;P&gt;  ENDAT.&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;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="6" type="ul"&gt;&lt;P&gt;use the Customer Number field in place of "CUSTOMER NUMBER",&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt; the above code will give the total of field Diff1, &lt;/P&gt;&lt;P&gt;In the same way u can do it for the other total fields.&lt;/P&gt;&lt;P&gt;Pls try it out and let me know if it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Suraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Feb 2009 05:47:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-help-for-adding-amount-fields/m-p/5224570#M1207982</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-23T05:47:59Z</dc:date>
    </item>
  </channel>
</rss>

