Help in fixing Errors in Routine

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
rcil
Charter Member
Charter Member
Posts: 70
Joined: Sat Jun 05, 2004 1:37 am

Help in fixing Errors in Routine

Post by rcil »

Hello All,
I need some help in fixing the routine.

The purpose of this routine is to know the job status, jobinfo, starttime endtime and linkcounts.

I am calling the after job routine in the same job. The code is as follows

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H

JobVar=trim(field(InputArg,",",1))
StageName=field(InputArg,",",2)
LinkName=field(InputArg,",",3)

ProgramName="Testjob"
Call DSLogInfo(" JOBNAME ":JobVar, ProgramName)
Call DSLogInfo("STAGELINKS ":StageName, ProgramName)
Call DSLogInfo(" LinkName":LinkName, ProgramName)

RowCount=DSGetLinkInfo(DSJ.ME,StageName,LinkName,DSJ.LINKROWCOUNT)
Call DSLogInfo(" Number of records ":trim(RowCount),ProgramName)
ErrorCode = 0      ;* set this to non-zero to stop the stage/job
When I run this as an after job routine in the same job I am getting the output as -1 or sometimes -7. Could anyone please let me know what is wrong with this code and description of -1 and -7. What would be the best approach to know the jobinfo, status, starttime endtime and linkcounts.

thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What is your "JobVar" argument value? It needs to be the result of either a DSAttachJob() call or the mnemonic constant of "DSJ.ME"

The -1 and -7 are error codes, they will be one of the possible errors documented in the DSGetJogInfo routine. I'm not at a DS system at the moment, but I'm fairly certain that -1 is the error for BADHANDLE. You can search the "{DataStageProjectPath}/include/JOBCONTROL.H" text file for -7 to get the value or read the routine call to get the list of possible errors.
srividya
Participant
Posts: 62
Joined: Thu Aug 25, 2005 2:31 am
Location: Ashburn,VA

Post by srividya »

Hi

I really don know much about the errors :oops:
but the routine i have writes the Jobname,Jobstatus,StartTime,EndTime to a sequential file., if this serves ur purpose

the Arguments to be passed is the "InputArg" which is the path of the sequential file to which the routine will be writing the details of the job
Hope you find it useful





[color=darkred]$INCLUDE DSINCLUDE JOBCONTROL.H


OpenSeq InputArg To FileVar Then

WriteSeq "JOBNAME,JOBSTATUS,JOBSTART,JOBEND" To FileVar Else
Call DSLogFatal("Cannot write to ":InputArg , "WriteAuditToSeqFile")
Go TO ErrorExit ;

End
Loop
ReadSeq Dummy From FileVar Else Exit ; * at end-of-file
Repeat
JobName = DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)
JobStatus = DSGetJobInfo(DSJ.ME,DSJ.JOBINTERIMSTATUS)
If JobStatus Matches 1
Then JobStatus="Success"
If JobStatus Matches 2
Then JobStatus="Compiledwithwarnings"
If JobStatus Matches 3
Then JobStatus="Aborted"
JobStart = DSGetJobInfo(DSJ.ME,DSJ.JOBSTARTTIMESTAMP)
JobEnd= DSGetJobInfo(DSJ.ME,DSJ.JOBLASTTIMESTAMP)

WriteSeqF JobName:",":JobStatus:",":JobStart:",": JobEnd To FileVar Else
Call DSLogFatal("Cannot write to ":InputArg , "WriteAuditToSeqFile")
GoTo ErrorExit
End
ErrorCode = 1 ;
End Else
Call DSLogFatal("Cannot open file ":InputArg , "WriteAuditToSeqFile")
GoTo ErrorExit
End
ErrorExit:
ErrorCode = 0 ;


End:[/color]
franck.dubreucq
Participant
Posts: 1
Joined: Thu Dec 23, 2004 11:07 am

Post by franck.dubreucq »

According to the Server Job Developer's Guide, errcode -1 stands for DSJE_BADHANDLE (Invalid JobHandle) and -7 for DSJE_BADSTAGE (StageName does not refer to a
known stage in the job)
rcil
Charter Member
Charter Member
Posts: 70
Joined: Sat Jun 05, 2004 1:37 am

Post by rcil »

All the inputs are greatly appreciated. My special thanks to Srividay as his/her routine solved my problem.

This is the great place to get help.

thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Seek FileVar,0,2 Else NULL
is much, much more efficient than

Code: Select all

Loop 
ReadSeq Dummy From FileVar Else Exit ; * at end-of-file 
Repeat 
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply