One Star

Global variable

Hi
I'm trying to download files from ftp from two folders: folder1 and folder2
And store that files into local machine in their respective folders. In local machine, name of folders are same like folder1 and folder2
Path of folders in local machine is C/Users/royDesktop/Talend At this location both both folders are there folder1 and folder2
So for common path I have developed context variable and trying to add after any global variable.
In child job, how can I call global variable with context variable in fields in tftpfilelist , tftpget components.
Like this context.remotedirectory + folder1(how to define global variable here for different varable and keep changing while job run.)
Is that possible to get values of these variable from parent job like I'm trying to do ?

Parent JoB
prntscr(dot)com/9ct9ea

Child Job
prntscr(dot)com/9cta50
13 REPLIES
Five Stars

Re: Global variable

Hi,
In your parent, your tFlowToIterate generate global variable automaticaly (check option).
So, keep your context variable with your path 'C/Users/royDesktop/Talend' and add a context variable 'folder_name' (default empty). These 2 context variable must be declarated on the parent job and the child job.
In your parent job, on the tRunJob component, add a variable on parameter list 'folder_name' value globalMap.get("row2.name_of_the_folder_in_schema"))
And, in the chlid use context path et context folder.
Arnaud
One Star

Re: Global variable

Hi arnaudbroens

Here is my parent job

prntscr(dot)com/9cu21a

Child Job

prntscr(dot)com/9cu2ai

Properties of components

prntscr(dot)com/9cu2k5
prntscr(dot)com/9cu2or
prntscr(dot)com/9cu2uq
prntscr(dot)com/9cu314
Can you check please where am doing wrong ?
Five Stars

Re: Global variable

Roy,
In your tFlowToIterate1 check the option 'Use the default (key, value) in global variables'.
Screen me this component and tRunJob please.
Thanks,
Arnaud
One Star

Re: Global variable

arnaudbroens

I have checked the default (key, value) in tflowtoiterate.

Here is my trunjob properties 
http://prntscr.com/9cu9su
And here is the error

Exception in component tFTPFileList_1
com.enterprisedt.net.ftp.FTPException: 550 /roy/null: No such file or directory
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:1201)
Five Stars

Re: Global variable

Roy,
Can you screen me this tFTPFileList_1 please ?
Thanks,
Arnaud
One Star

Re: Global variable

aranaudbroens
Here is the shot
http://prntscr.com/9cujsq
Five Stars

Re: Global variable

The options are ok. Can you put a tLogRow after tFixedFlowInput_1 to see data and write me the result please ?
Thanks,
Arnaud
One Star

Re: Global variable

Hey
here's the shot
http://prntscr.com/9cuosp
Don't know arnaudbroens, where am short in this job Smiley Sad
One Star

Re: Global variable

When I add 
context.remotedirectory+globalMap.get("remotedirectory") in remote directory filed in tftpfilelist it show error
Exception in component tFTPFileList_1
com.enterprisedt.net.ftp.FTPException: 550 /roy/null: No such file or directory
/roy/ : this path of ftp I have stored in context variable. And when I add /roy/+ global variable I have declared shows error
I'm trying to add use global variable with /roy/ path cos directory's folders could change automatically on every iteration from parent job.
Hope you understand what am looking for 
Smiley Happy
Five Stars

Re: Global variable

A global variable works only in the current job. It's the reason why we put global variable value in a context.
However, the context variable must be declarated in your child job, isn't it ? Can you print me that please ?
Thanks,
Arnaud
One Star

Re: Global variable

hey arnaudbroens
For child job I have declared the context variable there
Like you see 
http://prntscr.com/9cv287
http://prntscr.com/9cv25a
http://prntscr.com/9cv22n
Job is running, when I create separate subjobs in child job for every different folders seperately
For example
Child job
tftpconnection
|
tftpfilelist(context.remotedirectory)----->tftpget(context.localdirectoryFolder1----filled in localdirectory) and (context.remotedirectoryFolder1----filled in remotedirectory)
|
tftpfilelist(context.remotedirectory)----->tftpget(context.localdirectoryFolder2----filled in localdirectory) and (context.remotedirectoryFolder2----filled in remotedirectory)
But What I'm looking is
In child job I need like this
tftpconnection
|
tftpfilelist(context.remotedirectory)----->tftpget(context.localdirectory+globalvariable(will iterate from parent job)----filled in localdirectory) and (context.remotedirectory+globalvariable(will iterate from parent job)----filled in remotedirectory)
SO that I don't need to create lot of sub jobs in child job for different different folders
Folder name value should come from parent job one by one and should be added to context variable I have defined dynamically.
Smiley Happy
Five Stars

Re: Global variable

Well, i think your job it's ok !
1. The parent generate 2 values (for local and remote http://prntscr.com/9cuosp).
2. The parent give 2 parameters to the child (global variable be transformed in context variable) http://prntscr.com/9cu9su
3. The parent call twice child
4. The child job use the context variable (in fact global variable from parent)
tftpconnection
|
tftpfilelist(context.remotedirectory)----->tftpget(context.localdirectory+globalvariable(will iterate from parent job)----filled in localdirectory) and (context.remotedirectory+globalvariable(will iterate from parent job)----filled in remotedirectory)

5. Execution : 2 transits in the child job
tftpconnection
|
tftpfilelist(context.remotedirectory)----->tftpget(context.localdirectoryFolder1----filled in localdirectory) and (context.remotedirectoryFolder1----filled in remotedirectory)
|
tftpfilelist(context.remotedirectory)----->tftpget(context.localdirectoryFolder2----filled in localdirectory) and (context.remotedirectoryFolder2----filled in remotedirectory)

It isn't the right way ?!
Arnaud
Five Stars

Re: Global variable

I want to do multiple subjob of step 5 in one subjob by passing global variable
Please check your message box....