on 2022 Dec 07 4:26 AM
Hello All,
I am looking to use window expressions in ABAP Routines in BW environment but getting following syntax error:
"OVER" is invalid here (due to grammar). contains an invalid character or it is a
As per this blog: https://blogs.sap.com/2021/11/24/window-expressions-in-abap-sql/ , we should be able to use window expressions in ABAP SQL (i.e. Open SQL in ABAP). However, I get the above stated error message when I attempt to use RANK( ) or others such window expressions such asSUM( ), COUNT( ), AVG( ), etc. SQL I am using within my test ABAP routine looks like:
TYPES: BEGIN OF ls_windowfunctst,
CITY TYPE c length 50,
RANK TYPE i,
SALES TYPE p length 000009 decimals 000002,
END OF ls_windowfunctst.
DATA: lt_windowfunctst TYPE STANDARD TABLE OF ls_windowfunctst,
wa_windowfunctst TYPE ls_windowfunctst.
SELECT
CITY,
RANK( ) OVER( PARTITION BY CITY ORDER BY CITY ) as SALES_RANK,
SALES
FROM ZFMSALES
INTO CORRESPONDING FIELDS OF TABLE @lt_windowfunctst.
We are running 7.5 SP8 for ABAP/BASIS ON HDB 2.0 on BW side.
If anyone has used window expressions with ABAP/Open SQL successfully, could you please advise what I might be doing wrong here? I suspect its not supported, but have not been to confirm this (hoping I am wrong since these expressions are pretty useful!).
TIA.
Request clarification before answering.
Hello Vince,
I'm afraid that windows expressions in ABAP SQL are not available in your release.
In SAP BW/4HANA 2021, your example above is running fine.
Note that there is a mismatch in the type declaration. You use RANK in the type declaration but SALES_RANK in the field list.
Regards,
Dominik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Window expressions were introduced to ABAP SQL with release 7.54.
From that release on you do not need AMDP or Native SQL to use a window expression in ABAP any more.
Window expressions are not supported by ABAP CDS. In order to use them before 7.54, you can use AMDP.
Kind regards
Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vince,
the blog, which you linked looks like that the examples have been written in a HANA Calculation View.
I assume what you try will not work in pure ABAP (SE38 report).
You will have to use either an ABAP CDS View or a Calculation view, or in case of BW you can use an AMDP script.
Good luck 🙂
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you all for your responses. And thank you Safa for updating the blog.
We plan to migrate to BW 2021 sometime next year, so we look forward to using these tools in our ABAP tool kit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vince.
As it is already mentioned by Horst, window expressions are introduced with release 7.54 and so the example unfortunately doesn't work for you. I already update the blog though with this information, thank you for brings it up and thanks others for their comments 🙂
Regards
Safa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 14 | |
| 8 | |
| 6 | |
| 6 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.