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

How to validate selection-screen field

Former Member
0 Likes
35,836

Hi all,

How to validate a selection-screen field defined as a select-options.for Ex i declared a selection-screen field select-options:s_matnr for mara-matnr.

Then how to validate this field.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
11,480

Hi,

write the below code in AT SELECTION-SCREN.

EX :

AT SELECTION-SCREEN.

*-- Validate the Selection screen data

PERFORM VALIDATE_SELSCR_DATA.

WRITE THE below code in Form "VALIDATE_SELSCR_DATA".

IF S_MATNR[] IS INITIAL.

*--MATNR is initial.

message e000(MsgCLass) with 'matnr is empty'.

ELSE.

SELECT MATNR

INTO MARA-MATNR

FROM MCHA

UP TO 1 ROWS

WHERE MATNR IN S_MATNR.

ENDSELECT.

IF SY-SUBRC <> 0.

MESSAGE E000 WITH 'Invalid MATNR entered'.

ENDIF.

ENDIF.

9 REPLIES 9
Read only

abdul_hakim
Active Contributor
0 Likes
11,480

Hi

Use the below code..

AT SELECTION-SCREEN

IF NOT S_MATNR[] IS INITIAL.

<SOME MESSAGE>

ENDIF.

Regards,

Abdul

Message was edited by: Abdul Hakim

Message was edited by: Abdul Hakim

Read only

Former Member
0 Likes
11,481

Hi,

write the below code in AT SELECTION-SCREN.

EX :

AT SELECTION-SCREEN.

*-- Validate the Selection screen data

PERFORM VALIDATE_SELSCR_DATA.

WRITE THE below code in Form "VALIDATE_SELSCR_DATA".

IF S_MATNR[] IS INITIAL.

*--MATNR is initial.

message e000(MsgCLass) with 'matnr is empty'.

ELSE.

SELECT MATNR

INTO MARA-MATNR

FROM MCHA

UP TO 1 ROWS

WHERE MATNR IN S_MATNR.

ENDSELECT.

IF SY-SUBRC <> 0.

MESSAGE E000 WITH 'Invalid MATNR entered'.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
11,480
at selection-screen.
if s_field[] is inital.
message...

else.
select ..

if sy-subrc <> 0.
message ...
endif.

endif.
Read only

Former Member
0 Likes
11,480

Hi murali,

validations are made using the check tables

for ur ex.. for matnr the check table is mara

and code as follows would work

select single matnr

into v_matnr

from mara

where matnr in s_matnr.

if sy-subrc <> 0.

display error message.

endif.

Read only

Former Member
0 Likes
11,480

In the event

at selection-screen.

perform validate_material.

form validate_material.

data: v_matnr type mara-matnr.

if not s_matnr is initial.

select matnr

from mara up to 1 rows

into v_matnr

where matnr in s_matnr.

endselect.

if sy-subrc <> 0.

message exxx(message-id) with 'Please enter valid Material'.

endif.

endif.

endform.

Read only

0 Likes
11,480

hi

use

AT SELECTION-SCREEN

IF NOT S_MATNR[] IS INITIAL.

<SOME MESSAGE>

ENDIF.

plz reward points if it solve dur query!!

Regards

Gunjan

Read only

Former Member
0 Likes
11,480

Hi Murli,

The select-option is stores the data as an internal table and strctly validation to be done if the OPTION is 'EQ'. So on trick is to store all the entries s_matnr-low in an internal table when OPTION is EQ & sign is I.

Then select the data from mara where matnr in s_matnr and store the data in another internal table.

Now compare the two, if the entry is there in select option but not in data retrieved from Mara U can display error message.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
11,480

Hi,

at selection-screen on s_matnr.

if not s_matnr[] is initial.

select single matnr into v_matnr from mara

where matnr in s_matnr.

if sy-subrc ne 0.

message e000 with 'Enter valid Material Number'.

leave list-processing.

endif.

endif.

Kindly reward points if it helps.

Read only

prabhu_04
Explorer
0 Likes
11,480
data : gv_matnr type mara-MATNR.
SELECT-OPTIONS : s_matnr FOR GV_MATNR.
if S_MATNR is INITIAL.
  MESSAGE : 'Enter the Material Number ' TYPE 'E'. 
  ENDIF.