In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to use a development method similar to building blocks for SAP API development", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use a development method similar to building blocks for SAP API development".
Open the Operators tab of Modeler and see that there are more than 300 Operator under different Categories.
Each Operator can perform a function in a certain area, such as connecting to the ABAP system and reading data, generating random data, writing data to some persistent storage, calling API, and so on. By combining these Operators, we finally implement an end-to-end scenario.
Before we start using these Operator to build API, let's try some of the simplest Operator. Drag and drop a Data Generator with the icon of the Terran radar station in StarCraft to the editing page.
This Operator defines an Output Port of type String, meaning that the random number it generates, as the type of String, is passed to other Operator through the Output Port.
The Output Port of Data Generator above points to the Input Port of another Terminal Operator, which represents the direction of data flow, output from Data Generator to Terminal.
These Operators as nodes and the directed segments of connected nodes are combined to form the Graph in SAP Data Intelligence (figure).
One of the characteristics of SAP Data embracing open technology is mentioned on its website:
For example, Kafka Consumer and Producer Operator provided by SAP Data Intelligence can easily implement producer-consumer scenarios without programming by maintaining a Kafka Broker address:
Now go back to the need to add, delete, change and check API mentioned at the beginning of this article. This API can be called by consumers through HTTP, and the operating objects that are added, deleted, modified and checked through API are only maintained in the memory of the Graph runtime, which is actually a simple object key-value pair implemented by JavaScript. For simplicity, persistence operations are omitted.
The API implemented by Graph is finally shown in the following figure, which consists of a total of six Operator, including one HTTP Server, four JavaScript Operator and one Multiplexer.
According to the help documentation, the HTTP Server Operator encapsulates the functionality of the simplest HTTP server and can receive HTTP requests on a user-configured endpoints.
How to configure Operator? Select "Open Configuration" from the right-click menu, and click the edit icon of Routes:
According to the SAP help documentation, HTTP Server Operator is only responsible for receiving HTTP requests and is not responsible for business processing after receiving these requests, but is handed over through Output Port to other Operator downstream of Graph. The Route configuration information is clear at a glance. After receiving the HTTP request with parameter id on the path / objects, the request is forwarded to other Operators through get, post and delete Output Port respectively according to the HTTP request type.
Next we implement the response logic for the HTTP GET operation. Drag a JavaScript Operator from the Operators tab to the editing page, rename it GET Handler, create an Input Port called request, and connect it to HTTP Server's get Output Port.
Right-click GET Handler and select the Open Script menu item:
It is anticipated that after HTTP Server receives the GET,POST and DELET requests, there is some general logic to deal with, such as parsing the object ID parameter values passed in by the consumer from the URL and handing it over to the downstream Operator for further processing. Therefore, the design here is that after receiving the request, the three Handler only construct a command object, which contains the operation type of the in-memory JavaScript object key-value pair corresponding to the HTTP request (the GET request corresponds to the delete corresponding to the select,POST request) and the passed parameter ID value:
From the figure above, we can see that there is no difference in the implementation code of the three Handler except for the type of operation (objectStore.command) passed to the downstream node through the command Output port.
When any HTTP request is received by HTTP Server, only one of the three Handler will be triggered. Three kinds of Handler produce three possible output operations, which are passed to the triplex multiplexer with Trident icon in the image above through an Output Port named command. This multiplexer ensures that the last JavaScript Handler can handle all three possibilities at the same time. After performing the corresponding key-value pair operation, the processing result is passed to the Input Port of HTTP Server through the data flow marked by the orange dotted line above.
Inside the JavaScript Handler named Object Store, an empty JavaScript object is defined with the variable objects as the storage entity for the key-value pair. For the three operations of select,insert and delete, add, delete, modify and search with this object respectively.
In this way, the Graph forms a complete closed loop from receiving the HTTP request to writing the result to the Input Port named Response in the HTTP Server after processing the request.
After the Graph is developed, click the run button, and after it is running, you can use tools such as Postman or programming languages to consume it. Copy down its Runtime Handle on the console:
First, test the API read function and try to read an instance with an ID of 1:
Https:///app/pipeline-modeler/service/v1/graphs//operator/httpserver1/objects/1
The message "no obect with ID" returned is the error handling that we hard-coded in Object Store JavaScript Handler.
Then call HTTP Post to insert a JavaScript object with a key of 1:
Then read it with HTTP GET, this time successfully:
Use HTTP DELETE to request to delete the object with an ID of 1:
At this point, I believe you have a deeper understanding of "how to use a development method similar to building blocks for SAP API development". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.