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

validation of selection screen fields

Former Member
0 Likes
1,387

Hi All,

I have a doubt regarding validation of selection screen fields Examp if I take material declared as selec-options:s_matnr for mara-matnr.

when I am validating I am doing like below.

select single matnr from mara into l_matnr where matnr eq s_matnr-low.

if sy-subrc ne 0.

error mesg.

endif.

select single matnr from mara into l_matnr where matnr eq s_matnr-high.

if sy-subrc ne 0.

error mesg.

endif.

I enterted material values in the selction screen say 100 to 150.

s_matnr-low is 100.

s_matnr-high is 150.

I have the materials data like this 99,101,104,159.For this case if we will do the above validation it wil give error since 90 is not there in db but actually speaking it should fetch 101.104,159 since this falls under the range of 99 to 150.Please let me know how can we do the validations for this type of scenarios?

Thanks&Regards

Mahesh

Hi All,

I have a doubt regarding validation of selection screen fields Examp if I take material declared as selec-options:s_matnr for mara-matnr.

when I am validating I am doing like below.

select single matnr from mara into l_matnr where matnr eq s_matnr-low.

if sy-subrc ne 0.

error mesg.

endif.

select single matnr from mara into l_matnr where matnr eq s_matnr-high.

if sy-subrc ne 0.

error mesg.

endif.

I enterted material values in the selction screen say 100 to 150.

s_matnr-low is 100.

s_matnr-high is 150.

I have the materials data like this 99,101,104,159.For this case if we will do the above validation it wil give error since 90 is not there in db but actually speaking it should fetch 101.104,159 since this falls under the range of 99 to 150.Please let me know how can we do the validations for this type of scenarios?

Thanks&Regards

Mahesh

10 REPLIES 10
Read only

Former Member
0 Likes
1,244

hi,

instead of writing different select queries , write singl select like:-

select single matnr from mara into l_matnr where matnr in s_matnr.

if sy-subrc ne 0.

error mesg.

endif.

Regards

Nilesh

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,244

Hi

Here you can use the single select quety for your purpose.

As matnr is a selection parameter it contains low and high values at a time and validate.

Regards,

Sreeram

Read only

Former Member
0 Likes
1,244

hi,

If you give a range of values in your selection screen,

The output will be inbetween those range..

Validation checks :- if all the range values are not in the database it will return you the error message..

Selection option is for range of values..

rewards,

regards,

nazeer

Read only

Former Member
0 Likes
1,244

Like the select statement you are writing you are only validating the values which are in the high and low of the select option.... if you want ot validate all the data that you have enetered then try using

in bet s_matnr-low and s_matnr-high. or else s_matnr will also wrok but it will not validate the s_matnr-high and will show all the data which comes in the range till s_matnr-high though you migh have netered the high value wronmg..

Regards,

Jayant

Please award if helpful

Read only

Former Member
0 Likes
1,244

Hi Mahesh,

Please Use the query like this:


Select single matnr from mara into l_matnr where matnr in s_matnr.
if sy-subrc ne 0.
error mesg.
endif.

The select query which you are using is wrong because you are checking only low and high value of the s_matnr field. which is wrong.

Use 'IN' instead of '='.

Read only

Former Member
0 Likes
1,244

<b>Only validate for the lower value:</b>

AT SELECTION-SCREEN.


    SELECT SINGLE mtart FROM t134 INTO l_mtart
                      WHERE mtart = s_mat-low.

    IF sy-subrc <> 0.
      MESSAGE e000 WITH text-016.
    ENDIF

Read only

0 Likes
1,244

<b>Because if none of the material is invalid then only the error message should display. Otherwise, if atleast one material is valid then the processing sould continue with that material.</b>

Read only

0 Likes
1,244

Hi All,

I know how to validate the selection screen fields but the problem here is when I enter 100 to 150 since 100 mat is not there it gives error mesg but ideally speaking it should not give the error mesg since 101 is there and other values r there in the database.

Thanks&Regards

Mahesh

Read only

0 Likes
1,244

Hi,

That is because you are using s_matnr-low and s_matnr-high separately.Then it will take only 100 and 150.It won't take between 100 and 150.

If you want it to take between 100 and 150, then try this.

if not s_matnr[] is initial.

select single matnr from mara into l_matnr where matnr <b>in s_matnr</b>..

if sy-subrc ne 0.

error mesg.

endif.

endif.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,244

Hi,

Try this and reward points by clicking the star on the left of reply,if it helps.

<b>if not s_matnr-low is initial.</b>

select single matnr from mara into l_matnr where matnr eq s_matnr-low.

if sy-subrc ne 0.

error mesg.

endif.

<b>endif.</b>