2007 May 19 10:16 AM
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
2007 May 19 11:11 AM
It is because if at least one value satisfy them you should proceed otherwise exit.
2007 May 19 10:26 AM
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.
2007 May 19 11:11 AM
It is because if at least one value satisfy them you should proceed otherwise exit.
2007 May 19 2:03 PM
2007 May 19 2:09 PM
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
2007 May 19 3:11 PM
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?
2007 May 19 4:25 PM
2007 May 20 7:36 AM
It will work sheshu . But i want to know the llogic behind that.
2007 May 20 3:36 PM
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
2007 May 20 3:47 PM
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.
2007 May 20 4:11 PM
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