Five Stars

Compare values returned by subjobs and execute another.

Hi,

 

I've 2 subjobs (Subjob #1 & #2) whom return values (put in the globalmap) and i want to execute another subjob (Subjob #3) if these values are equals.

 

I'v tried with the "if" trigger but the third subjob is always played even if values aren't equals.

 

----

# Subjob #1 : Sales query    
tMysqlInput_1 ----- tMap_1 ------ tFileOutputDelimited_1 (myFile.csv)
                        |
                        |
                        |
                    tAggregateRow_1 ----- tJava_1 (globalMap.put("CA_Ventes",row4.SUM)
                        
# Subjob #2 : Statistics query                    
tMysqlInput_2 ----- tJava_2 (globalMap.put("CA_Stats",row5.SUM_MONTANT_LIVRE_)

# Subjob #3 : (globalMap.get("CA_Stats") == globalMap.get("CA_Ventes"))? put FTP : Die and call

------

 

Any idea ?

 

PS : i use TOS for Data integration v6.5.1.

 

Thanks.

 

JCP

1 ACCEPTED SOLUTION

Accepted Solutions
Five Stars

Re: Compare values returned by subjobs and execute another.

Hi,

 

The problem came from the way i compared my values in the if trigger.

 

I replace :

globalMap.get("CA_Stats") == globalMap.get("CA_Ventes")

By :

((BigDecimal)globalMap.get("CA_Stats")).compareTo(((BigDecimal)globalMap.get("CA_Ventes"))) == 0

 

And it works fine.

 

Thanks !

 

JCP

8 REPLIES
Nine Stars

Re: Compare values returned by subjobs and execute another.

Hi,

 

What are you trying to do in subjob3?

 

Regards,

 

Veeru Boppudi
Five Stars

Re: Compare values returned by subjobs and execute another.

Hi,

 

The subjob #3 puts the file generated by subjob#1on an FTP server.

 

JCP.

Fifteen Stars

Re: Compare values returned by subjobs and execute another.

The looks like it should be OK. Can you post a screenshot please and also show the RunIf condition? It might also be interesting to see how you set the globalMap values.

Rilhia Solutions
Five Stars

Re: Compare values returned by subjobs and execute another.

The job :

2018-03-23 18_12_30-Talend Open Studio for Data Integration (6.5.1.20180116_1512) _ Local_Project (C.png

 

 

 

The second id condition : globalMap.get("CA_Stats") != globalMap.get("CA_Ventes") 

 

The subjob #3 isn't yet designed but i tried with Sendmail and Die components.

 

Components tJava_2 and tJava_3 put values in the globalmap :

 

#2 :

globalMap.put("CA_Ventes",row2.SUM);

 

#3 :

globalMap.put("CA_Stats",row3.SUM_MONTANT_LIVRE_);

 

 

 

Thanks,

JCP

Nine Stars

Re: Compare values returned by subjobs and execute another.

can you please check globalMap assignment working properly ?

 

Display global value before using in condition. 

 

I tried the same and it's working.

 

GlobalDependency.PNG

 

Regards,

 

Veeru Boppudi
Five Stars

Re: Compare values returned by subjobs and execute another.

I've modified the job because globalmap variables were'nt well assigned.

 

 

2018-03-23 19_24_24-Talend Open Studio for Data Integration (6.5.1.20180116_1512) _ Local_Project (C.png

 

The component tJava_4 print the variables as shown above in the execution tab.

 

Variables are equals but  the "not" condition is always played.

Nine Stars

Re: Compare values returned by subjobs and execute another.

so issue resolved ? if yes please mark it as solved.

 

Regards,

 

Veeru Boppudi
Five Stars

Re: Compare values returned by subjobs and execute another.

Hi,

 

The problem came from the way i compared my values in the if trigger.

 

I replace :

globalMap.get("CA_Stats") == globalMap.get("CA_Ventes")

By :

((BigDecimal)globalMap.get("CA_Stats")).compareTo(((BigDecimal)globalMap.get("CA_Ventes"))) == 0

 

And it works fine.

 

Thanks !

 

JCP