Page 1 of 1

Routine help

Posted: Wed May 03, 2006 10:06 am
by reddy
Hi Guys,

I created the following routine :

$INCLUDE DSINCLUDE JOBCONTROL.H
EQU SLASH to "\", SPACE to " "
Action = action
JobHandle = ""
StartTimeStamp = ""
EndTimeStamp = ""
ReadRec = ""
WriteRec = ""
RowRec = ""
JobDesc = ""
Ans = ""
JobNo = 1
If JobNo Then
* attach to job
ErrorMode = DSJ.ERRFATAL
JobHandle = DSAttachJob (JobName, ErrorMode)
If JobHandle Then
* get job status
InfoType = DSJ.JOBSTATUS
JobStatus = DSGetJobInfo (JobHandle, InfoType)
Gosub StatusDesc
* get last entry
EventType = DSJ.LOGANY
LastEventId = DSGetNewestLogId(JobHandle, EventType)
If LastEventId Then
EventDetail = DSGetLogEntry(JobHandle, LastEventId)
EndTimeStamp = Field(EventDetail,SLASH,1)
EndDate = Field(EndTimeStamp,SPACE,1)
EndTime = Field(EndTimeStamp,SPACE,2)

EventId = LastEventId
Loop
EventId = 1
EventDetail = DSGetLogEntry(JobHandle, EventId)
Until Index(EventDetail,"Starting",1) Or EventId = 0 Do
FirstEventId = EventId
StartTimeStamp = Field(EventDetail,SLASH,1)
StartDate = Field(EndTimeStamp,SPACE,1)
StartTime = Field(EndTimeStamp,SPACE,2)
Repeat
* check for finished
If Index("21",JobStatus,1) Then
* read/write array
ReadRec = "" ; WriteRec = "" ; ReadCnt = 0 ; WriteCnt = 0
For EventId = LastEventId to FirstEventId Step -1
EventDetail = DSGetLogEntry(JobHandle, EventId)

Rows = Index(EventDetail,"rows read",1)
If Rows = 0 Then Rows = Index(EventDetail,"rows written",1)

If Rows Then
EventDesc = Field(EventDetail,SLASH,4)
MaxCnt = Dcount(EventDesc,@VM)
For Cnt = 1 to MaxCnt
RowDesc = EventDesc<1,Cnt>
RowRec<1,Cnt> = Field(RowDesc,SPACE,5)
RowRec<2,Cnt> = Field(RowDesc,SPACE,1)
RowRec<3,Cnt> = Field(RowDesc,SPACE,3)
Type = Field(RowDesc,SPACE,3)
If Type = "read" Then
ReadCnt += 1
ReadRec<1,ReadCnt> = Field(RowDesc,SPACE,5)
ReadRec<2,ReadCnt> = Field(RowDesc,SPACE,1)
ReadRec<3,ReadCnt> = Field(RowDesc,SPACE,3)
End
If Type = "written" Then
WriteCnt += 1
WriteRec<1,WriteCnt> = Field(RowDesc,SPACE,5)
WriteRec<2,WriteCnt> = Field(RowDesc,SPACE,1)
WriteRec<3,WriteCnt> = Field(RowDesc,SPACE,3)
End
Next Cnt
Exit
End
NextId:
Next EventId
End
End
End Else
JobDesc = "No JobHandle"
End
RtnAns:
Begin Case
Case Action = "Start"
Ans = StartTimeStamp
Case Action = "End"
Ans = EndTimeStamp
Case Action = "Rows"
Ans = RowRec
Case Action = "Read"
Ans = ReadRec
Case Action = "Write"
Ans = WriteRec
Case Action = "Status"
Ans = JobDesc
Case 1
Ans = ""
End Case
End
Goto TheEnd
StatusDesc:
Begin Case
Case JobStatus = 0
JobDesc = "Running"
Case JobStatus = 1
JobDesc = "Finished"
Case JobStatus = 2
JobDesc = "Finished(Log)"
Case JobStatus = 3
JobDesc = "Failed"
Case JobStatus = 11
JobDesc = "Validated"
Case JobStatus = 12
JobDesc = "Validated(Log)"
Case JobStatus = 13
JobDesc = "Validation Failed"
Case JobStatus = 21
JobDesc = "Reset"
Case JobStatus = 91
JobDesc = "Failed"
Case 1
JobDesc = "Unknown (":JobStatus:")"
End Case
Return(Ans)

TheEnd:
If Len(JobHandle) Or Not(IsNull(JobHandle)) Then
Errcode = DSDetachJob(JobHandle)
End

while doing testing with jobaname and any one of the action it's running for ever but it complied without errors.

Can you guys please help me out what's wrong with this routine.

Thanks
Reddy

Posted: Wed May 03, 2006 11:22 am
by kduke
Please edit your post and put code tags around the routine so it will be indented. At first glance it looks like the loop never gets to 'Starting' or ID = 0 so it continues forever.