Call a Routine in a Parameter value

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
kab123
Participant
Posts: 92
Joined: Tue May 18, 2004 4:05 pm

Call a Routine in a Parameter value

Post by kab123 »

Hi,

Can we call a routine as a parameter value in job properties.
like, I would like to use previous month end date as a parameter.
I know if it is a UNIX server, we can use a shellscript. but we are using a NT server.
Can somebody give me some inputs..

Thanks
Perwezakh
Premium Member
Premium Member
Posts: 38
Joined: Mon Jun 06, 2005 9:13 am
Location: Chicago, IL

Re: Call a Routine in a Parameter value

Post by Perwezakh »

kab123 wrote:Hi,

Can we call a routine as a parameter value in job properties.
like, I would like to use previous month end date as a parameter.
I know if it is a UNIX server, we can use a shellscript. but we are using a NT server.
Can somebody give me some inputs..

Thanks
No can't use script in parameter. But yes use can use shell scripts as a before and after routine. As per your use you can use your date shell scripting as a before routine and feed this date value to you job.
kab123
Participant
Posts: 92
Joined: Tue May 18, 2004 4:05 pm

Post by kab123 »

We are on NT platform, we cannot call any shell script.
I wanted to used a parameter that should have a previous month end date at runtime. we use this parameter in the source stage SQL get data for that month only.. any ideas ??

Thanks in advance..
rcanaran
Premium Member
Premium Member
Posts: 64
Joined: Wed Jun 14, 2006 3:51 pm
Location: CANADA

Post by rcanaran »

Have you tried using DOS EXEC (.bat) instead of .sh ?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In a job sequence you can call a routine OR a command/script/BAT file. Provided it's upstream of your Job activity, its return value can be used to supply the parameter value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kab123
Participant
Posts: 92
Joined: Tue May 18, 2004 4:05 pm

Post by kab123 »

Ray - We are using Batch Control program, we are not using DS sequencer.
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Call a Routine in a Parameter value

Post by sachin1 »

hello, if my interpretation about your doubt is clear, i think you want to use a parameter, just like all other parameters used in JOB-PROPERTIES.

If you want to use this job to be executed from Batch file.
Then i think below could be a solution which is quite cumbersome.
you have to use these coding in JOB-CONTROL tab of Job-properties.

DSGetJobInfo.
DSSetParam
DSRunJob
DSWaitForJob
DSDetachJob, with DSSetParam you can set your parameter at run-time and use it for further processing.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If you have the info in afile, you can certainly write a small routine to type the value of the file, capture its return and send it back [using DSExecute()]. Call this routine in the job parameter's area,the return value of the routine will then be populated in the job parameter.
I think thats what you were asking right?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ivannavi
Premium Member
Premium Member
Posts: 120
Joined: Mon Mar 07, 2005 9:49 am
Location: Croatia

Post by ivannavi »

DSguru2B said:
Call this routine in the job parameter's area
I have just tested this. Created a rutine (Transform function server routine)that does nothing but assign to "Ans" like this:
Ans="test_text".

Then I put a call to this function into "default value" of a parameter on parameters tab of job properties. The value of the parameter is sent to a seq file.
My function name is Expand. Well it didn't expand. Instead of "test_text", I see "Expand("dummy")".

What am I missing?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ivannavi wrote:What am I missing?
Nothing, other than the fact that you cannot use a routine in a Job Parameter's default value. You have been led astray. :cry:

Note Ray's answer - Sequence job, Routine Activity stage, downstream Job Activity stage takes the result of the routine call. If you want a 'GUI' solution, that is.

Otherwise, if you are using hand rolled Job Control code, simply call your routine to 'expand' the pathname before you do your DSSetParam calls. You'll need a DEFFUN statement so your job knows it's a 'user defined' routine and not one of its own. Search the site for quite a number of discussion on the subject. You'll need something like:

Code: Select all

DEFFUN Expand(A) calling "DSU.Expand"
Depending on the number of arguments required.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ivannavi
Premium Member
Premium Member
Posts: 120
Joined: Mon Mar 07, 2005 9:49 am
Location: Croatia

Post by ivannavi »

Thank you Chulett very much. I was hoping to avoid involving job sequence in this. I guess DSguru was talking about setting parameters through job sequence.
I know everything about job setting its own parameters not being possible.
But there is always hope... :lol:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can, of course, do anything in job control (batch) code that a job sequence can do - a job sequence is nothing more than a job control code generator.
Therefore, in your batch code, use DSExecute() to execute your command, script, BAT file, whatever and to capture its output, then use that to provide a value to the job parameter using DSSetParam() before calling DSRunJob().
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