#1 2011-11-23 09:25:28

asa436
Member
Registered: 2011-09-19
Posts: 21

Trigger 'Run if' Issue

Hi,
i have files in a folder with date at the end of their names as shown in figure 1. I want to iterate all these files by using tFileList but want to forward only those files which match the current date. I do this by adding a 'Run if' trigger on TFileList. The if condition is shown in figure 2. I have run the code seperately and it works fine but when i add this code to 'if' condition it gives 'index out of range'. The error is shown in figure 3.
Figure 4 shows the whole job.
any idea?

regards.


Uploaded Images

Last edited by asa436 (2011-11-23 09:29:54)

Offline

#2 2011-11-23 10:39:01

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Trigger 'Run if' Issue

Hi
You made a wrong upload, because i can't find figure 1.
Just type the names next time.

When String.indexOf("xxx") can't find "xxx", it will return -1.
So the method StringHandling.LEFT() get a wrong expression like this.
StringHandling.LEFT(((String)globalMap.get("tFileList_1_CURRENT_FILE")),-1)
Then you got the error "String index out of range:-1".

Best regards!
Pedro


Only Paranoid Survive.

Offline

#3 2011-11-23 11:35:25

asa436
Member
Registered: 2011-09-19
Posts: 21

Re: Trigger 'Run if' Issue

Hi Pedro,
Thanks for the reply.
i think the upload is ok, Figure 1 is the left most figure showing the zip files present in the folder.
then the next figure shows the 'if' condition code and so on as i mentioned earlier.

and i test the if condition on tJava where i printed "strings matched" through this if condition. Everything worked fine there.
please let me know if there is anything missing that you need to solve this issue.

regards.

Offline

#4 2011-11-23 14:15:08

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Trigger 'Run if' Issue

Hi
The expression globalMap.get("tFileList_1_CURRENT_FILE").indexOf("201") leads to the error.
If directory which is seted in tFileList doesn't contains a file "*201*.rar", the error will occurs.
Please show me the basic settings of tFileList, or recheck it whether there is a file named "*201" in the directory.

Best regards!
Pedro


Only Paranoid Survive.

Offline

#5 2011-11-24 21:03:42

tmaurin
Member
Company: Cosmos Consulting
Registered: 2011-05-17
Posts: 30
Website

Re: Trigger 'Run if' Issue

Hi !

Why you don't use :

tFileList --ITERATE--> tFileProperties. In your tFileList you put a mask like this sample :

"AccountCN_" + TalendDate.formatDate("yyyy_MM_dd", new Date()) + ".zip"
or
"*" + TalendDate.formatDate("yyyy_MM_dd", new Date()) + "*"
or
"*" + TalendDate.formatDate("yyyy_MM_dd", new Date()) + ".*"


Thomas Maurin
Chef de projet décisionnel
Cosmos Consulting
http://www.cosmos-consulting.fr

Offline

#6 2011-11-25 06:56:19

asa436
Member
Registered: 2011-09-19
Posts: 21

Re: Trigger 'Run if' Issue

Hi pedro,
attached is the tFileList properties. but it is working the way tmaurin mentioned. Thanks.


Uploaded Images

Offline

#7 2011-11-25 06:57:32

asa436
Member
Registered: 2011-09-19
Posts: 21

Re: Trigger 'Run if' Issue

Hi Thomas Maurin,

File mask  in tFileList_1 worked perfectly, thanks a lot smile
syntax :
"*" + StringHandling.TRIM(TalendDate.formatDate("yyyy_MM_dd ",TalendDate.getCurrentDate())) + ".zip"
,
may i get your contact email or any other contact to ask about few queries ...
thanks.
Regards,
Abdus Saboor Ahmad
ETL/BI Developer
Cell #:+92331-5058253
@skype : asa436
Profile @ Linkedin:http://pk.linkedin.com/in/asa436

Last edited by asa436 (2011-11-25 08:55:44)

Offline

#8 2011-11-25 07:16:12

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Trigger 'Run if' Issue

Hi
tmaurin's workaround is perfect.
But your previous job is OK, too.
I just pointed out the essential reason why this error occurs.

Best regards!
Pedro


Only Paranoid Survive.

Offline

Board footer

Powered by FluxBB