Derived parameters

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

Post Reply
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Derived parameters

Post by PhilHibbs »

Can a value be derived from a parameter and used in, say, a Sequential File stage path?

For instance, if the user enters a SITE parameter of ABC, I want to use ASDF in the file name. If they enter DEF, I want to use QWER. There will be about a dozen site codes, each of which has an associated code that I need to use in the file name.

Does the user have to enter the matching pair of parameters, or can the second parameter be derived from the first?

If not, here comes a feature suggestion.

Also, are there any job parameters that are not prompted to the user? I just want to store a value in one place and re-use it, and not have it changable at run time.
Phil Hibbs | Capgemini
Technical Consultant
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can set / modify the parameter values in the job sequencer / batch from where the jobs are called.

Alternatively, you can try using the DSSetParam with the DSJ.ME job handle in the job control section. I assume you will start using the sequential file even before setting these parameters internally in job control.

Thirdly, you can have Unix links to file with know names. For e.g. assume Site1 has file called file100, you can link this file100 as File_For_Site1 and open the file called File_For_#SITE# in your job.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
sequence job getting first prameter, pasing it to a routine activty that you'll write to do manipulations on the user's parameter, passing the return value to a job activity as a parameter which is used as the file's directory value.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

you can try using the DSSetParam with the DSJ.ME job handle in the job control section

This does not work. A running job is not permitted to change its own parameter values.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Conversion from one parameter to another can be done, for example, in a Routine invoked from a Routine Activity in a Job Sequence. That Job Sequence can then start the job with the resolved values supplied as values for its parameters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

An Alternative method, without using Job sequence. Say You server jobname is JOBA. I will create another server job JOBB, with all the parameters, that you have defined for JOBA. JOBB wont be having any mappings/stages. In the Job Control of JOBB, i will write a piece of code, like:
SITE,DBName,DBUser,DBPassword,FileName are the parameter of JOBB
------------------------------------------------------------------------------
GetFilePath=''
If SITE='ABC' Then
GetFIlePath='ASDF'
End Else
If SITE='DEF' Then
GetFIlePath='QWER'
End Else
If SITE='' Then
Call DSLogFatal("Path Of the File Is not specified")
Abort
End

*Setup Fact, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("JOBA", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: Fact", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "DBName", DBName)
ErrCode = DSSetParam(hJob1, "DBUser", DBUser)
ErrCode = DSSetParam(hJob1, "DBPassword", DBPassword)
ErrCode = DSSetParam(hJob1, "FilePath", GetFilePath)
ErrCode = DSSetParam(hJob1, "FileName", FileName)
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: JOBA", "JobControl")
End
---------------------------------------------------------------------------------

You can add few more error handling in it.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your JobB is a job sequence lovingly hand-crafted. :D

You've created job control code. All a Job Sequence is is a graphical user interface to doing exactly the same. Obviously hand-coding allows for maximum flexibility and flair, while using a Job Sequence allows for maximum ease of use, particularly for those unfamiliar with the programming language.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

Yep its a job sequence only :). With Job Sequence in my previous thread I meant GUI only, but I didnt phrase the word properly.
I am also very new to Basic Code. So learning through R&D enjoying it. :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you create a Job Sequence and compile it successfully, you can view the generated code on the Job Properties window Job Control tab.

It's a bit daunting because of all the name re-mappings and computer-generated variable names, but can be edifying nonetheless.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

yep i have seen that. The first time i created a job sequence with just two job_activity stage. I was terrified to see some 50 lines code :lol: , for just two stages.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A lot of the lines are comments, or declarations. There are relatively few lines of actual processing code, unless you have lots of job parameters (the job sequence actually checks to see that they were actually set, a common deficiency in human-written code).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

You could build a comparison table, and do a lookup comparison, but of course, results will need to be propagated, or repeated in all the needed jobs.
Post Reply