on 04-18-2006 12:15 AM
Hi Gurus,
I am unclear about the meaning or usage of the syntax 'select single ... into...'
Could you please help to clarify?
Thanks,
Alfonso
hi Alfonso,
to add info given by Praveen...
select single will retrieve only one record eventhough there is more record meet the select statement.
e.g we have data in database
customer customer_group
a x
b x
c x
d y
using select single customer into lv_customer
where customer_group = 'x'.
we will get a only customer = a, though b and c also
meet the condition.
in data loading, it's suggested to avoid select single since it may be #1 performance killer, retrieve some records from database and move first to internal table and later fetch from internal table would normally better than select single record from database each time.
take a look some sample code on this
you can use transaction ABAPHELP to see more detail about select single. and ABAPDOCU may also useful.
hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also..u can read all required data into an internal table and then use 'READ TABLE <int table> WITH KEY <key field names> BINARY SEARCH'.
This can be used when-
all key fields are present in internal table and available from communication structure.
sort internal table by the key fields.
Else it will push first available record from int table into the work area.
regards,
Vishvesh
Hello Alfanso,
Following is the text from SAP help.
To read a single entry from the database, use the following:
SELECT SINGLE <cols> ... WHERE ...
To ensure that the line can be uniquely identified, you must specify values for all of the fields of the primary key of the table in the WHERE clause. If the WHERE clause does not contain all of the key fields, the syntax check produces a warning, and the SELECT statement reads the first entry that it finds that matches the key fields that you have specified.
The result of the selection is either an elementary field or a flat structure, depending on the number of columns you specified in <cols>. The target area in the INTO clause must be appropriately convertible.
If the system finds a line with the corresponding key, SY-SUBRC is set to 0, otherwise to 4.
Hope it helps.
Regards,
Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.