DSSetParam Function error

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
har
Participant
Posts: 118
Joined: Tue Feb 17, 2004 6:23 pm
Location: cincinnati
Contact:

DSSetParam Function error

Post by har »

Hi,
My whole idea behind this before job routine is to read values from a seq file and pass these values into Job Parameter.After doing some R&D and searching forum i written the following code.when i complie the code its not throwing any error,but when i try to run job using this routine the job is in run mode only ,i mean job is not processing any rows or it wont abort.
Any Sugeestion would be great full
Here is the code :
$INCLUDE DSINCLUDE DSD_STAGE.H
$INCLUDE DSINCLUDE JOBCONTROL.H
* $INCLUDE DSINCLUDE DSD.H
ParameterFile =InputArg

IntialCount = 0
Counter = 0
OpenSeq ParameterFile To ParameterFileVar
On Error
Msg = 'Error opening parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End
Else
Msg = 'Cannot open parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End

*----------------------------------------------------------------------------
* File Opened
* Read the parameter list from the file.
*----------------------------------------------------------------------------
Loop
ReadSeq Line From ParameterFileVar
On Error
Msg = 'Cannot read parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
Call DSLogwarn(Msg, TransformName )
End
Then
Counter += 1
End
if Counter = Line
Then
Exit
End
Repeat
ParamValue = Line

CloseSeq ParameterFileVar

JobHandle = DSAttachJob(Party_Test, DSJ.ERRFATAL)

ErrCode = DSSetParam(JobHandle,"FileName",ParamValue)

Thanks,
Hary
Har
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Re: DSSetParam Function error

Post by sud »

Hey,

Could not see anywhere you are doing DSRunJob. Where are you executing the job ?

Generally it is a good idea to check the status of the job before executing, pasting a sample code :

Code: Select all

        JobHandle = DSAttachJob("MY_JOB",DSJ.ERRWARN)
        errSetParam = DSSetParam(JobHandle,"JOB_TABLE_NAME",tableName)
        JobStatus = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
        If JobStatus = 3 
        then 
              err = DSRunJob(JobHandle,DSJ.RUNRESET)
              err = DSWaitForJob(JobHandle)
        END
        errRun = DSRunJob(JobHandle,DSJ.RUNNORMAL)
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
har
Participant
Posts: 118
Joined: Tue Feb 17, 2004 6:23 pm
Location: cincinnati
Contact:

Post by har »

Hi,
I add the following code,still its not thowing any recodrs or warnings.
job it self is run mode.
I call this routnie in beforeJob subroutine and in Input Value : /home/abc/filename.txt
Is this the right way to pass teh values or some other way.
here is the modified routine :
$INCLUDE DSINCLUDE DSD_STAGE.H
$INCLUDE DSINCLUDE JOBCONTROL.H
* $INCLUDE DSINCLUDE DSD.H
ParameterFile =InputArg

IntialCount = 0
Counter = 0
OpenSeq ParameterFile To ParameterFileVar
On Error
Msg = 'Error opening parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End
Else
Msg = 'Cannot open parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End

*----------------------------------------------------------------------------
* File Opened
* Read the parameter list from the file.
*----------------------------------------------------------------------------
Loop
ReadSeq Line From ParameterFileVar
On Error
Msg = 'Cannot read parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
Call DSLogwarn(Msg, TransformName )
End
Then
Counter += 1
End
if Counter = Line
Then
Exit
End
Repeat
ParamValue = Line

CloseSeq ParameterFileVar

JobHandle = DSAttachJob(Party_Test, DSJ.ERRFATAL)
Status = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)

*----------------------------------------------------------------------------
*To check is the job is in runnable state.
*If not its reset
*----------------------------------------------------------------------------

If Status = DSJS.RUNFAILED or Status = DSJS.STOPPED Then
Call DSLogInfo("Job is to be reset: " : Party_Test, Setdsparms)
ErrCode = DSRunJob(JobHandle, DSJ.RUNRESET)
ErrCode = DSWaitForJob(JobHandle)
Status = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
If Status <> DSJS.RESET Then
Call DSLogFatal("Job Failed TO RESET: " : Party_Test, Setdsparms)
End
ErrCode = DSDetachJob(JobHandle)
JobHandle = DSAttachJob(TempJobName, DSJ.ERRFATAL)
If NOT(JobHandle) Then
Call DSLogFatal("Job Attach Failed: " : Party_Test, Setdsparms)
Abort
End
End

ErrCode = DSSetParam(JobHandle,"FileName",ParamValue)


ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(JobHandle)
Status = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
ErrMsg = "Party_Test Job failed to run!"
Call DSLogFatal("Job Failed: Party_Test", "JobControl")
End


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

Post by chulett »

har wrote:I call this routnie in beforeJob subroutine and in Input Value : /home/abc/filename.txt
Is this the right way to pass teh values or some other way.
No... and this is what I was worried was going on when I read the first post. You cannot set the parameter values of a running job, which is what you are doing in a 'before job' scenario.

You need to attach, set and then issue the run as well all in one swell foop.
-craig

"You can never have too many knives" -- Logan Nine Fingers
har
Participant
Posts: 118
Joined: Tue Feb 17, 2004 6:23 pm
Location: cincinnati
Contact:

Post by har »

Craig,
can i get some hint or help in implementing your method..
Thanks,
Har
Har
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check sud's post... he was asking where you were actually running the job and showed some code to do so.

Basically, a controlling job or 'batch' would need to read in your parameter file, attach to the job in question, set the parameters values and then run and monitor the actual job. If you are running 7.5.1A of DataStage, this can all be done from the GUI via a Sequence job and the new SetUserVariables stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply