Job Sequencer run

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
DSDev2000
Participant
Posts: 7
Joined: Thu Jul 22, 2004 5:20 pm

Job Sequencer run

Post by DSDev2000 »

Hi,

I developed a Job sequencer which receives a parameter, its value hard coded in Job Properties. This sequencer contains set of Jobs to produce result for a particular parameter value.

This I want to upgrade to repeat this Sequencer process to loop to support more than one parameter input value.

1. SeqJob ParamX -> Result1
2. SeqJob ParamY -> Result2
.
.
.
N. SeqJob ParamZ -> ResultN. for N number of values (Parameter)

The parameter value, I am thinking to pass from the text file. I searched this forum, I couldn't get Idea to implement. I request to throw light on this.

Richard T Paul

"When is CARNIVAL Feast?"
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Any chance you are running 7.5? That version adds two new Sequencer stages to allow "looping" in the GUI. Before that you are typically talking a fair amount of hand coded job control to accomplish this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSDev2000
Participant
Posts: 7
Joined: Thu Jul 22, 2004 5:20 pm

Job Sequencer run - Job Control

Post by DSDev2000 »

Hi to all,

Thank you Chulett for letting know option in V 7.5, but I am using V 7.0.
I am comparatelively new to DataStage Sequencer and Job Control code. Any one give idea how can I change existing Job Control Code which Job Sequencer created; in order to achive Job sequencer Loop by passing a parameter value in every repeat.

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

Post by kduke »

You would have to create a batch job. A batch job is a job with no stages just BASIC code. There is a job properties icon or under the edit menu there is edit job properties menu item. Under this there is a job control tab. Click on it. You can type in any BASIC code you want as long as the job will compile.

There is a drop down list at the top. If you select a job then click on the add job button then it will add the code to run that job. It will ask for all the parameter values first. You can create a loop around this job control code and run that job over and over.

Have fun.
Mamu Kim
DSDev2000
Participant
Posts: 7
Joined: Thu Jul 22, 2004 5:20 pm

Job Sequencer run - DSSetParam

Post by DSDev2000 »

Hi to all,

I developed sequencer job loop as Kim stated. Further, This loop runs for "N" number of times with same Parameter Value which was set by "DSSetParam" routine.

I have input values in a parameter/text file to pass as parameter (say 5 values). This sequencer job has to run 5 times with every time new value [say value1 at first time, value2 at second time...] which derived from Parameter/text file. (One parameter value at a time from the file, job uses one parameter.)

Now my job takes first value from file repeating for 5 times. I got struck up. Please any DS Gurus help me out.

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

Post by kduke »

I am not sure I understand your problem but let me take a guess.

Code: Select all

ParamList1 = ''
ParamList1<1> = 1
ParamList1<2> = 2
ParamList1<3> = 3
ParamList1<4> = 4
ParamList1<5> = 5

for i=1 to 5
  ParamValue = ParamList1<i>
  ParamName = "Whatever"
  DSSetParam... ParamName = ParamValue
next i

Mamu Kim
chucksmith
Premium Member
Premium Member
Posts: 385
Joined: Wed Jun 16, 2004 12:43 pm
Location: Virginia, USA
Contact:

Post by chucksmith »

We could tell you how to read from a sequential file in BASIC and you could include it in the loop Kim described, but could we use the command stage to kick off the job and feed it from the parameter file?

Code: Select all

SEQ ----> Command Stage
DSDev2000
Participant
Posts: 7
Joined: Thu Jul 22, 2004 5:20 pm

Post by DSDev2000 »

Hi to all,

Thank you kim for giving valuable idea
Acutally, I have Processing Numbers with starting and Ending date in sequential file (no of lines differ every time whenever requests come to process).

These numbers with dates, I have to pass to my Sequencer job one by one. untill all the numbers are processed.

Like:-
-------
Process.txt
-------------
261273155,01/02/2003,03/06/2003
045678891 ,05/04/2004,07/01/2004
845678991 ,01/04/2003,06/05/2003
456788932 ,07/02/2003,11/08/2003
458975987 ,05/01/2003,12/10/2003
245547896 ,10/02/2003,11/25/2003
124578996 ,08/01/2003,10/26/2003
125879623 ,01/02/2004,06/03/2004
587945662 ,02/03/2004,06/06/2004

The Job:
---------
In Sequencer, first Job activity uses this number with date updates table information, routine stage runs java program and creats sequential file. finally, routine stage does FTP to the another server.

