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: 

decimal places adjustment based on company code or currency

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

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.

0 Kudos

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.

0 Kudos

so instead of round you need to cut?

0 Kudos

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

0 Kudos

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

koolspy_ultimate
Active Contributor
0 Kudos

just use


replace all occurrences of '.' with ''.