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

Validating Selection screen fields..its not easy.

Former Member
0 Likes
515

Hi All,

Kindly tell me how to evaluate selection screen fields.

1.u will use select matnr frim mara into p_matnr where matnr = ...

2 or u will use select single matnr...

3.or u will use select single *....

4. or select ..up to 1 row..

5 REPLIES 5
Read only

Former Member
0 Likes
486
data : p_matnr like mara-matnr,
          v_matnr like mara-matnr.

select single matnr from mara into v_matnr where matnr eq p_matnr.

write : v_matnr.
Read only

Former Member
0 Likes
486

if u want only one field ie matnt from mara then use -

select single matnr into p_matnr from mara where...

Read only

Former Member
0 Likes
486

Hi Shankar ,

You have listed most of the ways of validating a selection screen element.

The way i would do is use SELECT SINGLE MATNR , the reason for this i just want to check if the user has entered at least one valid value so that i proceed the rest of processing , so if i get at least one record which is valid then i can procceed with processing else will display an error message.

Why i dont prefer the other 3 cases is it results in unnecessary access of data from the tables which is actually not required.

Regards

Arun

Read only

RaymondGiuseppi
Active Contributor
0 Likes
486

Usually i try to optimize like thge following example:

(1) Define SSCRFIELDS strcture in your program

(2) In SELECTION-SCREEN control check if user press enter for control on lauched the program

AT SELECTION SCREEN ON s-matnr.

if SSCRFIELDS-ucomm = 'ONLI'

or SSCRFIELDS-ucomm = 'PRIN'.

select * from mara into table t_mara where matnr in s-matnr.

else.

select single * from MARA where matnr in s-matnr.

endif.

if sy-subrc <> 0.

message e665(cn).

endif.

So, in case of real execution, i can use previous controls result to execute complex controls, in other case, i perform only elementary checks.

Regards

Read only

Former Member
0 Likes
486

hi,

data l_matnr type mara-matnr.

parameters : p_matnr like mara-matnr.

at selection-screen.

if p_matnr is not initial .

select matnr from mara into l_matnr .

if sy-subrc <> 0.

MESSAGE e027(zz_mess).

endif.

endif.