Routine for writing Log to Sequential file

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
Prashantoncyber
Participant
Posts: 108
Joined: Wed Jul 28, 2004 7:15 am

Routine for writing Log to Sequential file

Post by Prashantoncyber »

I ran the below routine which writes logs to Sequential somewhere picked up from this forum.

But it is just writing very fews logs instead of whole logs.

Pls guide what changes are required in this routine to get whole log written to sequential file.

Thanks
Prashant


$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

StartDate = DSGetJobInfo (DSJ.ME, DSJ.JOBSTARTTIMESTAMP)
SummaryArray = DSGetLogSummary (DSJ.ME,DSJ.LOGINFO,StartDate,"9999-12-31", 0)
Answer=""
NLines=0
Loop
Str = Field(SummaryArray,@FM,NLines+1)
If Str<>"" Then
NLines=NLines+1
EventId=Field(Str,"\",1)
TimeStamp=Field(Str,"\",2)
EventMessage=Field(Str,"\",6)
Answer<-1>=EventId:" ":TimeStamp:" ":EventMessage
End
Until Str=""
Repeat

Answer=OConv(Answer,"MCP")
Loop
I= Index(Answer,"'",1)
If I>0 Then Answer=Answer[1,I-1]:Answer[I+1,Len(Answer)]
Until I=0
Repeat

x=Answer
ValidOpen = @FALSE
filename = "/ascl/dsadm/Ascential/DataStage/Projects/LETS/LogToSequentialFile_PA.txt"
OPENSEQ filename TO FILE Then
ValidOpen = @TRUE
End Else
CREATE FILE Then ValidOpen = @TRUE
End
If NOT(ValidOpen) Then
Call DSLogFatal("Could not create the file: ":filename, "OutputFile")
End

AM.CNT = DCOUNT(x, @AM)
For i=1 to AM.CNT
WRITESEQ x TO FILE else
Call DSLogFatal("Could not update the file: ":filename, "OutputFile")
End
Next i
WEOFSEQ FILE
ErrorCode = 0 ;* set this to non-zero to stop the stage/job

Ans =1


ErrorCode = 0 ;* set this to non-zero to stop the stage/job
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Please lookup up the documentation on the DSGetLogSummary routine - especially the description of the third parameter. Then compare that with the output of your DSGetJobInfo() call.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

EventMessage is wrong. The message begins in field number 4, and may include backslashes.

You want something like

Code: Select all

Field(Str, "\", 4, 999)
Str was a poor choice of variable name, since it is also the name of an intrinsic function.

Your code is horribly cumbersome. You process the log information twice. Further, you're reading the log from a job that is still running; you will never get the "job finished" event.

Presumably the middle loop is intended to remove double quote characters. You could more easily have used:

Code: Select all

Answer = Convert('"', '', Answer)
to achieve this end.
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