2006 Oct 14 3:03 PM
Hello,
I have a problem with a select statement. I don't really know how to write it.
I wrote it like this:
SELECT DISTINCT marc~matnr
FROM marc
JOIN mara ON marcmatnr = maramatnr
...
where marc~mmsta NOT IN ('01','02','03')
<b>AND marc~mmstd >= sy-datum</b>
The problem is on the last line. That field may be empty and, in that case, this select should return the corresponding records. But, as I wrote the select, it doesn't work. Any ideea?
2006 Oct 14 3:08 PM
2006 Oct 14 3:12 PM
Hi George,
You are checking the date in WHERE claus, so you have to pass the date..without that you wont get the result.
Still if you want the values eventhough you are passing date as empty. Then write separate select statement without where clause-Date checking.
<b>if p_date is initial.</b>
SELECT DISTINCT marc~matnr
FROM marc
JOIN mara ON marcmatnr = maramatnr.
where marc~mmsta NOT IN ('01','02','03')
<b>else.</b>
SELECT DISTINCT marc~matnr
FROM marc
JOIN mara ON marcmatnr = maramatnr
...
where marc~mmsta NOT IN ('01','02','03')
AND marc~mmstd >= <b>p_date.</b>
<b>endif.</b>
pls reward if it helps.
Thanks
Eswar