‎2007 May 17 2:58 PM
Hello people,
I have a table 'TableA' with a column 'xpto' that has DATS data type.
A lot of lines in this table has this field empty.
I have to create a SQL query to select those lines with this field not empty.
Select * from TableA
where xpto is not null
It does not work.... The result is all the lines in the table.
What is wrong?
Thanks!
‎2007 May 17 3:15 PM
This works:
DATA: dt LIKE sy-datum.
SELECT SINGLE * FROM bkpf WHERE budat <> dt.
Rob
‎2007 May 17 3:00 PM
‎2007 May 17 3:01 PM
‎2007 May 17 3:03 PM
I have already tried
ne ''
<> ''
and those ones dont work too........
‎2007 May 17 3:06 PM
Easiest way to do this is :
constants l_xpto type tableA-xpto value is initial
Select * from TableA
where xpto ne l_xpto.
You can see the NULL/NOT NULL settings for the column through SE11
Utilities -> Database Object -> Display.
I tend to set the "Initial Value" flag when adding columns to tables, which creates the database column as NOT NULL with a default value (whatever SAP considers the initial value for that datatype). I think SAP does this by default, but I've had issues where it hasn't so I do this to ensure consistency
Chris Bain
‎2007 May 17 3:15 PM
This works:
DATA: dt LIKE sy-datum.
SELECT SINGLE * FROM bkpf WHERE budat <> dt.
Rob
‎2007 May 18 8:35 PM
Thanks a lot everybody!
When I create a blank variable, it works!