Skip to content
NextLytics
Megamenü_2023_Über-uns

Shaping Business Intelligence

Whether clever add-on products for SAP BI, development of meaningful dashboards or implementation of AI-based applications - we shape the future of Business Intelligence together with you. 

Megamenü_2023_Über-uns_1

About us

As a partner with deep process know-how, knowledge of the latest SAP technologies as well as high social competence and many years of project experience, we shape the future of Business Intelligence in your company too.

Megamenü_2023_Methodik

Our Methodology

The mixture of classic waterfall model and agile methodology guarantees our projects a high level of efficiency and satisfaction on both sides. Learn more about our project approach.

Products
Megamenü_2023_NextTables

NextTables

Edit data in SAP BW out of the box: NextTables makes editing tables easier, faster and more intuitive, whether you use SAP BW on HANA, SAP S/4HANA or SAP BW 4/HANA.

Megamenü_2023_Connector

NextLytics Connectors

The increasing automation of processes requires the connectivity of IT systems. NextLytics Connectors allow you to connect your SAP ecosystem with various open-source technologies.

IT-Services
Megamenü_2023_Data-Science

Data Science & Engineering

Ready for the future? As a strong partner, we will support you in the design, implementation and optimization of your AI application.

Megamenü_2023_Planning

SAP Planning

We design new planning applications using SAP BPC Embedded, IP or SAC Planning which create added value for your company.

Megamenü_2023_Dashboarding

Dashboarding

We help you with our expertise to create meaningful dashboards based on Tableau, Power BI, SAP Analytics Cloud or SAP Lumira. 

Megamenü_2023_Data-Warehouse-1

SAP Data Warehouse

Are you planning a migration to SAP HANA? We show you the challenges and which advantages a migration provides.

Business Analytics
Megamenü_2023_Procurement

Procurement Analytics

Transparent and valid figures are important, especially in companies with a decentralized structure. SAP Procurement Analytics allows you to evaluate SAP ERP data in SAP BI.

Megamenü_2023_Reporting

SAP HR Reporting & Analytics

With our standard model for reporting from SAP HCM with SAP BW, you accelerate business activities and make data from various systems available centrally and validly.

Megamenü_2023_Dataquality

Data Quality Management

In times of Big Data and IoT, maintaining high data quality is of the utmost importance. With our Data Quality Management (DQM) solution, you always keep the overview.

Career
Megamenü_2023_Karriere-2b

Working at NextLytics

If you would like to work with pleasure and don't want to miss out on your professional and personal development, we are the right choice for you!

Megamenü_2023_Karriere-1

Senior

Time for a change? Take your next professional step and work with us to shape innovation and growth in an exciting business environment!

Megamenü_2023_Karriere-5

Junior

Enough of grey theory - time to get to know the colourful reality! Start your working life with us and enjoy your work with interesting projects.

Megamenü_2023_Karriere-4-1

Students

You don't just want to study theory, but also want to experience it in practice? Check out theory and practice with us and experience where the differences are made.

Megamenü_2023_Karriere-3

Jobs

You can find all open vacancies here. Look around and submit your application - we look forward to it! If there is no matching position, please send us your unsolicited application.

Blog
NextLytics Newsletter Teaser
Sign up now for our monthly newsletter!
Sign up for newsletter
 

Currency conversion with SAP HANA SQLScript in transformation routines

Often in SAP BW HANA, the currency must be converted during the loading processes. For example, in a corporation with companies in different countries, the local currency is converted into the currency of the corporation.

Meanwhile it is possible to implement many typical requirements of the ETL process with SQLScript. HANA users are supported by predefined functions. In this article we will take a closer look at currency conversion. You can find more information on areas of application for SQLScript in our whitepaper.

Advantages of SQLScript

By using SQLScript instead of ABAP you benefit from Code Pushdown. Calculations are performed on the database level. This prevents that the data is first loaded from the database to the ABAP server in order to then carry out the calculations there.

As a result you can achieve better performance. SQLScript allows you to access the data of the HANA database directly and avoid unnecessary transfers between the database and the application server. You can save a lot of time in this way, especially when doing calculations with large amounts of data.

Requirements

To perform currency conversion in SQLScript, the following currency tables must be available in HANA:

  • TCURR - Exchange Rates
  • TCURV - Exchange rate types for currency translation
  • TCURF - Conversion Factors
  • TCURN - Quotations
  • TCURX - Decimal Places in Currencies

Definition of the TCURR table

Parameters of the CONVERT_CURRENCY function

The SQLScript function CONVERT_CURRENCY is used to perform the currency conversion. The parameters of this function are shown below. The Reference column indicates whether the parameter can refer to a column in the data table or whether a fixed constant must be specified.

Parameter

Reference

Description

AMOUNT

Yes

Sum to be converted

SOURCE_UNIT

Yes

Currency to be converted

TARGET_UNIT

Yes

Target currency

REFERENCE_DATE

Yes

Key date for exchange rate determination

SCHEMA

No

Database schema of the conversion tables

CLIENT

Yes

Client in which the conversion is performed

ERROR_HANDLING

No

Defines the error handling. For example, when a currency is unknown. The following options are possible:

fail on error - the conversion aborts with an error (default value)

