cancel
Showing results for 
Search instead for 
Did you mean: 

How to do numeric field validation

susmita_panigrahi
Active Participant
0 Kudos

Hi All.

I have one input field of data type decimal.The user should enter the numeric value inside this filed.If he will enter "abcd" then messgae should display Enter numeric value.

How i will do numeric vale validation for context of data type Decimal?

If i am entering numeric value i am getting out put where as if i am entering abcd then i am getting null pointer exception.

Thanks

Susmita

Accepted Solutions (1)

Accepted Solutions (1)

former_member192434
Active Contributor
0 Kudos

Answers (4)

Answers (4)

susmita_panigrahi
Active Participant
0 Kudos

Hi

This issue is solved.I have created a string value attribut and convert it to BigDecimal format before calling the BAPI.

Thanks

Susmita

Former Member
0 Kudos

Hi Susmita,

Numeric is a subset of decimal. If you enter, 666, it will be considered as 666.00 if it is a decimal data type.

If you want to display error on "abcd" format, then

1. Go to dictionaries

2. Move to Simple Type

3. Create a simple type

4. Set its type as decimal

5. Bind that type to the context attribute

This will automatically give an error, if you enter a wrong format in the decimal field

Thanks,

Nikhil

Former Member
0 Kudos

Hi Susmitha,

You doesnt need to write nay seperate code for doing the validation for decimals or alphabets. If you bound the UI element with the Context Attribute of type Decimal the Webdynpro Generic Validation service will automatically validates the user input is Intergers or not. If the user enters the alphabets this service will cancel the navigation and throws an error message to the User

Thanks and Regards,

Raju Bonagiri

Former Member
0 Kudos

In case the data type of the bound context attribute is numeric the WebDynpro Generic Validation Service should check the entered data automatically. In case you can´t use it just try to parse the value into the correct data type and catch the exception. If the exception occurs display a message to the user.