cancel
Showing results for 
Search instead for 
Did you mean: 

How to ensure only a numeric value is entered into an amount field?

former_member195355
Participant
0 Kudos

Hiya,

Is there anyway to ensure a numeric field can only have numeric values added to it?

I have this situation for an input table:

Each of these elments is linked to an amount field but the user can currently enter whatever they like e.g. hello!

Accepted Solutions (0)

Answers (3)

Answers (3)

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

The standard data type check ensures that the value of amount field contains only numeric But it happens upon any action on alv table. So, you are getting message displayed after scroll, or some other action.

I don't think you can restrict the user entering non-numeric in the amount field with this standard check i.e. raise an error message as soon as user key in non-numeric value.

Regards,

Rama

Former Member
0 Kudos

On save check the all value with the help of Comparison operator..

          Comparing Strings (SAP Library - ABAP Programming (BC-ABA))

I think this will work..  read the attribute value, let say lv_attribute..

IF lv_attribute CN  '1234567890.'.    "if true, means some alphabet is here..


<show some error message >


endif.

former_member222068
Active Participant
0 Kudos

Hi Robert,

Use the data element of currency type.

Thanks & Regards,

Sankar Gelivi

former_member195355
Participant
0 Kudos

Hi Sankar,

Thanks for replying.

I'm not sure if I understand what you're saying - if I use a data element of currency type it won't let me add numeric values will it?

In anycase I have found that it does work and the followign message appears:

It's just that you need to scroll up/down the table first?!

Weird?

Does anyone know why that might be?

Thanks!