05-12-2011 9:52 AM
Hi experts,
my requirement is i have to adjust the decimal places in amount fields of internal table based on company code or currency given by user.
suppose for example in my internal tables having 5 amount fields like 1.50 1.234 1.45 1.34, 1.67 for company code is in01
the same values for VN01 should be like this
150 1234 145 134 167 ....
can any body plz tell me any functional module is there to covert or abapcode?
Thanks in advance,
veena.
05-12-2011 10:01 AM
i would suggest you to host a second internal table where your amount field are actually of type char. E.G. char20.
You can then use the WRITE TO statement with the DECIMALS addition in order to get what you want written to this char fields.
Then you can use this new internal table for output issues.
05-12-2011 10:12 AM
My report was clasical report so my amount fieds are not in only one table and when i am using write to it is giving round vale but thats not my requirement.
05-12-2011 10:15 AM
05-12-2011 10:53 AM
Hi,
Define a variable type String.
Data : Var type string.
If BUKRS = 'XYZ'.
Var = '1.45'.
REPLACE ALL OCCURRENCES OF '.' in Var WITH space.
endif.
Try This.
Sample Code.
DATA : var TYPE p DECIMALS 2.
DATA : STR TYPE STRING.
var = '1.45'.
STR = VAR.
REPLACE ALL OCCURRENCES OF '.' in str WITH space.
WRITE : str.
Sameer
05-12-2011 7:04 PM
That code is a bad idea. Why would you hard-code that type of action for currency/amount handling?
@poster: If the output is based on the local currency defined for the specified company code or one specified by the user, then use it. SAP handles amount output automatically with a currency specification because the currency definition identifies where/how the decimal is output.
Just use WRITE as Florian indicated but use the CURRENCY extension instead of DECIMALS. You can do this dynamically based on the company code easily...
A simple 3 line program shows you how this works:
PARAMETERS: p_wrbtr type wrbtr.
write:/ p_wrbtr CURRENCY 'USD'.
write:/ p_wrbtr CURRENCY 'JPY'.
Edited by: Brad Bohn on May 12, 2011 1:07 PM
05-16-2011 9:25 AM