<?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: Aggregate function SUM with dynamin column name? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037113#M1350306</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;Thanks for the replies. &lt;/P&gt;&lt;P&gt;Yes the coloumn is dynamic . I already tried by passing the field symbol. But it is giving syntax error as unknown field list. &lt;/P&gt;&lt;P&gt;Can you help me on passing filed symbol to SUM function? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Aravind&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Aug 2009 09:55:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-04T09:55:43Z</dc:date>
    <item>
      <title>Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037110#M1350303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem to find the sum of a dynamic column while retrieving the data from data base using Select Sum aggregate. &lt;/P&gt;&lt;P&gt;The problem is i am unable to pass the dynamic column name to the SUM aggreagte function, i.e suppose i am retrieving data from COSR . based on the period entered  in the selection screen  i need to sum the values of a field in COSR. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to use SUM aggregate function in this case? Please help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Aravind&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2009 09:33:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037110#M1350303</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-04T09:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037111#M1350304</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;Try the following code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select SUM(sme001) 
from COSR
into v_total
where gjahr in s_gjahr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the column to sum is dynamic, pass it to a field symbol and use it in the select statement.&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>Tue, 04 Aug 2009 09:45:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037111#M1350304</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-04T09:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037112#M1350305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aravind,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you trying to sum fields SME001 to SME016? Try using Field Symbols:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  field-symbols &amp;lt;lfs_field&amp;gt; type cosr-sme001.&lt;/P&gt;&lt;P&gt;  data: l_variable(2) type c,&lt;/P&gt;&lt;P&gt;           l_field type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  p_prefix = 'cosr-sme0'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  while l_variable le 16.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    concatenate p_prefix l_variable into l_field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    assign (l_field) to &amp;lt;lfs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      p_amount  = p_amount + &amp;lt;lfs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    l_variable = l_variable + 1.&lt;/P&gt;&lt;P&gt;  endwhile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Benedict&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: benedict choa on Aug 4, 2009 5:51 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2009 09:51:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037112#M1350305</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-04T09:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037113#M1350306</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;Thanks for the replies. &lt;/P&gt;&lt;P&gt;Yes the coloumn is dynamic . I already tried by passing the field symbol. But it is giving syntax error as unknown field list. &lt;/P&gt;&lt;P&gt;Can you help me on passing filed symbol to SUM function? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Aravind&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2009 09:55:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037113#M1350306</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-04T09:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037114#M1350307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use dynamic select:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. if you can retrieve the field name, for example field1 and you will be retrieving from table1, then just do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_field1 = 'FIELD1'.&lt;/P&gt;&lt;P&gt;lv_table1 = 'TABLE1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate 'SUM(' lv_field1 ')' 'from ' lv_table1 'into' 'lv_sum' into lv_string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select (lv_string).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want to add where condition, just add it in the string.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2009 10:03:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037114#M1350307</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-04T10:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037115#M1350308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try something like this im not sure whether it matches ur req&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append ur dynamic field to internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

parameters:pa_lgort type mard-lgort.

data:field type string.

data:begin of it OCCURS 0,
      text(25) type c,
     end of it.
data:begin of it1 OCCURS 0,
      labst type mard-labst,
     end of it1.

concatenate 'sum(' 'labst' ')' INTO field SEPARATED BY space.   "&amp;lt;--pass ur dynamic field here.
append field to it.
select (it) from mard into table it1 where lgort = pa_lgort.
break-point.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Keshu Thekkillam on Aug 4, 2009 3:39 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Keshu Thekkillam on Aug 4, 2009 3:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2009 10:09:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037115#M1350308</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2009-08-04T10:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037116#M1350309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply. But if i use the same procedure syntax error is occuring as select statment ended unexpectedly? &lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Aravind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2009 01:25:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037116#M1350309</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-05T01:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate function SUM with dynamin column name?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037117#M1350310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the replies. &lt;/P&gt;&lt;P&gt;I tried in all the ways mentioned. I think it is not possible to use SUM with a dynamic coloumn. So i used another syntax and closing the thread. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Aravind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2009 07:47:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-function-sum-with-dynamin-column-name/m-p/6037117#M1350310</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-05T07:47:58Z</dc:date>
    </item>
  </channel>
</rss>

