[resolved] getting null value in globalMap key talend 5.2v

One Star

[resolved] getting null value in globalMap key talend 5.2v

Hi,
I have scenario to load data based on column "Company" value. i.e. if Company value is "ABC" then output row will insert in that Abc.txt file as delimiter "|" . and if "ABC.txt" file not exist then it would create new and load data into it. if value in company field will change new file with that value (company) should create and load that row into that destination file.
refer image 3 for source data schema,

I have prepared data flow, please find it in attachment. using tsetglobalvar I am assigning company value to global variable and using this variable value for destination file creation. (see image 1 and 2)
using tJavaRow for debugging the global variable value up to tjavaRow it works properly but issue comes in tFileOutput destination, it shows "null" for global variable "cmpy".
Could any one please give the reason why it shows null?
Thanks in advance!!

Accepted Solutions
Seven Stars

Re: [resolved] getting null value in globalMap key talend 5.2v

Why would you need tFilterRow to filter other companies' data? Using tFlowToIterate allows you to send each flow to the correct file.
Yes, it will iterate as many times as you have rows in the source but that is what you have to do to use information from the data flow to determine the destination of that flow when you don't know all the possible destinations when you design the job.
You could design the job as follows instead:
tInput ("select distinct company from ")
--tFlowToIterate-->
tInput ("select * from table where company='"+globalMap.get("row1.Company")+"'")
--> tMap --> tFileOutputDelimited

All Replies
Seven Stars

Re: [resolved] getting null value in globalMap key talend 5.2v

You need to use tFlowToIterate. Please see many existing posts on the forum on how to do this.
One Star

Re: [resolved] getting null value in globalMap key talend 5.2v

Hi Alevy,
Thanks for the reply, if I use tFlowToIterate then I have to use another component "tFilterRow" to filter data of other companies. and also suppose I am having 1000 companies then this need to iterate thousand times. this is unnecessarily burden, and causes performance impact.
Thanks
Seven Stars

Re: [resolved] getting null value in globalMap key talend 5.2v

Why would you need tFilterRow to filter other companies' data? Using tFlowToIterate allows you to send each flow to the correct file.
Yes, it will iterate as many times as you have rows in the source but that is what you have to do to use information from the data flow to determine the destination of that flow when you don't know all the possible destinations when you design the job.
You could design the job as follows instead:
tInput ("select distinct company from ")
--tFlowToIterate-->
tInput ("select * from table where company='"+globalMap.get("row1.Company")+"'")
--> tMap --> tFileOutputDelimited
One Star

Re: [resolved] getting null value in globalMap key talend 5.2v

Hi Alevy,
Thanks, its working fine, but I have one further query, In the example I have mentioned, "using tJavaRow for debugging the global variable value up to tjavaRow it works properly but issue comes in tFileOutput destination, it shows "null" for global variable "cmpy"."
Could you give me reason why we can not use "cmpy" as global variable in tOutputDelimieted?
Thanks in advance!
Seven Stars

Re: [resolved] getting null value in globalMap key talend 5.2v

Because the output destination is initialised before the input starts to be read so the variable is not populated. Otherwise the file would have to be opened and closed for each row, which is not usually necessary and where using tFlowToIterate comes in. tJavaRow, on the other hand, is executed as part of the flow.