Routine outputs director log - record split problem
Posted: Tue Jan 15, 2008 4:58 am
I have a routine which takes the name of a job and outputs the log for that job. Here it is below:
It seems to work fine in test and produces the result I expect. If I produce a file and use datastage to read the file and load it, I have no problem.
The trouble is, I want to use this routine in a transform to then output the results which I can split into the relevant fields and load it to a database. But I seem to be having problems as I only seem to be able to output one row when I use the "Field (string, delimiter, instance [ ,number] )" function to try and split it out in the transform stage.
I also tried to remove all CR/LF from the output so I output one big line and try to split it that way, but I still only seem to have the first record showing in the results.
Is there something I am missing? Or a better way of doing this?
Thanks
Code: Select all
*Read Job Log
hJob = DSAttachJob(Arg1, DSJ.ERRNONE)
If hJob <> 0 then
Job_Invocation = DSGetJobInfo (hJob,DSJ.JOBINVOCATIONID)
Start_TS = DSGetJobInfo (hJob, DSJ.JOBSTARTTIMESTAMP)
End_TS = DSGetJobInfo (hJob,DSJ.JOBLASTTIMESTAMP)
If Trim(Start_TS) = "" Then Log_Start_TS = TimeStamp Else Log_Start_TS = Start_TS
If Trim(End_TS) = "" Then Log_End_TS = TimeStamp Else Log_End_TS = End_TS
Print "TimeStamp ":TimeStamp
If TimeStamp >= Log_End_TS then
Logs_Any = DSGetLogSummary (hJob, DSJ.LOGANY, Log_Start_TS, Log_End_TS, 50)
Logs_Warn = DSGetLogSummary (hJob, DSJ.LOGWARNING, Log_Start_TS, Log_End_TS, 50)
Logs_Fatal = DSGetLogSummary (hJob, DSJ.LOGFATAL, Log_Start_TS, Log_End_TS, 50)
Logs_out = Logs_Any:"\": Logs_Warn:"\": Logs_Fatal
* Logs_out = Change(Change (Logs_Any, @FM, LF),"\", "|") : LF : Change(Change (Logs_Warn, @FM, LF),"\", "|") : LF : Change(Change (Logs_Fatal, @FM, LF),"\", "|")
OpenSeq LOGFileName To PathFvar
Else
CREATE PathFvar Else ABORT
OpenSeq LOGFileName To PathFvar else ABORT
WEOFSEQ PathFvar
WRITESEQ Logs_out TO PathFvar ELSE STOP
end
ErrCode = DSDetachJob(hJob)
end
end
Ans=Ereplace (Logs_out, Char(13), "|")
End:
The trouble is, I want to use this routine in a transform to then output the results which I can split into the relevant fields and load it to a database. But I seem to be having problems as I only seem to be able to output one row when I use the "Field (string, delimiter, instance [ ,number] )" function to try and split it out in the transform stage.
I also tried to remove all CR/LF from the output so I output one big line and try to split it that way, but I still only seem to have the first record showing in the results.
Is there something I am missing? Or a better way of doing this?
Thanks