Passing current date to to Job Parameter

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
pdntsap
Premium Member
Premium Member
Posts: 107
Joined: Mon Jul 04, 2011 5:38 pm

Passing current date to to Job Parameter

Post by pdntsap »

I am trying to implement what Ray suggested here but looks like I am missing a lot things.

I have a server job and in the Job Control tab of the server Job Properties, I have the following code

Code: Select all

ErrCode = DSSetParam(ParallelJob, "Year", "2011")
where ParallelJob is the name of the parallel job, Year is a parameter used in the parallel job and I am initializing it with a value of 2011 (I will change it to current year later on and do the same for current month and current day).

I connect this server job to the parallel job in a job sequence but the value for the year parameter is never pased from the server job to the parallel job. I guess I might be way off to a working solution, but any pointers will be appreciated.

Thanks.
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Please check the syntax for DSSetParam. It looks incorrect.
pdntsap
Premium Member
Premium Member
Posts: 107
Joined: Mon Jul 04, 2011 5:38 pm

Post by pdntsap »

The correct syntax is

paramerr = DSSetParam (qsales_handle, "quarter", "1").

Thus, I changd my code to:

Code: Select all

ErrCode = DSSetParam(ParallelJob_handle, "Year", "2011") 
But, still the parameters in the parallel job are not set. I guess I am missing the big picture here.

Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How is ParallelJob_handle allocated its 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Technically, the correct syntax is:

ErrCode = DSSetParam(JobHandle,ParameterName,ParameterValue)

I'd also be curious if you are checking ErrCode after the call to see if it succeeded and if not, why.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

But it only works if the job handle is valid, resulting from an earlier successful invocation of DSAttachJob() or use of DSJ.ME.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... and that exact parameter name exists in the job and the value it is being set to is valid for the parameter type. Check the ErrCode. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
pdntsap
Premium Member
Premium Member
Posts: 107
Joined: Mon Jul 04, 2011 5:38 pm

Post by pdntsap »

Thanks guys for the replies. I had forgotten about my post for the last couple of days but please see below for the solution that seems to work.

I used the UserVariables Activity to initialize the Year and Month User Variables as below:

Code: Select all

Year = OCONV(@DATE,"DY")
Month = OCONV(@DATE,"DM")
The Parallel job downstream from the UserVariables Activity gets the value for the current year and current month job parameters from the User variables above.

Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You may find that @YEAR and @MONTH system variables are available so that you don't need to use Oconv() at all.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pdntsap
Premium Member
Premium Member
Posts: 107
Joined: Mon Jul 04, 2011 5:38 pm

Post by pdntsap »

You are right. I initially used @YEAR and @MONTH but if I remember right, @YEAR returned 11 and @MONTH returned 8. But, I needed 2011 and 08 respectively.
OCONV(@DATE,"DY") returns 2011 and I do further processing in OCONV(@DATE,"DM") to get month as 08.

Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are no datatypes. So...

Code: Select all

"20" : @YEAR
Fmt(@MONTH, "R%2")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pdntsap
Premium Member
Premium Member
Posts: 107
Joined: Mon Jul 04, 2011 5:38 pm

Post by pdntsap »

It works perfect and thanks.

On a related note, I found the Built-in Transforms and Routines chapter in Server Job Development guide. This chapter talks about the Fmt function among other things. There was no mention about the Fmt function in the Parallel Job Development guide. So can I assume that most transforms and routines that work in a Server job will also work in a Parallel jobs?
Is it also safe to assume that Parallel jobs are superset of Server jobs?
Maybe my questions should be in a totally new post.

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

Post by chulett »

I shouldn't have let the original hijack go on as long as it did. Split now, welcome to your own post on the subject. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
pdntsap
Premium Member
Premium Member
Posts: 107
Joined: Mon Jul 04, 2011 5:38 pm

Post by pdntsap »

Sure Craig. Will do that.
Post Reply