Have you ever wanted to loop within an SDA process, something like this?
Unfortunately, what I've drawn above isn't supported, and while you can design it within the process editor you can't run it. Attempting to do so will result in an execution error. But don't despair, there is another way to achieve similar results.
While SDA doesn't support loops within processes, it does allow a process to invoke itself. The use-cases are going to vary, and what you use as your "loop control" mechanism will depend on your use case. In some cases, for instance database deployments, there is a manifest or control file that contains the scripts to run, and the idea is to read the file and for each script process it within it's own loop. While we always recommend using an actual configuration tool for database deployments (i.e. DaticalDB for example), we also understand that it may be challenging to implement if you're not doing it already, and sometimes we need to take a phased approach to automation which may require using a manifest or control file initially. Long story short, there are valid reasons for needing to "loop" a process, so let's talk about how we can do it.
For this example, we're going to write to a file and use the "Monitor File Contents" plug-in step to exit after 3 "loops". Our process is shown in Figure 2.
Here's what we are doing:
Let's take a look at this in action.
First, we run the process. The output is shown in Figure 3. below. You'll see my first step returns "Success". The second one, "Monitor File Contents", returns "Failed". This failure takes us down the failure path to the loop step. We'll also see that next to the Loop Failure indicator is a link to "View Child Process". Because this process run went down the loop path, it'll never hit the "Complete" step.
Drilling into the second process run using the "View Child Execution", we can see the results in Figure 4 below. Because this is a child process, we can see the "View Parent Details" link. Clicking this would take us back to the output displayed in Figure 3. This second process-run did our "Do some stuff" step, and then went into "Monitor File Contents" which failed. As before, this failure causes us to go down the loop path, so this child has a child of it's own, which we can drill into by clicking the "View Child Execution" link.
Drilling into the third process run, we can see the results in Figure 5 below. As before, we "Do some stuff", but this time when the "Monitor File Contents" step runs it finds our target string in our output file that has been being built, and returns true. Because we get a true value here, we take the appropriate branch towards "Complete".
This is a basic example of how you can have a process invoke itself in order to "loop". As I mentioned before, your use-case and method of controlling the loop logic is going to vary, but if you get stuck ask for help in the forums and we're happy to help you out.
The example (generic) process is attached. If you run this, you'll need to manually clean up the control (temp.out) file in your agent directory, otherwise this will only work the first time through. I used a generic process for this example, however the concept works just as well in component processes.