10-08-2007 3:06 PM
Hello experts,
Can we do query's in SAP with conditions? Like we can do in SQL Server or MySQL or whatever. Something like:
SELECT field1, (if field2='1' THEN 'YES' ELSE 'NO') as field2 FROM TABLE WHERE <conditions2>.
I know that SAP is not a database and these things are Database related but as i just began in SAP, i wanted to know if this is possible or not.
Best Regards,
Jorge
10-08-2007 3:14 PM
Eg:
SELECT konob zgeog vtweg kvgr1 kunnr pkunwe
FROM s770e INTO TABLE i_s770e
WHERE konob = p_konob
AND zgeog = p_zgeog
AND vtweg = s_vtweg-low
AND kvgr1 IN r_kvgr1
AND kunnr IN r_kunnr
AND pkunwe IN r_pkunwe.
Please give me reward point If it is useful
Thanks
Murali Poli
10-08-2007 3:16 PM
So the answer is 'no'.
The only thing we can do is to condition the where and not the select itself.
Regards,
Jorge
10-08-2007 3:21 PM
Jorge,
You can do one thing.
Condition the where as shown above and after the select, use
if sy-subrc<>0.
If the select statement returns any values, sy-subrc will be zero and if it doesnt return anything sy-subrc<>0. So you can basically have a condition kind of thing on the select also.
Regards
Aneesh.
10-08-2007 3:23 PM