Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
How can I set context variables to see other context variables?
I would like to do like below:
ID Value
parentID parentValue + context.childID
childID childValue
Im using Talend Open Studio for Data Integration.
Best regards.
I'm afraid that is not possible. You will notice that the context window takes all values as literal values. For example, you do not need to surround Strings in quotes. You can only set literal values here. So trying to reference another context variable will simply be understood as setting the value to the name of the variable.
However, there is absolutely nothing wrong with using the tJava component to achieve what you want. Talend is a Java tool and you will notice that the design window simply enables Java code generation behind the scenes. If you want to achieve your requirement you can start your job with a tJava component and carry out the context manipulation there. You can do this anywhere in the job, but my assumption is that you want it done at the beginning because if it was possible to do this in the context window, it would be done at the beginning of the job.
@coffeeno ,in a subjob you can sett contexts using tjava component
(String)globalMap.put("childID",childValue);
(String)globalMap.put("parentID",parentValue + context.childID);
Thanks for your reply.
I would like to use global context , not globalMap in tJava.
Is this impossible ?
@coffeeno ,you can check with tContextLoad to load the contexts.
@coffeeno ,check the below example you can set.
Java code:
context.childID="EDG";
context.parentID=context.childID+"DEF";
System.out.println(context.childID);
System.out.println(context.parentID);
thanks for replies.
My question is how to set context variables to see other variables without using tJava.
Context variables can see other context variables in the same job. They can also be passed between jobs. Can you elaborate on your question as @manodwhb has covered my interpretations of your question.
Thanks.
>context.parentID=context.childID+"DEF";
I know by using tJava, i can set context variables to see other context variables.
But I would like to know ,in only within context window, how to set context variables to see other context variables.
because i suppose context variables within context window will be property-file after making batches,
which is i want to do.
Best regards.
I'm afraid that is not possible. You will notice that the context window takes all values as literal values. For example, you do not need to surround Strings in quotes. You can only set literal values here. So trying to reference another context variable will simply be understood as setting the value to the name of the variable.
However, there is absolutely nothing wrong with using the tJava component to achieve what you want. Talend is a Java tool and you will notice that the design window simply enables Java code generation behind the scenes. If you want to achieve your requirement you can start your job with a tJava component and carry out the context manipulation there. You can do this anywhere in the job, but my assumption is that you want it done at the beginning because if it was possible to do this in the context window, it would be done at the beginning of the job.