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

Screen-Validation

Former Member
0 Likes
941

Hi,

Could any post solution for given below requirement.

I have to design validation logic for a selection-screen where I need to input only Numeric values for a field so that it should give an error message if I enter Non-Numeric values.

Thanks,

G sandeep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
899

declare the parameters as type N

parameters : p_numc(10) type N.

Here U can only enter numeric's .. u cannot enter non-numeric values

8 REPLIES 8
Read only

Former Member
0 Likes
900

declare the parameters as type N

parameters : p_numc(10) type N.

Here U can only enter numeric's .. u cannot enter non-numeric values

Read only

faisalatsap
Active Contributor
0 Likes
899

Hi,

Please Test the following Sample Code.

PARAMETERS: pstring TYPE string.

AT SELECTION-SCREEN.

  IF pstring CA '1234567890'.

    MESSAGE 'You enter Nomaric' TYPE 'I'.

  ENDIF.

Test following Too for Non Nomaric

PARAMETERS: pstring TYPE string.

AT SELECTION-SCREEN.

  IF pstring CN '1234567890'.

    MESSAGE 'You enter NON Nomaric' TYPE 'I'.

  ENDIF.

Hope will solve out your problem,

Kind Regards,

Faisal

Read only

Former Member
0 Likes
899

HI,

You can declare the field as Numeric..

Parameter : p_field(10) type N.

OR
Parameter : p_field(10) type C.

AT Selection-screen on p_field.
If NOT p_field CO '1234567890'.
" Error Message.
ENDIF.

Read only

Former Member
0 Likes
899

Hi Sandeep,

You can achieve that by either:

1. create a select-option which refer to integer data type. By default SAP will do automatic checking of the input against the data type, or

2. Create your own validation using event AT SELECTION SCREEN ON <select-option>.

LOOP at <select-option>.

IF NOT <select-option>-low CO '1234567890'.

  • throw the message

ENDIF.

IF NOT <select-option>-high CO '1234567890'.

  • throw the message

ENDIF.

ENDLOOP.

Regards,

Lim...

Read only

Former Member
0 Likes
899

Hi,

Define the parameter type as 'N', So when you are entering non numaric value in that selection screen it doesnt allow you

Regards

Ramakrishna Pathi

Read only

Former Member
0 Likes
899

PARAMETER p_numc TYPE string.

AT SELECTION-SCREEN.

DATA: lw_out TYPE string,

lw_htype TYPE dd01v-datatype.

CALL FUNCTION 'NUMERIC_CHECK'

EXPORTING

string_in = p_numc

IMPORTING

string_out = lw_out

htype = lw_htype.

CHECK lw_htype <> 'NUMC'.

  • ERROR MESSAGE

Read only

Former Member
0 Likes
899

hi,

Declare the parameter as N i.e numeric.

This will not allow ant non- numeric values.

Thanks

Suraj

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
899

Hi,

U can use the FM 'NUMERIC_CHECK'.

The import parameter is STRING_IN. If u are entering numeric values, like 0 to 9..it will display the output parameter STRING_OUT as inputed number padded with zeros and HTYPE as NUMC, which means the value entered is numeric.

If u enter any non numeric value, this will output the HTYPE value as CHAR.

Keerthi.