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.
Context
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
Create a UI5 application in VS Code.
While creating the application, provide the service URL to configure an OData service automatically.
Navigate to webapp/manifest.json.
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.
abap-cloud-default_abap-trial-9a87ace7trial-dev is for the RAP-based OData V4 service hosted on SAP BTP as shown in below screenshot.
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.
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 connectionsProper 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
IntroductionIn 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.ContextI aim to integrate three different OData services from different database sources :On-Premise S/4HANA OData V2 ServicesZPR_EMP_DETAILS_SRV : Fetches employee details.ZFI_TEST_ODATA_SRV : Fetches financial data.SAP BTP ABAP Environment OData V4 ServiceZUI_TAB_TRAVDAT_O4_AKS_001: Fetches travel-related data using the RAP Model. Steps to Connect Multiple OData ServicesStep 1: Add Data Sources in UI5 ApplicationCreate a UI5 application in VS Code.While creating the application, provide the service URL to configure an OData service automatically.Navigate to webapp/manifest.json.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.jsonEach 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 ConnectionsIn 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: OAuth2UserTokenExchangeNote :Destination :S4HANA_CONN is used for two OData V2 services hosted in the on-premise S/4HANA system as shown in below screenshot.abap-cloud-default_abap-trial-9a87ace7trial-dev is for the RAP-based OData V4 service hosted on SAP BTP as shown in below screenshot. 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.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 connectionsProper authentication handling (Basic/OAuth2)Consistent data retrieval (prevents mixing/overwriting datasets).ConclusionBy 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 Read More Technology Blogs by Members articles
#SAP
#SAPTechnologyblog