Assigning context variables in tJavaRow

One Star

Assigning context variables in tJavaRow

Hi I'm trying to assign context variables in a tJavaRow with a tMap output.
My job is like this:
(process)--------tMap---(out)---main---tJavaRow
In my tJavaRow:
context.C1=out.BUSINESS_ID;
context.C2=out.SOURCE;
context.C3=out.COUNTRY;
This returns "null". When I put a tLogRow after my tMap I see the data. I tried with a tJava in vain.
Any Idea?
Thanks
One Star

Re: Assigning context variables in tJavaRow

Don't think this is the right way to do it as the conntexts will only have the value of the last mapping. Also tLogRow won't print the context values.
One Star

Re: Assigning context variables in tJavaRow

Thanks Janhess
This is exactly I'm trying to do, having the value of the last mapping in my context variables. but it dosn't work.
One Star

Re: Assigning context variables in tJavaRow

Are you sure? in your tJavaRow put a println for the contexts to see the value.
One Star

Re: Assigning context variables in tJavaRow

janhess,
When in my tjavarow I do : System.out.println(context.C1) I have "null" in the console. I can't explain this
One Star

Re: Assigning context variables in tJavaRow

Ah I remember. You need to specify the input fields as
System.out.println(input_row.field name)
So in your case you would have
context.C1=input_row.BUSINESS_ID;
context.C2=input_row.SOURCE;
context.C3=input_row.COUNTRY;

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now