Unable to use Job parameter in JobControl

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
manishk
Participant
Posts: 32
Joined: Tue Oct 25, 2005 8:45 pm

Unable to use Job parameter in JobControl

Post by manishk »

Hi

I have a job "manishtest". This is a server job which i am running on Windows NT. I have defined the job parameters :

1 FileWatch ( String type )
2 JobToRun (Strin Type )
3 Loop (String Type )

I will be assigning the value through Job Sequence. So want to have these as dynamic.

When i am using this , it is failing saying unable to find the job.


Job_Name1 = DSAttachJob(DSJ.ME,DSJ.ERRFATAL)
Dummy = DSSetParam(Job_Name1, "FileWatch",DSJ.PARAMDEFAULT)
Dummy1 = DSSetParam(Job_Name1, "Loop",DSJ.PARAMDEFAULT)
JobName2 = DSSetParam(Job_Name1, "JobForRun",DSJ.PARAMDEFAULT)

I am using JobName2 as a variable in reset of the code assuming the JobName2 is having the job Name.

Please suggest in this regard

Thanks
Manish
Thanks
Manish
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

If the code you posted is in the JobControl job then DSJ.ME refers to the JobControl job, not the job you want to run "manishtest"
Job_Name1 = DSAttachJob(DSJ.ME,DSJ.ERRFATAL)
Dummy = DSSetParam(Job_Name1, "FileWatch",DSJ.PARAMDEFAULT)
Dummy1 = DSSetParam(Job_Name1, "Loop",DSJ.PARAMDEFAULT)
JobName2 = DSSetParam(Job_Name1, "JobForRun",DSJ.PARAMDEFAULT)
So it should be more like:

Code: Select all

hjob1 = DSAttachJob("manishtest",DSJ.ERRFATAL) 
I don't know how you are planning on getting the dynamic values of the job parameters, but you need to set a local variable to the value you want.
(this is pseudo-code)

Code: Select all

varFileWatch = <something>
varLoop = <something>
varJobForRun = <something>
then use these variables like this:

Code: Select all

Dummy = DSSetParam(hjob1, "FileWatch",varFileWatch) 
Dummy1 = DSSetParam(hjob1, "Loop",varLoop) 
JobName2 = DSSetParam(hjob1, "JobForRun",varJobForRun)
That should get you started.
John
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Manishk - Curious why we are talking about manual Job Control code if you are allegedly using a 'Job Sequence'?


[waves to John]
-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 »

DSJ.ME as the job handle is expressly forbidden to DSAttachJob() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
manishk
Participant
Posts: 32
Joined: Tue Oct 25, 2005 8:45 pm

Post by manishk »

HI

Thanks for the input.
My intention for writing JobControl is : Want to run Job every 10 min and evry ten minute it will wait for the file and run the job which depends on the file. To schedule the job to run between 10 am to 5 pm i am using Sequence. The loopin and wait for file, is being handled in the job control.

When i am hard cding the value , this Job control is running fine. The challege is , we have different "JobToRun" values. Due to this reason i made it as a Job Parameter.

So when i trying to use the parameter values , it is not happening.

As you guys i have suggested , i made the changes , but the Job is hangin when i am trying to Attach the job.

The job Name which has JobController is "manishtest" ie "manishtest"contains these code

The starting code as per you input is :

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

**************************CREATE A BLOCK FOR RUNNING JOB**********************
Version_Name = "Current"

JobForRun = "RSE2_SEQ"
Loop = 1

Job_Handle = DSAttachJob("manishtest",DSJ.ERRFATAL)

Loop = DSSetParam(Job_Handle, "Loop",Loop)
JobForRun = DSSetParam(Job_Handle, "JobForRun",JobForRun)

Entity_Name=JobForRun1


Job_Stat=DSGetJobInfo(JobForRun1,DSJ.JOBSTATUS)
Counts=0

*************************************************************************************

L$CREATESTATUS :

Counts=Counts+1
Call DSLogInfo("Iteration ":Counts ,"Run_":Entity_Name )
IF DSWaitForFile("#FileName# timeout:3S") = DSJE.NOERROR (0)
Then
******************************RUN JOB 1**********************************************
*********
L$RUNJOB1:
*********
**************************START OF RUN JOB BLOCK FOR ONE JOB************************
Job_Name=JobForRun1

*Job_Handle = DSAttachJob(Job_Name,DSJ.ERRFATAL)

Call DSLogInfo("JOB ":Job_Name:" Attached Successfully ","Run_":Entity_Name)

Job_Stat=DSGetJobInfo(Job_Handle,DSJ.JOBSTATUS)

*************************************************************************************
IF (Job_Stat=DSJS.RUNOK OR Job_Stat =DSJS.RUNWARN OR Job_Stat =DSJS.VALOK OR Job_Stat =DSJS.RESET OR Job_Stat =99)

THEN
**SEND REQUEST FOR RUNNING JOB

Run_Err = DSRunJob(Job_Handle, DSJ.RUNNORMAL)

IF (Run_Err <> 0)
THEN
Call DSLogFatal("Job Or Sequence is not in a Runnable State : ":Job_Name, "Run_":Entity_Name)
END
END
Thanks
Manish
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Check the exit status (returned value) of DSSetParam. If it is a negative integer you have some more design to do.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply