Passing parameter

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Passing parameter

Post by admin »

Excellent, I am now subscribed ! Ok, Im sitting with a problem. I am very new to Datastage. I am writing a control job that will run another job by sending a parameter to the job.

My problem: how do I send a parameter from one job to another ? I am busy reading the manuals, but havent found a solution yet.

Hope you can help.
Dirk


-----Original Message-----
From: Dirk Moolman [mailto:dirkm@reach.co.za]
Sent: Thursday, September 27, 2001 3:06 PM
To: Datastage List
Subject: Testing


Testing !



Dirk Moolman
Database Administrator
Reach Technologies
South Africa

www.thefuelgroup.co.za

"No pessimist ever discovered the secret of the stars, or sailed to an uncharted land, or opened a new doorway for the human spirit." -Helen Keller




==========================================================
This message contains information intended for the perusal, and/or use (if so stated), by the stated addressee(s) only. The information is confidential and privileged. If you are not an intended recipient, do not peruse, use, disseminate, distribute, copy or in any manner rely upon the information contained in this message (directly or indirectly). The sender and/or the entity represented by the sender shall not be held accountable in the event that this prohibition is disregarded. If you receive this message in error, notify the sender immediately by e-mail, fax or telephone representations contained in this message, whether express or implied, are those of the sender only, unless that sender expressly states them to be the views or representations of an entity or person, who shall be named by the sender and who the sender shall state to represent. No liability shall otherwise attach to any other entity or person. ==========================================================
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Hi Dirk,
you are welcome!!
If you have to pass parameters to a job from a job control you have to use DSSetParam before performing DSRunJob:

ErrCode = DSSetParam(jobHandle, ParamName, ParamValue)

You can find more documentation in Datastage help on line.

Regards,
Riccardo
----- Original Message -----
From: "Dirk Moolman"
To: "Datastage List"
Sent: Thursday, September 27, 2001 3:22 PM
Subject: Passing parameter


> Excellent, I am now subscribed ! Ok, Im sitting with a problem. I
> am
very
> new to Datastage.
> I am writing a control job that will run another job by sending a
parameter
> to the job.
>
> My problem: how do I send a parameter from one job to another ? I am
> busy reading the manuals, but havent found a solution yet.
>
> Hope you can help.
> Dirk
>
>
> -----Original Message-----
> From: Dirk Moolman [mailto:dirkm@reach.co.za]
> Sent: Thursday, September 27, 2001 3:06 PM
> To: Datastage List
> Subject: Testing
>
>
> Testing !
>
>
>
> Dirk Moolman
> Database Administrator
> Reach Technologies
> South Africa
>
> www.thefuelgroup.co.za
>
> "No pessimist ever discovered the secret of the stars, or sailed to an
> uncharted land, or opened a new doorway for the human spirit." -Helen
> Keller
>
>
>
>
> ==========================================================
> This message contains information intended for the perusal, and/or use
> (if so stated), by the stated addressee(s) only. The information is
> confidential and privileged. If you are not an intended recipient, do
> not peruse, use, disseminate, distribute, copy or in any manner rely
> upon the information contained in this message (directly or
> indirectly). The sender and/or the entity represented by the sender
> shall not be held accountable in the event that this prohibition is
> disregarded. If you receive this message in error, notify the sender
> immediately by e-mail, fax or
telephone
> representations contained in this message, whether express or implied,
> are those of the sender only, unless that sender expressly states them
> to be the views or representations of an entity or person, who shall
> be named by the sender and who the sender shall state to represent. No
> liability shall otherwise attach to any other entity or person.
> ==========================================================
>
>
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Dirk,
There are a set of routines that are used that allow you to run jobs, wait for them to complete, and pass parameters. The routine you are looking for is DSSetParam. Heres some example code

* Setup EGARPCroReconCroLoadIds, run it, wait for it to finish, and test for success

hJob2 = DSAttachJob("EGARPReconCroLoadIds", DSJ.ERRFATAL)

ErrCode = DSSetParam(hJob2, "AuditAppName", AuditAppName)

ErrCode = DSSetParam(hJob2, "croacct", croacct)

ErrCode = DSSetParam(hJob2, "crouser", crouser)

ErrCode = DSSetParam(hJob2, "cropass", cropass)

ErrCode = DSSetParam(hJob2, "startid", startid)

If NOT(hJob2) Then

Call DSLogFatal("Job Failed: EGARPReconCroLoadIds", "JobControl")

Abort

End

ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)

ErrCode = DSWaitForJob(hJob2)

Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)

If Status = DSJS.RUNFAILED Then

* Fatal Error - No Return

Call DSLogFatal("Job Failed: EGARPReconCroLoadIds", "JobControl")

End



Dirk Moolman wrote: Excellent, I am now subscribed ! Ok, Im sitting with a problem. I am very new to Datastage. I am writing a control job that will run another job by sending a parameter to the job.

My problem: how do I send a parameter from one job to another ? I am busy reading the manuals, but havent found a solution yet.

Hope you can help.
Dirk


-----Original Message-----
From: Dirk Moolman [mailto:dirkm@reach.co.za]
Sent: Thursday, September 27, 2001 3:06 PM
To: Datastage List
Subject: Testing


Testing !



Dirk Moolman
Database Administrator
Reach Technologies
South Africa

www.thefuelgroup.co.za

"No pessimist ever discovered the secret of the stars, or sailed to an uncharted land, or opened a new doorway for the human spirit." -Helen Keller




