Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
DenizZilyas
Participant

Introduction

Looping Process Call refers to a way of repeating processes in an SAP program using loops, calling one or more processes within a specific cycle. This can be useful, especially when working with large data sets or when automating a series of tasks. f we are working with large datasets, fetching them all at once increases RAM consumption.

With this method, we retrieve our data in fragments based on a certain condition, and after the loop ends, our data is merged as a whole. From a performance perspective, we alleviate the strain on memory. It reduces processing time and enhances performance. It simplifies our overall data analysis.

Now, we will design a scenario in cloud integration. We will fetch large data from OData and loop it through a specific condition (looping process call). Then, we will observe the results together.

Prerequisite: BTP Cockpit access and Integration Suite

 DenizZilyas_0-1707331615217.png

                                                       Figure 1. Integration Overview

 

Step 1. First, we will create a CPI link to be able to make calls to the service.

DenizZilyas_1-1707331805920.png

                                                         Figure 2. Sender HTTPS Adapter

Adapter Type: HTTPS
Address: Specific

Step 2. We specify that the looping process call will work according to the condition expression specified in the "condition expression" field. By stating ".hasMoreRecords contains 'true', we indicate that the loop will continue to run as long as there are multiple records. You can take a look at (hasMoreRecords).

When this condition returns false, the loop will end.

DenizZilyas_2-1707331969068.png

                                                                   Figure 3. Loop Process Call

Step 3.OData informations.

DenizZilyas_3-1707332181911.png

                                                              Figure 4.Odata Adapter Connection Information

Step 4.We use the "select" clause to choose which fields we want to retrieve from the Orders entity.

Our method is GET.

We need to mark "Process in Pages". If we don't mark it, the system will send all the data at once after entering the loop once.

DenizZilyas_4-1707332243889.png

                                                Figure 5.Odata Adapter Processing Information

Step 5.After passing through the filter, the data will no longer include "Orders" but will start with "Order." This is because we need the information of "Orders/Order" due to sending the data in fragments. After completing the process of sending fragmented data, we will merge it in the "Message Body" of the Content Modifier.

DenizZilyas_5-1707332324844.png

                                                                       Figure 6.Filter

Step 6.${property.payloadStack}${in.body} : We use it to continue adding each incoming fragmented data to the body. You can take a look at it.

DenizZilyas_6-1707332378498.png

                             Figure 7. Content Modifier-Exchange Properties-Append Body

Step 7.We add the "Orders" tag, which we ignored with the filter, to this content modifier. Once the loop is completely finished, we add the merged data as a property.

DenizZilyas_7-1707332475109.png

                                                   Figure 8.Content Modifier-Message Body

Step 8.To indicate that the last data will come in XML format, we add the "Content-Type" header.

DenizZilyas_8-1707332515739.png

                                                                    Figure 9.Content Type

Step 9. We fill in the necessary information for the email adapter.

DenizZilyas_9-1707332643738.png

                                             Figure 10.Mail Adapter Connection Information

Step 10.We determine who the email will come from and who it will go to.

DenizZilyas_10-1707332739713.png

                                                                 Figure 11.Mail Adapter Processing Information

Step 11. Save and Deploy. Then once we have created a CPI link, we need to call it using the GET method in Postman after the deployment.

Step 12. We are making a call to the CPI service using the CPI username and password.

DenizZilyas_11-1707332940878.png

                                                           Figure 12.Postman 

Step 13. It entered the loop a total of 6 times, but on the 6th request, since there was no data left inside, it combined the data sent in fragments, exited the loop, and continued to 'End'.

DenizZilyas_12-1707333330109.png

                                                          Figure 12.Monitoring

When we look at our first loop, it indicates that in the first request, it fetched the first 200 records from the entire data set and provided the information that the next loop would start with OrderID 10448 using the expression "$skiptoken=10447".

DenizZilyas_13-1707333542419.png

DenizZilyas_14-1707333726493.png

In each loop, as it adds data, it indicates that there were 400 records in the 2nd request, and when it enters the 3rd loop, it won't fetch the same initial 400 records again. Similarly, it shows that in the next loop, the data will start with OrderID 10648.

DenizZilyas_15-1707333794986.png

The important point to note is that it continues to loop as long as the condition we set is met, meaning it enters the loop as long as it evaluates to true.

DenizZilyas_16-1707334152764.png

When we check the final step, we understand that this condition returns false, indicating that it has fetched all the data inside.

DenizZilyas_17-1707334204127.png

 

DenizZilyas_18-1707334310475.png

Due to the condition, since the Loop process has ended, we receive information that the last data has the OrderID number 11047.

Finally, I wanted to add an email adapter. It notifies all the information via email.

DenizZilyas_19-1707334434312.png

DenizZilyas_20-1707334526540.png

 

 

 

 

 

 

 

 

 

 

6 Comments
learninghubx01
Explorer
0 Kudos

Wonderful blog

SATHEESHKUMAR
Explorer
0 Kudos

Hi DenizZilyas,

Nice Blog , Keep blogging.

 

rasjoshi
Active Contributor
0 Kudos

Hi DenizZilyas,

 

what if we still have more records to fetch but loop max iteration value reached? In such scenario How to fetch missing records?

DenizZilyas
Participant
0 Kudos

@rasjoshi If we mark the throw exception when it reaches the maximum iteration, we will get the data equal to the number of iterations we specified, since it exceeds the number of iterations. If we count the API with the $count parameter when triggering it in Postman, we can view how many pages will arrive on average. And we can determine an average number of iterations. We should increase the number of iterations just in case. The number of iterations is a process that will prevent lost data. If you want, you can also give 9999 here. Integration ends when there is no more data inside.

rasjoshi
Active Contributor
0 Kudos

Thanks for the reply DenizZilyas, thats the question if interface hits upper limit of 99999 how to fetch remaining data? 

DenizZilyas
Participant
0 Kudos

You are welcome @rasjoshi  CPI max gives this much as a limit. It shouldn't be a case with 9999 iterations anyway. There will be many problems in terms of performance anyway, it will be a very tiring and long process for CPI. So if it reaches the upper limit you won't be able to retrieve the remaining data.

Labels in this area