Page 1 of 1

Looping a Job on Windows

Posted: Thu Nov 29, 2007 1:10 am
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.

Posted: Thu Nov 29, 2007 1:17 am
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

Posted: Thu Nov 29, 2007 1:25 am
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

Posted: Thu Nov 29, 2007 1:45 am
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

Posted: Thu Nov 29, 2007 3:16 am
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.

Posted: Thu Nov 29, 2007 4:38 am
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

Posted: Thu Nov 29, 2007 6:39 am
by Amit_111
From Where will I get to learn this batch programming.............Currently I dont have any knowledge in Batch programming

Posted: Thu Nov 29, 2007 7:52 am
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.

Posted: Thu Nov 29, 2007 1:28 pm
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.

Posted: Fri Nov 30, 2007 12:47 am
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??

Posted: Fri Nov 30, 2007 12:56 am
by chulett
Yup. :D

Posted: Fri Nov 30, 2007 2:36 am
by ray.wurlod
The syntax of dsjob does not change at all

Posted: Fri Nov 30, 2007 4:50 am
by Amit_111
Thanks very much Guys.... :)