Execute multiple cp commands in a Sequence job

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Developer9
Premium Member
Premium Member
Posts: 187
Joined: Thu Apr 14, 2011 5:10 pm

Execute multiple cp commands in a Sequence job

Post by Developer9 »

Hi,
I have the following requirement and I need input for designing of my job

Code: Select all

copy multiple files from source to target  directory with timestamp added to the Filename.
Current design to copy single file in a sequence

Code: Select all

UserVariable_Activity (Generate timestamp)----> Execute Command Activity (cp source dir file  target dir file_timestamp )
How can I modify the above design to copy multiple files in a single sequence ?

Thanks for the input
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Define 'multiple files' - multiples based on what, a wildcard pattern?

Me, I'd write a script.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Developer9
Premium Member
Premium Member
Posts: 187
Joined: Thu Apr 14, 2011 5:10 pm

Post by Developer9 »

There is no wildcard pattern ..Each file is generated by individual job.

1.Alternative I can think is having a seperate link for each file

Code: Select all

UV -->Execute activity (file1) 
UV -->Execute activity (file2)
UV -->Execute activity  (file3)
2.Looping ?Can I implement this way?

Code: Select all

Start loop -->Read file1 -->generate timestamp -->cp file1 -->end loop 
Start loop -->Read file2 -->generate timestamp -->cp file2 -->end loop
Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As a general statement, I would think #2 would be more better.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Developer9
Premium Member
Premium Member
Posts: 187
Joined: Thu Apr 14, 2011 5:10 pm

Post by Developer9 »

@Chulett,

Draft Design :

Code: Select all

Start Loop  <-----------------------        End Loop
|                                                         |
|                                                         |
uv_activity ---------------------------Exec_Activity

In uv_activities define variables like below

Code: Select all

uv_timestamp  time_stamp logic
uv_file1  filename1
uv_file2  filename2
..so on
Exec_Activity

Code: Select all

cp sourcedir uv_file1.txt target dir uv_file1_uv_timestamp.txt
Loop type specifies is Numeric loop From 1 Step1 To 6 (6 times)

How do we implement the logic for the first iteration of loop read file1 ,second iteration of loop read file2 so on ?Is it possible ?

I am working on this above approach ..any input is appreciated



Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You may want to reconsider using a numeric loop. Rather, can you build a delimited list of the filenames to process first? You can then pass that list to the Start Loop stage and it can loop through the list until it runs out of elements in the list. It can then leverage the built-in loop counter to pass filename #1 to the job / activity on the first iteration, filename #2 on the second iteration, etc etc.

Make any sort of sense? Is this the first time you've built any kind of a looping Sequence job? (just trying to level set here)
-craig

"You can never have too many knives" -- Logan Nine Fingers
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

We have a generic FTP job that loops for the number of files being transfered. Each invocation reads a text file that lists the filenames. I like simple and easy, so it goes like this:

Code: Select all

1) Find number of files in current list. I use UV stages as needed.
2) Set end of loop counter with the file count.
3) Read text file for the filename for each iteration of the loop.
4) I can add or delete files from each list as needed, no changes to DS code.
My file list looks like this:

Code: Select all

1:filename1
2:filename2
3:filename3
etc.
Something very important in my design is error handling and restartability. The main sequence stage -- FTP for me, cp command for you -- is checkpointed. I can rerun a job and have it restart at the failed iteration without further intervention.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Post Reply