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

Getting incorrect value while converting to USD Currency.

Former Member
0 Likes
3,382

Hi All,

I am trying to convert HUF amount(Hungarian Currency Format) to USD Amount.While doing this calculation exchange rate is taken when the document is created i.e.Doc creation Date..But i want the exchange rate to be exchange rate for today(Day when report is run).

Please Help ASAP.

Code for Currency Conversion which i used is following -

CLEAR wa_po_curr_usd .

     REFRESH  it_po_curr_usd .

     wa_ekko-netpr = wa_ekko-rlwrt.

     IF is_cdhdr-udate IS NOT INITIAL. .

       DATA : lcurr LIKE tcurc-waers .

       IF wa_ekko-waers NE c_usd.

         CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

           EXPORTING

             client           = sy-mandt

             date             = is_cdhdr-udate

             foreign_currency = c_usd

             local_amount     = wa_ekko-netpr

             local_currency   = wa_ekko-waers

             type_of_rate     = 'M'

             read_tcurr       = 'X'

           IMPORTING

          foreign_amount   = wa_ekko-po_cur_usd.

       ELSE.

         wa_ekko-po_cur_usd = wa_ekko-rlwrt.

       ENDIF.

     ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,775

Hi,

Is your question resolved ?

If not, I might be able to work with you to resolve this. Before that, from a functional point of view, here are my assumptions: 

  1. Are you taking the data from Sales Order ?
  2. You are wanting to use the data for the reports ?
  3. You are not considering the Pricing Condition Screen Price for this ?

If all of the assumptions are correct, we can discuss this further

Thanks.

15 REPLIES 15
Read only

venkateswaran_k
Active Contributor
0 Likes
2,775

         CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

           EXPORTING

             client           = sy-mandt

             date             = is_cdhdr-udate     ===== Pass here sy-datum

             foreign_currency = c_usd

             local_amount     = wa_ekko-netpr

             local_currency   = wa_ekko-waers

             type_of_rate     = 'M'

             read_tcurr       = 'X'

           IMPORTING

          foreign_amount   = wa_ekko-po_cur_usd.

       ELSE.

         wa_ekko-po_cur_usd = wa_ekko-rlwrt.

       ENDIF.

     ENDIF.

Read only

0 Likes
2,775

Hi,

Thanks for quick reply.

But I want the date to be last approval date of PO.

Read only

0 Likes
2,775

Check "BAPI_PO_GETRELINFO"  to get release related information of PO. You may find final approval date in its export parameters.

Regards

Read only

0 Likes
2,775

Hi Umesh,

Pass the PO number to this Table.

U will get release date and other release details also,Table : EREV and Field : FGDAT

Read only

Former Member
0 Likes
2,775

Hi Umesh,

use below FM to covery to USD currency,I have used same in my program also.

pass sy-datum to date field.

DATA :  LOCAL_AMOUNT TYPE KONV-KBETR.

IF KONV-WAERS <> 'USD'.

          CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

            EXPORTING

             CLIENT                  = SY-MANDT

              DATE                    = G_GOHEAD-BUDAT     

              FOREIGN_AMOUNT          = KONV-kbetr

              FOREIGN_CURRENCY        = KONV-WAERS

              LOCAL_CURRENCY          = 'USD'

*            RATE                    = 0

             TYPE_OF_RATE            = 'M'

*            READ_TCURR              = 'X'

           IMPORTING

*            EXCHANGE_RATE           =

*            FOREIGN_FACTOR          =

             LOCAL_AMOUNT            = LOCAL_AMOUNT

*            LOCAL_FACTOR            =

*            EXCHANGE_RATEX          =

*            FIXED_RATE              =

*            DERIVED_RATE_TYPE       =

*          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.

* Implement suitable error handling here

          ENDIF.

ENDIF.

Read only

venkateswaran_k
Active Contributor
0 Likes
2,775

Hi

One more thing,,,

type_of_rate     = 'M' 

M - Gives Average Rate

G - Gives Selling Rate

B - Gives buying rate

What is the value you are passing.   If you Pass 'M' it will give you average rate.

Read only

0 Likes
2,775

Hi,

I am passing type_off_rate = M..

is that makes any difference to my USD value conversion.

Thanks in Advance.

Read only

0 Likes
2,775

Probably Yes,  M is the average.    Try with G or B

Read only

Former Member
0 Likes
2,776

Hi,

Is your question resolved ?

If not, I might be able to work with you to resolve this. Before that, from a functional point of view, here are my assumptions: 

  1. Are you taking the data from Sales Order ?
  2. You are wanting to use the data for the reports ?
  3. You are not considering the Pricing Condition Screen Price for this ?

If all of the assumptions are correct, we can discuss this further

Thanks.

Read only

0 Likes
2,775

logic for calculating the exchange rate from PO currency to USD should be like this -

See below PO.

The PO 1st time got released on 12/19/2011 and Proc. State (PROCSTAT of EKKO) status changed from 03 to 05

Again the PO value has been changed and it got changed from 05 to 03 on 07/15/2013

Again the PO has been rejected and value changed from 03 to 08

And again the rejection has been cancelled and the value got changed to 3

So we have to put a  logic that, we need to take the date of last 03 value and give the exchange rate of that day.

Please Help.

Read only

0 Likes
2,775

Hi,

So you are looking for the Purchase Order Scenarios and not Sales Order.

Your information should easily be accessed between these Tables :

EKKO         -     PO Header; 

EKPO         -     PO Item

CDHDR      -     Change Document Header;

CDPOS      -     Change Document Item;

TCURR      -     Currency Table with Exchange Rate Type used by your company.

Thanks.

Read only

0 Likes
2,775

Hi,

My question is "How should i know/calculate the exchange rate for a specific date" i.e. in my case is last PO Updation date.

Read only

0 Likes
2,775

Hi,

I am not having the SAP System in front of me.

I will get back to you soon.

Read only

0 Likes
2,775

Hi,

One of the things I can think of is take the PO Change Date go to the Exchange Rate Table take the conversion factor, check the PO Rate and then do the math.

The Exchange Rate Type M would have it's period. It cannot be forever. Also you might check the table TCURF too for this.

Take the M Type Period and check the date on which you are running the report and use that rate which is relevant for the period.

Unfortunately, I do not have the SAP System in front of me so cannot give too many details, otherwise I would have given more details.

Hope this helps.

Thanks.

PS: One of the things I can say on this report is that it will not be accurate in comparison to the PO as the Exchange Rate Type is really the one which makes it how the rate fluctuations are captured in SAP. There is no way, that you can capture real time dynamic currency rates. This is a struggle in many projects/companies.

Read only

0 Likes
2,775

I am currently looking into TCURR table but not finding exact rate for specific date..

Please Help....