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: 

Wrong conversion from number to string.

Former Member
0 Kudos

Hi,

We are using now a function to convert a float number to a string. Now, we are using function module C14W_NUMBER_CHAR_CONVERSION but this function doesnu2019t take into account the decimal notation defined in the user parameter. For example if we have decimal notation Y 1 234 567,89 a float number 1.2345666666660000E+03 is converted as 1234,567 instead as 1 234,567 with a blank space.

Does anybody know how to convert in a proper way?

Regards,

Joan B. Altadill

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Joan,

You can try one more thing with WRITE command, as below.

Var1 (Float value)

Var2 (String)

WRITE Var1 to Var2.

Now the Var1 will be converted automatically to Var2 as per user's settings of decimals.

if this doesn't work then 1st convert your float value to packed value then to string.

Hope this helps.

4 REPLIES 4

Former Member
0 Kudos

Hi Joan,

There are two ways to go about this:

1) You can go to your user Settings and modify the decimal notation specific to your profile.

2) Otherwise, you can first convert your float to a simple character format, replace all fullstops with commas and viceversa, and then make the actual conversion.

Let me know if you need the actual code for this.

Cheers,

Shailesh.

0 Kudos

Hi,

We have the user with the appropiate parameter but the function C14W_NUMBER_CHAR_CONVERSION doesn't take into account. The number appears without any separator (only the decimal part is shown using ,). This is the problem, the first option you propose simply does not work.

The second option is not valid because our layouts are used for users with different formats and in such case we have to develop any case in a different way.

Do you know another option?

Regards,

Joan

0 Kudos

Hello,

I agree with the first option : changing the user-setting (change the format of the decimal).

If you change the user-setting make sure that you deconnect from the system and reconnect to test the modification.

Former Member
0 Kudos

Hi Joan,

You can try one more thing with WRITE command, as below.

Var1 (Float value)

Var2 (String)

WRITE Var1 to Var2.

Now the Var1 will be converted automatically to Var2 as per user's settings of decimals.

if this doesn't work then 1st convert your float value to packed value then to string.

Hope this helps.