How do I group conditions in a SELECT statement in ABAP?

血红的双手。 提交于 2019-12-10 16:36:27

问题


First off, I have no experience with ABAP, I'm operating on guesswork here.

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.

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').

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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/11623637/how-do-i-group-conditions-in-a-select-statement-in-abap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!