Skip to Content
Author's profile photo Sriprasad Shivaram Bhat

SAP CP-IS [ SAP HCI ] Looping Process Call in detail

Introduction:

You might have come across the scenario where you want to set the retry for SOAP adapter or you want to loop some set of steps till some condition is met,so here is the solution for that is  “Looping Process Call”.

More about Looping Process Call:

If you are having programming language experience ( at least basics ) its very easy to correlate with concept of While(Condition) {  perform some action } loop.

while ( condition )
{

 Process Steps in Local Integration Process

}

Instead of some code here we have Location Integration Sub Process .The sub process will run as long as the loop condition is fulfilled.

Looping Process Call can be added to Integration Process by pulling Process Call step from Palette and then selecting Switch to Looping Process.

Lets take few scenarios where we can leverage above steps

Scenario 1: 

Process the Compound Employee Data in batches using Looping Process.

1.Timer Event: To schedule the interface deployment.

2.Content Modifier: To have some data and some headers.

3.Looping Process Call: Call the Local Integration Process till Condition specified is true.

<1> Name of the Local Integration Process that needs to be called.

<2> Expression Type [ XML based or non XML based (Header Property )]

<3> SAP defined property which will tell whether Query has more records or not.

         Format: ${property.SAP_SuccessFactorsHasMoreRecords.<RECEIVER_SYS_NAME>.

                                      <RECEIVER_CHANNEL_NAME>}

<4>Max No of iterations to be mentioned to avoid infinite loops.

4.External Call: Call to SuccessFactors systems which will give Receiver System Name                                                 and Channel Name.

5. Message Mapping: Message Mapping to convert from Compound Employee Structure to                                                    Custom Structure.

6. Converter: To convert from XML to CSV format.

7. Channel: SFTP Channel to send the converted data to SFTP server.

Advantage of using Looping Process in above Scenario:

If you take an example of SuccessFactors system having employee data more 25 to 30K ,post your query step if converter and message mapping will receive all data together causing heap memory issue.If you use Looping process data will be sent to mapping and further step chunk by chunk( based on Page size mentioned in SF Channel ) without  putting complete load of data into Mapping Step and converter in one shot.

Scenario 2:

To set the manual retry in SOAP channel.

<1> Expression Type: Set the Expression Type as XML

<2> Condition Expression: Enter the condition till the condition becomes false.In our case                       local integration process to be called whenever we receive the Error Response from                           SOAP call inside the Local Integration process.

<3>Max No of iterations: Enter value for how many times call to be retried in the case of                           SOAP call failure.In our case we need to set the retry value of 5 times in case of SOAP                       call failure to target system.

Scenario 3:

Scenario where you have a  Adhoc Report scheduled in SuccessFactors using SAP HCI and you need to pull the data only after the Job is finished and you need to loop the process till JobStatus is running.

<1> Condition Expression: Local Integration Process Call will be looped till jobstatus is                                  running.

Conclusion:

Very useful step to handle requirements where we need to perform some task in looping manner.

References:

[1] Looping Process:

SAP HELP- Looping Process Call

Regards,

Sriprasad Shivaram Bhat

