Assign Job Parameter from a File

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
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Assign Job Parameter from a File

Post by nick.bond »

I need to assign a date to a job parameter so it can be used to restrict the records returned from my source system.

The date I need will be extracted from SAP BW prior to the job being run so the job knows the last successful load date. It can be extracted into either a hashed file or a flat file.

Can someone please tell me how I can get the value from a file and assign it to a job parameter.

Is it possible to do this with a routine? I tried to write the code to simply set a job parameter using DSSetParam from a routine but it didn't work.

If someone could give me example code and explain where this code needs to be used I would be very grateful.

Thanks in advance,

Nick.
Regards,

Nick.
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Re: Assign Job Parameter from a File

Post by raju_chvr »

From where are you calling the Routine ? is it from before-job sub-routine ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You can't set a Job Parameter from inside a job, even in a before-job subroutine, as at that point the job has already started and it's too late. A couple of ways to accomplish what you need...

You can write a routine to pick up the value from your file and then return it as the output of the routine. In a Sequence job, put a Routine Activity stage before your Job Activity stage, run your routine and set the Parameter value to the Routine Activity stage's return code.

Or, write a simple job that reads it and puts the value out into the User Status area. Again, in a Sequence job, run the first job and then set the Parameter value to the UserStatus value of the previous job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

chulett wrote:You can't set a Job Parameter from inside a job, even in a before-job subroutine, as at that point the job has already started and it's too late. A couple of ways to accomplish what you need...

You can write a routine to pick up the value from your file and then return it as the output of the routine. In a Sequence job, put a Routine Activity stage before your Job Activity stage, run your routine and set the Parameter value to the Routine Activity stage's return code.
I am about to suggest the same after he answers my question. :oops:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Assign Job Parameter from a File

Post by ray.wurlod »

bondcaliwood wrote:I need to assign a date to a job parameter so it can be used to restrict the records returned from my source system.

The date I need will be extracted from SAP BW prior to the job being run so the job knows the last successful load date. It can be extracted into either a hashed file or a flat file.

Can someone please tell me how I can get the value from a file and assign it to a job parameter.

Is it possible to do this with a routine? I tried to write the code to simply set a job parameter using DSSetParam from a routine but it didn't work.

If someone could give me example code and explain where this code needs to be used I would be very grateful.

Thanks in advance,

Nick.
You must do this in a controlling job. In the controlling job:
  • attach the "real" job checking for success (DSAttachJob())
    open the file (OpenSeq)
    read the parameter name/value pair (ReadSeq)
    set the parameter in the attached job, checking for success (DSSetParam())
    close the file (CloseSeq)
    request that the attached job be run (DSRunJob())
    wait for the attached job to finish ("sleep" wait or "busy" wait)
    check the exit status of the attached job, react accordingly (DSGetJobInfo())
    check any other metrics you need do
    detach the child job (DSDetachJob())
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

Thanks, It looks like I need to do this in a controlling job.

I will have a go and no doubt be back with another question when it doesn't work!

Cheers, Nick.
Post Reply