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

Round FM always INPUT_INVALID

Former Member
0 Likes
4,009

Hi!


I need to do conversion from/to JPY currency for updating prices. Since the currency does not allow decimal places, I though of rounding off the amount first with 0 decimal places if JPY is the currency.


I am testing FM ROUND in SE37 and I always get INPUT_INVALID Message: Please use a number field for the input value.


I should place a number in the input field, right? I expect that when I put


Decimals 0

Input         24.6

Sign


I will have output


25.


But then I always get the input:invalid error no matter what I enter in the decimals and input field.


Can someone help? Thanks!

Hi!


I need to do conversion from/to JPY currency for updating prices. Since the currency does not allow decimal places, I though of rounding off the amount first with 0 decimal places if JPY is the currency.


I am testing FM ROUND in SE37 and I always get INPUT_INVALID Message: Please use a number field for the input value.


I should place a number in the input field, right? I expect that when I put


Decimals 0

Input         24.6

Sign


I will have output


25.


But then I always get the input:invalid error no matter what I enter in the decimals and input field.


Can someone help? Thanks!

5 REPLIES 5
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
1,926

Hello Regina

Define your input(value) with either TYPE 'P', 'I' or 'F' else it will throw exception of invalid format.

Thanks

Read only

Former Member
0 Likes
1,926

But is 24.6 or 24,6 not of type F?

Read only

0 Likes
1,926

Hello Regina,

Please paste the code written for rounding here.Thanks

Read only

Former Member
0 Likes
1,926

Hi ,

It works inside the code, even though getting error in SE 37 .It is because function module picks import and export parameter based on the variable you are passing to it .

DATA lv_in   TYPE F VALUE '410.73' ,
         LV_P    TYPE P DECIMALS 2 ,
         LV_OUT  TYPE p DECIMALS 0 .
move LV_IN TO LV_P .

CALL FUNCTION 'ROUND'
   EXPORTING
     DECIMALS            = 2
     input               = LV_P
     SIGN                = '+'
  IMPORTING
    OUTPUT              = LV_OUT
* EXCEPTIONS
*   INPUT_INVALID       = 1
*   OVERFLOW            = 2
*   TYPE_INVALID        = 3
*   OTHERS              = 4
           .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


Try this sample code its working fine .


Regards ,

Juneed Manha

Read only

Former Member
1,926

Hi, check FM source code, the only possibility how to get INPUT_INVALID exception is:


* pruefen, ob INPUT eine Zahl ist
   describe field input type t.
   if t ne 'F' and t ne 'P' and t ne 'I'
               and t ne 'a' and t ne 'e'.                      "*063i
     message e310 with 'INPUT' raising input_invalid.
   endif.


So INPUT parameter has to be one of these types. But if you are testing the FM via SE37 -> test/execute, you can not choose data type of the parameter, it's set automatically, and that could be the problem.

Also in the source code you will see that if you send empty SIGN parameter, no rounding will be performed, see documentation in SE37 for the parameter.


Br

Bohuslav