In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of SAP C/4HANA Sales Cloud's use of OData services and third-party system integration. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
It is clearly mentioned that the sales cloud includes SAP Cloud for Customer (C4C), SAP Revenue Cloud and Callidus Cloud.
Partner asks if there are more detailed steps on how to integrate with the Restful API exposed by SAP C4C in a third-party system. This article gives a concrete example to expose the creation function of SAP C4C sales order through a custom OData service, and then Partner can choose the appropriate programming language according to the needs of the project (JavaScript is chosen in this article).
Jerry has previously released a video showing how to manually create a sales order in SAP C4C. The steps are easy to understand.
Https://v.qq.com/x/page/d0809f4tswl.html
Now that we expose the sales order creation function through OData, we can complete the order creation of C4C in a third-party system or application.
If you don't know much about SAP OData, you can read the beginning of my article first:
SAP OData programming Guide
Here are the detailed steps.
Log in to the C4C system, visit the work center Administrator, work center view OData Service Explorer, where you can switch between standard OData services published by SAP and customer-defined OData services.
Because the customer-defined OData service allows the customer to decide which nodes of which Business Object and which fields to choose to generate the OData model, this flexible way can prevent the unwanted fields in the customer business scenario on the Business Object from appearing in the OData model.
Click the New button to create a new OData service:
Specify a view for permission control in the Work Center View field, and only users assigned to this view have access to the OData service.
Click Select Business Object to select the Business Object based on which OData model is created from the pop-up dialog box.
The following figure shows an OData service that has been created and is in the Active state. On the left are all the fields of the Root node of CustomerQuote, the BO, each with a Select attribute that can be checked or unchecked, and the BO field appears in the OData model on the right.
In addition to the Root node, the fields on other child nodes of BO can also appear in the OData model. For example, the child nodes CustomerQuoteItem, CustomerQuoteParty and CustomerQuoteText of the OData model on the right of my image are automatically brought to the OData model on the right after being selected from the node of the same name on the left.
In theory, after the creation and activation of the OData model based on the BO model, the OData service can be used, which reflects the power of the SAP C4C OData services customization framework. However, I also received some questions from some friends backstage, listed below.
Question 1: still take the sales order creation scenario in this article as an example, suppose I want the OData service I created to allow consumers to specify the value of External Reference when calling, but I searched the entire BO list and didn't find a field with that name on the BO of the sales order.
Jerry: External Reference is the UI text, not the technical name of the BO field.
Add the parameter debugMode=true to the url of the C4C system in the browser, then refresh the page, hold down the Ctrl key and click the External Reference field
You can see which field on the UI model is bound to this UI field.
Click Show Model on the UI model field, and you can see that the BO field to which the UI model field is bound is named BuyerID.
So in the OData development tool, we just need to select the BO field BuyerID and move it to the OData model on the right.
Question2: I want my OData service to support the creation of line project data, such as specifying product ID, description and purchase quantity, and so on. How do I know which fields on BO nodes need to be added to the OData model?
Jerry: now open the UI Designer of Cloud Application Studio, navigate to the UI model COD_SALESORDER_QC on the sales order creation page, find the Product ID field, and you can see the name and full path of the BO field bound to this Product ID field in its Properties panel:
Root-.ItemProposal-ProductUUID-content
So we need to add the ProductUUID field under the corresponding path of BO to the OData model. It can be observed here that ProductID's Create and Update are not checked, while ProductUUID supports Create and Update. This behavior is related to the standard implementation of C4C sales order line item creation-consumers need to provide the product UUID contained in the line item to be created, and then C4C will query the corresponding product in the system according to UUID and display its ID to UI. If the consumer does not specify a ProductUUID when invoking the OData service, the line item creation logic will not be executed.
After the OData model is created, we can test it with the tool Postman (or the test tool that comes with C4C) before consuming it in the programming language.
Because SAP C4C backend adopts the same defense against Cross-site request forgery (cross-site request forgery) as SAP CRM,SAP S/4HANA, it adopts CSRF token verification mechanism, so when we call OData service to create sales order, we need to pass a legitimate CSRF token to C4C system.
How to get a legal CSRF token? Construct a HTTP GET request in Postman with the header field named
X-csrf-token, the value is fetch:
When the HTTP GET request is sent, the server generates a CSRF token, which is returned to the consumer through the HTTP response structure header field x-csrf-token:
SNwnYC9cV4xeGSYZmJ8Dtw==
Next, we create a new HTTP Post request in Postman and send the CSRF token previously obtained through HTTP GET to the C4C system in the form of HTTP Post request header field.
The key lies in the body of the HTTP Post request. The highlighted part of the following figure is the input data for creating a sales order that I specified in the HTTP Post request:
Send this Post request in Postman, and get a response from C4C after a few seconds. The order is created successfully, and the ID is 9000000451:
To facilitate comparison, the following is the display of sales orders generated by the OData service I created with Postman in the system. The Postman input field corresponding to field 1: 6 can be found earlier.
The fields highlighted in the blue area are not maintained in the input I constructed in Postman, but are automatically determined by the various determination configurations of the SAP C4C system. The most typical ones are Partner determination,Organization determination,Pricing determination, which SAP veteran drivers deal with every day.
After passing the test in Postman, you can write code and consume it.
If you want to copy and paste the code listed below directly, you can get it from my github:
Https://github.com/i042416/KnowlegeRepository/blob/master/ABAP/C4COData/create_SalesOrder.js
Note that this code is for demonstration purposes only, lacks robust error handling, and cannot be used directly in a production environment.
The following code uses the request module provided by nodejs to request CSRF token from C4C. Note the values of the url in line 3 and the Authorization header in line 11. I use false values. Please replace them with your actual C4C url and authentication information.
After Token gets it, it is placed in the header structure of the HTTP Post request constructed on line 41 as the value of the field x-csrf-token. Line 47 sends the POST request, and the data of the C4C response is stored in the JavaScript variable data.
Finally, I used a simple console.log to print out the successful sales order ID:
Executing the js file with node on the command line will print out the CSRF token obtained from C4C and the successfully created order ID.
Let's review the three main steps of integrating with external systems with C4C OData in SAP C/4HANA Sales Cloud:
1. In the OData model editing page of C4C, according to the business needs, select the appropriate fields from the corresponding BO nodes and add them to the OData model.
two。 Test the OData model with the OData testing tool that comes with Postman or C4C to make sure it works properly.
3. Choose the appropriate programming language to consume OData services according to the needs of the project.
This is the end of the sample analysis on SAP C/4HANA Sales Cloud's use of OData services and third-party system integration. I hope the above can be helpful and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.