Application Development 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: 

Validation for Select-Option - Issue

former_member305388
Active Contributor
0 Kudos
114

Hi Experts!!

I have a select-option s_field on which I have written a validation under AT SELECTION-SCREEN. Now, the problem is that, if validation fails in second line of s_field, then to change it when we click on Extension, it's not allowing to enter but is throwing error message again and again as AT SELECTION-SCREEN is called.

Suppose, I have entered 2 single values as C001 and F001. s_field will have 2 entries. Now, C001 is a valid value but F001 is not. PFB my code:



LOOP AT s_field.

SELECT SINGLE *
  FROM ztable INTO ls_field
  WHERE field EQ s_field-low.

IF sy-subrc NE 0.
 " Error Message
ENDIF.

ENDLOOP.

Now, for C001, sy-subrc will be 0. But for F001 sy-subrc is 4 and hence will throw an error. Now, to correct this, I am trying to enter into extension, but as this will be called again, I am unable to. Hope I explained it clearly.

I do not see any possibility to correct this. Can anybody please suggest if any workaround can be implemented?

Your help is highly appreciable.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
71

Hi

For validating the Selection Screen Elements try as follow:

At Selection Screen on Input_Field_name ( ie here give your field name for eg: At selection screen on s_field ).

under this write your condition.

At selection screen on s_field

SELECT SINGLE *

FROM ztable INTO ls_field

WHERE field EQ s_field-low.

IF sy-subrc NE 0.

" Error Message

ENDIF.

Thanks,

Renuka.

2 REPLIES 2

Former Member
0 Kudos
72

Hi

For validating the Selection Screen Elements try as follow:

At Selection Screen on Input_Field_name ( ie here give your field name for eg: At selection screen on s_field ).

under this write your condition.

At selection screen on s_field

SELECT SINGLE *

FROM ztable INTO ls_field

WHERE field EQ s_field-low.

IF sy-subrc NE 0.

" Error Message

ENDIF.

Thanks,

Renuka.

Former Member
0 Kudos
71

Hi,

You can try the following:

AT SELECTION-SCREEN on s_field.

LOOP AT s_field.

SELECT SINGLE *

FROM ztable INTO ls_field

WHERE field EQ s_field-low.

IF sy-subrc NE 0.

MESSAGE s398(00) DISPLAY LIKE 'E' with 'ERROR MESSAGE'.

ENDIF.

ENDLOOP.

I hope this works as per your requirement.

<<point-begging removed>>

Edited by: micky prasad on Jan 6, 2012 1:00 PM

Edited by: kishan P on Jan 9, 2012 1:40 PM