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

Check if Table contains specific value

Former Member
0 Likes
19,092

Hi Guru's,

How do i check if a table contains a specific value?

I want to check if a table contains the value that a user entered, is there any option to check the table without select query.

or

which is the best way to check the table for a specific record with respect to performance?

Regards,

Sudheer.M

Hi Guru's,

How do i check if a table contains a specific value?

I want to check if a table contains the value that a user entered, is there any option to check the table without select query.

or

which is the best way to check the table for a specific record with respect to performance?

Regards,

Sudheer.M

13 REPLIES 13
Read only

paul_max1
Explorer
0 Likes
6,190

Hi sudheer,

SELECT SINGLE after which you verify the value of sy-subrc. If 4, value doesn't exist, if 0 value exist.

Read only

Former Member
0 Likes
6,190

hi Sudheer,

You will need a select query to access the database for sure.

The best way of doing this perfomance wise would be using upto 1 rows statement as this would return the result set when and entry is found satisfying your where clause.

Select USER_ENTRY

UPTO 1 ROWS

from ZTABLE

WHERE USER_ENTRY = LV_UENTRY.

Hope this helps. Please revert if issues.

Regards,

DN.

Read only

former_member197475
Active Contributor
0 Likes
6,190

Hi Sudheer.

You can check the table contents in T-Code SE16. Enter the table name and execute it to check the data.

BR,

RAM

Read only

sivaganesh_krishnan
Contributor
0 Likes
6,190

HI sudheer,

I would code it as,

SELECT count( * ) from table UP TO 1 ROWS WHERE field = value.

if sy-subrc <> 0 .

"value not exits .

endif.

" if subrc is 0 then value exits

Read only

Former Member
6,190

Dear, If you want to get that value in some report program then you need to use the select statement.

lv_str type string.

Select single <any_column_name> from <table_name> into lv_str where <Column_name**>   = ^^.

if sy-subrc <> 0.

" Means entry doesn't exist.

else.

" entry exist.

endif.

** Column name, one which that particular entry is store.

^^ Value of entry.

if you just want to check then try in se16 or se11.

Read only

Former Member
0 Likes
6,190

I am using select single in a report which is taking too much time, so is there any option to redude the time.

will select upto 1 row reduce the time????

Read only

0 Likes
6,190

SELECT SINGLE on primary key for sure.

Read only

0 Likes
6,190

Select single also look at the very first record.

Read only

6,190

HI Sudheer,

Try reading the answers in this dicussion . Iam sure your douts will be cleared

Read only

0 Likes
6,190

In addition to what Paul Max said,

If you cannot select single on Primary Key due to input constraints, you can index your input  parameter:

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eb20446011d189700000e8322d00/content.htm

Regards,

KS

Read only

0 Likes
6,190

Sudheer,

Select single is preferred when you have all hte primary keys in your where clause, else its always advisable to use UPTO N ROWS statement.

You can put a trace ON and check the performance yourself.

Regards,

DN.

Read only

former_member187651
Active Participant
0 Likes
6,190

Dear Sudheer,

You got two ways for value check in table against your input.

1. Programmatic:   

  Select Single * from xyz  where condition.

2. Direct go to SE11 or Se16

  Input your value and get the result.

I think with posts above you got the result.

Regards,

Chandan

Read only

Former Member
0 Likes
6,190