Skip to Content
Technical Articles
Author's profile photo Syed Ejazuddin

Bridging the World between SAP ECC and SAP Business Technology Platform through Event-Driven Architecture – Part 2

This blog post will be an extension of part1 in which we are going to use the SAP ERP Central Component (SAP ECC) business partner oData service to pull backend master data through SAP Cloud Application Programming Model. As part1 was mostly focused on Advanced Business Application Programming (ABAP), here we are including the flavor of Nodejs. It’s cool right (ABAP + Nodejs).Once we build application, we are going to pull master data locally and you don’t need to get login to SAP Business Technology Platform (SAP BTP) to access the master data. We will also see how we can see Fiori Frontend just by adding simple UI annotation. We will also see that this application will have the capability to fetch business partner data not from SAP ECC but SAP S/4HANA as well.


if you want to access the business partner from SAP ECC , Please follow part1.

Build a Cloud Application Programming.

Open VS Code and type command cds init eccextension.

Go to Project Folder CD eccextension and open the project using Code . You can see the project detail as below. Start a Server using cds watch

What Does CDS Watch Do?

Basically in the simpler word, it just watches all your file in your projects and whenever you do any changes in the file, it restart the server and changes will be immediately served in your localhost. As contrary to SAP ECC, you don’t need to activate the object again and again after each changes and that’s gives developer much flexibility to concentrate on business logic. Now you can see above in the snapshot that watch telling that there is no models found. Models is basically an entity or you can say like a table types/internal table in SAP ECC.

Now what our models should look like. As we are focusing on business partner oData service, so our structure should be similar to service. Now before creating model, we have to import the same .edmx file to our project which we have imported in SAP ECC for creating oData Service. Just drag the file directly to the /eccextension folder and run command cds import API_BUSINESS_PARTNER.edmx

What does this CDS import Do?

Now as you we are going to define the model for Business partner oData service, it’s always necessary that CDS should understood this schema and this what this command do. You will noticed that API_BUSINESS_PARTNER.edmx file get imported to folder /srv/external and it also generated that file with name API_BUSINESS_PARTNER.csn. CSN is Core Schema Notation and this is the notation which is understood by CDS framework. You will also see that package.json file will be updated with cds.require configuration for the imported business partner service.

Create a new file cds under /srv and put below code.

using { API_BUSINESS_PARTNER as external } from '../srv/external/API_BUSINESS_PARTNER.csn';

