Bridging the World between SAP ECC and SAP Business Technology Platform through Event-Driven Architecture – Part 1
SAP ERP Central Component (SAP ECC) implementation is mostly done using Advanced Business Application Programming (ABAP) for business implementation. However these implementation comes with a lot of challenges and risk the way they manage critical business information, although implementation of SAP ECC are too valuable. However just imagine that SAP ECC customers building an extension application on SAP Business Technology Platform (SAP BTP) and ripening the benefit of SAP HANA making there business much faster. Yes, I am talking about Side-by-Side Extensibility of SAP ECC. This extensibility will offer a lot of new use cases such as IoT scenarios, SAP and third party application integration, Integrating SAP ECC real time data with cloud applications and this all comes without much disturbing the core.
This blog post will be mostly focused for community who want to try there hands on various technology 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 few ABAP basic to create a quick backend API in SAP ECC and Node.js to create a business application on SAP Business Technology Platform.
We will see how we can create a Business Partner oData Service in SAP ECC and then call this SAP ECC oData Service using SAP Cloud Application Programming model locally using basic authentication. But the Question arise that why we should create this services in SAP ECC. Can we not get this API from SAP API Business Hub . Yes You can get the API from SAP API Business Hub for SAP S/4HANA but unfortunately it’s not available for SAP ECC and here comes the blocker as these API works as the bridge between backend and SAP Business Technology Platform. However it’s not difficult to create that as well in SAP ECC. In this blog post we are going to replicate SAP S/4HANA Standard Business Partner Service API_BUSINESS_PARTNER using it’s EDMX. And of course this comes will a lot of advantages like you don’t need to change a business application to migrate from SAP ECC to SAP S/4HANA as your EDMX of SAP ECC will be similar to SAP S/4 HANA. In the end you will see that how one Cloud Business Application can pull both SAP ECC and SAP S/4HANA master data. So let’s Start!!
Create Business Partner oData Service
Navigate to link to download EDMX of Business Partner from API Business Hub.
Navigate to Transaction SEGW to create Project. Please fill the data as shown in below snapshot.
Navigate to Data Model-> Import -> Data Model from File
Import EDMX file of Downloaded API_BUSINESS_PARTNER using “Browse” and click on “Next”
You will see all the entity automatically got imported through EDMX file. Click on “Finish”
Note: You might face issue of importing EDMX error due to conversion of data type. Please ignore for this scenario. Continue for generation.
Click in “Generate” to enable DPC, MPC, Model and Service Successfully. Save in “Local Package” or in “Transport”. Clicking on “Generate” You will get a dialog box with message “Do You still want to generate runtime artifacts (yes/no)”. Here Select “Yes” to continue.
Below Successful message will show all the registered Model and Service.
Navigate to Service -> Runtime Artifacts -> Right Click on runtime artifact ZCL_ZAPI_BUSINESS_P_DPC_EXT’ -> Go to ABAP Workbench.
You will be navigated to Data Provider Class Builder where we implement all the CRUD related operation for Required entity set. Expand Class -> Methods -> Inherited Methods. This is the location where you can find all the business entity. To implement the entity, we have to redefine each entity.
Find entity A_BUSINESSPARTNE_GET_ENTITYSET and redefine as shown below.
Copy and Paste the below Code in 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: Just to note that here in this code snippet, i have written select query to fetch all record. However to select single record, it will be preferable to use BAPI.
After Pasting the Code, Save the Code and You will get message that Code is Saved. Then Check the Code that your syntax is correct. Last everything went without error, then Activate the object. Once the activation is successful you will get message in the below for successful activation. Please see the image below.
Note: Never do force Activation as it will dump the Object. If activation is giving error, revisit the previous steps and ensure every step is done properly.
Register Your oData Service
Navigate to Transaction /n/iwfnd/maint_service and Click on “Add Service” to register the service.
Follow the below steps to register newly created Business Partner in Gateway.
Once it’s registered, you will see service in your gateway service catalog.
Test Your Service
Click on registered service and Click on “SAP Gateway Client”
Click on “Execute” and you will see status code ‘200’ in your response body. Status Code other than ‘200’ means some error in Service activation.
In the response, you might notice that all the entity set are the one that belongs to standard service API_BUSINESS_PARTNER like A_BusinessPartner, A_BusinessPartnerAddress etc. In other words, it has inherited all the properties of standard business partner. If you will 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 🙂
Change the Requested URI and put A_BusinessPartner after Service like below. Click on “Execute” and you will see status code ‘200’ in your response body. Status Code other than ‘200’ means some error in Service activation.
So here in response, you can see all the Backend data pulled by your service.
Test From Postman
If you want to access your API outside SAP ECC, you need the IP to get it worked. It will be the same IP you need it while you want to configure cloud connector. There are many ways to get it like from transaction SMICM, Gateway, etc. But as we are inside gateway, you can directly click on “Call Browser” and it will popup you the service url with IP and PORT.
Once you get the IP and PORT, you can access from POSTMAN easily. While you select Authentication as “Basic Auth” , your Username will be SAP Logon User ID and Password will be GUI Password.
Creating oData service in SAP ECC from EDMX of standard services comes with a lot of advantages such as getting rid of creation of complex entity manually. As the Association and Navigation property remains same, the way of calling these services as compared to standard remains unchanged.
In my blog post ,we will see how we can consume this service from SAP Cloud Application Programming Model, and can use the same application for accessing both SAP ECC and SAP S/4HANA master data.
In later blog post, We will also move up our level and get introduce with SAP Enterprise Messaging, SAP Cloud SDK , SAP Integration Suite and SAP Fiori Elements and also try to built extension scenario based on these service
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