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
Reading from Parameter File
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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)
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)