Stefan Hagen introduced the use of Cloud C4C in application in the blog, SAP Cloud application Studio performance Best Practices Studio performs some performance-related best practices for ABSL programming.
Some guideline are sketchy in the article. Here are a few concrete examples.
How to bulk invoke Bo action
A bad example:
The first and fourth lines have two loops, and then in the second loop call a more time-consuming Servicerequest Bo's standard action finishfulfilmentprocessing defined on the item node. The time complexity of the code is O (n2)
The right approach:
The principle of optimization is that c4c, like many other NetWeaver-based SAP products, supports bulk operations with its Bo core service. The so-called bulk operation, technically, is that the input parameters of these service are an inner table, not a single data. If you have done CRM development, you can analogy crm_order_maintain this function module, all of its input parameters are internal table structure. C4C's Bo provides a service interface definition that also fully incorporates this design to support bulk operations.
In this bad example, the pseudo code for the ABAP code is compiled as follows: (because C4C's backend code is not open to partner and the client, I can only provide pseudocode). It can be seen that although Bo's action is to perform bulk operations, this notation does not play the role of bulk operations, each time inside the loop as the input parameter of the inner label in the second row is emptied, resulting in each call Bo action when the input parameter only one record.
For the correct example, the pseudo-code generated after compilation is:
It is clear to see that the execution of the Bo action has been placed outside the loop.
How to Bulk Execute Bo Retrieve
When we tried to call Bo's Retrieve method in cloud studio through the Code AutoComplete feature, the IDE would prompt us to have three overloads (overload) for the Retrieve method, which indicates that retrieve can support passing in different parameters.
The correct and not recommended practices are shown in blue and red codes respectively. You can see that the blue code retrieve accepts input parameters as a collection containing two elements with IDs 3 and 4, so that 41 rows of calls can return 2 servicerequest of data at a time.
The pseudo-code of the ABAP code generated by line 43 after compilation:
The pseudo-code of the ABAP code generated by line 41 after compilation:
By comparison, it can be found that if the parameter passed into the retrieve is a collection of IDs, then the generated ABAP code calls an interface for the retrieve method of the inner table, which reads the data in bulk.
How to Bulk Execute Bo Create
For the underlying create operation, see line 54th of the following code, which only supports data creation based on a single node.
But for the createwithreference scenario, as with the retrieve scenario for the second example, not only does it support passing in a single data (line 56th), it also supports passing in a collection (line 58th).
These two different inputs cause the build-generated ABAP code to enter the execution logic of create_with_ref_1 and Create_with_ref_n respectively, producing performance differences.
To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:
C4C Cloud Application Studio does some performance-related best practices for ABSL development