Skip to Content
Author's profile photo Maciej Bialek

Forex interface with an example of Polish Central Bank

One of the most common and typical requirements one can get is to create an interface allowing to update foreign exchange rates based on data provided by national bank. Below you will find a simple step-by-step tutorial explaining how to create one with an example of polish central bank (NBP).

Here’s a basic description of API (REST) provided by NBP:

Service reply is returned in the JSON or XML format, depending on client requirements. The reply format may be indicated in two ways – with an query parameter ?format or with a HTTP Acceptheader:

  • JSON format: Accept: application/json header or ?format=json parameter
  • XML format: Accept: application/xml header or ?format=xml parameter

If the format has not been determined, XML is returned.

Historic data are available respectively:

  • for currency exchange rates – since 2 January 2002,
  • for gold prices – since 2 January 2013.

and a single enquiry cannot cover a period longer than 93 days.


You will also find examples of how to call the API:

Queries for complete tables

Templates of enquiries about complete tables of currency exchange rates

  • Current table of exchange rates of type {table}{table}/
  • Series of latest {topCount} tables of exchange rates of type {table}{table}/last/{topCount}/
  • Exchange rate table of type {table} published today (or lack of data){table}/today/
  • Exchange rate table of type {table} published on {date}(or lack of data){table}/{date}/
  • Series of exchange rate tables of type {table} published from {startDate} to {endDate} (or lack of data){table}/{startDate}/{endDate}/


For more detailed information please refer to:


Let me explain what our scenario looks like. This should give you an idea of what components are involved.

ECC initializes interface over abap proxy and sends it to SAP PO which forwards it to NBP. The message is sent as XML and the receiver adapter converts it to HTTP request.

API returns data as JSON. Receiver adapter converts JSON to XML and sends the response to SAP PO which forwards the XML message back to ECC.

Now, let’s get to work!

Enterprise Services Repository configuration:

 1. Open ESR and add two namespaces in the Software Component of your choice:

  • http://…/currency/nbp       – for receiver objects
  • http://…/currency/sap        – for sender objects

2. Create request data type in both namespaces. The data type should have the following structure:

3. Create two data types for response messages.

3.A. Namespace http://…/currency/nbp create data type as following:

3.B. In namespace http://…/currency/sap create data type as following:

4. Create message types using data types that you have prepared in previous step. You should create 4 message types:

  • MT for request in sender namespace (http://…/currency/sap)
  • MT for request in receiver namespace  (http://…/currency/nbp)
  • MT for response in sender namespace
  • MT for response in receiver namespace

5. Create two Service Interface objects. One in receiver namespace and the other one in sender namespace. Use message types prepared in step 4.

6. Create message mappings. In my case they have been created in receiver namespace but you can create separate Software Component for them or add them to sender namespace as well – it’s up to you.

7. Create operation mapping object using Service interfaces created in step 5 and both mappings created in step 6.

In the end you should end up with the following object structure:


Integration Directory configuration:

8.  Create ProxyOut sender communication channel. Since this is typical channel usually already available in your system, I will not cover how to create one in this tutorial.

9. Create receiver communication channel using REST adapter.

9.A. Leave General tab as it is.

9.B. In REST URL what we need to achieve is to map the Date parameter into URL string so the service replies with expected data.

Fill in URL Pattern field with below address. Make sure that the parameter Date is in {} brackets.{Date}

Then, configure other parameters as presented in below screenshot. Provide source value as XPath Expression, name of the element and XPath to this element in your request message.

9.C. In REST Operation tab make sure that you select values as presented below.

9.D. In Data Format tab make sure that you set following parameters:

  • Request Format / Data Format: XML
  • Response Format / Data Format: JSON
  • Response Format / Character Set: Manual Value
  • Response Format / Set Name: UTF-8

Then select 3 following parameters:

  • Convert to XML
  • Log JSON message
  • Add Wrapper Element

9.E. Leave another 4 tabs – Operation Rules, Response Determination, HTTP Headers and Error Handling – untouched, as they are.

10. Create integrated configuration with elements that you have previously created.


Finally, we are ready to test the interface. Below screens have been made in SPROXY transaction:

Voila! 🙂

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo ILIE ALEMAN

      Great example, thanks. One question about how to implement the last step of loading the rates in the system, what process have you implemented in your case? Abap calling to standard transaction/bapi to load the rates ? or xml to file downloading then file integration?