Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello.
in my process, I'm trying to create an output file, named with some context variables.
This variables are defined in general context by default value "".
I modify their values in tJavaRow and want to use the new value in tFileOutpuMSXML.
Here is tJavaRow description : I modify context.idDoc and context.currentDate.
And in tFileOutputMSXML, I set the file name like this (context.path_OUT is also a variable but only set in global context).
Result is that file name is only "_.xml" . None of the values were reported on the tFileOutputMSXML.
How should I proceed to create the right output file ?
Hi,
Attached a skeleton flow which can help in your use case.
You need to select the number of rows in row generator as 1. This will make sure that for each incoming record, a new flow with one record is generated in each iteration.
In the tjavarow, you can fetch the columns coming out of Oracle DB by giving Control+Space and search based on tFlowToIterate component name. All the components will be tagged to tFlowtoTerate and you can use this data to generate multiple files.
I would suggest to start with a simple scenario of tFlowtoIterate (mentioned in help documents) to understand the functionalities of the component and then build your use case after that.
Warm Regards,
Nikhil Thampi
Hi,
Could you please verify whether the data is correctly getting loaded to the context variables by printing using a String.out in tjavarow.
Please also note that tjavarow will process the data at row level but tFileOutputMSXML will produce a single file for all the records unless you add the iteration before that component.
Could you please verify these details and let us know the update?
Warm Regards,
Nikhil Thampi
Hi.
Thanks for your answer.
So, I added these lines in the tJavaRow code :
System.out.println(context.idDoc);
System.out.println(context.currentDate);
And in the logs, I get :
...
80
2018-08-14
...
These are expected values.
If you want to name a file using a context variable you MUST have the context variable's value set BEFORE the subjob with the file component has started. This is because the file output components create the files at the beginning of the subjob.
If you need to set data into multiple files, then you will need to either use a tLoop or a tFlowToIterate component. In these cases you will still need to set the context variable before the subjob (or the loop or iteration) starts.
OK thanks.
Actually, that's right. I need to have several output files. So, I guess I will use tFlowToIterate.
But how can I use it in my case ? Should I call it after the tJavaRow ? I can't create a iterate link from the tJavaRow.
So, do I have to insert another component between both components ?
Excuse me for all my questions, but I am brand new in Talend technology.
Hi,
Attached a skeleton flow which can help in your use case.
You need to select the number of rows in row generator as 1. This will make sure that for each incoming record, a new flow with one record is generated in each iteration.
In the tjavarow, you can fetch the columns coming out of Oracle DB by giving Control+Space and search based on tFlowToIterate component name. All the components will be tagged to tFlowtoTerate and you can use this data to generate multiple files.
I would suggest to start with a simple scenario of tFlowtoIterate (mentioned in help documents) to understand the functionalities of the component and then build your use case after that.
Warm Regards,
Nikhil Thampi
Hi.
So, I made the architecture you recommend, but I still don't have the right result. Let me explain :
On the property of tFlowToIterate, I added useful key values, and especially numMessage.
On the tRowGenerator, I have one row, like you specified. Other specifications are not important to me.
And finally, I want to get back value of numMessage in tFileOutputMSXML to create the name of the file, like this (path_OUT is defined in context) :
And still, the file name is null.xml.
I launched the job in Java debug, and in fact, the value of the file name is still set before value of numMessage in tFlowToIterate.
It is very strange to me because I also made a test based on existing documentation, and in this case, I could name the file with values set in tFlowToIterate. Here is the working case based on this scenario https://help.talend.com/reader/o2I5HrOFZtZItmjCxsjUtQ/5AnaNCZdnZGHZjMlcH_nLw :
Hi,
Could you please print the output of the data using a System.out.print in tjavarow and see the results?
We need to verify whether the data is coming as null for this column before iteration itself or whether the data is not loading properly to the variable of tflowtoiterate component.
Warm Regards,
Nikhil Thampi
Hi.
I added System.out.print in tjavarow as you recommand.
In the logs, I have the right values :
numMessage : -6
numMessage : -20
But anyway, I managed to by-pass this issue. I created a new job containing tRowGenerator, tJavaRow and tileOutputMSXML, so that variables are set before on tFlowToIteratee.
And now, it's working.
Thanks