10-11-2013 8:05 AM
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
10-11-2013 8:20 AM
Hi sudheer,
SELECT SINGLE after which you verify the value of sy-subrc. If 4, value doesn't exist, if 0 value exist.
10-11-2013 8:26 AM
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.
10-11-2013 8:46 AM
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
10-11-2013 8:49 AM
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
10-11-2013 8:55 AM
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.
10-11-2013 9:02 AM
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????
10-11-2013 9:06 AM
10-11-2013 9:06 AM
10-11-2013 9:13 AM
10-11-2013 9:18 AM
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
10-11-2013 9:52 AM
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.
10-11-2013 9:11 AM
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
10-11-2013 10:12 AM