set to null - NULL is returned as the result

keep unconverted - the original value is output

CONVERSION_TYPE

No

Defines the used exchange rate type

 

Besides the standard TCUR* tables, you can also use your own tables. You must define these using the following parameters.

Parameter

Reference

Description

PRECISIONS_TABLE

No

Decimal Places in Currencies (default TCURX)

CONFIGURATION_TABLE

No

Exchange rate types for currency translation (default TCURV)

NOTATION_TABLE

No

Quotations (defaultTCURN)

RATES_TABLE

No

Exchange Rates (default TCURR)

PREFACTORS_TABLE

No

Conversion Factors (default TCURF)


Increase the performance of your BW with SQLScript

Neuer Call-to-Action


Coding Examples

At this point we present some examples to illustrate the concept. In the first example, the document currency is converted into the local currency Euro. The key date is set manually.

outTab =
SELECT calmonth, comp_code, doc_currcy,
'EUR' AS loc_currcy,
recordmode,
deb_cre_dc,
CONVERT_CURRENCY( AMOUNT => deb_cre_dc,
SOURCE_UNIT => doc_currcy,
SCHEMA => 'SAPABAP1',
TARGET_UNIT => 'EUR',
REFERENCE_DATE => '2020-08-10',
CLIENT => '100',
CONVERSION_TYPE => 'EURX')
AS deb_cre_lc,
record, SQL__PROCEDURE__SOURCE__RECORD
FROM :inTab;

ERRORTAB= SELECT * FROM :ERRORTAB;

Alternatively, you can use the current date as the key date:

outTab =
SELECT calmonth, comp_code, doc_currcy,
'EUR' AS loc_currcy,
recordmode,
deb_cre_dc,
CONVERT_CURRENCY( AMOUNT => deb_cre_dc,
SOURCE_UNIT => doc_currcy,
SCHEMA => 'SAPABAP1',
TARGET_UNIT => 'EUR',
REFERENCE_DATE => current_date,
CLIENT => '100',
CONVERSION_TYPE => 'EURX')
AS deb_cre_lc,
record, SQL__PROCEDURE__SOURCE__RECORD
FROM :inTab;

ERRORTAB= SELECT * FROM :ERRORTAB;

You can also use variables in the currency conversion. In the following example, the current date is used as the key date for the currency conversion:

DECLARE lv_date nvarchar(8);
SELECT to_nvarchar (current_date,'YYYYMMDD')INTO lv_date FROM DUMMY;

outTab =
SELECT calmonth, comp_code, doc_currcy,
'EUR' AS loc_currcy,
recordmode,
deb_cre_dc,
CONVERT_CURRENCY( AMOUNT => deb_cre_dc,
SOURCE_UNIT => doc_currcy,
SCHEMA => 'SAPABAP1',
TARGET_UNIT => 'EUR',
REFERENCE_DATE => :lv_date,
CLIENT => '100',
CONVERSION_TYPE => 'EURX')
AS deb_cre_lc,
record, SQL__PROCEDURE__SOURCE__RECORD
FROM :inTab;

ERRORTAB= SELECT * FROM :ERRORTAB;

Alternatively, you can also use the month of the respective data set as the key date:

outTab =
SELECT calmonth, comp_code, doc_currcy,
'EUR' AS loc_currcy,
recordmode,
deb_cre_dc,
CONVERT_CURRENCY( AMOUNT => deb_cre_dc,
SOURCE_UNIT => doc_currcy,
SCHEMA => 'SAPABAP1',
TARGET_UNIT => 'EUR',
REFERENCE_DATE => CONCAT(calmonth, '01'),
CLIENT => '100',
CONVERSION_TYPE => 'EURX')
AS deb_cre_lc,
record, SQL__PROCEDURE__SOURCE__RECORD
FROM :inTab;

ERRORTAB= SELECT * FROM :ERRORTAB;

Summary

As you can see, the currency conversion can be done very easily in SQLScript. This way you can fully exploit the performance advantages of the HANA database. The predefined function also allows many configuration options.

Do you have questions about SQLScript? Or do you want to convert your transformation routines to SQLScript and are looking for experienced developers with SQLScript know-how? Please do not hesitate to contact us.

Learn more about  SAP HANA SQLScript

 

Further information can be found in the book "SQLScript for SAP HANA" (SAP PRESS, ISBN 978-3-8362-7408-1) by Jörg Brandeis 

, ,

avatar

Chris

Chris Fidanidis has been working in the SAP BW environment since 2007. During these years he has implemented several planning projects and used various SAP tools such as SAP BSP, SAP BW-IP, SAP BPC, SAP BW Embedded BPC. He has gained experience primarily as a developer, architect, project manager and team leader. He enjoys playing basketball and barbecue whenever possible.

Got a question about this blog?
Ask Chris

Blog - NextLytics AG 

Welcome to our blog. In this section we regularly report on news and background information on topics such as SAP Business Intelligence (BI), SAP Dashboarding with Lumira Designer or SAP Analytics Cloud, Machine Learning with SAP BW, Data Science and Planning with SAP Business Planning and Consolidation (BPC), SAP Integrated Planning (IP) and SAC Planning and much more.

Subscribe to our newsletter

Related Posts

Recent Posts