Component family |
Custom Code |
|
Function |
tSetGlobalVar allows you to |
|
Purpose |
tSetGlobalVar facilitates the |
|
Basic settings |
Variables |
This table contains two columns.
Key: Name of the variable to be
Value: Value assigned to this |
Advanced settings |
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a |
Global Variables |
ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
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 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. |
This scenario is a simple Job that prints out the value of a global variable defined
in the tSetGlobalVar component.
-
Drop the following components from the Palette onto the design workspace: tSetGlobalVar and tJava.
-
Connect the tSetGlobalVar component to the
tJava component using a Trigger > OnSubjobOk connection.
-
Double-click the tSetGlobalVar component to
display its Basic settings view. -
Click the plus button to add a line in the Variables table, and fill the Key and Value fields with
K1 and 20 respectively. -
Then double-click the tJava component to
display its Basic settings view. -
In the Code area, type in the following
lines:123String foo = "bar";<span></span>String K1;<span></span>String Result = "The value is:";<span></span>1Result = Result + globalMap.get("K1");<span></span>12System.out.println(Result);<span></span><span></span>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.