Application Development 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: 

number format error in ECC

Former Member
0 Kudos

Hi All,

I feel its routine question , but i'm facing strange issue.

I had gone through SDN and google and not found any solution.

My Issue : while entering amount in amount field , system raising error as number format should be in __.__,__~

From UI(NON-SAP system) user will enter amount value in any format, I have to convert into internal format in ECC system.

sample formats :

10000.00

10.000,00

10,000.00

I aware that these formats are based on user logon credentials .

my problem is im not able to convert amount from external format(10000.00) to internal format(10,000.00).

I have tried with the below possibilities.

1. tried with BAPI_CURRENCY_CONV_TO_INTERNAL .

    when im triggering the BAPI in background , im getting output as 10000.00

Followed the below URL's :

http://wiki.scn.sap.com/wiki/display/ABAP/Conversion+from+external+to+internal+number+format

https://scn.sap.com/thread/1040214

convert to internal format | SCN

https://scn.sap.com/thread/112768

I have tried all the possibilities which i have ,

Please suggest ,

Please don't consider this as basic question and lock this thread.

Regards,

Laxmi.

11 REPLIES 11

Former Member
0 Kudos

hi laxmi,

which data type you are using for the amount?

Does it has corresponding currency field?

0 Kudos

Hi Abdul,

Im using BSEG-WRBTR field

0 Kudos

In module pool the bseg-wrbtr format is deriving form the dictionary.

at which step you are getting error?

0 Kudos

Hi Abdul,

Actually , im trying to execute my RFC Function module(it consists of BDC code ) from UI , but while executing the RFC from out of system im facing the issue.

Clemenss
Active Contributor
0 Kudos

Hi,

just use FUNCTION 'RS_CONV_EX_2_IN' - this is what SAP does in editable ALV. It will respect user settings and everything. ou have to specify the field and structure name of your target, i.e.

  DATA:

    ls_tabfield TYPE tabfield,

    lv_value    TYPE bseg-wrbtr,

    lv_text     type text80.

  lv_text               = '10,000.00'. "or what ever your input is

  ls_tabfield-tabname   = 'BSEG'. "#EC_NOTEXT

  ls_tabfield-fieldname = 'WRBTR'. "#EC_NOTEXT

  CALL FUNCTION 'RS_CONV_EX_2_IN'

    EXPORTING

      input_external                     = lv_text

      table_field                        = ls_tabfield

*     CURRENCY                           = CURRENCY

    IMPORTING

      output_internal                    = lv_value

    EXCEPTIONS

      input_not_numerical                = 1

      too_many_decimals                  = 2

      more_than_one_sign                 = 3

      ill_thousand_separator_dist        = 4

      too_many_digits                    = 5

      sign_for_unsigned                  = 6

      too_large                          = 7

      too_small                          = 8

      invalid_date_format                = 9

      invalid_date                       = 10

      invalid_time_format                = 11

      invalid_time                       = 12

      invalid_hex_digit                  = 13

      unexpected_error                   = 14

      invalid_fieldname                  = 15

      field_and_descr_incompatible       = 16

      input_too_long                     = 17

      no_decimals                        = 18

      invalid_float                      = 19

      conversion_exit_error              = 20

      OTHERS                             = 21

            .

  IF sy-subrc <> 0.

    RAISE EXCEPTION ...

  ENDIF.

Make sure the bacth or RFC user uses rewuired logon language and has appropriate user settings.


Regards, Clemens

Former Member
0 Kudos

Hi Clemens ,

I have tried the same code in my system , im getting error as description not found for the target field.

Please help me...,

Regards,

Laxmi.

0 Kudos

Hi Clemens,

The above FM is not working for me.

My scenario is : I need to convert amount to internal format .

for ex : if user enters 10000.00 and user decimal notation(in user defaults) is 'X', then i needs to convert the amount to 10.000,00.

By using the above FM :

  1. its not accepting 10,000.00 as input .

  2. if i pass amount 3.04 as input its not accepting , and raising error as Correct the distance (2)                 between "." and "." or "." and ",".

 

I need a logic which will convert amount from any format to internal format based on user defaults.

Please suggest .

0 Kudos

Hi laxmiredd,

if the SAP standard function 'RS_CONV_EX_2_IN' does not accept 10,000.00 as input, then the current users format settings are different. Standard US settings will convert 10,000.00 or 10000.00 to internal representation of 10000.00 in BCD field BSEG-WRBTR.

If the conversion to internal format is successful, a simple WRITE lv_value to lv_text will format it according to current users settings, i.e. 10,000.00 in US settings or 10.000,00 in German representation.

If the input data come in mixed formats and the output format has to be switched within processing, I don't know exactly how to proceed. You may post a tyble of input values and expected output values and give conditions on 'user settings'.

If you encounter any error in SAP, please give message ID TYPE and NUMBER, Thanky you.

Regards, Clemens

former_member195402
Active Contributor
0 Kudos

Hi Laxmi,

the internal format will only show one comma or point (depending on your settings) to separate the pre-decimal point positions from the decimal places.

So 10000.00 and 10000,00 will be internal formats, the other ones (10,000.00 / 10.000,00) are external formats.

But don't forget: Also in the internal formats there is not really a comma or point, they are only logical separators depending on the domain definition (which may differ for special currencies or units) for currency or unit depending values.

Regards,

Klaus

0 Kudos

Hi Klaus,

as far as I know there is no such thing as user settings for internal format. SAP will always use a dot as decimal separator, i.e. when moving a decimal to a char field. And you are right, the dot does not exist (as it's all binary) but it is derived from domain definition or derived from associated currency or unit field.

Default and standard ABAP have the 'fixed point arithmetics' characteristic flagged in program properties. That means the decimal point is taken into consideration for calculations. In some old SAP programs, i.e. the pricing routines in function pool LV61A, we have no 'fixed point arithmetics' resulting in 10.0 * 10.0 = 1000.0. Generations of consultants don't understand why but know they have to divide the result of multiplications by 10.

Admitted, that's far off topic - but at least amusing that SAP never changed that.

So whatever program you are working on, make sure 'fixed point arithmetics' is checked or adjust all multiplications and divisions.

Regards, Clemens

vijayanandpaul_puvvula3
Active Participant
0 Kudos

Hello Lakshmi,

I had similar issue with currency amounts in SAP. The following FM takes amount and the currency and output the correct amount.

Use the following logic and it should work. It takes NETWR / WRBTR / any currency amount. converts to BAPI format, gets the amount in correct format and converts back to your NETWR / WRBTR etc. You can create a FM with Importing I_CURRENCY = 'USD' / 'KRW' / 'JPY' etc and changing the C_AMOUNT type NETWR.

  DATA: gv_netwr TYPE bapicurr-bapicurr.



  gv_netwr = c_amount.



  CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_BAPI'

    EXPORTING

      currency    = i_currency

      sap_amount  = gv_netwr

    IMPORTING

      bapi_amount = gv_netwr.



  IF sy-subrc = 0.

    c_amount = gv_netwr.

  ENDIF.