Assigned Tags

      26 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Moya Watson
      Moya Watson

      Great post - thanks for taking the time to share this, Sriprasad!

       

      Author's profile photo Biplab Das
      Biplab Das

      Good one Sri.Keep on blogging.

      Author's profile photo aravind pujari
      aravind pujari

      Thanks for explaining the usage of  Looping process call functionality in detail.

      Author's profile photo Gayathri Narayana
      Gayathri Narayana

      Very well illustrated !!  thanks for contributing to our community. Keep blogging !!

      Author's profile photo Former Member
      Former Member

      Nice one Sri, as mentioned in above comments it is very well illustrated by presenting it in a very simplified manner with the use case

      Author's profile photo Mark Bernabe
      Mark Bernabe

      Hi Sriprasad,

      Great blog as always! So in your example, the data from SF will be sent to the SFTP server for every iteration until ${property.SAP_SuccessFactorsHasMoreRecords} is false, right?

      Author's profile photo Sriprasad Shivaram Bhat
      Sriprasad Shivaram Bhat
      Blog Post Author

      Hello Mark,

      Data will be sent to SFTP Server only when all iterations are completed or condition mentioned becomes false.

      Regards,

      Sriprasad Shivaram Bhat

      Author's profile photo Mark Bernabe
      Mark Bernabe

      Hello Sripradad,

      Does it mean it will only send to the SFTP once? Will the messages from SF in the local integration process aggregate until it's false?

      Author's profile photo Khristian Paolo Elefante
      Khristian Paolo Elefante

      Hi Mark,

      Were you able to confirm if the data will only be sent to the sftp once or if it will be sent for every iteration?

      Author's profile photo Mark Bernabe
      Mark Bernabe

      Hi Khristian,

       

      Sorry for the delay. Messages will be sent to SFTP for every iteration.

      Author's profile photo Balaji Singaperumal
      Balaji Singaperumal

      Hi Sriprasad,

       

      I am trying the scenario 1 you explained. In my SF channel I am using page option to pull 5 records at time and looping count i have given as 2 in the looping process call but only the 5 records are passed to next step (guess the 5 records from 2nd loop ).  Its not accumulating to 10 records  then passing to next step. is this expected? do I have to use a gather step after Loop process call? Could you please help me out

       

      Regards,

      Balaji

      Author's profile photo Deepak Jaiswal
      Deepak Jaiswal

      Hi Sriprasad,

      We are using looping process call for Odata entity and need to send the xml to csv converted values after mapping step at one shot of all collected(gathered) xmls.

      Do we need to used gather step after looping process call ,as we need to add Header texts on the first line. But Header texts are getting repeated after each pagination size we entered in channel and file we are creating on append mode.

      Any suggestions to handle this scenario.Do we need to remove pagination.

      Regards

      Deepak

      Author's profile photo Pavan kumar
      Pavan kumar

      Hi Deepak Jaiswal ,

      After mapping please add XML to CSV and then Gather Step with option Plain Text,Concatenate and then Content modifier with Headers Field labels as constant and ${in.body} and then Send step

      Edit: Headers will be a problem in the above append mode, as the loop and gather will not wait until all the records are fetched from the ODATA API

      Edit on 21-Dec-2021: For the benefit of others, I set routing rule based on the looping condition contains 'true' and stored data into the write DS once the looping is completed then Data select from the write DS and preparing the data sets with headers before creating the file into SFTP.

      Cheers

      Pavan Nukala

      Author's profile photo Aditya W. Sharma
      Aditya W. Sharma

      A very well articulated and explained usage of Looping process, will be helpful for anyone to gain further perspective in the functionalities offered by SAP. Thanks Sri for the wonderful blog.

      Author's profile photo ashwini pandey
      ashwini pandey

      Hi Shri,

      One of the useful blogs in HCI -PI. Thank for sharing

      Author's profile photo Former Member
      Former Member

      Nice one prasad...very useful

      Author's profile photo Sana Faraz
      Sana Faraz

      This blog is valid for SuccessFactor OData and Generic OData but the format of the property defined in Looping Integration Process is:

      ${property.<ReceiverName>.<ChannelName>.hasMoreRecords} contains 'true'

      Author's profile photo Former Member
      Former Member

      Can we add multiple condition in condition expression?

      Author's profile photo Sriprasad S Bhat
      Sriprasad S Bhat

      Yes you can achieve by using "and" "or" operation in condition .

      Its very similar to giving condition in while loop.

      Regards,

      Sriprasad Shivaram Bhat

      Author's profile photo Former Member
      Former Member

      Can I use looping process call when an error message is returned? How can I form a condition expression with that? Currently what I'm doing is this: /error[code = 'COE_ENTITY_NOT_FOUND']. It does not loop when this is the returned message.

      Author's profile photo Athar Iqbal
      Athar Iqbal

      Hi Sri, i have an xml file which has multiple records. I need to call a REST service for each record. How could I achieve it using Looping Process.

      I am recieving the xml file from an external source via HTTPS Post.

      Thanks in advance

      Athar

      Author's profile photo Ashutosh Kumar
      Ashutosh Kumar

      Hi Sriprasad,

      I have a requirement where i want to join all the message obtained in batch processing, say after my interface specific mapping. Since all the messages in batches are coming one by one, how to combine/join them together?

      Author's profile photo Suresh Sakthivel
      Suresh Sakthivel

      Hi Sriprasad Shivaram Bhat ,

      Thanks for the wonderful Blog!!

      Could you confirm if we need to collate all the data and process together.

      Since we need to post the collated data into SFTP server as a Single file.

      Is it possible to gather and send it across . Pls confirm?

      Since in case of any issues during 'n'th iteration only partial data been sent to Target system.

      ASHUTOSH KUMAR  Mark Bernabe   - Could you share your inputs too?

      Best Regards,
      Suresh S

      Author's profile photo Rashmi Joshi
      Rashmi Joshi

      Hi Sriprasad Shivaram Bhat ,

      Thank you for the detailed article. Please help me to understand where can I see all possible properties available to be used in loop condition. I see in your example you have used below condition -

        Format: ${property.SAP_SuccessFactorsHasMoreRecords.<RECEIVER_SYS_NAME>.

                                            <RECEIVER_CHANNEL_NAME>}

       

      TIA,

      Rashmi

      Author's profile photo ANA MARTINEZ RAMIREZ
      ANA MARTINEZ RAMIREZ

      SFSF is returning SAP_SuccessFactorsHasMoreRecords with 'true' but at the last version Cloud Platform integration has configured 'TRUE' in the standard iflow. Could someone helps?

      Author's profile photo Prasenjit Sarkar
      Prasenjit Sarkar

      Hey Sri,

      Is there a standard attribute that can provide current loop count?

      Regards

      Prasenjit.