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: 

Re: Select Single * statement

colin_cheong
Contributor
0 Kudos

Hi ABAPers,

I had a question and hope you could give me an answer.

Here is it,

select single * into itab from VRMPA where MATNR in S_MATNR

This would return a single record into itab although it is not correct as there would be more than 1 incoming record and so it is not unique.

My question is

a. would the logic skip out when it hit the first record and would not process the second valid selection

OR

b. it would process all valid records and return only the last record processed

i need to know in order to improve the performance of the logic.

Thanks for the answer in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

When you do a select single, SAP will only retrieve 1 result, the first it encounters. So if you would have multiple material numbers in your select-option S_MATNR, only 1 of them will be in the result. The others are not further selected.

5 REPLIES 5

Former Member
0 Kudos

When you do a select single, SAP will only retrieve 1 result, the first it encounters. So if you would have multiple material numbers in your select-option S_MATNR, only 1 of them will be in the result. The others are not further selected.

rthoodi
Active Participant
0 Kudos

The logic skip out when it hits the first record and record was placed in itab, in contrast to select single , select up to 1 rows will fetch all records corresponding to itab based on where clause, but places only first record in itab.

However, make sure that when u use select single *, better use all key fields in where clause as possible and it is not necessary to get data into ITAB, just get data into wa_itab as there is only one record will fetched using select single statement.

Thanks

RK

Former Member
0 Kudos

Hi,

Its very basic question lot of information available in Google

Checkout this link

http://www.sap-basis-abap.com/abap/difference-between-select-single-and-up-to-1-row.htm

Regards and Best wishes.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Colin,

You would rather hit an F1 on SELECT SINGLE & read the SAP documentation which clearly states:

"If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set"

Source: [http://help.sap.com/abapdocu_70/en/ABAPSELECT_CLAUSE_LINES.htm#!ABAP_ALTERNATIVE_1@1@]

Former Member
0 Kudos

Select single with an IN operator is simply nonsensical. You would write

. . . .where matnr eq <matnr parameter>.