Four Stars

Fetch count of records from multiple files in child to parent job

Hi Team,

I have develop parent and child job. I am calling child job using tRunJob component. I need to get count of records from child job to parent job. 

I am having multiple files with same metadata. I am able to fetch count for single file but need to get count of all records from all files also need total count of that records.

Please help me in this scenario. Attached snap of parent and child job.

5 REPLIES
Twelve Stars

Re: Fetch count of records from multiple files in child to parent job

I'm assuming you are passing the count of records out of the child job to the parent job using the buffer output. If not, do that. The you can either use a tAggregateRow component after your tRunJob or just use your tJavaRow to sum the output 

Rilhia Solutions
Four Stars

Re: Fetch count of records from multiple files in child to parent job

Hi,

Thanks for the reply. I am explaining you flow of my job. I have multiple xml files which are having same schema so I am using "((Integer)globalMap.get("tFileInputMSXML_1_NB_LINE"))"  property to get total number of records. This I am using in child job so when I am having more than one file I need to get count of all files which processed in child job. I have tried your solution but it give me only count of last file which is processed. I need count of all files which is processing in Child job. Main thing is I am iterating file one by one. your help is appraisable. Thanks.

                            

Twelve Stars

Re: Fetch count of records from multiple files in child to parent job

When you receive your count values from the child job, you need to add those values in your tJava. Here is some example (assuming you are returning an integer value in a column called "myCount"......

 

int myCount = input_row.myCount;

if(globalMap.get("myCount")==null){
       globalMap.put("myCount", myCount);
}else{
      myCount = ((Integer)globalMap.get("myCount")) + myCount;
      globalMap.put("myCount", myCount);
}

output_row.myCount = myCount;

This code was written without testing, so you may need to tweak it. Your final total will appear after your last file. This will also give you a running total.

Rilhia Solutions
Four Stars

Re: Fetch count of records from multiple files in child to parent job

Hi rhall,

Thanks for the solution. I have resolved issue using context variable. I have used "+=" for context variable so it keep adding count of each file after process completed.

 

Twelve Stars

Re: Fetch count of records from multiple files in child to parent job

That is essentially what I was describing with my last post. The difference being that I used the globalMap HashMap instead of context variables

Rilhia Solutions