pass values to job parameters in a sequencer

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

SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

pass values to job parameters in a sequencer

Post by SonShe »

I have a sequencer with a few job parameters. Three of them I need to pass after determining the values in a shell script. I can do that. However, my boss wants me to not use a script for this. I don't know much basic programming.

I would appreciate any ideas or code from any one to help me.

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

Post by kduke »

Describe how you do this in a shell script or post the code.
Mamu Kim
kommven
Charter Member
Charter Member
Posts: 125
Joined: Mon Jul 12, 2004 12:37 pm

Post by kommven »

It depends on the req. Is it taking any variables from the env? and in what kind of job/Stage?

You can use some code like within ticks e.g. `OS /UNIX SHELL CODE` in the jobs that will run at OS and get the output into job, try this...
Kommven
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

kduke wrote:Describe how you do this in a shell script or post the code.
Kim, in the shell script I select a date from a Oracle table and store that in a variable. The second value is another date value that is either current date or the date supplied by the user that is stored in a unix file. I capture this date in a second variable. Based on this second date value, I determine a third value and store that also in variable. Then I call the sequencer with dsjob -run -param [1,2,3,4,5,......] options.

This is what I meant when I said I am comfortable doing it in shell script. But if I have to determine these three values in a routine, my question was how do I pass those values to the 3 job parameters for the sequencer? If I would have to pass only one value I could use the UserStatus to set the value of the job parameters.

If I have 3 values for 3 job parameters, how do I do that?

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

Post by kduke »

You need to create a batch job or a routine. A batch job is a job with no stages just code. In the job properties there is a control code tab. In this screen there is a drop down list of all the jobs. Select the job you want to run and it will add all the code to set the parameters and run the job.

To do this in a sequence then you need a routine which returns the value of the parameter. When you build the routine it will warn you that you are changing the value of an argument.

You still need the values of the dates from Oracle. I would just select these and write them into a hash file. Hard code the key to something like "StartDate". There is a SDK function to read a hash file. Modify or use this routine to read in these values.
Mamu Kim
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can return all 3 values concatenated with delimiters. This can then be parsed in your sequencer to pass to appropriate jobs. If you are using DS V7.5 or above, you can also make use of 'user defined variable' stage to define new variables to hold these values.
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

Kim, thanks for the reply. I definitely have a few challenges here like figuring out how to access a DB table from a routine, how to write to a hash file etc. But I believe there are enough number of postings in this forum to give me the idea. However, I still can't understand how I can set the values stored in the hash file to the job parameters ofthe sequencer. Are you saying that I should call the sequencer in the routine itself and pass the values with -param options, like I am doing in the shell script?

Please expand a bit more on this.

Thanks again.
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

Thanks Sainath. I thought of doing that. But I am using those values as part of the names of sequential files that I build. I don't know how/where I can parse the delimited string to use in creating the file name.

Thanks.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

When you pass from the routine, you can concatenate them with field delimiters in a multi valued field. This will help you in making them as param<1>, param<2> and param<3> when calling other jobs.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

If you write a job which reads from Oracle and writes to either a hash file or a sequential file then these are easy to read or write to in BASIC in either a routine or a batch job. I usually start jobs from batch jobs and not routines.

As to the routine returning start and end dates as one field. I would not do this. A routine can return more than one argument. So StartDate could be the first argument and EndDate the second. Routines normally return the Ans value. They can now return the arguments to a sequence.

Code: Select all

Job1
Oracle -> Trx -> ParamHash (StartDate)
Oracle -> Trx -> ParamHash (EndDate)

Seq
Routine(GetParam) -> Job1(MyJob)
Arg1 (StartDate)         Param StartDt ->GetParam.StartDate
Arg2 (EndDate)           Param EndDt ->GetParam.EndDate

Code: Select all

GetParam(StartDate, EndDate)
Ans = 1
open "ParamHash" to ParamHash then
   read rec from ParamHash, "StartDate" then
      StartDate = rec<1>
      read rec from ParamHash, "EndDate" then
         EndDate= rec<1>
      end else
         Ans = 0
      end
   end else
      Ans = 0
   end
end else
   Ans = 0
end

return(Ans)
Mamu Kim
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

kduke wrote:If you write a job which reads from Oracle and writes to either a hash file or a sequential file then these are easy to read or write to in BASIC in either a routine or a batch job. I usually start jobs from batch jobs and not routines.

As to the routine returning start and end dates as one field. I would not do this. A routine can return more than one argument. So StartDate could be the first argument and EndDate the second. Routines normally return the Ans value. They can now return the arguments to a sequence.

Code: Select all

Job1
Oracle -> Trx -> ParamHash (StartDate)
Oracle -> Trx -> ParamHash (EndDate)

Seq
Routine(GetParam) -> Job1(MyJob)
Arg1 (StartDate)         Param StartDt ->GetParam.StartDate
Arg2 (EndDate)           Param EndDt ->GetParam.EndDate

Code: Select all

GetParam(StartDate, EndDate)
Ans = 1
open "ParamHash" to ParamHash then
   read rec from ParamHash, "StartDate" then
      StartDate = rec<1>
      read rec from ParamHash, "EndDate" then
         EndDate= rec<1>
      end else
         Ans = 0
      end
   end else
      Ans = 0
   end
end else
   Ans = 0
end

return(Ans)


Thank you so much Kim. You are so good! I learn everytime I go to the forum from people like you.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Thanks.
Mamu Kim
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi Kim,
I have a requirement, where Job1 gives me a date which is also stored ina table (I can write it to ahash file if required) and then in job 2 I need this to be passed a parameter.
How do I go abou ti t.
Thanks a lot
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I think it is explained above. Write a job which reads the value in Oracle and stores it in a hash file. The key should be hard coded to some value like "MyDate". Use the above routine to return this value in an argument. This argument is available in a sequence after you call this routine in a routine activity.

Code: Select all

Sequence:

Oracle2HashJob -> GetMyDateRoutine -> RunJob

When you RunJob then set parameter to one of the arguments returned from GetMyDateRoutine.
Mamu Kim
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Thanks Kim,
Using the "ReturnValue" from the routine.
Post Reply