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 Conversion in SAP Query

Former Member
0 Kudos

Hi,

I have created a query where I am reading a table with currency = NOK. I need to convert this currency to EUR before saving it to a file. I have searched SAP Library and found the "Convert" function under ABC Analysis, but I do not think I can use this since I am going to save directly to a file. (In DBF Format). Somebody know how to solve this? Another possibility could be to be able to save in DBF-format directly from the MCIS (Information structure)reports, but I think this is not possible?

Thankful for any answers

Best Regards

Ellen Odegaard

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

Hi,

you're talking about sq01 / sq02 `

than you can solve it with an additional field (e.g. btr2)and an additional coding at event GET / record processing

-> use fm 'CONVERT_TO_LOCAL_CURRENCY' to convert your value

regards Andreas

10 REPLIES 10

Former Member
0 Kudos

Hi,

Please try CURRENCY_DOCUMENT_CONVERT.

andreas_mann3
Active Contributor
0 Kudos

Hi,

you're talking about sq01 / sq02 `

than you can solve it with an additional field (e.g. btr2)and an additional coding at event GET / record processing

-> use fm 'CONVERT_TO_LOCAL_CURRENCY' to convert your value

regards Andreas

0 Kudos

Hi Andreas,

yes I am using SQ01, SQ02. I think you can help me with my questions, but I am not an advanced user/programmer. Therefore I have additional questions for you which I hope you can help me with:

1. How can I create an extra field? I have app. 10 currency fields and then I would like to have only the fields in the new currency, not the old. (Because of the list width) Do I have to adjust the table?

2. How can I create an additional coding at event GET / record processing?

3. How can I insert formulas in queries? In the table I use it is only one currency..

Hope you still find the energy to help me

Best regards

Ellen

0 Kudos

hi,

in SQ02 there is a option called EXTRAS, click that one you find additional field/code/

add one field

curr1 like vbap-netpr then click code there you write relevant procedure for currency conversion

for ex in your case use FM CONVERT_TO_LOCAL_CURRENCY for this fm you should pass from currency, to currency , type,date and value

cheers,

sasi

0 Kudos

Hi

I am getting closer and closer to the solution! Now I have created an extra field in the Infoset in SQ02, called testcurr. Then I selected the tab "code".

And new questions appeared:

1 I entered the function module in "coding section" = Record Processing like mentioned earlier.

2 Should I enter the whole source code of the function module CONVERT_TO_LOCAL_CURRENCY in her?

3 How do I pass the variables?

from currency (= fixed value NOK) and to Currency (= fixed value= EUR). What type should I use? And the date and value are variables, so how could I put them in here?

Sorry about all these questions, but If you don't ask you will get no answers

Best regards

Ellen

Message was edited by: Ellen Odegaard

0 Kudos

hi,

1. in the new field you can see the code for the relevant field ( or try with start-of-selection)

2. yes there you should place the FM

from_currency = 'NOK'

to_currency = 'EUR'

date = sy-datum

value = vbap~netpr ( table name ~ field name)

cheers,

sasi

0 Kudos

Hi again

The point 2 is still not clear for me..

1. Should I put in the source code (256 lines) of the function module here, or should I just put in a reference to the Function module like:

FM convert_to_local_currency;

2. Where should I put in the import variables you refer to?

3. When I push "single test" of the Function module I get these import parameters:

CLIENT 210

DATE

FOREIGN_AMOUNT

FOREIGN_CURRENCY

LOCAL_CURRENCY

RATE 0

TYPE_OF_RATE M

READ_TCURR X

Is this the import parameters you are reffering to?

Best regards

Ellen

0 Kudos

hi,

don't put source code, just call the function module

goto one program (se38 ) in pattern - > enter the function module , it list out the fm details then copy the FM and paste it into the sq02

the importing parameters are correct

here i don't have system otherwiste i will paste exact code,

cheers,

sasi

0 Kudos

Hi ,

only the call of the fm:

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
     EXPORTING
          date             = sy-datum
          foreign_amount   = BSEG-DMBTR "your table-field
          foreign_currency = 'NOK'
          local_currency   = 'EUR'
     IMPORTING
          local_amount     = testcurr. "your add. field

Andreas

0 Kudos

Thank you all very much

I was able to generate the infoset now, and hopefully it works also by testing..

I have never tried this forum before, and this was a very positive experience

Best Regards

Ellen