order a job for each filename inside a directory

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
jsgoncalves
Participant
Posts: 12
Joined: Tue May 31, 2005 5:01 am

order a job for each filename inside a directory

Post by jsgoncalves »

i'd want to order a job (using datastage basic) for each file i'd find inside a directory (without knowing the filename or even the number of files inside the directory), how can i do it ? :( :evil:
thank you !
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Would it be possible to rephrase your question?

A DataStage routine can loop through each file in a given directory, but I am not sure what you then intend to do with the files found.
jsgoncalves
Participant
Posts: 12
Joined: Tue May 31, 2005 5:01 am

purpose intended

Post by jsgoncalves »

I will clarify this:

for each filename found in a given directory:
call a datastage job with a parameter = filename

thank you
:roll:
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

jsgoncalves,

I would write a Sequence. use the ExecuteCommand stage to get the "dir...." results of looking into a directory, and then with the Loop (start&end) go through each element in this list and use a JobActivity stage in the middle to call up your job.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

It is better to perform using file patterns than a global set. Also you need to arrange the values in the sequencer to process the files.
jsgoncalves
Participant
Posts: 12
Joined: Tue May 31, 2005 5:01 am

Post by jsgoncalves »

i've tried to write a Sequence:
- i use the a ExecuteCommand activity
- - dir #path#\*.*
- i then use a start loop
- - delimited values = #Execute_Command_0.$CommandOutput#
- - delimiter = CR/LF
- i then use a job (jobA) which receives a parameter parametro
- - in the sequencer i make parametro = Execute_Command_0.$CommandOutput

it fails...
is the delimiter wrong ? how could i get each element thru the parameter of jobA ?

thank you
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Ray posted a real nice routine to do exactly this. You might want to search for it.
Mamu Kim
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Did you check what delimiters the loop stage allows? This has been resolved and implemented by me several times in different clients.

If you have any problems in the iteration values, let us know.
jsgoncalves
Participant
Posts: 12
Joined: Tue May 31, 2005 5:01 am

Post by jsgoncalves »

i've solved the problem using job control but i'd much prefer to solve it using the loop (start&end) as it would be a much more clean solution , so i'm trying it very hard ...
i've tried to search for the list of possible delimiters and cannot get one which would work ...
command = dir /B #path#\a*.*
"
- Output from command ====>
alstompis_e.bat
alstompis_e.ds.log
alstompis_e.log
"
then i always get :
- teste3..JobControl (@StartLoop_Activity_1): Loop through list (1 items): iteration 1
- teste3..JobControl (@Job_Activity_5): Controller problem: Error calling DSSetParam(parametro), code=-4
[ParamValue/Limitvalue is not appropriate]
- teste3..JobControl (@Coordinator): Summary of sequence run
18:27:03: Sequence started
18:27:03: Execute_Command_0 (COMMAND dir) started
18:27:03: Execute_Command_0 finished, reply=0
18:27:03: StartLoop_Activity_1 loop iteration 1 started
18:27:03: Job_Activity_5 (JOB teste2) started
18:27:03: Exception raised: @Job_Activity_5, Error calling DSSetParam(parametro), code=-4 [ParamValue/Limitvalue is not appropriate]
18:27:03: Sequence failed


how can i get each result returned by the execute_command ?

:(
thank you
Post Reply