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: 

Dump while converting data for exchange rates.

former_member565051
Participant

Hello Expert,

I am importing the list of currency exchange values from the flat file and after some clean-ups, passing the file data to the BAPI

BAPI_EXCHRATE_CREATEMULTIPLE.

To pass the exchange rate, the data-type used by BAPI is UKURSP (length 9, decimal 5). So i am assigning my CHAR values to the bapi-data type to get he 5 decimal value.

It is working correctly if exchange value from the CSV file is, for eg, 0007.6269000 --> getting converted to 7.62690

but i am getting dump when the value is 15973.900000. This is not getting converted to 5 decimal required for BAPI;s field UKURSP.

How to solve the problem?

Kindly advise.

1 ACCEPTED SOLUTION

michael_piesche
Active Contributor

Please post the error message next time.

The value cannot be casted into the currency field, as it is too big:

  • The source value 15973.900000 hast 5 characters before the decimal point and 6 characters after the decimal point, whereas only the first is relevant, as the others are all 0.
    => So you would need a type that has at least 5 characters before and at least 1 character after the decimal point
  • The type UKURSP has in total 9 characters, 4 before the decimal point, and 5 after the decimal point
    => Therefore the value 15973.9 cannot fit into a variable of Type UKURSP without loosing information, and therefore it dumps

What currencies are involved in the exchange rate? Have you looked at the current "Currency Exchange Rates (V_TCURR)" to see how this exchange rate pair has been stored in the past?

  • Have you checked the customizing "Currencies: Translation Ratios (V_TCURF)" and whether you should be dividing that input value by the corresponding ratio?
  • And also whether instead of using the "Direct Quoted Exchange Rate" (Field KURSP, Type UKURSP), you might rather use the "Indirect Quoted Exchange Rate" (Field KURSM, Type UKURSM), which is the reciprocal (inverse value), see customizing "Currency Translation Exchange Rate Types V_TCURV)".

=> So inorder to save 'that' exchange rate in your system, you will definitly have to use to set the correct ratio factors and maybe use the inverse value instead in your BAPI, you should check your customizing and current values

BAPI value and ratios for direct quoted exchange rate:

  • EXCH_RATE Types UKURSP
  • FROM_FACTOR Types FFACT_CURR
  • TO_FACTOR Types TFACT_CURR

BAPI value and ratios for indirect quoted exchange rate:

  • EXCH_RATE_V Types UKURSM
  • FROM_FACTOR_V Types FFACT_CURR
  • TO_FACTOR_V TypesTFACT_CURR
11 REPLIES 11

michael_piesche
Active Contributor

Please post the error message next time.

The value cannot be casted into the currency field, as it is too big:

  • The source value 15973.900000 hast 5 characters before the decimal point and 6 characters after the decimal point, whereas only the first is relevant, as the others are all 0.
    => So you would need a type that has at least 5 characters before and at least 1 character after the decimal point
  • The type UKURSP has in total 9 characters, 4 before the decimal point, and 5 after the decimal point
    => Therefore the value 15973.9 cannot fit into a variable of Type UKURSP without loosing information, and therefore it dumps

What currencies are involved in the exchange rate? Have you looked at the current "Currency Exchange Rates (V_TCURR)" to see how this exchange rate pair has been stored in the past?

  • Have you checked the customizing "Currencies: Translation Ratios (V_TCURF)" and whether you should be dividing that input value by the corresponding ratio?
  • And also whether instead of using the "Direct Quoted Exchange Rate" (Field KURSP, Type UKURSP), you might rather use the "Indirect Quoted Exchange Rate" (Field KURSM, Type UKURSM), which is the reciprocal (inverse value), see customizing "Currency Translation Exchange Rate Types V_TCURV)".

=> So inorder to save 'that' exchange rate in your system, you will definitly have to use to set the correct ratio factors and maybe use the inverse value instead in your BAPI, you should check your customizing and current values

BAPI value and ratios for direct quoted exchange rate:

  • EXCH_RATE Types UKURSP
  • FROM_FACTOR Types FFACT_CURR
  • TO_FACTOR Types TFACT_CURR

BAPI value and ratios for indirect quoted exchange rate:

  • EXCH_RATE_V Types UKURSM
  • FROM_FACTOR_V Types FFACT_CURR
  • TO_FACTOR_V TypesTFACT_CURR

0 Kudos

Dear Michael,

Thank you very much for your response and suggestion.

I will definitely check this one.

Btw, the requirement is to update the TCURR table with the exchange rates present in CSV file.

and here i am getting the dump to convert currency IDR --> EUR.

I checked the TCURF table, and there the ratio is maintained as 'Ratio from' = 10000 and 'Ratio to' = 1 for IDR-->EUR.

0 Kudos
ajay.vyavahare Based on the factor you mention, the exchange rate should be 1.59739, no?

Ajay Pandurang VyavahareCan you please post all the values that fill for the BAPI structure. And let us know what you have tried so far after dealing with the dump.For the exchange rate value and ratios, it should look like that for the parameter EXCHRATE_LIST in the FM BAPI_EXCHRATE_CREATEMULTIPLE:
EXCHRATE_LIST-RATE_TYPE     = 'M'.  " just an example. what rate-type are you using?
EXCHRATE_LIST-FROM_CURR     = 'IDR'.
EXCHRATE_LIST-TO_CURRNCY    = 'EUR'.
EXCHRATE_LIST-VALID_FROM    = yourvalidfromdate.
EXCHRATE_LIST-EXCH_RATE     = '1.59739'.
EXCHRATE_LIST-FROM_FACTOR   = 10000.
EXCHRATE_LIST-TO_FACTOR     = 1.
EXCHRATE_LIST-EXCH_RATE_V   = 0.
EXCHRATE_LIST-FROM_FACTOR_V = 0.
EXCHRATE_LIST-TO_FACTOR_V   = 0.

0 Kudos

Hey Michael,

Thank you so much for new info.

I am passing below data (in this case eg. GBP) to my BAPI.

I checked the the V_TURF table for IDR-->EUR, there 'ratio-from' (FFACT) is maintained as 10000 and similarly value maintained as 1 for GBP-->EUR conversion.

So is it required to divide by the 'ratio-from' value maintained in TCURF table before filling out the structure for BAPI?

eg. For IDR, 15973.900000/10000 = 1.59739

Below data i am passing to the BAPI structure EXCHRATE_LIST.

EXCHRATE_LIST-RATE_TYPE     ='M'." 
EXCHRATE_LIST-FROM_CURR     ='GBP'.
EXCHRATE_LIST-TO_CURRNCY    ='EUR'.
EXCHRATE_LIST-VALID_FROM    = 20200614.
EXCHRATE_LIST-EXCH_RATE     ='0.97485'.
EXCHRATE_LIST-FROM_FACTOR   = 1.
EXCHRATE_LIST-TO_FACTOR     = 1.
EXCHRATE_LIST-EXCH_RATE_V   =0.00000.
EXCHRATE_LIST-FROM_FACTOR_V =0. 
EXCHRATE_LIST-TO_FACTOR_V   =0.

ajay.vyavahare

  1. You dont 'have to' use the exact same ratio in the BAPI as it is in the customizing in TCURF. The internal logic of the BAPI will convert your exchange rate value based on your ratio from the BAPI into the ratio from TCURF and store that converted exchange rate value into the currency table TCURR. (However, your choosen ratio with FROM_FACTOR and TO_FACTOR has to be applied to your EXCH_RATE, if it originally was based on the ratio 1:1.)
  2. In your case of IDR, you will have to convert your exchange rate value by a factor, because it is too big for the type of EXCH_RATE, so you could already to that by dividing it by factor 10 (e.g. exch_rate = 1597.39 with FROM_FACTOR = 10 and TO_FACTOR = 1.
  3. Based on BAPI documentation: "In order to prevent inaccuracies in calculation, however it is always advisable to keep the exchange rate numbers in a range from 0.1 to 10.0." (so with the FROM_FACTOR and TO_FACTOR, you achieve to keep the value between 0.1 and 10.0)
  4. Also based on BAPI documentation: "The exchange rate relation (or exchange rate factors) is used for entering exchange rates smaller than 0.00001 or greater than 10000. You can only make entries in the form '1 : scaling' or 'scaling : 1'. Scaling means one of the figures 1, 10, 100, ..., 100000000." (so at least one of the FROM_FACTOR or TO_FACTOR has to remain '1', whereas the other one can be between 1 and 10000)

It always helps to read the documentation of the BAPI and that for the parameters:

* Import: List of Exchange Rates To Be Generated
* Description
* The individual rows (field strings) in this table have the following meaning:
* Before the BAPI can be called up, the field string must contain all information about the exchange rate to be created. You must use the exchange rate types and currencies used in the SAP system (value ranges: see list of exchange rates / currency codes).
* By entering a date, you decide whether to insert a current exchange rate or a historical exchange rate. If you leave the date blank, the system uses today's date. Dates must always be entered with the format YYYYMMDD.
* The exchange rate itself must be greater than zero and less than 9999.99999. Up to five decimal places are permitted after the decimal point.
* The exchange rate relation (or exchange rate factors) is used for entering exchange rates smaller than 0.00001 or greater than 10000. You can only make entries in the form '1 : scaling' or 'scaling : 1'. Scaling means one of the figures 1, 10, 100, ..., 100000000.
*Example: On 1st June 1999, the relation between the two currencies CURA and CURB is 1 CURA = 12173.8000 CURB. The entry is to be made at the middle rate M. The field string might then look like this:
* Exch.Rate Type From Curr. To Curr. Exch. Rate From factor To factor
* M CURA CURB 1.21738 1 10000
* When writing the exchange rate to the SAP tables, the system compares the relations defined there with the ones you have requested. Where it finds discrepancies, a reconciliation is made with the system settings. If, in the example above, the system was working with the factors 1 : 1000, an exchange rate of 12.17380 would be entered in the table.
* In order to prevent inaccuracies in calculation, however it is always advisable to keep the exchange rate numbers in a range from 0.1 to 10.0.
* Value range
* To fill the key fields, you can display the list of exchange rate types and currency codes.

0 Kudos

ajay.vyavahare, please follow up on your open question.

  • comment answers or your question if there are still open issues.
  • otherwise mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question

Thank you Michael for your inputs.

Solution did work.

former_member565051
Participant
0 Kudos

sandra.rossi unfortunately the target field is having 4 digits before the decimal and 5 after the decimal (length 9), therefore conversion is not happening in this case.

0 Kudos

Sorry, I had deleted my original comment.

But as I say in my last comment, I think that the exchange rate should be 1.59739 if the factor is 10000 IDR for 1 EUR (means 15973.9 IDR for 1 EUR)

0 Kudos

Hi Sandra,

You are right. The value i need to pass will be 1.59739, and for that i need to divide the original value by its 'Ratio-to' value.

Thanks.