DATE
functions are not supported in OpenSQL
. I think they are either HANA(only) functions or implemented to AbapSQL
(A later Hana-specific version of SQL) through later updates on S4/Hana systems. The one you tried to use with TO_DATE
is definitely a HANA function.
SELECT * FROM EKKO
WHERE BUKRS = @CO_Code AND WAERS = 'USD'
AND substring( AEDAT, 1, 4 ) = 2017
INTO TABLE @data(RESULT).
You can also use AEDAT like '2017%'
or AEDAT like '2017____'
(_
wildcard for 1 character). The more specific your criteria the faster your query will be.
Edit 1:
OpenSQL Date functions are implemented with 7.51 they support calculations, but not extraction.
SAP Hana SQL - Datetime functions lists the function you tried to use, but it's a SAP Hana SQL reference page.
Edit 2:
To clarify, Abap SQL
is just a later (starting ABAP 7.53 and higher) iteration of Open SQL
. Rename to "Abap SQL" is directly related to transition to HANA database and cease of support of DB engines other than HANA DB. Backwards compatibility stays, but "some features" (likely meaning new features) will only be supported by HANA DB.
As a side note, latest versions of Abap (together with Hana DB) brings support to numeric date formats (as an option to use instead of current CHAR8
format). Extraction of years/months from numeric date is not as simple as substring, so I assume support for those kind of functions should appear in 'Abap SQL'.