Page 1 of 1

Setting Job Parameter in Before Job Subroutine

Posted: Tue Jan 03, 2006 12:38 am
by lata walekar
Hi !

Is it possible to set the parameters of a job from its before routine itself ? Actually, I want to set the starting value for the surrogate key generator for which I have created a job which fetches the maximum value generated from the database and this value has to be set in the job. I am able to set the parameter from a server routine but when the same was tried with a before routine it did not work. The code used is:

Code: Select all


$INCLUDE DSINCLUDE JOBCONTROL.H 


ErrorCode = 0      ;* set this to non-zero to stop the stage/job

TableName = LEFT(InpParam,INDEX(InpParam,',',1)-1)
ColName = RIGHT(InpParam,LEN(InpParam) - INDEX(InpParam,',',1))


* **********GET MAX****************** 

JobHandle = DSAttachJob("JOB_GET_MAX_ID", DSJ.ERRNONE) 

ErrorCode = DSSetParam(JobHandle,"JOB_TBL_NME",TableName)
ErrorCode = DSSetParam(JobHandle,"JOB_ID_COL",ColName)

ErrorCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
ErrorCode = DSWaitForJob(JobHandle)

If MaxVal <> 1 then MaxVal = MaxVal + 1

MaxVal = DSGetJobInfo (JobHandle,DSJ.USERSTATUS)


* **********GET MAX****************** 




JobHandle1 = DSAttachJob(DSJ.ME, DSJ.ERRNONE)
ErrorCode = DSSetParam(JobHandle,"JOB_ID_START",MaxVal)


Posted: Tue Jan 03, 2006 12:58 am
by balajisr
HI

No it is not possible to set value to the job parameter in before job subroutine.

Please do a search on this forum. It has explained this process many times.

--Balaji S.R

Re: Setting Job Parameter in Before Job Subroutine

Posted: Tue Jan 03, 2006 1:01 am
by chulett
Welcome! :D
lata walekar wrote:Is it possible to set the parameters of a job from its before routine itself ?
Short answer is no. Stick with your 'server routine' which I assume means via a Job Sequence.

Posted: Tue Jan 03, 2006 3:40 pm
by ray.wurlod
Long answer is "No". :lol:

Posted: Wed Jan 04, 2006 10:17 am
by alisoviejo
Hi,
I am calculating a date value in Job1 , now I need to pass this value to Job2 (as a parameter so that it can be used in the join condition) without landing the data into a dataset or table, can I acheive this using any stages in the sequencer ?

Thanks,

Posted: Wed Jan 04, 2006 11:20 am
by ArndW
You can use the user return variable, this method has been discussed a number of times, I just found this thread on the subject

Posted: Wed Jan 04, 2006 4:41 pm
by alisoviejo
Hi ,
Thanks for the reply, looked at it, and tried to develop a PX job which stores the value into a stage variable, and I am struck on how to retrieve this a s user status or parameter for the next job in a job seq.

Appreciate your help

Posted: Wed Jan 04, 2006 5:49 pm
by vmcburney
You should keep retrieving your surrogate key start value back at the sequence job level via a routine. It can be difficult getting the maximum key value used from within a parallel job as you have multiple instances of transformers and surrogate key generators in action and no easy way to get the last value used out of the job.

Write a reusable routine that gets the last key value used and call it before each job activity stage that calls a key generator job.

Posted: Thu Jan 05, 2006 8:24 am
by vinaymanchinila
Hi,
I am not looking for the surrogate key value, I am calculating DATE value in Job1 and need to pass it as parameter to the next job in a seq.

Posted: Thu Jan 05, 2006 8:44 am
by chulett
Check the post Arnd linked to, three posts up from yours. It explains the process.