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: 

Hello All, an urgent issue:- Currency Format

Former Member
0 Kudos
654

Hello All,

I created one program which download & printed the report after selecting the correspondence Radio button.

While I am downloading the file on local system it will download as .txt file format & while I select the radio button “printed report” it will do it for correspondence invoice number.

My issue is.

In output I have few currency values in diff field. Now User want those value should come in this format (1.000.000,00) every time.

So is there any function module which can convert the currency value format which user want? Or do I have to do some coding, if yes then what it should be.

Because here user want whatever system format should be but value come in that format only in both condition either downloading the file or printed one.

6 REPLIES 6

Former Member
0 Kudos
284

Hi,

Check out in this way ..


Call function 'BAPI_CURRENCY_CONV_TO_INTERNAL '
Exporting
currency = 'USD'
Amount External = V_Amount
Importing
Amount External = V_Amt

Regards,

Santosh

0 Kudos
284

Hi Santosh,

Thanks for your help, but my issue is format the ammount figure.

for example: if my system setting is to show ammount figure is 100,000,000.00 so in output it should come in 100.000.000,00.

user want in whatever setting he has in output ammount fig should come in that format.

0 Kudos
284

Sonu,

Try with below example.

Currency Conversion:

______________________

Use the function module

CONVERT_TO_LOCAL_CURRENCY

Writing currency amount to string without thousands seperator

This is usefull e.g. i connection with batch input/call transaction.

GI_OUTPUT-WRBTR: Field type Currency with amount

L_AMOUNT_STRING: Field type c with amount

PERFORM AMOUNT_TO_STRING USING GI_OUTPUT-WRBTR

CHANGING L_AMOUNT_STRING.

FORM AMOUNT_TO_STRING USING P_AMOUNT

CHANGING P_AMOUNT_STRING.

DATA L_SEP(1) TYPE C.

PERFORM GET_THOUSAND_SEPERATOR USING L_SEP.

WRITE P_AMOUNT TO P_AMOUNT_STRING.

REPLACE L_SEP WITH ' ' INTO P_AMOUNT_STRING.

CONDENSE P_AMOUNT_STRING NO-GAPS.

WRITE P_AMOUNT_STRING TO P_AMOUNT_STRING RIGHT-JUSTIFIED.

ENDFORM.

FORM GET_THOUSAND_SEPERATOR USING P_SEP.

DATA: L_AMOUNT LIKE BSEG-DMBTR,

L_AMOUNT_STRING(15) TYPE C.

Find 1000 seperator. If decimal seperator = . then

1000 seperator = , else 1000 seperator = .

L_AMOUNT = '1.00'.

WRITE L_AMOUNT TO L_AMOUNT_STRING.

IF L_AMOUNT_STRING CS ','.

P_SEP = '.'.

ELSE.

P_SEP = ','.

ENDIF.

ENDFORM.

Convert amount to/from string

CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'

EXPORTING

betrg = 3000

WAERS = 'DKK'

NEW_DECIMAL_SEPARATOR =

NEW_THOUSANDS_SEPARATOR =

IMPORTING

STRING = slam

.

CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'

EXPORTING

string = slam2

DECIMAL_SEPARATOR = '.'

THOUSANDS_SEPARATOR =

WAERS = 'HUF'

IMPORTING

BETRG = b2

EXCEPTIONS

CONVERT_ERROR = 1

OTHERS = 2

Language depending formatting

To format a currency amount with decimals according to the currency use

WRITE and the CURRENCY option.

Currency keys an d numbers of decimals are defined in table TCURX Decimal

Places in Currencies.

E.G.

Formatting an amount in Kuwatian Dinars:

Dmbtr = 123456.

Write dmbtr currency 'KUD'

123.456

Write dmbtr currency 'USD'

1234.56

Note that the formatting does not depend on the number of decimals in the

number in the program.

Dmbtr = '12.3456'.

Write dmbtr currency 'USD'

1234.56

To format the decimal and thousand sepearators according to the settings for

a specific country,

use the statement SET COUNTRY <country key>

Settings for countries are defined in table T005 Countries.

The country key used in the statement is field LAND1

E.g.

set country 'US'

Don't forget to reward if useful....

Former Member
0 Kudos
284

use FM: CONVERT_TO_LOCAL_CURRENCY

0 Kudos
284

yes, you should be use the command SET COUNTRY( here, you have diff formats ) and WRITE (check all of form you have to do that in help).

Regards,

Alexandre

Former Member
0 Kudos
284

You need to set this In his user profile.

systems->user profile->own data->defaults(TAB)----Decimal notation(Choose the first radio button)