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

Firstly, I have no experience with ABAP, I am working on guesses here.

I want to add a condition in SELECT to an existing report. Existing code is as follows:

SELECT SINGLE * FROM EKPO WHERE EBELN = GT_MSEG-EBELN AND EBELP = GT_MSEG-EBELP. 

I want to add a condition to exclude a record if the field F1 is a certain value and the field F2 is 0 (both conditions must be true to exclude the record). I 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: the field "F1 =" the value "AND F2 =" 0 "is unknown. It is not in any of the specified tables and is not defined by the" DATA "operator.

Fields F1 and F2 definitely exist in the ECPO table, I checked. The brackets seem to make the compiler treat the contents as a field name, but I don't know why.

Is the syntax incorrect, did I skip the definition somewhere or both?

+4
source share
1 answer
 SELECT SINGLE * FROM EKPO WHERE EBELN = GT_MSEG-EBELN AND EBELP = GT_MSEG-EBELP AND NOT ( F1 = 'value' AND F2 = '0' ). 

It worked. Basically, I just needed a place next to the brackets.

+9
source

All Articles