Page 1 of 1

Reading from Parameter File

Posted: Wed Feb 12, 2003 9:59 pm
by pramod_au
Hello

I have a parameter file which contains userId,Password,
Base directory path. I dont want to hardcode some parameters and path in my JOB.
I have have sequencer designed for my job. Can i read the parameter file and pass those parameter to the job sequencer,which in turn pass these parameters to Individual jobs present in the sequencer?

AIM :TO READ PARAMETER FILE AND USE IN JOB SEQUENCERS





Pramod

Posted: Thu Feb 13, 2003 1:44 am
by ray.wurlod
Yes you can. Again, a small amount of DataStage BASIC code will be required. An example will appear in the soon-to-be-announced CD of tools from the folks who bring you this site.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518

Posted: Thu Feb 13, 2003 2:38 am
by peterh
Here is piece of code which should help you...

Peter

* Get Parameters from file

ParFile=DSGetParamInfo(DSJ.ME,"ParamFile",DSJ.PARAMVALUE)
eof=0
LineNum=1
openseq ParFile to fileID else abort
loop until eof
readseq IDLine from fileID else eof = 1
IF LineNum=1 THEN
TDir=TRIM(FIELD(IDLine,";",1))
TDB=TRIM(FIELD(IDLine,";",2))
TUsr=TRIM(FIELD(IDLine,";",3))
TPwd=TRIM(FIELD(IDLine,";",4))
END
LineNum=LineNum+1
repeat

closeseq fileID
.
.
.
.
hJob1 = DSAttachJob(Job, DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed : ":Job, "JobControl")
Abort
End
* Fill Parameters
ErrCode = DSSetParam(hJob1,"SrcFilePath",DatFile)
ErrCode = DSSetParam(hJob1,"TDir",TDir)
ErrCode = DSSetParam(hJob1,"TDB",TDB)
ErrCode = DSSetParam(hJob1,"TUsr",TUsr)
ErrCode = DSSetParam(hJob1,"TPwd",TPwd)

ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)