One Star

context variables

Hello TOS-fans and experts,
as you can see in the subject my problem is that i want to create a context variable.
I have the tMap component, where i made an if-else-claus (with "...?..:..."). This if-clause divides a number through 1.5. This works fine.
Now i want to put the number 1.5 into a variable. I tried to use "create context" on the left and other things but nothing works.
Does anybody have an idea?
Thank your very much!!!
4 REPLIES

Re: context variables

Where you have a "Run" tab, do you also have a "Context" tab? If not, look under the "Window"/ "Show View" menu, and select "Conexts"
In the context tab, there are three subtabs, click on the left-most one ("Variables"), and there button with a "+" sign. Click it and will add a variable. On the "Variables" tab, you can't set the initial value. Just type in the name of the new context variable. You have to chose the type - Double or BigDecimal, probably.
To give the context varaible an initia lvalue, in the right-most tab, "Values as a Table", you can fill in the value.
You don't have to rely on the initial value. In your job, if you want, in a tJavaRow, tJavaFlex probably (probably not tJava) you can assign the variable - if your variable is named "divideMe", you'd context.divideMe = 1.5.
One Star

Re: context variables

Hell LevinMagruder.pf,
thank you a lot!!!It totally worked!
One Star

Re: context variables

Hi, I have another problem in this example. When i divide with my variable i want to get an output-field with the date of the last change...i tried some things with TalendDate.getDate() but it doesnt work. Can you do this also with a context-variable?

Thanks again!i appreciate your help very much!!

Re: context variables

Hi, I have another problem in this example. When i divide with my variable i want to get an output-field with the date of the last change...i tried some things with TalendDate.getDate() but it doesnt work. Can you do this also with a context-variable?

You should open another thread, and I think you should rephrase teh question, give detail of what your job would have as input (e.g., the initial value of your context variable is "input" - information your job starts of knowing) - and what wuold be output - the result, information your job creates. I can't tell what you want to happen.
In general, Talend lets you do anything java can do, so almost for sure teh answer is "you can do that" but for anythngi that's not a typical ETL operation, it can entail learning a bunch of java.
A thing to be aware of about this forum is, if a question has any answers, it doesn't stand out as an unanswered question, and it gets less views. If someone automatically marked questions as resolved or something that would be a patch. So don't worry about creating lots of threads