Technical Articles
Bridging the World between SAP ECC and SAP Business Technology Platform through Event-Driven Architecture – Part 1
SAP ERP Central Component (SAP ECC) is usually implemented using Advanced Business Application Programming (ABAP) for business implementation. However, the way this implementation manages critical business information can be challenging and risky, even though the implementation itself is quite valuable.
Is it possible for the SAP ECC customers to build an extension application on SAP Business Technology Platform (SAP BTP) and leverage the benefit of SAP HANA to make their business much faster? Yes, it is; by using the Side-by-Side Extensibility feature of SAP ECC. This extensibility offers a lot of new use cases without disturbing the core implementation, such as IoT scenarios, SAP and third party application integration, and integrating SAP ECC real time data with cloud applications.
This blog post primarily targets those who wish to try their hands on various technologies on SAP Cloud Platform, like SAP Cloud Application Programming Model, SAP Enterprise Messaging, SAP Cloud SDK , SAP Integration Suite, and SAP Fiori Elements. This will also help to understand a few ABAP basics for creating a quick backend API in SAP ECC and Node.js for creating a business application on the SAP BTP.
We will see how to create a Business Partner oData Service in SAP ECC and then call this SAP ECC oData Service using the SAP Cloud Application Programming model locally, with basic authentication. However, the question arises as to why we should create this service in SAP ECC. Is it possible to get this API from the SAP API Business Hub?
Yes, this API is available in the SAP API Business Hub for SAP S/4HANA, unfortunately it’s not available for SAP ECC and the main blocker is the fact that this API works as a bridge between the backend and SAP Business Technology Platform. This API can, however, be created for SAP ECC as well and in this blog post we are going to replicate the SAP S/4HANA Standard Business Partner Service API_BUSINESS_PARTNER using it’s EDMX. This is, of course, accompanied by a lot of advantages, such as there will no longer be a requirement to change a business application to migrate from SAP ECC to SAP S/4HANA as the EDMX of SAP ECC will be similar to that of SAP S/4HANA.
You will soon see how one Cloud Business Application can pull both SAP ECC and SAP S/4HANA master data. So, let’s get started!
Create Business Partner oData Service
- Navigate here to download the EDMX of Business Partner from API Business Hub.
2. Navigate to the transaction SEGW to create a Project.
Enter the data as shown below:
3. Navigate to File → Data Model → Import → Data Model
4. Import the EDMX file of the downloaded API_BUSINESS_PARTNER using Browse → Next.
All the entities are automatically imported through the EDMX file. Click on Finish.
Note: You might face an issue while importing the EDMX, due to an error in the conversion of data type. Please ignore the error for this scenario and continue for generation.
5. Click in Generate to enable DPC, MPC, Model, and Service successfully. You can save this either in the Local Package or in the Transport.
You will get a dialog box with a message “Do you still want to generate runtime artifacts (yes/no)”; select Yes.
The following success messages will show all the registered Models and Services:
6. Navigate to Service → Runtime Artifacts.
Right click on the runtime artifact ZCL_ZAPI_BUSINESS_P_DPC_EXT → Go to ABAP Workbench.
7. You will be navigated to the data provider class builder, where all the CRUD-related operations for the required entity set are implemented.
You can find all the required business entities at Expand Class -> Methods -> Inherited Methods. You must redefine each entity that has to be implemented.
For example, find entity A_BUSINESSPARTNE_GET_ENTITYSET and redefine as shown below.
Copy and paste the code below in the entity A_BUSINESSPARTNE_GET_ENTITYSET.
METHOD a_businesspartne_get_entityset.
* &--------------------------------------------------------------------------------------------*
* & Data Declaration
* &--------------------------------------------------------------------------------------------*
*Fetch the Business Partner Detail from Business Partner Master Table into local internal table.
SELECT partner,
name1_text,
bu_sort1
FROM but000 INTO TABLE @DATA(lt_partner)
*Pass the record of local internal table record to output entity of Business Partner API
LOOP AT lt_partner INTO DATA(ls_partner).
APPEND VALUE #( businesspartner = ls_partner-partner "Business lv_partner
businesspartnerfullname = ls_partner-name1_text "Business Full Name
searchterm1 = ls_partner-bu_sort1 "Search Term
) TO et_entityset.
ENDLOOP.
ENDMETHOD.
Note: This code snippet is written so that the select query to fetches all records. However, it is recommended to use BAPI, to select single record.
You must save the code after it is pasted. You can then check the code syntax. If there is no error, you can activate the object. Once the activation is successful, you will get the following message:
Note: Never perform a forced activation, as it will dump the object. If activation is failing with errors, revisit the previous steps and ensure that every step is performed properly.
Register Your oData Service
- Navigate to the transaction /n/iwfnd/maint_service and click on Add Service to register the service.
2. Follow the steps below to register the newly created Business Partner in Gateway.
3. The service will be visible in your gateway service catalog once it’s registered.
Test Your Service
- Click on Registered Service → SAP Gateway Client
2. Click on Execute and you should see the status code 200 in your response body.
Any status code other than 200 means there is an error in service activation.
3. In the response, you might notice that all the entity sets belong to the standard service API_BUSINESS_PARTNER, such as A_BusinessPartner and A_BusinessPartnerAddress. In other words, it has inherited all the properties of the standard business partner.
4. You can see the metadata of this custom service by putting $metadata at the end of url; you will see the namespace API_BUSINESS_PARTNER.
Isn’t that cool!
5. Change the requested URI and put A_BusinessPartner after the Service, as shown below.
6. Click on Execute and you should see the status code 200 in your response body.
Any status code other than 200 means there is an error in service activation.
7. Below, you can see all the backend data pulled by your service in response:
Test From Postman
You need the IP to access your API from outside SAP ECC. It will be the same IP and you would need it while you configure the cloud connector. There are many ways to get it, such as the transaction SMICM and the Gateway.
Inside the Gateway, you can directly click on Call Browser and the service URL will pop up with the IP and PORT.
Once you get the IP and PORT, you can access from POSTMAN easily.
If you select Authentication → Basic Auth, your username will be your SAP logon user ID and the password will be your GUI password.
.
Conclusion
Creating an oData service in SAP ECC from EDMX of standard services comes with a lot of advantages, such as getting rid of manual creation of complex entities. Since the Association and Navigation property remains the same, the way of calling these services, as compared to standard, remains unchanged.
What Next
In my blog post , we will see how we can consume this service from SAP Cloud Application Programming Model, and use the same application for accessing SAP ECC and SAP S/4HANA master data.
In a later blog post, you will also be introduced to SAP Enterprise Messaging, SAP Cloud SDK , SAP Integration Suite, and SAP Fiori Elements, and also try to build an extension scenario based on these services.
SAP ERP Extension on SAP Discovery Centre
We have recently released a Mission for an event-driven extension scenario for SAP ERP 6.0, which is available on SAP Discovery Centre . You can watch the Mission Demo video 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 to the sample reference application here.
Thank you Syed....Very detailed explanation,good work.... Awaiting for the part 2..
Thanks Datta. I am glad that you liked it.
Thanks, good explanation.
But regarding the select from but000:
Does not seem the proper way, or? You should use some BAPI like BAPI_BUPA_CENTRAL_GETDETAIL, or? Thanks
Thanks Clemens for the feedback. I am glad that you liked it.
You are exactly correct that we should used above BAPI . But as this blog post is just to show on how to fetch all business partner master data through oData i have used entity A_BUSINESSPARTNE_GET_ENTITYSET as the above BAPI needs mandatory business partner number as one of the importing parameter. However when we moved slowly to next blog post towards integration with SAP Cloud Platform, we will redefine more entity and this entity as well and then BAPI will come into picture as we will going to get this BP ID from business application.
Nice Blog Syed, Very informative...
Hi @Syed Ejazuddin
Can you please explain how do we perform CRUD operations in business partner api using RFC. Is there any particular RFC available for this?
Thanks in advance
Very Informative Syed Ejazuddin