Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Dynamic FileName in a TFileOutputRaw

 Hi there;
I'm having difficulties setting a dynamic file name in a TFileOutputRaw component, something I have done in other components before.
So here is the job
0683p000009MCpH.jpg
Simple 4 step process

Read from an Queue,
First TjavaRow creates a file name in a context variable. Here the file name has been made to be a constant "singleout.txt"
Write the flow from the Queue to a TFilePutputRaw.
In the next step either it is Right or Wrong I use a Tjava to print the context variable used to transfer the name to prove that the context variable is actually set in the first TJavaRow.
0683p000009MCpM.jpg
If the tFileOutputRaw is set this way (above) it work fine.
If I set it up as below:
0683p000009MCpR.jpg
it does not, and I get the following output
0683p000009MCpW.jpg
Notice in the first and last highlighted text! The first shows the value of the context.currentOutPutFileName from within the first tJavaRow and the last highlighted text shows the same variable from either of the tJava components demonstrating that the context variable has been set and is accessible.
But if you look at the actual error (second yellow highlight) it should that the "constant" part of the path is seen  by the component but that the variable part (the context variable) is not interpreted at all? So I get an exception saying that I can't write to a directory directly implying I need a file name?
So why is the component not seeing the context variable in the filename?
Labels (3)
1 Solution

Accepted Solutions
Gopi1
Contributor II
Contributor II

append this code at last.
+".text" file name must have any extension otherwise Talend will think it as directory.

View solution in original post

4 Replies
Gopi1
Contributor II
Contributor II

append this code at last.
+".text" file name must have any extension otherwise Talend will think it as directory.
Anonymous
Not applicable
Author

gopi121 - your are right but I don't know why??
I added the +".text" to the filename in the component dialog and it worked
but what I don't understand is that the file name that is assigned to the context.currentOutPutFileName does contain an extension.
This is the line in the tJavaRow that I am using for testing


context.currentOutPutFileName = "singleout.txt";

why isn't this working?
Anonymous
Not applicable
Author

Ok - I used a globalMap instead of context and that appeared to solve things as far as the file name.
Anonymous
Not applicable
Author

Hi!

the BUG in code of component tFileOutputRaw.

0683p000009M62V.jpg

 

For FIX it, you need in file 

{path to ESB}\Studio\plugins\org.talend.designer.components.localprovider_{your version of studio}\components\tFileOutputRaw\tFileOutputRaw_main.javajet

 

change the code

String cid = node.getUniqueName();
String encoding = ElementParameterParser.getValue(node, "__ENCODING__");
 
by this:  
String cid = node.getUniqueName();
String filename = ElementParameterParser.getValue(node, "__FILENAME__");
%>
fileName_<%=cid%> = <%=filename %>;
<%    
String encoding = ElementParameterParser.getValue(node, "__ENCODING__");

0683p000009M62a.jpgCHANGES IN CODE

after these changes, I can dynamically change the path to the file at runtime.

0683p000009M62f.jpg