Financial Management Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
vpolovyy
Explorer
444

Recently we had an opportunity to build a prototype for digital payments solution and successfully integrated Digital Currency Hub service platform. Here we would like to share some practical aspects ouf our work.

Configuration steps in the S/4 system

Our S/4 systems are designed to work with traditional currencies(fiat) in treasury and payment operations. To be able to operate with digital currencies via DCH, you will need a new payment method and new house bank account.

  1. Define a new payment method in your country and company code
  2. Use a custom payment medium format, where you’ll be able to call custom function modules. This is where you’ll integrate API-Calls offered by DCH to transfer payment instructions. Disable DME Mapping Engine in format settings
  3. Define an internal bank master data record of type "payment system". Then use this record to set up a house bank account, account determination rules and GL account for payment clearing

Having completed this step, you should be able to use your new payment method while booking an invoice and assign it to business partners.

Configuration steps in the DCH payment platform

In general DCH is a cloud plattform and uses the Fiori Launchpad user interface design, that we know. It is easy to navigate and find an appropriate tile for a specific task 

  1. Define cryptocurrencies: We used stablecoins in our case. DCH offers an option to map traditional (fiat) currencies to cryptos. So using this setup we were able to initiate payments in fiat currencies in S/4 and transfer the funds in stablecoins. Another benefit of this aproach is no need to maintain a new crypto-currency and exchange rates in S/4. 
    There are also some related tasks to be done: networks, custodians etc.
  2. Set up integration. Write down client ID and client secret somewhere safe, as you will need this data for authentification later
  3. Finally set up your master data in DCH: 
    - Create a company as payment initiator as a conterpart for your company code
    - Replicate business partners records, which you choose for test. Tipp: use business partner ID in S/4 as external ID in DCH. This will make your integration a lot more transparent 

General overview

This is how it all fits together in our test environment.

vpolovyy_0-1749071652636.png

Technical implementation

Certain configuration steps must be performed by your system engineers. Just like other solutions by SAP, S/4 Systems connect to DCH via cloud connector. Hence somebody needs to take care of cloud connector add-on installation, setting up a logon procedure and network security.

The API integration takes place via REST calls in ABAP. Use function modules of your custom payment medium format as wrappers. All necessary information such as business partner, amount, currency, will be delivered automatically by the interface of the function modules.

Now, lets face the most technical part of our prototype. ABAP Coding would generally consist of handling two tasks:

1) Authentication call and retrieving the access token

The purpose here is to retrieve the access token by an authification call using previuosly retrieved client ID and client secret. We used generic HTTP-Client Class for our purpose.

cl_http_client=>create_by_url(
   exporting
      url = auth_url,
      ssl_id = 'ANONYM'
   importing
      client = data(mo_token_client)
).
mo_token_client->request->set_method( 'POST' ).
mo_token_client->authenticate(
   exporting
      username = client_id,
      password = client_secret
).

Submit the call and check the http-code by mo_token_client->response->get_status( ) method. If “200” value is returned, read response object and retrieve access token from the JSON Body by mo_token_client->response->get_cdata( ) method.

2) API Call

Create another instance of http-client for api calls and set your access token as a header parameter:

cl_http_client=>create_by_url(
   exporting
      url = api_url,
      ssl_id = 'ANONYM'
   importing
      client = data(mo_http_client)
).
mo_rest_client->if_rest_client~set_request_header(
   iv_name = 'Authorization',
   iv_value = |Bearer { lv_access_token }|
).

Prepare payment payload from deep structure in ABAP to a JSON string by calling /ui2/cl_json=>serialize( ).

            Finally submit your payments to payment platform

lo_request->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
lo_request->set_string_data( io_payments ).
mo_rest_client->if_rest_resource~post( lo_request ).

Check the result of API call. This is indicated by the response object. If all went well, you should see a new transaction in DCH. Initially its status would be "In process" and then changed to "Completed".

Conclusion and outlook

This case covers a very basic scenario of payment processing with digital currencies. Its puspose is to trigger a fund transfer from one party to another and ensure correct booking in S/4 . At the end your booked invoice is automatically cleared by F110-payment run and payments are processed in usual manner.

More advanced options are upcoming, when the ongoing DCH-release with Multi Banking Connectivity becomes available.

But no matter, if you run your payments on larger scale using MBC or use simple integration as described here, adding the option of digital payments may turn out highly beneficial. Treasurers might be attracted by optimization af cross-border payments costs, processing speed and becoming independent from banking holidays and working hours

2 Comments
Sarah-Sally
Newcomer
0 Kudos

Great Documentation !
Thank you very much for that :-).

vpolovyy
Explorer
0 Kudos

Thanx Sarah!