August 17, 2023

tFlowToIterate – Docs for ESB 5.x

tFlowToIterate

tFlowToIterate_icon32_white.png

tFlowToIterate Properties

Component
family

Orchestration

 

Function

tFlowToIterate iterates on the input data and
generates global variables.

Purpose

This component is used to
read data line by line from the input flow and store the data
entries in iterative global variables.

Basic
settings

Use the default (key, value) in global
variables

When selected, the system uses the default value
of the global variable in the current Job.

 

Customize

key: Type in a
name for the new global variable. Press Ctrl+Space to access all available variables either
global or user-defined.

 

 

value: Click in
the cell to access a list of the columns attached to the defined
global variable.

Usage

You cannot use this
component as a start component. tFlowToIterate
requires an output component.

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.

NB_LINE: the number of rows processed. This is an After
variable and it returns an integer.

CURRENT_ITERATION: the sequence number of the current
iteration. This is a Flow variable and it returns an integer.

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.

Connections

Outgoing links (from this component to another):

Row: Iterate

Trigger: Run if; On Component Ok;
On Component Error.

Incoming links (from one component to this one):

Row: Main;

For further information regarding connections, see
Talend Studio User
Guide
.

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: Transforming data flow to a list

The following scenario describes a Job that reads a list of files from a defined input
file, iterates on each of the files and displays their content row by row on the
Run console.

Setting up the Job

  1. Drop the following components from the Palette onto the design workspace: two tFileInputDelimited components, a tFlowToIterate, and a tLogRow.

  2. Connect the first tFileInputDelimited to
    tFlowToIterate using a Row > Main link,
    tFlowToIterate to the second tFileInputDelimited using an Iterate link, and the second tFileInputDelimited to tLogRow using a Row >
    Main link.

    Use_Case_tFlowToIterate1.png

Configuring the Components

  1. Double-click the first tFileInputDelimited to display its Basic settings view.

  2. Click the […] button next to the
    File Name field to select the path to
    the input file.

    Note

    The File Name field is
    mandatory.

    Use_Case_tFlowToIterate2.png

    The input file used in this scenario is
    Customers.txt. It is a text file that contains a list
    of names of three other simple text files: Name.txt,
    E-mail.txt and Address.txt.
    The first text file, Name.txt, is made of one column
    holding customers’ names. The second text file,
    E-mail.txt, is made of one column holding
    customers’ e-mail addresses. The third text file,
    Address.txt, is made of one column holding
    customers’ postal addresses.

    Fill in all other fields as needed. For more information, see tFileInputDelimited properties. In this scenario, the header and the footer
    are not set and there is no limit for the number of processed rows.

  3. Click Edit schema to describe the data
    structure of this input file. In this scenario, the schema is made of one
    column, FileName.

    Use_Case_tFlowToIterate7.png
  4. Double-click tFlowToIterate to display
    its Basic settings view.

    Use_Case_tFlowToIterate3.png

    Click the plus button to add new parameter lines and define your
    variables, and click in the key cell to
    enter the variable name as desired. In this scenario, one variable is
    defined: "Name_of_File".

    Alternatively, you can select the Use the default
    (key, value) in global variables
    check box to use the default
    in global variables.

  5. Double-click the second tFileInputDelimited to display its Basic settings view.

    Use_Case_tFlowToIterate4.png

    In the File name field, enter the
    directory of the files to be read, and then press Ctrl+Space to select the global variable “Name_of_File”. In this scenario, the syntax is
    as follows:

    Click Edit schema to define the schema
    column name. In this scenario, it is RowContent.

    Fill in all other fields as needed. For more information, see tFileInputDelimited properties.

  6. In the design workspace, select the last component, tLogRow, and click the Component tab to define its basic settings.

    Use_Case_tFlowToIterate6.png

    Define your settings as needed. For more information, see tLogRow properties.

Saving and executing the Job

  1. Save your Job by pressing Ctrl+S.

  2. Execute the Job by pressing F6 or
    clicking Run on the Run tab.

    Use_Case_tFlowToIterate5.png

Customers’ names, customers’ e-mails, and customers’ postal addresses appear on
the console preceded by the schema column name.


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