Talend tForeach

Talend tForeach is the same as the foreach loop that creates a loop and iterates the same. In this chapter, we show you a simple example of the tForeach. Drag and drop the tForeach component to the job designer window.

Talend tForeach Foreach Loop Example 1

As you can see from the tForeach below, it has only the Values section in the Component tab to add values for the foreach iteration. Let me use the + button to add a few values.

Add Values to its component

Next, we used the tJava component to display or print those foreach iteration values.

Let me add the following Java code to read the current value in the foreach loop iterator. Next, run the Talend tForeach job.

System.out.println(((String)globalMap.get("tForeach_1_CURRENT_VALUE")));
tJava code to display the result

From the below tForeach image, you can see that it executes 7 times for all the values and displays the result using the println statement.

Run the Talend tForeach Foreach loop Job