Reset Job if necessary

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
Terala
Premium Member
Premium Member
Posts: 73
Joined: Wed Apr 06, 2005 3:04 pm

Reset Job if necessary

Post by Terala »

Is it possible to RESET a call job( I am using UtilityRunJob) from Transformer stage? Or Can i use Job control code to check the job status and if necessary RESET before running the Job.
Can any one please provide the basic code.

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

Post by ray.wurlod »

You can use job control code.
Create a job sequence with a Job activity set to "reset if required then run", compile it, and examine the generated job control code.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
The routine you need is DSPrepareJob(hJob)
this will reset if needed the job refered by the hJob handle.
Though I'm not certain it is in the Utility you mentioned so you need to copy it and add it to the code.
While your at it you might want to add code so that your encripted passwords won't show up in the job log (best way by naming cnventions).

Code: Select all

hJob = DSPrepareJob(hJob)
If Not(hJob) Then 
  Call DSLogInfo("Failed","DSPrepareJob")
End
(note was edited for correction of spelling mistakes to horrifying to leave as they were ;))
IHTH,
Last edited by roy on Sun Aug 14, 2005 1:09 am, edited 3 times in total.
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Thanks Roy!

This is the part of existing UtilityRunJob code and i added the code you suggested to Prepare the job (it is between START and END). Hope it works, am I missing anything.. !

Code: Select all

   JobHandle = DSAttachJob(RunJobName, DSJ.ERRFATAL)
      
    Message = DSRMessage('DSTAGE_TRX_I_0014', 'Attaching job for processing - %1 - Status of Attachment = %2', RunJobName:@FM:JobHandle )
    Call DSLogInfo(Message, RoutineName)
    LimitErr = DSSetJobLimit(JobHandle, DSJ.LIMITROWS, RowLimit)
    LimitErr = DSSetJobLimit(JobHandle, DSJ.LIMITWARN, WarnLimit)

* Need to check if error occurred.
    ListOfParams = DSGetJobInfo(JobHandle, DSJ.PARAMLIST)
    ListCount = Dcount(ListOfParams,',')
    For ParamNum = 1 To ParamCount
 	Message = DSRMessage('DSTAGE_TRX_I_0015', 'Setting Job Param - %1  Setting to %2', Param(ParamNum,1):@FM:Param(ParamNum,2))
 	Call DSLogInfo(Message, RoutineName)
        ErrCode = DSSetParam(JobHandle, Param(ParamNum,1),Param(ParamNum,2))
    Next ParamNum





*START
*Need to check if the job to be prepared - START
*        
    JobHandle = DSPrepareJob(JobHandle)
    If Not(JobHandle) Then
       Message = DSRMessage('DSTAGE_TRX_I_0015A', 'Failed - DsPrepareJob', RunJobName)
       Call DsLogInfo(Message, RoutineName)
    End
*
*Need to check if the job to be prepared - END
*END





    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
    ErrCode = DSWaitForJob(JobHandle)
    Status = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
    JobEndTime = DSRTimestamp()
    If Status = DSJS.RUNFAILED Then
         Message = DSRMessage( 'DSTAGE_TRX_E_0020', 'Job Failed: %1', RunJobName)
         Call DSLogWarn(Message, RoutineName)
    End
Post Reply