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

passing value to function module

Former Member
0 Likes
1,019

Hi.

i want to pass th values thru function mudule of currency field.

please reply.

local currency can be any currency and value coming from eban-rlwrt and foreign currency has to be USD only and has to output foreign amount in USD .Also,the local amount will come from RLWRT.

how to pass values thru FM 'CONVERT_TO_FOREIGN_CURRENCY'.

please tell me how to declare the variable and to be put in the importing and exporting parameters.

i am trying hard to learn this as i am a bit novice.

thnks!

8 REPLIES 8
Read only

Former Member
0 Likes
892

local curr---> loc type RLWRT.

and for curr--->for type RLWRT.

same data type can be used...

Read only

0 Likes
892

how to define the foreign amount which will be outputted with the currency always to be in USD.?

Read only

0 Likes
892

Hi,

data : f_curr type WAERS value 'USD'.

Now pass f_curr to FOREIGN_CURRENCY parameter

regards,

Advait

Read only

Former Member
0 Likes
892

Hi,

Take a look at the documentation of the function and find the below example in it :



CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

    EXPORTING   DATE             = BKPF-WWERT

                FOREIGN_CURRENCY = BKPF-WAERS

                LOCAL_CURRENCY   = T001-WAERS

                 LOCAL_AMOUNT     = BSEG-DMBTR

                 RATE             = BKPF-KURSF

                 TYPE_OF_RATE     = 'M'

    IMPORTING   EXCHANGE_RATE    = KURS

                FOREIGN_AMOUNT   = BSEG-WRBTR

                FOREIGN_FACTOR   = FAKTOR-F

                 LOCAL_FACTOR     = FAKTOR-L

    EXCEPTIONS  NO_RATE_FOUND    = 4

                NO_FACTORS_FOUND = 8.


So you will declare the variables as the same type as passed here i.e BKPF-WWERT, BKPF-WAERS, BSEG-DMBTR and so on.

regards,

Advait

Read only

Former Member
0 Likes
892

Hi,

I have seen one code in book Common SAP R/3 Functions Manual

By William Lawlor. which converts local currency to foreign currency.

I made bit changes in parameters like made foreigh currency as USD.

Execute the program and check.

Data: xrate type f,

famt type p,

ffact type f,

lfact type f.

parameters:fcurr like TCURC-WAERS default 'USD',

lcurr like TCURC-WAERS,

lamt type p.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

  • CLIENT = SY-MANDT

DATE = sy-datum

FOREIGN_CURRENCY = fcurr

LOCAL_AMOUNT = lamt

LOCAL_CURRENCY = lcurr

  • RATE = 0

  • TYPE_OF_RATE = 'M'

  • READ_TCURR = 'X'

IMPORTING

EXCHANGE_RATE = xrate

FOREIGN_AMOUNT = famt

FOREIGN_FACTOR = ffact

LOCAL_FACTOR = lfact

  • EXCHANGE_RATEX =

  • DERIVED_RATE_TYPE =

  • FIXED_RATE =

EXCEPTIONS

NO_RATE_FOUND = 1

OVERFLOW = 2

NO_FACTORS_FOUND = 3

NO_SPREAD_FOUND = 4

DERIVED_2_TIMES = 5

OTHERS = 6

.

IF SY-SUBRC = 0.

write:/ lamt, 'converted form', lcurr, 'to', fcurr, 'is:', famt.

else.

write:/ lamt, 'not converted'.

ENDIF.

Hope this helps you.

Cheers!!

VEnk@

Edited by: Venkat Reddy on Oct 31, 2008 5:14 PM

Read only

0 Likes
892

it is giving parameter error while declaring lcurr.Also please mention how to put lamt from eban-rlwrt.

thanks in adv.

Read only

0 Likes
892

You can pass the value eban-RLWRT as it is.

There is no data type defined for the parameters

FOREIGN_CURRENCY)

VALUE(LOCAL_AMOUNT)

VALUE(LOCAL_CURRENCY)

VALUE(RATE) DEFAULT 0

So you can pass eban-rlwrt directly.

regards,

Advait

Read only

0 Likes
892

Hi,

I have tried with an idea as you said local currency might be anything.

So in the first two parameters in have shown you to select the currency type, and as you were asked like you want USD should be foreign currency always i kept it as default one.

And i have created a search help ZEBAN where i have given table as EBAN and in parameters i gave RLWRT as field so that when i execute the report i can give the amount from eban table and select the amount from EBAN-RLWRT.

Just changes to the above code in the place of parameters.

parameters:fcurr like TCURC-WAERS default 'USD',

lcurr like TCURC-WAERS,

lamt like eban-rlwrt matchcode object zeban.

Hope you got my idea.

Cheers!!

VEnk@

Edited by: Venkat Reddy on Oct 31, 2008 7:06 PM