tFTPPut using variables

Highlighted
Four Stars

tFTPPut using variables

Hi,

 

I am trying to move files from a local directory to an SFTP server using the tFTPPut component.

 

Since there are many files (and they are coming from various locations) I am using variables to specify the local directory, the remote directory, filemask and new name as shown below.

 

tFTPPut_using_Variables.PNG

This results in a "file name invalid!" error message being displayed when executing the job for a single file.

 

However when I provide literal values (taken from the variables) then the job runs correctly and places the file on the SFTP server location such as the setup below.

 

tFTPPut_using_Literals.PNG

Please let me know if there is something wrong with my setup & is it possible to use the variables to specify the local directory, filemask & new name?

 

Thanks


Accepted Solutions
Highlighted
Sixteen Stars
Sixteen Stars

Re: tFTPPut using variables

Hi,

 

Are you sure the row3 fields are all populated?

If yes, I suggest you to use global variables instead of row field.

You can use tFlowToIterate before to genrate the required variables.

Also, can you share a screenshot for the complete job design?


TRF

View solution in original post

Highlighted
Community Manager

Re: tFTPPut using variables

I believe this is probably because of the same reason you cannot select a file to write to from a flow. This is an irritating "feature" of Talend, but easy to get round. Instead of using your row variables, connect the component before teh ftp component to a tFlowToIterate component. This will put all of the columns into a globalMap HashMap. You can access the variables as below.....

globalMap.get("row.column")

"row" and "column" correspond to your row name (feeding into the component) and column name. 

 

If you connect your tFlowToIterate component to your FTP component using an Interate link, then you can use the variables stored in the globalMap.

 

If you are familiar with Java you will know you will need to cast these variables. If you are not, basically you will need to change the class type they refer to. To simplify this just think about the Column Type in the schema. If it says String you will need to use the following code....

((String)globalMap.get("row.column))

View solution in original post


All Replies
Highlighted
Sixteen Stars
Sixteen Stars

Re: tFTPPut using variables

Hi,

 

Are you sure the row3 fields are all populated?

If yes, I suggest you to use global variables instead of row field.

You can use tFlowToIterate before to genrate the required variables.

Also, can you share a screenshot for the complete job design?


TRF

View solution in original post

Highlighted
Community Manager

Re: tFTPPut using variables

I believe this is probably because of the same reason you cannot select a file to write to from a flow. This is an irritating "feature" of Talend, but easy to get round. Instead of using your row variables, connect the component before teh ftp component to a tFlowToIterate component. This will put all of the columns into a globalMap HashMap. You can access the variables as below.....

globalMap.get("row.column")

"row" and "column" correspond to your row name (feeding into the component) and column name. 

 

If you connect your tFlowToIterate component to your FTP component using an Interate link, then you can use the variables stored in the globalMap.

 

If you are familiar with Java you will know you will need to cast these variables. If you are not, basically you will need to change the class type they refer to. To simplify this just think about the Column Type in the schema. If it says String you will need to use the following code....

((String)globalMap.get("row.column))

View solution in original post

Highlighted
Community Manager

Re: tFTPPut using variables

Seems I essentially put what @TRF put. Sorry mate, I left this open ready to comment and then got sidetracked with some fo my actual work. Ended up filling it in later and then saw yours :-)

Highlighted
Sixteen Stars
Sixteen Stars

Re: tFTPPut using variables

@zsiddiqi, with my post you got the idea, with @rhall_2_0 post, you got the details Smiley Wink


TRF
Highlighted
Four Stars

Re: tFTPPut using variables

Thanks @TRF @rhall_2_0

 

I tried it with tFlowToIterate and that solved all my problems. I didn't have to use global variables either

Highlighted
Sixteen Stars
Sixteen Stars

Re: tFTPPut using variables

@zsiddiqi very strange!!!

Can you share your job design?


TRF
Highlighted
Community Manager

Re: tFTPPut using variables

I think that is a lucky timing quirk @TRF. While the tFlowToIterate is processing the following iterating, the row variables used may still hold valid values. But the globalMap values should be used to be safe in my opinion.

Highlighted
Sixteen Stars
Sixteen Stars

Re: tFTPPut using variables

@zsiddiqi I agree with @rhall_2_0, you should use the global variables.


TRF

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog