August 17, 2023

tSetGlobalVar – Docs for ESB 5.x

tSetGlobalVar

tSetGlobalVar_icon32_white.png

tSetGlobalVar properties

Component family

Custom Code

 

Function

tSetGlobalVar allows you to
define and set global variables in GUI.

Purpose

tSetGlobalVar facilitates the
process of defining global variables.

Basic settings

Variables

This table contains two columns.

Key: Name of the variable to be
called in the code.

Value: Value assigned to this
variable.

Advanced settings

tStatCatcher Statistics

Select this check box to gather the Job processing metadata at a
Job level as well as at each 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.

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

This component is generally used as a one-component subjob.

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

Knowledge of Java language is required.

Scenario: Printing out the content of a global variable

This scenario is a simple Job that prints out the value of a global variable defined
in the tSetGlobalVar component.

Use_Case_tSetGlobalVar1.png

Setting up the Job

  1. Drop the following components from the Palette onto the design workspace: tSetGlobalVar and tJava.

  2. Connect the tSetGlobalVar component to the
    tJava component using a Trigger > OnSubjobOk connection.

Configuring the tSetGlobalVar component

  1. Double-click the tSetGlobalVar component to
    display its Basic settings view.

    Use_Case_tSetGlobalVar2.png
  2. Click the plus button to add a line in the Variables table, and fill the Key and Value fields with
    K1 and 20 respectively.

  3. Then double-click the tJava component to
    display its Basic settings view.

    Use_Case_tSetGlobalVar3.png
  4. In the Code area, type in the following
    lines:

    In
    this use case, we use the Result variable. To access the
    global variable list, press Ctrl + Space bar on
    your keyboard and select the relevant global parameter.

Job execution

Save your Job and press F6 to execute it.

The content of global variable K1 is displayed on the
console.

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