==========================================================
This message contains information intended for the perusal, and/or use (if so stated), by the stated addressee(s) only. The information is confidential and privileged. If you are not an intended recipient, do not peruse, use, disseminate, distribute, copy or in any manner rely upon the information contained in this message (directly or indirectly). The sender and/or the entity represented by the sender shall not be held accountable in the event that this prohibition is disregarded. If you receive this message in error, notify the sender immediately by e-mail, fax or telephone representations contained in this message, whether express or implied, are those of the sender only, unless that sender expressly states them to be the views or representations of an entity or person, who shall be named by the sender and who the sender shall state to represent. No liability shall otherwise attach to any other entity or person. ==========================================================



---------------------------------
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone with Yahoo! by Phone.
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

I think what Dirk wants is to get the parameter from the current job and pass it to the controlled job. The function for reading a parameter value from a job is DSGetParamInfo(), and the job handle of the current job is DSJ.ME. From this (lets say the parameter name is Password):

Pwd = DSGetParamInfo(DSJ.ME,"Password",DSJ.PARAMVALUE)
hJob1 = DSAttachJob("OtherJob",DSJ.RUNNORMAL)
JobName = DSGetJobInfo(hJob1,DSJ.JOBNAME)
If JobName = DSJE.BADHANDLE
Then Call DSLogFatal("Cannot attach job OtherJob","Control") ErrCode = DSSetParam(hJob1,"Password",Pwd)
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Dirk/Ray:

If you are developing a batch job to control other jobs, the parameters are available as BASIC variables in the batch job. There is no need to do anything fancy, just reference the variable wherever necessary in the BASIC code that you need it. If you derive the variable in the BASIC logic, thats fine also.

I develop a master controlling batch job that is parametized so that the job control is dynamic to the conditions at runtime. For example, I put parameters into the controlling batch that prompt whether to archive datasets, clear work areas, etc. Within the BASIC of the batch job I then reference these parameters and take the appropriate action. Sometimes a parameter in a controlled job is the result of a derivation in the controlling batch job. DataStage is quite flexible in supporting this kind of activity via the batch job. I think that the batch job is the most under utilized component of DataStage. It allows you to insert external processes, send messages between jobs, and do all kinds of fancy things. You should really exploit this capability to the fullest.

Good luck!
-Ken





ray.wurlod@Informix.Com on 27-Sep-2001 18:54



Please respond to datastage-users@oliver.com

To: datastage-users
cc:
Subject: RE: Passing parameter


I think what Dirk wants is to get the parameter from the current job and pass it to the controlled job. The function for reading a parameter value from a job is DSGetParamInfo(), and the job handle of the current job is DSJ.ME. From this (lets say the parameter name is Password):

Pwd = DSGetParamInfo(DSJ.ME,"Password",DSJ.PARAMVALUE)
hJob1 = DSAttachJob("OtherJob",DSJ.RUNNORMAL)
JobName = DSGetJobInfo(hJob1,DSJ.JOBNAME)
If JobName = DSJE.BADHANDLE
Then Call DSLogFatal("Cannot attach job OtherJob","Control") ErrCode = DSSetParam(hJob1,"Password",Pwd)
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Ken,

DSGetParamInfo is, imho, a cleaner approach, since its result can be tested to check whether the parameter name actually exists in the job (a subsequent "developer" may have unthinkingly removed it). You can also find out other information, such as parameter type, design time default value, run time default value (as set in Directory) and so on.

As to your other comments regarding batch jobs (which I call job control routines), I agree wholeheartedly!

Regards,
Ray

-----Original Message-----
From: Ken_2_Bland@sbphrd.com [mailto:Ken_2_Bland@sbphrd.com]
Sent: Friday, 28 September 2001 09:41
To: datastage-users@oliver.com
Subject: RE: Passing parameter



Dirk/Ray:

If you are developing a batch job to control other jobs, the parameters are available as BASIC variables in the batch job. There is no need to do anything fancy, just reference the variable wherever necessary in the BASIC code that you need it. If you derive the variable in the BASIC logic, thats fine also.

I develop a master controlling batch job that is parametized so that the job control is dynamic to the conditions at runtime. For example, I put parameters into the controlling batch that prompt whether to archive datasets, clear work areas, etc. Within the BASIC of the batch job I then reference these parameters and take the appropriate action. Sometimes a parameter in a controlled job is the result of a derivation in the controlling batch job. DataStage is quite flexible in supporting this kind of activity via the batch job. I think that the batch job is the most under utilized component of DataStage. It allows you to insert external processes, send messages between jobs, and do all kinds of fancy things. You should really exploit this capability to the fullest.

Good luck!
-Ken





ray.wurlod@Informix.Com on 27-Sep-2001 18:54



Please respond to datastage-users@oliver.com

To: datastage-users
cc:
Subject: RE: Passing parameter


I think what Dirk wants is to get the parameter from the current job and pass it to the controlled job. The function for reading a parameter value from a job is DSGetParamInfo(), and the job handle of the current job is DSJ.ME. From this (lets say the parameter name is Password):

Pwd = DSGetParamInfo(DSJ.ME,"Password",DSJ.PARAMVALUE)
hJob1 = DSAttachJob("OtherJob",DSJ.RUNNORMAL)
JobName = DSGetJobInfo(hJob1,DSJ.JOBNAME)
If JobName = DSJE.BADHANDLE
Then Call DSLogFatal("Cannot attach job OtherJob","Control") ErrCode = DSSetParam(hJob1,"Password",Pwd)
Locked