Five Stars

tFileOutputDelimited variable filename not working

Hi 

 

I'm trying to set the filename of the tFileOutputDelimited with a variable, but this doesn't seem to work. 

 

Goal is to read an excel, which has got one or multiple lines per customer_po_no and then split it into a file per customer_po_no.

Therefor I have this job:


jobOverview.jpg

In the tJavaRow_1 I do: 

 

System.out.println("PO: " + input_row.CUSTOMER_PO_NO);

context.CUSTOMER_PO_NO = input_row.CUSTOMER_PO_NO;

 

and in tFileOutputDelimited_2 I set the filename as:

 

context.CUSTOMER_PO_NO + ".csv" 

 

I see the number being printed is the correct one, however the filename is null (blank)

 

any ideas ?

 

thanks and kind regards

Christoph

1 ACCEPTED SOLUTION

Accepted Solutions
Six Stars

Re: tFileOutputDelimited variable filename not working

Oh sorry, I missed that.

You could do something like this - 

1) Use tFlowToIterate after  tMap.

2) Then join tJava using iterate flow.

3) Set the values of input row fields for tFileOutDelimited in tJava like - row2.<fieldname> = ((String)globalMap.get("output.<fieldname>"));

4) And filename you can fetch using ((String)globalMap.get("output.customer_po_no")) in tFileOutputDelimited component.

 

Please refer the attached screenshot for better clarity.

 

Best Regards,

Abhishek

 

4 REPLIES
Six Stars

Re: tFileOutputDelimited variable filename not working

Hi Christoph,

I think what you should do, you should use here OnComponentOk trigger on tJavaRow instead of using main row.

I suppose what's happening here is main flow is getting executed before the value is set to the context variable customer_po_no.

 

Best Regards,

Abhishek

 

Five Stars

Re: tFileOutputDelimited variable filename not working

hi Abhishek

 

thanks for the tip, but the tFileOutput requires a row input instead of an OnComponentOK, how should I overcome that ?

 

regards

Christoph

Six Stars

Re: tFileOutputDelimited variable filename not working

Oh sorry, I missed that.

You could do something like this - 

1) Use tFlowToIterate after  tMap.

2) Then join tJava using iterate flow.

3) Set the values of input row fields for tFileOutDelimited in tJava like - row2.<fieldname> = ((String)globalMap.get("output.<fieldname>"));

4) And filename you can fetch using ((String)globalMap.get("output.customer_po_no")) in tFileOutputDelimited component.

 

Please refer the attached screenshot for better clarity.

 

Best Regards,

Abhishek

 

Five Stars

Re: tFileOutputDelimited variable filename not working

Thanks Abhishek, your tip got it working!

 

quite surprised though, I would expect that in a tJavaRow component, connected to the main row, the order of the execution should be sequential, and this would avoid the issue with the context variable not being filled in? where is my understanding wrong there, any idea ?