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: 

currency convert

Former Member
0 Kudos

Hi,

i have a doubt. the value of currency(1,649.20) in excel file. how can we convert in to number(1649.20) into internal table.how can we write the code for this in abap program. pls, anybody send me the reply ASAP..

Thanks & Regards,

sunil.,

5 REPLIES 5

Former Member
0 Kudos

Hi,

While the data is transferred from Excel to itab, it will take as 1649.20. You need not do anything.

Thanks,

Sriram Ponna.

former_member386202
Active Contributor
0 Kudos

Hi,

Declare that variable as type P with 2 decimal places.

Data : lv_amt type p decimals 2.

Regards,

Prashant

Former Member
0 Kudos

Hi,

One thing you need to do is :

Upload the Excel data using FM GUI_UPLOAD. This will upload the table of your excel sheet into internal table.

Then loop the internal table and then use the REPLACE statement to replace ',' with space.

Do F1 to check the syntax.

Also you can use the following FM

CONVERT_TO_FOREIGN_CURRENCY : It converts local currency to foreign currency.

CONVERT_TO_LOCAL_CURRENCY : It converts from foreign currency to local currency

Please revery back if some more doubts are there.

Reward if useful.

Regards,

Lalit

Former Member
0 Kudos

Hello ,

Goto transaction SU3.

goto DEFAULT tab

Change the DECIMAL NOTATION as per your requirement

SAVE

(OR)

lv_text = 12,000.

CALL FUNCTION 'STRING_REPLACE'

EXPORTING

pattern = ','

substitute = space

changing

text = lv_text

EXCEPTIONS

WRONG_STRING_LENGTH = 1

OTHERS = 2.

(OR)

Look at the function module BAPI_CURRENCY_CONV_TO_INTERNAL

With Regards,

BVS

Former Member
0 Kudos

Hi this will work 4 u.

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'

with regards,

Hema Sundara.

pls give points if this helps u.