The following is returning -13,
ErrlogInfo = DSGetLogSummary(JobHandle,DSJ.LOGANY,JobStartTime,JobEndTime,MaxLog)
Plz let me know how to write a routine!!!
Thanks,
BB
Moderators: chulett, rschirm, roy
Code: Select all
LogEntries = DSGetLogSummary(JobHandle, DSJ.LOGINFO, JobStarted, JobEnded, 0)
Code: Select all
FUNCTION TestLogSummary(JobName, StartTimeStamp, EndTimeStamp)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
* Code assumes that correctly formatted timestamps are provided for
* the second and third arguments. This is not checked.
* Initialize return variable.
Ans = 0
* Attach the job specified in the first argument. Use an innocuous function
* to establish that it worked, otherwise return -1.
hJob = DSAttachJob(JobName, DSJ.ERRNONE)
RealJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If RealJobName Matches "'-'1N0N"
Then
Ans = -1 ; * no such job
End
Else
Result = DSGetLogSummary(hJob, DSJ.LOGINFO, StartTimeStamp, EndTimeStamp, 0)
* Comment this out if you prefer multi-line output in the test window.
Convert @FM To "~" In Result
* Use DSLogInfo to display result in Test window
Call DSLogInfo(Result, "Testing")
End
* Detach job, ignoring errors.
ErrCode = DSDetachJob(hJob)
RETURN(Ans)
ray.wurlod wrote:The line LogEntries[10] = DSGetLogSummary(...) is trying to overwrite the last 10 characters of anything that might already be in the LogEntries variable with the result of the function. Square brackets in DataStage BASIC imply substring operations.
What you are trying to do in the routine is to get the log for the currently running job. You create a comma-delimited record mostly from data parsed from the result of DSMakeJobReport (basic level), but the final field is something from the result of DSGetLogSummary.
Unfortunately, you have not captured this successfully. If you usethen the variable called LogEntries will contain one field for every informational message in the log between the times indicated. Note that there are no square brackets in the syntax.Code: Select all
LogEntries = DSGetLogSummary(JobHandle, DSJ.LOGINFO, JobStarted, JobEnded, 0)
Let's examine the arguments to DSGetLogSummary. DSJ.ME is OK, it's the handle to the current job. DSJ.LOGINFO is OK, it's a predefined constant. The next two arguments, however, are expected to be timestamps, but you have removed the hyphens and colons and converted the space to an underscore. This will cause an error when you invoke DSGetLogSummary.
If you read the on-line help for DSGetLogSummary you will note that it returns a dynamic array, one element per log event retrieved. Each element is a backslash-delimited string containing event ID, timestamp, event type, and zero or more lines of event message.
But you are writing only one line to your audit info file. Which of the potentially many lines from DSGetLogSummary do you require? And, just to make life interesting, some of those lines may themselves contain quote characters!
If you can specify exactly you wanted to record, then maybe we can be more helpful with figuring out the best way to do it in code.
In the interim, create the following transform function Routine, and test it to see what DSGetLogSummary returns.By "test" I mean run it in the Routine's Test environment. Double click on the Result cell after running to see the full results.Code: Select all
FUNCTION TestLogSummary(JobName, StartTimeStamp, EndTimeStamp) $IFNDEF JOBCONTROL.H $INCLUDE DSINCLUDE JOBCONTROL.H $ENDIF * Code assumes that correctly formatted timestamps are provided for * the second and third arguments. This is not checked. * Initialize return variable. Ans = 0 * Attach the job specified in the first argument. Use an innocuous function * to establish that it worked, otherwise return -1. hJob = DSAttachJob(JobName, DSJ.ERRNONE) RealJobName = DSGetJobInfo(hJob, DSJ.JOBNAME) If RealJobName Matches "'-'1N0N" Then Ans = -1 ; * no such job End Else Result = DSGetLogSummary(hJob, DSJ.LOGINFO, StartTimeStamp, EndTimeStamp, 0) * Comment this out if you prefer multi-line output in the test window. Convert @FM To "~" In Result * Use DSLogInfo to display result in Test window Call DSLogInfo(Result, "Testing") End * Detach job, ignoring errors. ErrCode = DSDetachJob(hJob) RETURN(Ans)
ray.wurlod wrote:In that case try replacing DSJ.LOGINFO (which returns only informational messages) with DSJ.LOGWARNING (which returns only warning messages) in your DSGetLogSummary call.
You might also introduce a "quick check" on whether the job finished successfully using DSGetJobInfo. Read more in on-line help.
ray.wurlod wrote:In that case try replacing DSJ.LOGINFO (which returns only informational messages) with DSJ.LOGWARNING (which returns only warning messages) in your DSGetLogSummary call.
You might also introduce a "quick check" on whether the job finished successfully using DSGetJobInfo. Read more in on-line help.