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: 

Converting char to decimal value format as defined in SU3(User profile)

Former Member
0 Kudos

Hi Techies,

Is there any FM to convert CHAR value into Decimal fomat as defined in SU3.

If we use, WRITE statement for printing the value in decimal format , it shows the value in decimal format correctly

in SU3 transaction , there are three different decimal format notations which can be user specific

I would appreciate your valuable inputs ....

Thanks

Santhosh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

your requirement is not very clear.

can you please explain?

what you have and what you need?

you want your write statement to vary or to be different from user profile setting?

why do you want that?

5 REPLIES 5

Former Member
0 Kudos

your requirement is not very clear.

can you please explain?

what you have and what you need?

you want your write statement to vary or to be different from user profile setting?

why do you want that?

rainer_hbenthal
Active Contributor
0 Kudos

To be honest, i do not understand. You know that write will be the solution, si why dont you use it? Or ist the to clause unknown?


write decimalvar to charvar.

Oops, just saw that you need the other way round, charvar to decimalvar.

So, this is going like this:

check usersettings

depending on decimal setting delete thousand separator

in case you have a comma to separate the decimals turn that to a dot.

now you can assign this to a decimalvar


decimalvar = charvar.

Edited by: Rainer Hübenthal on Oct 7, 2009 8:03 AM

0 Kudos

Hi Techies,

Thanks for all inputs so far. I apologize that I did not explain well.

To be more understood, We have the three type of decimal notation which could be set in SU3 as follows

1.234.567,89

1,234,567.89

1 234 567,89

Based on the setting decimal setting notation here ,I want to display a var of char type

in decimal format.

Going further ,

If input is

input = 491338.52 ( Char type)

If decimal notation format is 1.234.567,89

Output has to be : 491.338,52

If decimal notation format is 1,234,567.89

Output has to be : 491,338.52

If decimal notation format is 1 234 567,89

Output has to be : 491 338,52

Is there a way FM or anyway to do this

Hopefully , you have got it.

One of you guys has given me a valuable input complying to my need,Let me try and get back .

Thanks

Santhosh

0 Kudos

This is my code in a generic method to transform a table into a csvrow

when 'P'.
        tmpstr = <p_field>.
        len = strlen( tmpstr ) - 1.
        tmpstr = tmpstr+0(len).
        if <p_field> < 0.
          sign = '-'.
        else.
          sign = ' '.
        endif.

        case decimalformat.
          when 'X' or 'E'.
            split tmpstr at '.' into int frac.
            ptmp = int.
            write ptmp to cp.
            shift cp left deleting leading space.
            replace all occurrences of '.' in cp with ','.
            concatenate
              s
              sign
              cp
              '.'
              frac
              delimiter
            into s in character mode.

          when 'Y' or 'D'.
            split tmpstr at '.' into int frac.
            ptmp = int.
            write ptmp to cp.
            shift cp left deleting leading space.
            replace all occurrences of ',' in cp with '.'.
            concatenate
              s
              sign
              cp
              ','
              frac
              delimiter
            into s in character mode.

          when ' '.
            concatenate s sign tmpstr delimiter into s in character mode.

          when others.
            concatenate s '????????' delimiter into s in character mode.

        endcase.

where pfield is a fieldsymbol type P. (honestly ist from type any, but determined by RTTI). I needed this cause i want to format the value from "outside" without taking the user settings in consideration as write...to.. is doing.

What i'm doing is to use the write... to... clause modifying the result (change decimal point, thousand separator and sign) according to the demanded decimal notation.

Edited by: Rainer Hübenthal on Oct 7, 2009 4:47 PM

former_member222860
Active Contributor
0 Kudos

Try with this FM

HRCM_STRING_TO_AMOUNT_CONVERT