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

Currency formatting

Former Member
0 Likes
2,155

Hi Experts,

I have a field dtvbdpr-grwrt which is of type CURR (Currency format length = 13, decimal = 2). Now the value for this field coming in debugging is 25515.00, however I need to store only 25515 in this field without decimals. How can I do that?

I tried dtvbdpr-grwrt = floor( dtvbdpr-grwrt ) and dtvbdpr-grwrt = TRUNC( dtvbdpr-grwrt ); it does not work.

Its quite urgent. Rewards will given for any helpful suggestion.

Regards,

Raman

Hi Experts,

I have a field dtvbdpr-grwrt which is of type CURR (Currency format length = 13, decimal = 2). Now the value for this field coming in debugging is 25515.00, however I need to store only 25515 in this field without decimals. How can I do that?

I tried dtvbdpr-grwrt = floor( dtvbdpr-grwrt ) and dtvbdpr-grwrt = TRUNC( dtvbdpr-grwrt ); it does not work.

Its quite urgent. Rewards will given for any helpful suggestion.

Regards,

Raman

11 REPLIES 11
Read only

Former Member
0 Likes
1,668

Hi

Declare a TYPE I field and move that field to I type field and see.In script you can use (.0) along with the field for not displaying the decimals. &VBDKR-NETWR(.0)&

Explore the following maths related functions.

<b>abs</b> -Absolute value of the argument arg

<b>sign-</b> Plus/minus sign of the argument arg: -1, if the value of arg is negative; 0 if the value of arg is 0; 1 if the value of arg is positive.

<b>ceil</b> -Smallest integer number that is not smaller than the value of the argument arg.

<b>floor-</b> Largest integer number that is not larger than the value of the argument arg.

<b>trunc</b>- Value of the integer part of the argument arg

<b>frac</b>- Value of the decimal places of the argument arg

Reward points if useful

Regards

Anji

Message was edited by:

Anji Reddy Vangala

Read only

0 Likes
1,668

Thanks for the quick reply Anji,

If i store it in a CHAR field, then there is no issues. But my requirement is that i need to store it in the currency field dtvbdpr-grwrt only.

Regards,

Raman

Read only

Former Member
0 Likes
1,668

hi,

Use any of these FM.

HR_IN_ROUND_AMT

HR_NZ_ROUNDING_DECIMALS

Alternatively use the FM's 
1) ROUND_AMOUNT
2) FI_ROUND_AMOUNT

Regards

Reshma

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,668

Hi

you can use simply.

dtvbdpr-grwrt = dtvbdpr-grwrt(5) na.

U can use the FM's

ROUND_AMOUNT also for the same purpose.

Regards,

Sreeram Kumar.Madisetty

Message was edited by:

sree ram

Read only

0 Likes
1,668

Hi Sree,

I tried dtvbdpr-grwrt(5) but it gives me a syntax error that this operation cannot be performed on currency fields.

Regards,

Raman

Read only

0 Likes
1,668

try FM FTR_CORR_SWIFT_DELETE_ENDZERO

Read only

0 Likes
1,668

Hi Raman,

you can't achieve this functionality as system internally treat this field as field with two decimals.

So either you have define a char field and pass value to it.

Reward points if useful.

Regards,

Atish

Read only

Former Member
0 Likes
1,668

Hi Raman,

SAP stores all currency type fields internally with 2 decimals. Currency amout field is linked to the currency and formatted based on the specific currency configuration. For example Bahrain dinar which has decimal places, an amount of 2320.234, will be stored internally as 23202.34. So the requirement for rounding shoulb be based on currency.

This might be helpful to you .

<a href="http://raviinsap.blogspot.com/2007/10/roundinf-off-of-amount-fields-in-sap.html">Rounding off Amount fields in SAP</a>

Ravi

Read only

Former Member
0 Likes
1,668

Hi Raman,

Alternatively, you can define a new currency just for your purpose with number of decimals 0, similar to Japanese yen.

Ravi

Read only

Former Member
0 Likes
1,668

Hi USe :

Write dtvbdpr-grwrt to l_grwrt CURRENCY 'JPY' .

where l_grwrt will be type C(15)

It will work!!

Thanks Praveen

Read only

Former Member
0 Likes
1,668

For moving currency amounts into your field, you should use FM CURRENCY_AMOUNT_IDOC_TO_SAP. For displaying the amount from your field, you should use either WRITE ... CURRENCY ... either FM CURRENCY_AMOUNT_SAP_TO_IDOC. By this may, SAP always take care of decimals according to the currency and you never have to multiply or divide by 100.