各位好
很困擾的是,如果我在欄位名稱後加上',',SAP會出現語法錯誤訊息:Comma without preceding colon (after SELECT ?).;如果我把','移除,SAP又會不認識第一個'case'指令,是否能請熟悉ABAP的專家協助小第修正這個問題?
謝謝!!
其實我不會 SAP
參考這篇
SELECT num1, num2,
CASE WHEN num1 < 50 AND num2 < 50 THEN @both_l
WHEN num1 >= 50 AND num2 >= 50 THEN @both_gt
ELSE @others
END AS group
FROM demo_expressions
ORDER BY group
INTO TABLE @DATA(results).
如果正確的話
再一點一點
改成你的指令
了解,謝謝!!
這個寫法有兩個地方要注意一下版本:
在 ABAP 7.40 SP 5
以前,在 SELECT 欄位之間使用逗號,必須在括號裡面,之後的版本開始支援 (Comma-Separated Lists),可以參考官方文件,和官方論壇的這個問題中,回答1的第二個評論
Commas have been allowed in SELECT statements in older versions, but only within parentheses, such as:
SELECT (carrid, connid, fldate) FROM sflight INTO.........
Comma-separated lists are now also possible in programs of ABAP language version Standard ABAP (Unicode) where the program attribute fixed point arithmetic is activated:
※ In the statement SELECT
When columns, aggregate expressions, or SQL expressions are specified in the SELECT list
能直接在 SELECT 欄位當中寫 Case When 是從 ABAP 7.4 SP08
開始支援:
The SQL expressions introduced with 7.40, SP05 into the SELECT list were enhanced with 7.40, SP08 as follows:
You can use SQL expressions after GROUP BY
You can use SQL expressions together with aggregates
You can use SQL expressions as argument of aggregates
You can use a seached CASE expression besides the simple CASE
https://blogs.sap.com/2014/10/08/abap-news-for-740-sp08-open-sql/
感謝通靈亡~~感恩~