You don't need the "Declaration" or the "Iteration" values. What you want is a variable in the "Condition" that is a boolean that evaluates to true
and is set to false
when you are wanting to end the loop.
Best practice says you should use context variables for actual contexts supplied to a job either on run time or when starting a child job and then use the globalMap for globally available variables across a single job.
So in this case you should initialise a boolean globalMap variable set to true (you could do this in a tJava component with globalMap.put("loop",true)
or use the tSetGlobalVar component) and then in your tJavaRow you can set the globalMap variable to false with globalMap.put("loop",false)
.
If you were to use "loop" as your globalMap variable then you'd use ((Boolean)globalMap.get("loop"))
in your "Condition" in the tLoop.
A worked simple example of this might look like the following:
First we set the loop variable to true
as we want it to at least start!
And then we set the condition of the while loop to the boolean global variable:
And then finally we run some code in the tJava component that does something and conditionally sets the global variable to false, ending the loop:
if (((Integer)globalMap.get("tLoop_2_CURRENT_ITERATION")) == 3) {
globalMap.put("loop", false);
} else {
System.out.println(((Integer)globalMap.get("tLoop_2_CURRENT_ITERATION")));
};