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 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.

Talend tForeach 2

Let me use the + button to add few values.

Talend tForeach 3

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

Talend tForeach 4

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")));
Talend tForeach 5

From the below tForeach image, you can see that it has been executed 7 times for all the values, and displayed the result using the println statement.

Talend tForeach 6

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.