10-07-2009 6:48 AM
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
10-07-2009 6:56 AM
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?
10-07-2009 6:56 AM
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?
10-07-2009 7:02 AM
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
10-07-2009 3:36 PM
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
10-07-2009 3:46 PM
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
10-07-2009 7:45 AM