Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a situation on the picture. How can I print out variable that was created in a tMap?
I am confused by this. Why do you want to print them out in the tJavaRow without passing them to the tJavaRow? What is the issue with supplying them to the tJavaRow? The reason I ask is that you will not be able to achieve this without seriously compromising the "timing" of the flow of data. If you have 100 rows being processed by the tMap, you cannot assume that when the flow gets to the tJavaRow for row 1, that the value in the Var.var1 will be valid for row 1. It may very well be processing row 100 at that point, or may have finished.
"Row" links and "Iterate" links work in different ways and what you are wanting would require an "Iterate" link. Unfortunately tMap components do not supply these.
Now, you can use some Java and extend the first solution I sent you to achieve this, but it really sounds like an awful lot of work to achieve something for a reason I cannot fathom with the information you have given. But here is the approach you could use to solve this if you do need it.....
1) Create a routine method similar to the one I gave, but this time load the Var variable to a HashMap with a "key" which is unique in your dataset. The HashMap should be available to the whole routine.
2) Create another routine method which will return the value of the HashMap element when supplied the correct "key"
3) In your tJavaRow call the second method (see above) and supply the "key" field. This will return the value for your Var that relates to that particular datarow.
As you can see, all your are really doing here is circumnavigating the normal flow in order to do something that would be easier done by simply passing the value.
What is the reason that it needs to be done this way?
I'm not sure I entirely understand this requirement, but if you are trying to simply print the value of a variable and use it in the tMap, you could try a little trick with a routine. For example....
public static String printStringValue(String data){
System.out.println("My variable:"+data);
return data;
}
Not the most elegant of methods, but it will works for Strings. Just create a new routine and add the above code. Then call that routine in your tMap when you use the variable. It will pass it back to the tMap untouched and print out to the output window.
please explain your scenario briefly.....
I have a tMap and inide I created some variables(in the middle column), Now I would like to print out those variable with tjava row?
The code I have given you is intended to be used when you use your tMap variables. So when you create them in the box in the middle, you will either use them in further variables or in the output. With the method I have given you above (for Strings only) you can use your variables and print them out. For example, if you are concatenating as String in your tMap variable, it might look like this.....
row1.val1 + "_"+row1.val2
The above variable might be called "concatString". You may want to output that to the job AND see what it holds. With the method I have given you, you can simply add this code to your output column....
routines.MyTalendRoutines.printStringValue(Var.concatString)
I've assumed the name of the routine as "MyTalendRoutines".
Can you create an example job, export it and upload it ?
Can you have a look at this pictures and I have a question at the bottom. This is from the example you sent me.
variable to print
I would print var1 in this tJavaRow, is that possible?
Maybe I have assumed you want to do something a little more complicated. All you need to do is add ....
Var.var1
...to your out12 newColumn expression. Then in your tJavaRow just use the following code....
System.out.println(input_row.newColumn);
The example I gave you enables you to print the value of your variable to the output from within your tMap. This is useful in debugging. I assumed that is what you wanted this for
Is it possible to print
Var.var1
without passing it to the out12 newColumn expression ?