Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Akshay_Anil
Explorer
810

Introduction

In this post, I will explain how to connect multiple databases and OData services to SAP BTP using BAS . This guide covers configuring UI5 applications to consume multiple OData services from both SAP S/4HANA (on-premise) and SAP BTP ABAP environment, ensuring seamless data integration.

Summary

I aim to integrate three different OData services from different database sources :

On-Premise S/4HANA OData V2 Services

  • ZPR_EMP_DETAILS_SRV : Fetches employee details.
  • ZFI_TEST_ODATA_SRV : Fetches financial data.

SAP BTP ABAP Environment OData V4 Service

  • ZUI_TAB_TRAVDAT_O4_AKS_001: Fetches travel-related data using the RAP Model.

 

Steps to Connect Multiple OData Services

Step 1: Add Data Sources in UI5 Application

  1. Create a UI5 application in VS Code.

  2. While creating the application, provide the service URL to configure an OData service automatically.

  3. Navigate to webapp/manifest.json.

  4. Modify the dataSources section to include multiple OData services as follows:

"dataSources": {
  "mainService": {
    "uri": "/sap/opu/odata/sap/ZPR_EMP_DETAILS_SRV/",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0"
    }
  },
  "subService": {
    "uri": "/sap/opu/odata/sap/ZFI_TEST_ODATA_SRV/",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0"
    }
  },
  "rapService": {
    "uri": "/sap/opu/odata4/sap/zui_tab_travdat_o4_aks_001/",
    "type": "OData",
    "settings": {
      "odataVersion": "4.0"
    }
  }
}

Step 2: Configure Models in manifest.json

Each model corresponds to an OData service:

"models": {
  "": {
    "dataSource": "mainService",
    "preload": true,
    "settings": {}
  },
  "subModel": {
    "dataSource": "subService",
    "preload": true,
    "settings": {}
  },
  "rapModel": {
    "dataSource": "rapService",
    "preload": true,
    "settings": {
      "operationMode": "Server",
      "autoExpandSelect": true,
      "earlyRequests": true
    }
  }
}

Step 3: Configure ui5.yaml for Backend Connections

In ui5.yaml, configure the destinations for OData services:

server:
  customMiddleware:
    - name: ui5-middleware-simpleproxy
      afterMiddleware: compression
      configuration:
      ui5:
          path:
            - /resources
            - /test-resources
          url: https://ui5.sap.com
        backend:
# On-premise SAP System Destination 1 - Replace with your URL
        - scp: true
        path: /sap/opu/odata/sap/ZPR_EMP_DETAILS_SRV/
        url: https://your-onpremise-system-hostname:port/
        destination: SAHANA_CONN
        client: 'your client ID'
        authenticationType: BasicAuthentication

  # On-premise SAP System Destination 2 - Replace with your URL  
        - scp: true
        path: /sap/opu/odata/sap/ZFI_TEST_ODATA_SRV
        url: https://your-onpremise-system-hostname:port/
        destination: SAHANA_CONN
        client: 'your client ID'
        authenticationType: BasicAuthentication

  # SAP BTP ABAP Environment Destination - Replace with your instance URL
        - scp: true
        path: /sap/opu/odata/sap/zui_tab_travdat_o4_aks_001/
        url: https://your-abap-instance-guid.abap.region.hana.ondemand.com
        destination: abap-cloud-default_abap-trial-9a87acc7trial-dev
        client: 'your client ID'
        authenticationType: OAuth2UserTokenExchange

Note :

Destination :

S4HANA_CONN is used for two OData V2 services hosted in the on-premise S/4HANA system as shown in below screenshot.

Screenshot 2025-01-26 181350.png

abap-cloud-default_abap-trial-9a87ace7trial-dev is for the RAP-based OData V4 service hosted on SAP BTP as shown in below screenshot.

Screenshot 2025-01-26 181306.png

 

Authentication Types:

  • On-premise S/4HANA services use BasicAuthentication, which is simpler but less secure for cloud-based scenarios.
  • The SAP BTP service uses OAuth2UserTokenExchange, enabling secure token-based communication.

All the Connected OData will be Listed in Service Manager as shown in below screenshot.

Screenshot 2025-01-26 191910.png

Important Note on OData Connection Methods:

Avoid connecting directly to OData services via the Service Manager, as it can lead to data inconsistency issues (e.g., all requests may unintentionally retrieve only the last edited destination). Instead, I prefer using the Destination Service (as shown in the configuration above) for:

  • Stable & secure connections
  • Proper authentication handling (Basic/OAuth2)
  • Consistent data retrieval (prevents mixing/overwriting datasets).

Conclusion

By following these steps, you can successfully integrate multiple OData services in a SAP BTP-based Fiori application. This setup allows seamless data flow between on-premise S/4HANA and cloud-based SAP BTP ABAP environment, ensuring a modern, scalable architecture.

I hope this helps! Let me know your thoughts or if you have any questions.
Thanks,

Akshay Anil 
Technical Consultant, SAP ABAP | BTP | Fiori | Ui5

SAP Business Application Studio  OData  

1 Comment
Labels in this area