service CatalogService {
  entity BusinessPartners as projection on external.A_BusinessPartner {
    key BusinessPartner, BusinessPartnerFullName, SearchTerm1  

We are creating a service called “CatalogService” which will have entity called BusinessPartners. This entity will select three field BusinessPartner, BusinessPartnerFullName and SearchTerm1 from A_BusinessPartner. Here we have define BuisnesPartner as Key Field. Here we are also importing CSN file to be used as projection for our A_BusinessPartner entity.

Now we are done with modelling. It’s time to write some select query to fetch data from SAP ECC. Create a file with name service.js inside /srv folder. Copy paste the below code.

	 * Implementation for Business Partner Service
	module.exports = async (srv) => {
	    const BupaService = await'API_BUSINESS_PARTNER');
	    srv.on('READ', srv.entities.BusinessPartners, async (req) => {
	        const res = await BupaService.tx(req).run(req.query.redirectTo(BupaService.entities.A_BusinessPartner))
	        return res;

In this code we are basically writing a sql query under the hood to fetch business partner record from A_BusinessPartner to the corresponding BusinessPartners model service. So even though A_BusinessPartners will have all the field as per metadata but Business Partners service will have only three field as shown above and it will fetch data corresponding to that field.

Now it’s not always possible to connect with live data and we need few data locally to mock the service so that we can test it. Basically it’s like a unit testing of your service and provides that feature as well. Under /external folder, create folder /data and inside of it a file with this exact name: API_BUSINESS_PARTNER-A_BusinessPartner.csv and paste the following contents inside of it:

1;John Doe;S4 Eventing
2;Henry Thomas; SF Eventing
3;Jacob;ECC Eventing

Now you are done with building Basic application and we are good for the testing locally. Run command cds watch if you have stops the server else it will automatically serves you if you have not stopped yet. You will notice that watches will tell that it’s mocking API_BUSINESS_PARTNER. It means mocking with locally.

Navigate to https://localhost:4004 in your browser and you will see service running.

Here there will be two thing. One is path from /api-business-partner which is basically  API_BUSINESS_PARTNER service. If you click on entity on A_BusinessPartner you will going to see all field but with data locally.


If you see below, you will see service /catalog with entity BusinessPartners which we have created in file service.cds.

Here you will notice that this BusinessPartners. entity is only showing three field which have selected as our model.


Lets Create Frontend with SAP Fiori Annotation. Create a file service-ui.cds under /serv folder and paste the below code.

annotate CatalogService.BusinessPartners with {
		BusinessPartner @title:'Business Partner'
annotate CatalogService.BusinessPartners with @(

		UI: {
			SelectionFields: [ BusinessPartner ],
			LineItem: [
				{ Value: BusinessPartner, Label: 'Business Partner' },
				{ Value: BusinessPartnerFullName, Label: 'Business Partner Name' },
				{ Value:  SearchTerm1, Label: 'Search Term' }
			HeaderInfo: {
				TypeName: 'Business Partner',
				TypeNamePlural: 'Business Partners',
				Description: { Value: BusinessPartnerFullName }

Click on Fiori of BusinessPartners entity.




It’s time to pull  SAP ECC Business Partner Data now. Goto Package.json and insert below under your model section. If you want to run locally, either remove this section or comment this code.

"credentials": {
"url": "http://<ECCPublicIP>:Port/sap/opu/odata/sap/ZAPI_BUSINESS_PARTNER_SRV",
"username": "XXX", "ECC Logon UserID
"password": "XXX"  "ECC Logon Password

Run the cds watch if you have stopped your service. You will see that now it’s getting connected to SAP ECC rather than mocking.

Navigate to https://localhost:4004 and click on entity BusinessPartners.


Now you can see all SAP ECC Business Partner into your browser.

You can use the same code to mock both SAP S/4HANA ( Cloud or On-Premise ) business partner locally as well .

SAP S/4 HANA on-Premise

"credentials": {
"url": "http://<SAP S/4 HANA on-Premsie Public IP:Port/sap/opu/odata/sap/API_BUSINESS_PARTNER",
"username": "XXX", "SAP S/4 HANA on-Premise GUI Logon
"password": "XXX"  "SAP S/4 HANA on-Premise GUI Password

SAP S/4 HANA Cloud

"credentials": {
"url": "https://XXXX/sap/opu/odata/sap/API_BUSINESS_PARTNER",
"username": "XXX", "Communication User
"password": "XXX"  "Communication Password

If you want to directly clone the code from github , you can go to the Github Reference


Now you have got the idea on how you can create oData service in SAP ECC through service gateway builder(SEGW) and also run your application locally without much coding. However this process is done just to ensure that your code and service is running fine. However this code will only become productive once you deployed this application to SAP Business Technology Platform.

What Next

In next part we will see how we can Configure, build and deploy this application on SAP BTP and then we will move to event driven architecture for SAP ECC and at last we will be going to see few extension scenario based on some business logic.

SAP ERP Extension on SAP Discovery Centre

We have recently released a Mission for event-driven extension scenario for SAP ERP 6.0 which is available on SAP Discovery Centre . You can watch the Mission Demo video from here. This will demonstrate how we can extend the SAP ECC without disrupting any core business processes. To get more insight about our extension scenario and steps involved, Please refer our sample reference application here



Assigned Tags

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

      Hi Syed,

      Awesome Post and very helpful .

      one Question ,In case of single sign-on we don’t have userid and password then

      how we can call OP odata service .

      Is it possible to use Destination Instead  of credentials ? If possible let me know the steps.