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

Function module to validate input value

Former Member
0 Likes
3,365

Hi all,

can you please provide me the name of the function module to validate input value.

I have a case where i have to validate decimal values. sometimes users may enter wrong decimal values by mistake instead of "0.23" "0..23' and it gives CONVT_NO_NUMBER runtime error so have to come up with some solutions to validate user input.

Please provide me Function module if anybody knows.

Thanks,

8 REPLIES 8
Read only

Former Member
0 Likes
1,907

Try this one


data: lv_htype TYPE dd01v-datatype.

    CALL FUNCTION 'NUMERIC_CHECK'
      EXPORTING
        string_in = my_number
      IMPORTING
        htype     = lv_htype.

    IF lv_htype NE 'NUMC'.
       Raise an error here...
    ENDIF.

Read only

0 Likes
1,907

Hi,

Thanks for the reply but how about decimal values. i have to check on decimal values like if user inputs 0..23 instead of 0.23 it should not raise an system error. with 0.23 also it gives as CHAR.

Thanks,

Read only

0 Likes
1,907

Hi,

While declaring the numeric fields use the below code, this validation will be taken care by SAP itself ;

parameter : dmbtr like bsis-dmbtr.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,907

The standard format checks are taken care by the SAP system itself one need not to validate them.

Ex:

parameters:

p_pack type p decimals 3.

Now, if u try to execute the program with incorrect data ( Ex :0..234 or 0.2345 ) the system itself throws an error message

Read only

Former Member
0 Likes
1,907

Use FM CATS_NUMERIC_INPUT_CHECK

If you maintaining different floating point, assign INTERNAL as 'X'.

Read only

0 Likes
1,907

I had the same requirement and this worked for me... Thanks!

Read only

Former Member
0 Likes
1,907

Hi,

Use try and catch for handling the exceptions and show exception message to user.

exception class : - CX_SY_CONVERSION_NO_NUMBER

Read only

Former Member
0 Likes
1,907

Hi,

Use Split statement on decimal  '.' .

if value are going into three variables then it's wrong input.

Example.

V1 = '0.23'

Split   V1 into V2 V3 V4 .

if V4 IS INITIAL .

"CORRECT ".

ELSE.

"WRONG "

ENDIF.

Check for V1 = '0..24'

value will come in V4 variable .

Regards,

Salil