August 17, 2023

tForeach – Docs for ESB 5.x

tForeach

tForeach_icon32.png

tForeach Properties

Component Family

Orchestration

 

Function

tForeach creates a loop on a list
for an iterate link.

Purpose

tForeach allows you to to create
a loop on a list for an iterate link.

Basic settings

Values

Use the [+] button to add rows to
the Values table. Then click on the
fields to enter the list values to be iterated upon, between double
quotation marks.

Advanced settings

tStatCatcher Statistics

Select this check box to collect the log data at a component
level.

Global Variables

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

CURRENT_VALUE: the value currently iterated upon. This is
a Flow variable and it returns a string.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see Talend Studio
User Guide.

Usage

tForeach is an input component
and requires an Iterate link to connect it to another
component.

Log4j

The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User
Guide
.

For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html.

Limitation

n/a

Scenario: Iterating on a list and retrieving the values

This scenario describes a two component Job in which a list is created and iterated
upon in a tForeach component. The values are then
retrieved in a tJava component.

  • Drop a tForeach and a tJava component onto the design workspace:

tForeach_scenario_components.png
  • Link tForeach to tJava using a Row > Iterate
    connection.

  • Double-click tForeach to open its Basic settings view:

tForeach_scenario_basic_settings.png
  • Click the [+] button to add as many rows to
    the Values list as required.

  • Click on the Value fields to enter the list
    values, between double quotation marks.

  • Double-click tJava to open its Basic settings view:

tForeach_scenario_tJava_basic_settings.png
  • Enter the following Java code in the Code
    area:
    System.out.println(globalMap.get(“tForeach_1_CURRENT_VALUE”)+”_out”);

  • Save the Job and press F6 to run it

    The tJava run view displays the list values
    retrieved from tForeach, each one suffixed with
    _out:

tforeach_scenario_tjava_run_view.png

Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x