Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SELECT <WITH CONDITIONS> INTO iTable

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

So the answer is 'no'.

The only thing we can do is to condition the where and not the select itself.

Regards,

Jorge

0 Kudos

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.

Former Member
0 Kudos

Ok.

Thanks everyone for your replies.