Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to assign value from tMAP column to global variable ?

Hi,
I am trying to assign the parsed string from tMAP as file name but getting null as output, How can I fix this issue ?

File_Name = "C:/users/Milind/ACARS/"+(String)globalMap.get("fltnum")+TalendDate.formatDate("yyyyMMddHHmmss", new Date()) + ".xls"
where fltnum is defined as VAR in the tMAP !
Thanks,
Milind
Labels (2)
24 Replies
Anonymous
Not applicable
Author

Hi Milind,
if you define fltnum as variable in the tMap, use Var.fltnum instead of globalMap.
If this will not work for you a screen shot and some more information about your data would be good.
Bye
Volker
Anonymous
Not applicable
Author

Thanks Volker,
I tried to use
"C:/users/Milind/ACARS/output/"+Var.fltnum+TalendDate.formatDate("yyyyMMddHHmmss", new Date()) + ".dt2" instead of
"C:/users/Milind/ACARS/output/"+(String)globalMap.get("SP7.fltnum")+TalendDate.formatDate("yyyyMMddHHmmss", new Date()) + ".dt2"
and I am getting the error
Var cannot be resolved !
Additing prntscrns here (not sure how it works .. but I am using image upload and after submit its not showing up)
Thanks,
Milind
Anonymous
Not applicable
Author

Hi Milind,
a screen shot would be very valuable. You should care about size (pixel and memory). You could see the server defined limits in the "Post reply" -form.
Bye
Volker
Anonymous
Not applicable
Author

Thanks for the Tip, Added the screenshots !
Milind
Anonymous
Not applicable
Author

Hi Milind,
now I got it. If you define a variable inside a tMap it is only visible to this tMap. If you need to store a value for later use, You should use a context variable for this. So define a context variable, add before your tMap where you defined the actual var a tJavaRow. In tJavaRow press the button "generate code" to generate the mapping from in to out for all of your metadada and add the following code as additional line:
context.fltnum= input_row.fltnum_new;

Now you could change the string for creating the file name to:
"C:/users/Milind/ACARS/output/"+context.fltnum+TalendDate.formatDate("yyyyMMddHHmmss", new Date()) + ".dt2"

Bye
Volker
Anonymous
Not applicable
Author

Thanks Volker, This is what I did
1. Defined a context variable fltnum
2. In Map created another output set_fltnum and assigned it to tJavaRow
3. In tJavaRow the code is context.fltnum = input_row.fltnum;
4. In TFiledelimited used filename =
"C:/users/Milind/ACARS/output/"+context.fltnum+TalendDate.formatDate("yyyyMMddHHmmss", new Date()) + ".dt2"
its still outputting filename as null+timestamp".dt2
I know I am doing something wrong but not sure what is it ?
amaumont
Contributor III
Contributor III

Set your output "set_fltnum" as first output into the tMap and it should work.
Instead of use context variable you could set a new variable into the globalMap:
globalMap.put("fltnum", myValue)

Then get it by:
globalMap.get("fltnum")

It's just more verbose, I hope we will improve the globalMap syntax soon.
Anonymous
Not applicable
Author

Thanks to clarify my solution.
Milind: sorry, my explanation was not clear. You should add the tJavaRow in your stream (not as additional output from tMap). If you use a additional output this should work if you ensure it is processed first. So this output must be upside from your main stream in tMap.
Bye
Volker
Anonymous
Not applicable
Author

Thanks for the suggestion, Again not sure what am I doing wrong .. still same results