<?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 ABAP code needed in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512845#M236381</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 want to send summarized data from one table (ztable) to another table. Could you please &lt;/P&gt;&lt;P&gt;help me in writing ABAP code for the following funtionality.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------" /&gt;&lt;P&gt;TABLE 1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;metricId, CalenderMonth, LOCATION, ValueType,  V1, V2, V3&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;ABC	FEB-2005	      A	       10       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	FEB-2005	      A	       50       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	FEB-2005	      A	       60       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	FEB-2005	      B	       60       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	MAR-2005	      A	       10       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	APR-2005       	      D	       50       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	APR-2005       	      D	       60       XX  XX  XX&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------" /&gt;&lt;P&gt; sum     AA  BB CC&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V1 - Real value1&lt;/P&gt;&lt;P&gt;v2-  Real value2&lt;/P&gt;&lt;P&gt;v3-  Real value3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note I need summation based on value type,month and metric id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In above table, location is unique (composite key) to a particular value type (10 or 50 or 60) within a given month and metric id. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to send summarized data into another table based on value type, within a given month and metric id.&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;Final summation value = Summation of (value1 + value2 +  &lt;/P&gt;&lt;P&gt;                        value3)										 	&lt;/P&gt;&lt;P&gt;                      =  AA + BB + CC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;TABLE 2&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;(metric Id) (Calender month)  (Value type) (Final Value)&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;                                                &lt;/P&gt;&lt;P&gt;  ABC            FEB-2005	    10	        XX	                    &lt;/P&gt;&lt;P&gt;  ABC		 FEB-2005	    50	        XX	                    &lt;/P&gt;&lt;P&gt;  ABC		  FEB-2005	    60	        XX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate if any one can help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Avneet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Aug 2006 18:15:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-08-23T18:15:30Z</dc:date>
    <item>
      <title>ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512845#M236381</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 want to send summarized data from one table (ztable) to another table. Could you please &lt;/P&gt;&lt;P&gt;help me in writing ABAP code for the following funtionality.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------" /&gt;&lt;P&gt;TABLE 1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;metricId, CalenderMonth, LOCATION, ValueType,  V1, V2, V3&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;ABC	FEB-2005	      A	       10       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	FEB-2005	      A	       50       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	FEB-2005	      A	       60       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	FEB-2005	      B	       60       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	MAR-2005	      A	       10       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	APR-2005       	      D	       50       XX  XX  XX&lt;/P&gt;&lt;P&gt;ABC	APR-2005       	      D	       60       XX  XX  XX&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------" /&gt;&lt;P&gt; sum     AA  BB CC&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V1 - Real value1&lt;/P&gt;&lt;P&gt;v2-  Real value2&lt;/P&gt;&lt;P&gt;v3-  Real value3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note I need summation based on value type,month and metric id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In above table, location is unique (composite key) to a particular value type (10 or 50 or 60) within a given month and metric id. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to send summarized data into another table based on value type, within a given month and metric id.&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;Final summation value = Summation of (value1 + value2 +  &lt;/P&gt;&lt;P&gt;                        value3)										 	&lt;/P&gt;&lt;P&gt;                      =  AA + BB + CC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;TABLE 2&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;(metric Id) (Calender month)  (Value type) (Final Value)&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;                                                &lt;/P&gt;&lt;P&gt;  ABC            FEB-2005	    10	        XX	                    &lt;/P&gt;&lt;P&gt;  ABC		 FEB-2005	    50	        XX	                    &lt;/P&gt;&lt;P&gt;  ABC		  FEB-2005	    60	        XX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate if any one can help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Avneet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 18:15:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512845#M236381</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-23T18:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512846#M236382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Avneet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAP provides us with the ABAP statement COLLECT statement to summarize data.&lt;/P&gt;&lt;P&gt;If, for example, the fields containing ABC FEB-2005 A 10 constitute a unique key within the itab then the COLLECT statement will summarize all values for this unique key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If, however, the key is unique as described above, but you want to summarize the values for 10 50 60 together then you have to replace 10 50 60 with an alternative unique key (e.g. 'XX').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you collect?. The only thing you need is a second table in which you collect your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data:
  gt_ztable_collect    TYPE TABLE OF ... (like ztable)

  LOOP at ztable INTO gs_line.
    COLLECT gs_line INTO gt_ztable_collect.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the collect fields must be on the end of the structure and the key fields at the beginning of the structure.&lt;/P&gt;&lt;P&gt;Please read the SAP documentation for the COLLECT statement carefully.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;   Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 18:36:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512846#M236382</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2006-08-23T18:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512847#M236383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;report zrep.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;        metricid like ztable-metricid,&lt;/P&gt;&lt;P&gt;        calid like ztable-calid,&lt;/P&gt;&lt;P&gt;        valtype like ztable-valtype,&lt;/P&gt;&lt;P&gt;        location like ztable-location,&lt;/P&gt;&lt;P&gt;        v1 like ztable-v1,&lt;/P&gt;&lt;P&gt;        v2 like ztable-v2,&lt;/P&gt;&lt;P&gt;        v3 like ztable-v3,&lt;/P&gt;&lt;P&gt;      end of itab.&lt;/P&gt;&lt;P&gt;data : begin of ltab,&lt;/P&gt;&lt;P&gt;        metricid like ztable-metricid,&lt;/P&gt;&lt;P&gt;        calid like ztable-calid,&lt;/P&gt;&lt;P&gt;        valtype like ztable-valtype,&lt;/P&gt;&lt;P&gt;      end of ltab.        &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;  select * into itab from ztable.&lt;/P&gt;&lt;P&gt;  loop at itab.&lt;/P&gt;&lt;P&gt;    at new valtype.&lt;/P&gt;&lt;P&gt;       clear ltot.&lt;/P&gt;&lt;P&gt;    endat.&lt;/P&gt;&lt;P&gt;    move corresponding itab into ltab.&lt;/P&gt;&lt;P&gt;    ltot = itab-v1 + itab-v2 + itab-v3 + ltot.&lt;/P&gt;&lt;P&gt;    at end of valtype.&lt;/P&gt;&lt;P&gt;       move-corresponding ltab into ztable1.&lt;/P&gt;&lt;P&gt;       ztable1-final = ltot.&lt;/P&gt;&lt;P&gt;       insert ztable1.&lt;/P&gt;&lt;P&gt;    endat.&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;Anurag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 18:41:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512847#M236383</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-23T18:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512848#M236384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks UWE and anurag for your quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anurag, the code you sent is summarizing values only based on value type. However, I want to summarize the data based on value type, month and metric id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please correct me if am wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I mean, many metric id,many months, three value types are there. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you pls help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Avneet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 19:38:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512848#M236384</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-23T19:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512849#M236385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The AT event is different than On change events...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AT is triggered when any of the fields to the left of the one defined changes ...hence you can see my definition of the internal table, if either of metricid/calendar or valtype changes it would be triggered i.e. for each unique combination of metricid&lt;EM&gt;calid&lt;/EM&gt;valtype the total would be inserted in ztable1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ON Change is triggered on change of the particular field only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Please note that you need to sort the internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anurag&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : Please reward help answers &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Anurag Bankley&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Anurag Bankley&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 19:42:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512849#M236385</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-23T19:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512850#M236386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help and suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you be able to explain me in detail and send me code. I would greatly appreciate your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Avneet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 19:46:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512850#M236386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-23T19:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP code needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512851#M236387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Anurag,Uwe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help and I have awarded points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Avneet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 20:10:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-needed/m-p/1512851#M236387</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-23T20:10:01Z</dc:date>
    </item>
  </channel>
</rss>

