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

calculation on chars

Former Member
0 Likes
2,102

hi all,

I have an amount in a char or string field. On any calculation(even absolute) on that field the decimal value is lost or shifted on either side.

I need this field as char only because I'm concatenating it with a sign.

pls suggest a solution.

Thanks in advance,

Archana

hi all,

I have an amount in a char or string field. On any calculation(even absolute) on that field the decimal value is lost or shifted on either side.

I need this field as char only because I'm concatenating it with a sign.

pls suggest a solution.

Thanks in advance,

Archana

10 REPLIES 10
Read only

christian_wohlfahrt
Active Contributor
0 Likes
1,524

Hi Archana!

How about using field = field * -1 for switching the sign. In output you have several options in write ... using edit mask to place a sign and the decimals.

Regards,

Christian

Read only

Former Member
0 Likes
1,524

Hi Archana,

First do the required calculations not necesary to define as string. While concatenating into another string, simply pass that value into a string type variable. And finally concatenate those 2 strings into the final one.

Regards,

Sudhakar.

Read only

0 Likes
1,524

and just by the way:

Until last week I never tried but this works!!!

variable = - variable.

Might be faster than

variable = variable * -1.

Read only

Former Member
0 Likes
1,524

Initially declare the field as AMOUNT field.

Do, the necessary calculations on the field. Finally move this data into a char field and u can concatenate the '-' value to the char field.

Hope this helps U.

Pl. award appropriate points.

Read only

Former Member
0 Likes
1,524

Hi Archana,

You can convert the String field to char by FM CHAR_FLTP_CONVERSION and then perform the calculations. After the calculations you can again convert the Floating field to char field by using FM FLTP_CHAR_CONVERSION.

Lokesh

Pls. Reward appropriate points.

Read only

Former Member
0 Likes
1,524

Hi,

For putting '-'sign in front of amount you can use

FM 'CLOI_PUT_SIGN_IN_FRONT'.

Always refer currency field with write.

WRITE:/ sum_it-dwrbtr currency bkpf_it-waers.

and remaining manipulation you can do as usual before write statement.

Can i know for which currencies the decimal is lost.

Thanks.

Read only

0 Likes
1,524

Hi Deepak,

initially I have this value in a string field...but as soon as I transfer it into an amount field, the decimal value gets lost or is shifted (as though divided by ten or hundred)...so I actually don reach the stage to reverse the sign...

and I have tried all the above but nothing is working...

pls help...this is very unusual...

Read only

0 Likes
1,524

Hi,

Change your CHAR field to

Data: amnt like bseg-wrbtr.(example).

So that you can do what ever manipulations you want.As i said you need to refer currency field while write statement.

When comes to Decimal for JPY and KOR you wont find Decimals for this currencies.

I hope this will help u.

Thanks.

If this helps u reward with points.

Read only

0 Likes
1,524

Hi Archana!

You need a conversion from string to number - this would even happen implicit in calculation.

Please try further with FM CHAR_FLTP_CONVERSION (or make some own coding like shift left, replace ',.'...). Only in case of correct conversion all the other hints can help.

Regards,

Christian

Read only

Former Member
0 Likes
1,524

first move the string to a variable with type p decimals 2 , carry out the calculations and move back the result to the string.