Exiting loop without aborting job
Moderators: chulett, rschirm, roy
Exiting loop without aborting job
Hi there
I have implemented the following sequence job.
Command stage ---- User Variable Stage ---- StartLoop ---- Job ---- EndLoop
This sequence reads files out of a directory and then passes the value to the same job using the User Variable Stage. The job works perfectly with one small problem. When the Command Stage gets to the last file and it loops back to find the next, there is no file for it to find - however, the job still runs and then ABORTS because it cannot find a file in the directory.
Problem is - we do not want to reset jobs all the time before we can run them again - we'd prefer if the loop exited gracefully !!!! Any way we can get around the ABORT situation ...
Your help is always appreciated.
Barbara
I have implemented the following sequence job.
Command stage ---- User Variable Stage ---- StartLoop ---- Job ---- EndLoop
This sequence reads files out of a directory and then passes the value to the same job using the User Variable Stage. The job works perfectly with one small problem. When the Command Stage gets to the last file and it loops back to find the next, there is no file for it to find - however, the job still runs and then ABORTS because it cannot find a file in the directory.
Problem is - we do not want to reset jobs all the time before we can run them again - we'd prefer if the loop exited gracefully !!!! Any way we can get around the ABORT situation ...
Your help is always appreciated.
Barbara
-------------------------
https://www.ssa.co.za
https://www.ssa.co.za
There's no "loop" in the Command Stage, it should just be generating a snapshot, a static list of the files available at the time it ran. Sounds like you have an "extra" delimiter at the end of your list, something causing it to loop one more time than it should. Verify that and then trim it off before the StartLoop stage consumes it.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Take a look at the Webinar on job sequence techniques with file processing. (www.dsxchange.net)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi there
This is the output from my command stage:
CO 19 TRANS DEC08.csv
CO 18 TRANS REPORT.csv
File Not Found
My user variable stage has the following syntax:
Trim(Left(Convert(@FM, ",", Cmd_TransFile_To_Load.$CommandOutput), Len(Cmd_TransFile_To_Load.$CommandOutput) - 1))
Where do I trim the last space if I'm not doing it already in my user variable stage ?
Thanks !
Barbara
PS: Will check out suggestion that Ray made in the mean time ...
This is the output from my command stage:
CO 19 TRANS DEC08.csv
CO 18 TRANS REPORT.csv
File Not Found
My user variable stage has the following syntax:
Trim(Left(Convert(@FM, ",", Cmd_TransFile_To_Load.$CommandOutput), Len(Cmd_TransFile_To_Load.$CommandOutput) - 1))
Where do I trim the last space if I'm not doing it already in my user variable stage ?
Thanks !
Barbara
PS: Will check out suggestion that Ray made in the mean time ...
-------------------------
https://www.ssa.co.za
https://www.ssa.co.za
Hi there Ray,
Unfortunately, security with regards to the Internet is so strict here in this organization that the Webinar is not accessible....
I'll have to wait to hear if anyone on the forum has ideas for me with regards to trimming the last file in the list.
Thanks a mil.
Barbara
Unfortunately, security with regards to the Internet is so strict here in this organization that the Webinar is not accessible....
I'll have to wait to hear if anyone on the forum has ideas for me with regards to trimming the last file in the list.
Thanks a mil.
Barbara
-------------------------
https://www.ssa.co.za
https://www.ssa.co.za
Hi Barbara,
Can you post the exact command you're using to generate the file list?
Also, you may want to type "help dir" and "help for" in a cmd window. In particular, I've sometimes used "for" instead of "dir" to generate a list of files.
For example:
Check out the file modifiers at the end of the for help text.
HTH,
Scott
Can you post the exact command you're using to generate the file list?
Also, you may want to type "help dir" and "help for" in a cmd window. In particular, I've sometimes used "for" instead of "dir" to generate a list of files.
For example:
Code: Select all
for %i in (c:\temp\*.csv) do @echo %~dpnxi#
HTH,
Scott
Hi there
This is the exact syntax for my command:
DIR /B/O-D "\\mcbcptfs01\groups\MHD\Data to load\Payroll files\TRANS files\*.csv" ls -m
**Please remember that this is on a Windows platform** (Don't know if it makes any difference).
Please let me know how I should change this ?
Barbara
This is the exact syntax for my command:
DIR /B/O-D "\\mcbcptfs01\groups\MHD\Data to load\Payroll files\TRANS files\*.csv" ls -m
**Please remember that this is on a Windows platform** (Don't know if it makes any difference).
Please let me know how I should change this ?
Barbara
-------------------------
https://www.ssa.co.za
https://www.ssa.co.za
YOU WERE RIGHT !!!! (As usual ...)
Thanks so much !!!
I will happily mark topic as resolved ... AGAIN !
Kind regards
Barbara
Thanks so much !!!
I will happily mark topic as resolved ... AGAIN !
Kind regards
Barbara
-------------------------
https://www.ssa.co.za
https://www.ssa.co.za
Hi Barbara,BIuser wrote:**Please remember that this is on a Windows platform** (Don't know if it makes any difference).
Yes as Craig noted, the O/S makes a difference as to what commands you execute (I'm sure you know that )
I'll just point out that my "for" example in my earlier post is Windows syntax. Knowing that syntax is useful to have in your Windows kitbag, and has helped me in the past. I still recommend a read of "help dir" and "help for" under Windows.
Regards,
Scott