Looping a Job on Windows

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
Amit_111
Participant
Posts: 134
Joined: Sat Mar 24, 2007 11:37 am

Looping a Job on Windows

Post by Amit_111 »

Hi All,

I have a DataStage job which needs to be executed 12 times with different set of parameters passed for each run.
I s there any way to loop this job for 12 times? If Yes, How can I do this?
I couldn't find any Start End Loop Activity in DS 6.0.

Thanks in Advance.
saikir
Participant
Posts: 92
Joined: Wed Nov 08, 2006 12:25 am
Location: Minneapolis
Contact:

Post by saikir »

Hi,

The 6.x version of DataStage does not have any loop start and stop actvities. These stages have been incorporated in the sequencers from the 7.x version of DataStage

Sai
saikir
Participant
Posts: 92
Joined: Wed Nov 08, 2006 12:25 am
Location: Minneapolis
Contact:

Post by saikir »

Hi,

The 6.x version of DataStage does not have any loop start and stop actvities. These stages have been incorporated in the sequencers from the 7.x version of DataStage

Sai
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can most easily accomplish this with a job control routine. Where do the twelve sets of parameter values come from? The following example assumes one set of parameter values per line in an input file.

Code: Select all

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
$INCLUDE UNIVERSE.INCLUDE FILEINFO.H
DEFFUN OpenSequentialFile(FilePath,OpenMode,WriteMode,LogMode) Calling "DSU.OpenSequentialFile"

hFile = OpenSequentialFile(pathname, "R", "A", "Y")
If Fileinfo(hFile, FINFO$IS.FILEVAR)
Then

   For LineNo = 1 To 12

      ReadSeq Line From hFile Else Exit
      GoSub ParseParameters

      hJob = DSAttachJob("MyJob", DSJ.ERRNONE)

      ErrCode = DSSetParam(hJob, "Param1", Param1Value)
      ErrCode = DSSetParam(hJob, "Param2", Param2Value)

      ErrCode = DSRunJob(hJob, DSJ.RUNNORMAL)
      ErrCode = DSWaitForJob(hJob)

      JobStatus = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
      Msg = "Iteration " : LineNo : " complete.  Job status = " : JobStatus
      If JobStatus = DSJS.RUNFAILED Or JobStatus = DSJS.CRASHED
         Then Call DSLogWarn(Msg, "JobControl")
         Else Call DSLogInfo(Msg, "JobControl")

      ErrCode = DSDetachJob

   Next LineNo

   CloseSeq hFile

End
Else

   Msg = "Can not open parameters file " : Quote(pathname) : " for reading."
   Call DSLogFatal(Msg, "Job control")

End

MainExit:
RETURN

ParseParameters:
* Here you parse out the parameter values from the line read from file.

Param1Value = Field(Line, ";", 1, 1)
Param2Value = Field(Line, ";", 2, 1)

RETURN
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Amit_111
Participant
Posts: 134
Joined: Sat Mar 24, 2007 11:37 am

Post by Amit_111 »

Hi Ray,

Actually I have a shell script which executes these jobs fine in Unix wherein I increament the Month by 1 and attach that month with all the Parameters by which all my parameters are updated with the latest.
But don't know how to do this in windows environment.
Sreedhar
Participant
Posts: 187
Joined: Mon Oct 30, 2006 12:16 am

Post by Sreedhar »

Hi,

Within Windows env (MS DOS) we have some thing called as Batch programming, using that conver your unix logic into the Batch understandable code, that should solve your problem.


Regards,
Shree
Regards,
Shree
785-816-0728
Amit_111
Participant
Posts: 134
Joined: Sat Mar 24, 2007 11:37 am

Post by Amit_111 »

From Where will I get to learn this batch programming.............Currently I dont have any knowledge in Batch programming
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

From a co-worker? Anyone there you could tap for help? They wouldn't need to know anything about DataStage to be able to help convert a script to a batch file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Any Microsoft education center would probably be able to help you. There are lots of books out there, such as DOS For Dummies - it's not a DataStage problem that you want to learn batch programming.

You might also acquire a UNIX emulator, such as MKS Toolkit or CygWin, that would mean that you can run your UNIX scripts on a Windows operating system.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Amit_111
Participant
Posts: 134
Joined: Sat Mar 24, 2007 11:37 am

Post by Amit_111 »

oooo........So you guys mean to say that all the DataStage commands such as dsjob -run etc. will work in batch files also. Only thing which will change is the syntax from Unix to windows Batch programming??
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yup. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The syntax of dsjob does not change at all
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Amit_111
Participant
Posts: 134
Joined: Sat Mar 24, 2007 11:37 am

Post by Amit_111 »

Thanks very much Guys.... :)
Post Reply