Implementing Currency Conversion

Objective

After completing this lesson, you will be able to Describe how to implement currency conversion.

Currency Conversion in SAP HANA Cloud

Most organizations operate in multiple currencies but will usually want to report in a single currency. When we load data to SAP HANA Cloud database the individual transactions are often stored in mixed currencies. SAP HANA Cloud calculation views can convert currencies during runtime.

The concept of currency conversion. Source data contains a measure amount with different currency values (EUR, USD, GBP). In the Semantics node, define conversion rules. The output contains only EUR currency value with calculated corresponding amount values.

Even if the reporting tool is able to convert currencies, you should always consider implementing currency conversion in the calculation view to ensure high performance as the conversion in SAP HANA Cloud is processed completely in-memory. Additionally, by defining the conversion rules in the calculation view you ensure consistency across reports that use the same calculation view as you define the rules only once and not in each report.

Currency Conversion

The key elements provided by SAP HANA Cloud are as follows:

  • A set of tables to store master data about currencies, exchange rate types, and the exchange rate values.

  • A semantic typeAmount with Currency which you set for the measure you want to convert.

  • Calculation view settings to define, for each measure, how the conversion should be processed (which rate and conversion dates should be applied, where to find the source and target currency).

Standard SAP Currency Conversion Tables

SAP HANA Calculation Views implement conversion mechanisms in a similar way as SAP solutions such as S/4HANA or BW/4HANA. This allows you to calculate converted data on-the-fly, or even to simulate conversion currencies with different rates, conversion dates, and so on.

Standard tables exist in most SAP systems (in particular, SAP Business Suite and SAP S/4HANA), and SAP HANA Cloud can use them to compute data conversion.

Standard SAP Currency Conversion Tables

Table NameDescription
TCURCCurrency codes
TCURRExchange rates
TCURVExchange rate types for currency translation
TCURFConversion factors
TCURNQuotations
TCURXDecimal places in currencies
TCURTCurrency code names
TCURWUsage of exchange rate Types

To enable currency conversion in SAP HANA Cloud, these tables must be available in the SAP HANA Cloud database. The tables are not provided by SAP HANA Cloud by default and you must provide them and update them yourself, either by creating a synonym to tables from an external schema, or using any of the available data provisioning tools.

Implementing Conversion in Calculation Views

To setup currency conversion in a calculation view, you need to follow some basic steps:

The process of currency conversion. First, assign the Amount with Currency semantic type to a measure. Second, enable it for conversion. Third, for the conversion, select the target currency, the source currency, and the conversion date and exchange rate type.

Assuming you have made the currency tables (TCUR*) available in the SAP HANA Cloud database, you can proceed.

Setting the Semantic Type

Setting the semantic type. In the Columns tab of Semantics node details, in the Semantics column, choose the Amount with Currency option for the relevant measure, such as GROSS_AMOUNT_USD.

When a measure contains a money amount, and if you want to enable conversion, you need to change its semantic type to Amount with Currency Code.

In the Columns tab of the semantic node, select a measure. Now, using the Semantics dropdown list, choose this semantic type: Amount with Currency Code.

Note

The semantic type Amount with Currency Code can be used even if conversion is not required. You would do this to provide currency information to the front-end tool so that it can display the amount alongside the currency.

In this case, you only have to set the Display Currency property to identify the currency in which the amounts are expressed. Do not set the Conversion flag.

Defining Currency Conversion Settings

The details of the currency conversion for GROSS_AMOUNT_USD in the Definition tab. For details, refer to the following table.

After assigning the semantic type, Amount with Currency Code, you then must enable conversion and define the main parameters used for conversion.

Key Settings for Currency Conversion

Key Settings for Currency Conversion

SettingDescriptionOptions
ClientThe client (MANDT) to use to filter the TCUR* tables contentSession Client / Fixed Client Number / Column / Input parameter
Source CurrencyThe currency in which the amounts to convert are expressedFixed / Column
Target CurrencyThe currency in which the amounts must be convertedFixed / Column / Input Parameter
Exchange TypeThe type of rate used to convert amounts. Example: Spot rate, average rate...Fixed / Column / Input Parameter
Conversion DateThe date used to match an amount and the corresponding conversion rateFixed / Column / Input Parameter
Exchange Rate(optional) A column from the source data that contains the exchange rate to be used 
Data TypeThe data type of the converted measure (overrides the data type of the converted column)Example: Decimal (15,2)
GenerateIf selected, this option creates a column that indicates for each converted amount the (target) currency in which it is expressed.The result currency column is never exposed to client tools. It is only available to other calculation views, where it can be used in additional calculations.
Upon FailureSpecifies the behavior if the conversion cannot be executed (for example, if the rateFail (a query on the view generates an error), NULL (the column is not populated), Ignore (keeps the source amount without converting it)
AccuracyDefines how the conversion must be performedIntermediate rounding / Retain all possible digits

It is important to carefully define how the exceptions must be handled when you are converting data. In addition, to reduce the risk of conversion failure, make sure that the currency conversion tables TCUR* in your SAP HANA system are updated on a regular basis, in particular in a side-by-side scenario where they should always be in sync with the data imported from the remote SAP system.

Decimal Shift and Rounding

By default, the precision of all values is two digits in SAP ERP tables.

As some currencies require accuracy in value, decimal shift moves the decimal points according to the settings in the TCURX currency table. If you want to round the result value after currency conversion to the number of digits of the target currency, select the Rounding checkbox.

A decimal shift back is necessary if the results of the calculation views are interpreted in ABAP. The ABAP layer, by default, always executes the decimal shift. In such cases, a decimal shift back helps you to avoid wrong numbers due to a double shift.

Reusing Currency Conversion Settings between Columns

It is possible to reuse the currency conversion settings for other measures in the same node of a Calculation View. This reduces manual definition and allows for more consistency by avoiding mistakes. The settings can be applied to several measures at the same time.

The currency conversion settings can be reused in two different ways:

  • Reference

    The settings defined in a measure are applied as is in the other measures that you select, and cannot be modified in the other measures.

    In other words, the settings will always remain consistent and only the source measure for currency conversion setting can be changed, thus impacting the ones that reference it.

  • Copy

    The setting defined in a measure is just copied to the other measures, but they are not bound to each other. The currency conversion settings of the other measures can be freely modified.

Using an Input Parameter for the Currency

The input parameter can also be described as a prompt, in that it asks the user what currency to use.

The definition of an input parameter for currency selection at runtime. Define Parameter Type: Direct, Semantic Type: Currency, Data Type: VARCHAR, and Length: 5.

If you want to define the currency at runtime, when the view is executed, you can create an input parameter.

VARCHAR (5) is the way that the currency code is defined in the TCUR* tables, so to be consistent, we recommend that you define the input parameter with the same data type.

Implement Currency Conversion

Log in to track your progress & complete quizzes