cancel
Showing results for 
Search instead for 
Did you mean: 

FM

Aummad
Participant
0 Kudos

hi,

some one please help me to understand the fm.

RSAR_CURRENCY_CONVERT.

CALL FUNCTION 'RSAR_CURRENCY_CONVERT'

EXPORTING

I_CURRENCY = S_DATAPAK-CURRENCY

CHANGING

C_AMOUNT = V_AMOUNT.

.

V_PRC = V_AMOUNT.

S_DATAPAK-/BIC/CPTPRI = V_PRC..

and also what is th meaning of

IF S_DATAPAK-/BIC/CPTPRI CO ' 0123456789

Thanks

Message was edited by:

Rob

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rob,

This FM RSAR_CURRENCY_CONVERT basically checks in TCURX table (table for Decimal Places in Currencies) and converts your amount based on that.

Here is the code.

DATA: shift TYPE i,

decimals TYPE i,

tmp TYPE p DECIMALS 2,

l_s_curx TYPE tcurx.

SELECT SINGLE * FROM tcurx INTO l_s_curx

WHERE currkey = i_currency.

IF sy-subrc = 0.

decimals = l_s_curx-currdec.

shift = 2 - l_s_curx-currdec.

ELSE.

  • if currency is not known, then use 2 decimals.

shift = 0.

ENDIF.

  • Number of decimals is given by table tcurc

  • too many decimals will simply be ignored

tmp = c_amount / 10 ** shift.

c_amount = tmp.

ENDFUNCTION.

Lets say your currency key (from source data is) USD.

Go to table TCURX and see number of decimal places for it.

Lets say it is 5.

C_Amount = 100 (on which this conversion is going to be applied)

so your decimal will become 5 and shift = -3

And then the tmp = 100/10 exp -3 (Double * is used for Exponential)

So tmp = C_Amount = 100000.00 (as tmp is of type decimal with 2 decimal points see declaration)

In your case you are passing the DATAPAK-Curreny and v_amount to this function module.And then changing

V_PRC = V_AMOUNT. and making your KF -/BIC/CPTPRI equal to V_PRC

S_DATAPAK-/BIC/CPTPRI = V_PRC

and also what is th meaning of

IF S_DATAPAK-/BIC/CPTPRI CO ' 0123456789

This means BIC/CPTPRI contains values like ' 0123456789'

You can check this by placing csor in ABAP code and press F1 (Function Key)

Hope it helps

Thanks

Chitrarth Kastwar

Answers (2)

Answers (2)

Former Member
0 Kudos

omeone please help me to connect vbak vbep and vbuk tables by using generic extraction by using function module

Former Member
0 Kudos

Hi Rob,

RSAR_CURRENCY_CONVERT

Basically this will take your input parameters I_CURRENCY and C_AMOUNT. then using table TCURX will use the CURRDEC field to shift the decimal place n amount of places to the left if the CURRKEY is maintained or does not move decimal place if not recognised or not maintained to do so.

So in your case the imput values will be S_DATAPAK-CURRENCY and S_DATAPAK-/BIC/CPTPRI, so if you use degugging you will be able to see what values S_DATAPAK-CURRENCY and S_DATAPAK-/BIC/CPTPRI are then try manually use the FM in SE37 to clearly see what is happening

Regards

Ben

PS assign points if useful