<?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: SELECT with calculations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004077#M1495684</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 your select statement like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT sf~carrid sf~connid sf~fldate sf~price sf~seatsocc sf~seatsmax - sf~seatsocc 
INTO CORRESPONDING FIELDS OF TABLE itab_flight
FROM ( sflight AS sf LEFT JOIN scarr AS sc ON sf~carrid = sc~carrid )
WHERE sf~carrid = carrier.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab_flight.
itab_flight-seatsavl = itab_flight-seatsmax - itab_flight-seatsocc.
modify itab_flight.
clear itab_flight.
endllop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;Sany&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Jun 2010 08:12:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-06-02T08:12:03Z</dc:date>
    <item>
      <title>SELECT with calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004076#M1495683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;good day&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to ABAP, How to I use calculation in SELECT statement, the following gives me errors&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT sf~carrid sf~connid sf~fldate sf~price sf~seatsocc ( sf~seatsmax - sf~seatsocc ) AS seatsavl 
INTO CORRESPONDING FIELDS OF TABLE itab_flight
FROM ( sflight AS sf LEFT JOIN scarr AS sc ON sf~carrid = sc~carrid )
WHERE sf~carrid = carrier.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the value of &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;seatsaval&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; to be the difference of &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;seatsmax&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; and &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;seatsocc&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanx in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jun 2010 08:04:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004076#M1495683</guid>
      <dc:creator>former_member804611</dc:creator>
      <dc:date>2010-06-02T08:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT with calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004077#M1495684</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 your select statement like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT sf~carrid sf~connid sf~fldate sf~price sf~seatsocc sf~seatsmax - sf~seatsocc 
INTO CORRESPONDING FIELDS OF TABLE itab_flight
FROM ( sflight AS sf LEFT JOIN scarr AS sc ON sf~carrid = sc~carrid )
WHERE sf~carrid = carrier.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab_flight.
itab_flight-seatsavl = itab_flight-seatsmax - itab_flight-seatsocc.
modify itab_flight.
clear itab_flight.
endllop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;Sany&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jun 2010 08:12:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004077#M1495684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-02T08:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT with calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004078#M1495685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These are only [aggregate functions|http://help.sap.com/abapdocu_70/en/ABENAGGREGATE_SHORTREF.htm] you can use within select statment. So calculate it either within select statement itself or later within loop&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT sf~carrid sf~connid sf~fldate sf~price sf~seatsocc sf~seatsmax sf~seatsocc
INTO CORRESPONDING FIELDS wa_flight  "use work area
FROM ( sflight AS sf LEFT JOIN scarr AS sc ON sf~carrid = sc~carrid )
WHERE sf~carrid = carrier.

"and calculate it yourself
wa_flight-seatsaval = wa_flight-seatsmax  - wa_flight-seatsocc.

append wa_flight to itab_flight.
ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jun 2010 08:23:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004078#M1495685</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-06-02T08:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT with calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004079#M1495686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you check with ABAP Documentation , there you can find the possibilities that can be done on a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT - aggregate &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;... { MAX( [DISTINCT] col ) &lt;/P&gt;&lt;P&gt;    | MIN( [DISTINCT] col ) &lt;/P&gt;&lt;P&gt;    | AVG( [DISTINCT] col ) &lt;/P&gt;&lt;P&gt;    | SUM( [DISTINCT] col ) &lt;/P&gt;&lt;P&gt;    | COUNT( DISTINCT col ) &lt;/P&gt;&lt;P&gt;    | COUNT( * ) &lt;/P&gt;&lt;P&gt;    | count(*) } ... . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;As many of the specified column labels as you like can be listed in the SELECT command as arguments of the above aggregate expression. In aggregate expressions, a single value is calculated from the values of multiple rows in a column as follows (note that the addition DISTINCT excludes double values from the calculation): &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MAX( [DISTINCT] col ) Determines the maximum value of the value in the column col in the resulting set or in the current group. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MIN( [DISTINCT] col ) Determines the minimum value of the content of the column col in the resulting set or in the current group. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AVG( [DISTINCT] col ) Determines the average value of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM( [DISTINCT] col ) Determines the sum of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT col ) Determines the number of different values in the column col in the resulting set or in the current group. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COUNT( * ) (or count(*)) Determines the number of rows in the resulting set or in the current group. No column label is specified in this case. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using aggregate expressions, all column labels that are not listed as an argument of an aggregate function are listed after the addition GROUP BY. The aggregate functions evaluate the content of the groups defined by GROUP BY in the database system and transfer the result to the combined rows of the resulting set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data type of aggregate expressions with the function MAX, MIN or SUM is the data type of the corresponding column in the ABAP Dictionary. Aggregate expressions with the function AVG have the data type FLTP, and those with COUNT have the data type INT4. The corresponding data object after INTO or APPENDING has to be selected accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jun 2010 10:07:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004079#M1495686</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-02T10:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT with calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004080#M1495687</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;"and calculate it yourself&lt;/P&gt;&lt;P&gt;wa_flight-seatsaval = wa_flight-seatsmax&amp;nbsp; - wa_flight-seatsocc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Produces syntax error dataobject wa_flight does not have a component seatsaval.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please explain this to resolve&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 12:53:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-with-calculations/m-p/7004080#M1495687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-09T12:53:22Z</dc:date>
    </item>
  </channel>
</rss>

