Does ABAP Open SQL support aggregate functions? (e.g. SUM, AVG)
When you hit F1 on "select", the ABAP Keyword Documentation opens up. Under "Open SQL" in the documentation is information on "SELECT - aggregate". So the SAP Keyword Documentation states that aggregate functions are possible in Open SQL.
But this guy (who seems amply qualified) says that open SQL in ABAP does not support aggregate functions such as sum:
Who is right? If ABAP does support aggregate functions, can I have a complete select statement using SUM and GROUP BY as an example?
I have written a select statement using SUM and GROUP BY but the resulting internal table is empty.
Aggregate functions can be used
see link:[Reading Aggregate Data for Columns|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3990358411d1829f0000e829fbfe/content.htm]
Certain Things are not possible in ABAP open sql such as rollback create Etc. I think these are not AGGREGATE functions
But i dont why he mentioned
in open sql you canu2019t use aggregate functions like sum,avg.
Edited by: Keshu Thekkillam on Sep 3, 2009 6:27 PM
Do you know if data type currency (CURR) is considered by the aggregate function SUM to be a numeric field? I'm just not getting any data in my results and I'm pretty confident my syntax is correct:
select zfmusfgarfistl zfmusfgarfund zfmusfgarefdocnr sum( zfmusfgahsl ) zfmusfga~budat
into (itab-rfistl, itab-rfund, itab-refdocnr, itab-hsl, itab-budat)
where rfistl = fld_fc and
racct = '48020900' and
budat >= p_pdates and
budat <= p_pdatee
zfmusfgarfistl zfmusfgarfund zfmusfgarefdocnr zfmusfgabudat.
data:v_netpr type ekpo-netpr. select sum( NETPR ) from ekpo into v_netpr where ebeln = '3000000023' . write v_netpr.
This works for me
Might be some problems in your where clause
check leading zeros in your value 48020900 and whether the date conditions matches the entries with your table values
Not sure what the guy wants. Of course Open SQL cannot include all the bells and whistles of each specific native SQL dialects, because Open SQL is designed to serve all database platforms alike, not only DB2, so it can only include common features. Some common features might have been left out for reasons unknown to me though.
Aggregates are certainly included, here is another helpful link.