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

select single s_matnr

Former Member
0 Likes
1,657

Hi all,

Can u please clear my doubt.

When we are validatuing a select-option field on the selection screen like this.

tables: mara.

select-options: s_matnr for mara-matnr.

At selection-screen on s_matnr.

Select single matnr form mara into mara where s_matnr in mara-matnr.

So my doubt is here in select statment in where condition we are using IN operator which searches for multiple records in the database, but select single hits the database only once. how can it be justified.

but select single hits the data

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,601

It is because if at least one value satisfy them you should proceed otherwise exit.

Hi all,

Can u please clear my doubt.

When we are validatuing a select-option field on the selection screen like this.

tables: mara.

select-options: s_matnr for mara-matnr.

At selection-screen on s_matnr.

Select single matnr form mara into mara where s_matnr in mara-matnr.

So my doubt is here in select statment in where condition we are using IN operator which searches for multiple records in the database, but select single hits the database only once. how can it be justified.

but select single hits the data

10 REPLIES 10
Read only

Former Member
0 Likes
1,601

Hi,

It will actually ensures that atleast one of the value in select-option has the entry in the table (MARA). If the table contains a record with the value in select-option then the sy-subrc value of this select single will be 0.

Read only

Former Member
0 Likes
1,602

It is because if at least one value satisfy them you should proceed otherwise exit.

Read only

Former Member
0 Likes
1,601

I t will select the first one.

Read only

Former Member
0 Likes
1,601

User validate only low value in all times and some time he want to validate high value.

Code follows :

  • Validation for low

At selection-screen on s_matnr-low.

Select single matnr form mara into mara where matnr = s_matnr-low.

if sy-subrc ne 0.

message.

endif.

at selection-screen on s_matnr-high.

Select single matnr form mara into mara where matnr = s_matnr-high.

if sy-subrc ne 0.

message.

endif.

Hope it clear and reward points if it is helpful

Thanks

Seshu

Read only

0 Likes
1,601

Sheshu it is ok when we take low or high values. But wat happens when we use IN operator that is what i want to know?

Read only

0 Likes
1,601

it will not work properly

Read only

0 Likes
1,601

It will work sheshu . But i want to know the llogic behind that.

Read only

0 Likes
1,601

Hi satish,

using IN operator will evaluate the range entered in select-options, that means also sign (in- or excluding) and option (all comparison operators =, <, <=, >, >=) are evaluated.

The SINGLE will just find (or find not) any of the values specified by the range. It will cause a warning in extended syntax check because select single should be used when full key is specified in WHERE clause. You are better off using the syntax


Select matnr 
  into mara-matnr up to 1 rows "[not: INTO mara]
  from mara  "[FROM not FORM]
  where matnr in s_matnr. "[syntax corrected]
endselect.

Regards,

Clemens

Read only

0 Likes
1,601

I mean syntactically correct and functionality wise you do not get exact results.

that is why we use put validation low and high separately.

you can write in operator but you do not exact validation.

Read only

0 Likes
1,601

Hi seshu,

you are evaluating only the first line of the range. You ignore any SIGN and OPTION values. It works only if no SIGN or OPTION is given. Then it will check if the material given in LOW or HIGH exists.

If you do not use the full RANGE functionality, it is useless to use SELECT-OPTIONS. Using IN operator will ensure that at least one material matches the range.

Regards,

Clemens