I need to know how to make a comparison in a SELECT for a field that has to be empty.
I'm trying to select some fields from bkpf, with the field stblg as empty. I've done it in this way:
SELECT c~kunnr a~belnr d~spart c~bldat c~waers a~hwaer f~mwskz
INTO CORRESPONDING FIELDS OF TABLE lt_data
FROM ( ( ( bsis AS f
INNER JOIN bkpf AS a ON f~belnr = a~belnr )
INNER JOIN bsad AS c ON c~belnr = a~belnr )
INNER JOIN vbrk AS d ON d~vbeln = c~belnr )
WHERE a~gjahr IN gjahr
AND a~bukrs IN bukrs
AND c~augdt IN augdt
AND a~stblg = ' '
AND f~hkont = '0034930020'.
Is this correct or do I have to use another thing? Thank you.
In your case, you can use AND a~stblg = ' '
or the already mentioned AND a~stblg EQ SPACE
- there is no difference (I would recommend to use SPACE
. With ' '
you can't be sure, if you want to check a space or if you forgot to fill something in the '.)
On database level empty can have another meaning.
Databases make a difference between space
or ' '
and no value (NULL
).
You can check NULL
in SAP with:
AND a~stblg IS NULL
In your case, this statement should select nothing, because SAP normally stores space for empty character values.