Application Development and Automation 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: 
Read only

SQL statement to determine if record exists

Former Member
0 Likes
4,408

Hi all,

Does anyone know the SQL-statement to determine if a record in a table exists? I don't want to read any data into the working-storage, I just need the returncode. I think it's something like, "transfer no data...." but I can't find the

exact syntax.

And yes....points for good/helpful answers guaranteed!

Thanks in advance.

Ivo

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,829

select single * from zark_alv_test where grade = 'G'.

if sy-subrc = 0 .

write : / 'Exists'.

else.

write : / 'Does not Exists'.

endif.

in this SELECT query u are jst checking and not fetching data into workarea this is one of the way and also performance wise advisable to use....

check the SY_SUBRC And then u will know whether the record exists in DB table .....

award points if useful thanks

3 REPLIES 3
Read only

former_member188827
Active Contributor
0 Likes
1,829

u cant use transporting no fields addition with db tables.its used with internal tables to chack whether a record exits or not.

u've to use simple select statment like..

Select single......from ..into ... where...

if sy-subrc = 0.

"record exists.

elseif sy-subrc eq 4.

"record doesnt exit.

endif.

Read only

Former Member
0 Likes
1,830

select single * from zark_alv_test where grade = 'G'.

if sy-subrc = 0 .

write : / 'Exists'.

else.

write : / 'Does not Exists'.

endif.

in this SELECT query u are jst checking and not fetching data into workarea this is one of the way and also performance wise advisable to use....

check the SY_SUBRC And then u will know whether the record exists in DB table .....

award points if useful thanks

Read only

Lakshmant1
Active Contributor
0 Likes
1,829

Hi Ivo,

Check FM TABLECOUNT.

Thanks

Lakshman