Before Job SubRoutine to set Job Parameter Values

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
rupeshg
Premium Member
Premium Member
Posts: 60
Joined: Thu Dec 22, 2005 6:02 am
Location: United Kingdom

Before Job SubRoutine to set Job Parameter Values

Post by rupeshg »

Hi,

Requirement: Before job subroutine (BASIC) to provide value (come from a shell script) to the Job Parameter of the same Job.

Job Parameter <-- Before Job Subroutine <-- Shell script

Solution so far: I can call the shell script and get its output value in a variable.

Call DSExecute("Unix", command, Ans, SystemReturnCode)

Where
command = shell script name with full path with proper arguments (works fine)

However, I am not able to assign it to the Job Parameter.

ErrCode = DSSetParam(JobHandle, "pEtlJobRunId", Ans)

Where
JobHandle=DSJ.ME
pEtlJobRunId= job parameter name
Ans = output from a shell script


Here the ErrCode = -1
meaning DSJE.BADHANDLE Invalid JobHandle. So, I come to a conclusion that I cannot attach the same job to set the job parameters (not even using DSAttachJob, job hangs for 1800 seconds and than errors out saying same job cannot be attached).

Is there a work around to this? So I can Set the job parameter values from the before job subroutine (for the same job).

Thanks in advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not possible "before job" as it's not really as "before" as you might think. The job is actually running at that point so it's too late to affect the job parameter values for that run.

You need to truly be "before" the job even starts to do anything like that. So that means job control code, a wrapper script or a Sequence job that gathers the required information, sets the parameter's value and then runs the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

As Craig has already intimated, the "Before Job" should actually be called "In the Job, but before the stages start executing".

It is a known (and irksome) limitation of DSAttachJob that one cannot attach to oneself. I tend to use something along the lines of the the following code in jobs where a job could conceivably attempt to attach to itself.

Code: Select all

IF DSGetJobInfo(DSJ.ME,DS.JOBNAME)='MyJobName' THEN JobHandle = DSJ.ME ELSE JobHandle = DSAttachJob('JobToAttach',DSJ.ERRNONE)
rupeshg
Premium Member
Premium Member
Posts: 60
Joined: Thu Dec 22, 2005 6:02 am
Location: United Kingdom

Post by rupeshg »

Thanks Craig and ArndW.

ArndW,

My jobname is "Test1" and I have added following code to my routine.

IF DSGetJobInfo(DSJ.ME,DS.JOBNAME)= 'MyJobName' THEN JobHandle = DSJ.ME ELSE JobHandle = DSAttachJob('Test1',DSJ.ERRNONE)

It still gets stuck for 1800 seconds before aborting.

Is there something wrong that I am doing?

Thanks in advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Arnd simply corrected your use of a routine attaching to the calling object. That doesn't change the fact that you cannot do what you are attempting to do... which it seems you are still attempting. Or are we just off in testing land? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
rupeshg
Premium Member
Premium Member
Posts: 60
Joined: Thu Dec 22, 2005 6:02 am
Location: United Kingdom

Post by rupeshg »

Thanks Craig.

I established from your first reply itself that it's not possible to attach the same job. I was just trying any slightest hope to get it work as that will save lot of extra work for me.

Anyways, I'll go with Job Control or Sequencer Job.

Thanks once again.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You can do the equivelent by using UtilityRunJob and modifying it to lookup the parameter values.
Mamu Kim
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

rupeshg wrote:Thanks Craig and ArndW.

ArndW,

My jobname is "Test1" and I have added following code to my routine.

IF DSGetJobInfo(DSJ.ME,DS.JOBNAME)= 'MyJobName' THEN JobHandle = DSJ.ME ELSE JobHandle = DSAttachJob('Test1',DSJ.ERRNONE)

It still gets stuck for 1800 seconds before aborting.

Is there something wrong that I am doing?

Thanks in advance.
IF DSgetJobInfo(DSJ.ME,DSJ.JOBNAME)='Test1' THEN JobHandle = DSJ.ME ELSE JobHandle = DSAttachJob('Test1',DSJ.ERRNONE)

but, as stated, this won't get you be the restriction that job parameters cannot be modified from within the job itself.
Post Reply