如何在ABAP的SELECT语句中对条件进行分组? [英] How do I group conditions in a SELECT statement in ABAP?
问题描述
首先,我没有使用ABAP的经验,我在这里进行猜测。
First off, I have no experience with ABAP, I'm operating on guesswork here.
我想在现有报告中为SELECT添加条件。
现有代码如下:
I want to add a condition to a SELECT in an existing report. The existing code looks like this:
SELECT SINGLE *
FROM EKPO
WHERE EBELN = GT_MSEG-EBELN
AND EBELP = GT_MSEG-EBELP.
我想添加一个条件以排除记录,如果字段F1是某个值而字段F2是0(两个条件都必须为真才能排除该记录)。我已经尝试过:
I want to add a condition to exclude the record if field F1 is a certain value and field F2 is 0 (both conditions must be true to exclude the record). I've tried this:
SELECT SINGLE *
FROM EKPO
WHERE EBELN = GT_MSEG-EBELN
AND EBELP = GT_MSEG-EBELP
AND NOT (F1 = 'value' AND F2 = '0').
我遇到语法错误:字段 F1 ='值'AND F2 ='0'为未知。它既不在指定表中,也不在 DATA语句中定义。
I get a syntax error: Field "F1 = 'value' AND F2 = '0'" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.
字段F1和F2确实存在于EKPO表中,我检查过。括号似乎使编译器将内容视为字段名称,但我不知道为什么。
Fields F1 and F2 definitely exist in the EKPO table, I've checked. It seems that the brackets are making the compiler look at the contents as a field name, but I don't know why.
语法不正确吗,我是否缺少
Is the syntax incorrect, am I missing a definition somewhere, or both?
推荐答案
SELECT SINGLE *
FROM EKPO
WHERE EBELN = GT_MSEG-EBELN
AND EBELP = GT_MSEG-EBELP
AND NOT ( F1 = 'value' AND F2 = '0' ).
此方法有效。基本上我只需要在方括号旁留一个空格。
This worked. Basically I just needed a space adjacent to the brackets.
这篇关于如何在ABAP的SELECT语句中对条件进行分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!