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

Validation for US quantity format

former_member609120
Contributor
0 Likes
517

Hi All,

In SAP Transaction VT02N, there is a tab for Additional Data. There is an input field 'Text 3' where the user will enter Gross Weight. I need to validate that the gross weight entered is in US Format.

The issue is that the input field is of type char where the user will enter a quantity.

US format is 123,456.000 i.e After the decimal 3 points and a comma after every 3 digits.

In case the value has 1 digit, 2 digits, 3 digits there is no comma. For 5 digits, 6 digits there will be 1 comma. For 7 digits, there will be 2 commas and so on.

I have already found the user exit.

Can someone suggest how should i validate that there is a comma after every 3 digits. Also input field should only contain '0,1,2,3,4,5,6,7,8,9 , and . '

Thanks,

Vanessa

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
433

try HRCM_STRING_TO_AMOUNT_CONVERT to validate the input. If it's valid, write the number back to a string by preceding it with SET COUNTRY 'US' (don't forget to reset it right after the write), check that the result equals the initial input.

Read only

former_member156446
Active Contributor
0 Likes
433

This would be a permanent and fool proof solution.

SELECT SINGLE dcpfm
        FROM usr01
        INTO lv_decf
        WHERE bname = sy-uname.

      IF lv_decf EQ space OR lv_decf EQ 'Y'.
        REPLACE ',' IN v_c WITH '.'.
      ENDIF.