I have to call the above sequencer job in a batch job, by passing Process Number and dates at a time. to repeat until end of process file.

SeqHistJob
-------------

Job Activity Stage: Get Process Number with dates
in Parameter and Run
SQL statements in -->

Routine Stage : Run Java Program that
Produces Resultfile
(Sh script) -->

Routine Stage: Run Sh script in Routine
to FTP transfer Resultfile.


I have to pass (Process Number, start & End dates) at a time, repeat for all remaining lines untill end of file.

So three parameters pass at a time. and run sequencer job for all process numbers in seq file.

Message for Kim
-------------------
" I have a sequential file which has a number and start & End date which needs to be feed to a job to process some information. SO the list I showed each element needs to be sent to a job as a parameter. Yes, this is correct"


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

Post by kduke »

I am not sure what a command stage is. I have not used it but there are several posts on reading a sequential file. From memory I think it is:

Code: Select all

openseq "path" to SeqPtr else ...
loop
while readseq Line from SeqPtr 

  DSSetParam using Line
  run job
repeat
This is sort of psuedo code. This should get you close. You need to search sequential file processing. You have the code to run a job. You need to read a line out of the sequential file and process it then loop until end of the file.

Try it. Let us know how it goes and as Ray says post your solution.

Thanks Kim.
Mamu Kim
DSDev2000
Participant
Posts: 7
Joined: Thu Jul 22, 2004 5:20 pm

Post by DSDev2000 »

Hi to all,

I achived to pass parameters by Shell Scripts ;

Like

For i in "ProcessFile.Txt"
do
ProcNum=$i
dsjob -file filename projname jobname -run -param Proc_Num=$ProcNum
done

I implemented only for Process numbers right now. I am thinking how can I do for process number, start date, end date in one line, may be break into three parts and assign to three parameter values. (" Is it possible DS Gurus") and run the DSJOB as above.

In mean time, I am trying Kim idea, it's kind of cool and neat.

Thank you all, expecting some more input from you regarding assign one line value into three parameters, I will post solution if I get any further breakthrough.

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

Post by kduke »

You could do it in a shell script as well.

Code: Select all


cat ProcessFile.Txt |
while read LINE
do
  set - $LINE
  ProcNum=$1
  StartTime=$2
  EndTime=$3
  if [ "$ProcNum"x != x ]
  then
    dsjob -file filename projname jobname -run -param Proc_Num=$ProcNum  -param StartTime="$StartTime"  -param EndTime="$EndTime"
  fi
done
If ProcessFile.Txt looked like:

123 2004-06-01 2004-06-02
124 2004-06-02 2004-06-03
125 2004-06-04 2004-06-04

If you have trouble with sequential files let us know.


You probably would need to use field() in BASIC to do this.

Code: Select all

  ProcNum = field(Line, " ", 1)
  StartTime = field(Line, " ", 2)
  EndTime = field(Line, " ", 3)
Mamu Kim
acool
Participant
Posts: 29
Joined: Tue Feb 17, 2004 4:31 pm

Post by acool »

Hi Kim,

I wrote a script like this, but the problem is, it ONLY process the fist variable, because there is no waiting, that is, the dsjob will be called for n times almost at the same, and only the first one will work.

is there any wait statement I can use?

kduke wrote:You could do it in a shell script as well.

Code: Select all


cat ProcessFile.Txt |
while read LINE
do
  set - $LINE
  ProcNum=$1
  StartTime=$2
  EndTime=$3
  if [ "$ProcNum"x != x ]
  then
    dsjob -file filename projname jobname -run -param Proc_Num=$ProcNum  -param StartTime="$StartTime"  -param EndTime="$EndTime"
  fi
done
If ProcessFile.Txt looked like:

123 2004-06-01 2004-06-02
124 2004-06-02 2004-06-03
125 2004-06-04 2004-06-04

If you have trouble with sequential files let us know.


You probably would need to use field() in BASIC to do this.

Code: Select all

  ProcNum = field(Line, " ", 1)
  StartTime = field(Line, " ", 2)
  EndTime = field(Line, " ", 3)
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I think there is a -wait option to dsjob. Please look it up or search for it.
Mamu Kim
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly. Or just type 'dsjob' from the command line without any arguments and it will remind you of the proper syntax. FYI, you have a couple of different options on what kind of status information you want to pass back as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply