Looping Function
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 17
- Joined: Mon Apr 21, 2008 9:53 pm
- Location: SG
Looping Function
I got a problem to move my files from process directory to archive directory.
File = ABC.txt
abc.txt|abc2.txt|abc3.txt
Sequence Job :
Execute Command --> Start Loop Activity (Loop from file, Delimiter = "|") --> Load the data from the file to database --> Execute Command (To move process file to archive folder) --> End Loop Activity.
My sequence job manage to move abc.txt and abc2.txt to archive folder but it did not manage to move abc3.txt to archive due to execute command.
Inside execute command : mv, parameters --> parameters set/#StartLoop.$Counter# parameters set/#StartLoop.$Counter#
Inside the logs, the error i got is as below :
mv process/abc.txt archive/abc.txt
mv process/abc2.txt archive/abc2.txt
mv process/abc3.txt --> did not pass in the archive directory and filename. Any ideas is this a bug or is due to my job design?
Thanks in Advance. :D
File = ABC.txt
abc.txt|abc2.txt|abc3.txt
Sequence Job :
Execute Command --> Start Loop Activity (Loop from file, Delimiter = "|") --> Load the data from the file to database --> Execute Command (To move process file to archive folder) --> End Loop Activity.
My sequence job manage to move abc.txt and abc2.txt to archive folder but it did not manage to move abc3.txt to archive due to execute command.
Inside execute command : mv, parameters --> parameters set/#StartLoop.$Counter# parameters set/#StartLoop.$Counter#
Inside the logs, the error i got is as below :
mv process/abc.txt archive/abc.txt
mv process/abc2.txt archive/abc2.txt
mv process/abc3.txt --> did not pass in the archive directory and filename. Any ideas is this a bug or is due to my job design?
Thanks in Advance. :D
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 17
- Joined: Mon Apr 21, 2008 9:53 pm
- Location: SG
abc..JobControl (@Execute_Command_23): Executed: cat C:/temp/testing.txt
Reply=0
Output from command ====>
abc.txt|abc2.txt|abc3.txt
abc..JobControl (@StartLoop): Loop through list (3 items): iteration 1
abc..JobControl (@Move): Executed: mv C:/temp/abc.txt C:/temp/archive/abc.txt
Reply=0
Output from command ====>
abc..JobControl (@StartLoop): Loop through list (3 items): iteration 2
abc..JobControl (@Move): Executed: mv C:/temp/abc2.txt C:/temp/archive/abc2.txt
Reply=0
Output from command ====>
abc..JobControl (@StartLoop): Loop through list (3 items): iteration 3
abc..JobControl (@Move): Executed: mv C:/temp/abc3.txt
Reply= C:/temp/archive/abc3.txt
Output from command ====>
abc..JobControl (@EndLoop): Loop finished
abc..JobControl (@Coordinator): Summary of sequence run
00:55:31: Sequence started
00:55:31: Execute_Command_23 (COMMAND cat) started
00:55:31: Execute_Command_23 finished, reply=0
00:55:31: StartLoop loop iteration 1 started
00:55:31: Move (COMMAND mv) started
00:55:31: Move finished, reply=0
00:55:31: StartLoop loop iteration 2 started
00:55:31: Move (COMMAND mv) started
00:55:31: Move finished, reply=0
00:55:31: StartLoop loop iteration 3 started
00:55:31: Move (COMMAND mv) started
00:55:31: Move finished, reply=-1
00:55:31: EndLoop loop finished
00:55:31: Sequence finished OK
Reply=0
Output from command ====>
abc.txt|abc2.txt|abc3.txt
abc..JobControl (@StartLoop): Loop through list (3 items): iteration 1
abc..JobControl (@Move): Executed: mv C:/temp/abc.txt C:/temp/archive/abc.txt
Reply=0
Output from command ====>
abc..JobControl (@StartLoop): Loop through list (3 items): iteration 2
abc..JobControl (@Move): Executed: mv C:/temp/abc2.txt C:/temp/archive/abc2.txt
Reply=0
Output from command ====>
abc..JobControl (@StartLoop): Loop through list (3 items): iteration 3
abc..JobControl (@Move): Executed: mv C:/temp/abc3.txt
Reply= C:/temp/archive/abc3.txt
Output from command ====>
abc..JobControl (@EndLoop): Loop finished
abc..JobControl (@Coordinator): Summary of sequence run
00:55:31: Sequence started
00:55:31: Execute_Command_23 (COMMAND cat) started
00:55:31: Execute_Command_23 finished, reply=0
00:55:31: StartLoop loop iteration 1 started
00:55:31: Move (COMMAND mv) started
00:55:31: Move finished, reply=0
00:55:31: StartLoop loop iteration 2 started
00:55:31: Move (COMMAND mv) started
00:55:31: Move finished, reply=0
00:55:31: StartLoop loop iteration 3 started
00:55:31: Move (COMMAND mv) started
00:55:31: Move finished, reply=-1
00:55:31: EndLoop loop finished
00:55:31: Sequence finished OK
-
- Participant
- Posts: 17
- Joined: Mon Apr 21, 2008 9:53 pm
- Location: SG
The bug is at the sequential file.
For Example :
abc.txt|abc2.txt|abc3.txt
Newline (but when i view the data in datastage, it will only be view as one row)
When creating a new sequential file in datastage, it will always give me a newline at the end of the whole file, even though i remove all the delimiters, why?
For Example :
abc.txt|abc2.txt|abc3.txt
Newline (but when i view the data in datastage, it will only be view as one row)
When creating a new sequential file in datastage, it will always give me a newline at the end of the whole file, even though i remove all the delimiters, why?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 17
- Joined: Mon Apr 21, 2008 9:53 pm
- Location: SG
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 17
- Joined: Mon Apr 21, 2008 9:53 pm
- Location: SG
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Execute Command -> User Variables -> Start Loop -> whatever -> End Loop
Trim the final field mark from the command's output and convert the other field marks to a printable delimiter in the user variable, and use a reference to the user variable in your Start Loop activity as the "list of things" through which to iterate.
It works, I've done it lots of times.
Trim the final field mark from the command's output and convert the other field marks to a printable delimiter in the user variable, and use a reference to the user variable in your Start Loop activity as the "list of things" through which to iterate.
It works, I've done it lots of times.
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.
-
- Participant
- Posts: 17
- Joined: Mon Apr 21, 2008 9:53 pm
- Location: SG
thanx thanx, it works prefect well.
But i got another question. I had tested my jobs both in windows and unix. Unix works fine. But when i am trying to compile the jobs in windows. It doesn't work. Does it means that window will have another method to solve this problem?
The error that i get when i am trying the same job in windows environment is listed as below :
Activity EndLoop : Referenced StartLoop cannot be found on an input link.
But i got another question. I had tested my jobs both in windows and unix. Unix works fine. But when i am trying to compile the jobs in windows. It doesn't work. Does it means that window will have another method to solve this problem?
The error that i get when i am trying the same job in windows environment is listed as below :
Activity EndLoop : Referenced StartLoop cannot be found on an input link.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: