Log files of a Datastage Job

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

DataStageCnu
Participant
Posts: 37
Joined: Sun Aug 01, 2004 1:18 am

Post by DataStageCnu »

I am also facing same problem. Here my intension is to pull all log to a file so that i can send it on mail.
The following is returning -13,

ErrlogInfo = DSGetLogSummary(JobHandle,DSJ.LOGANY,JobStartTime,JobEndTime,MaxLog)

Plz let me know how to write a routine!!!

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

Post by ray.wurlod »

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 use

Code: Select all

LogEntries = DSGetLogSummary(JobHandle, DSJ.LOGINFO, JobStarted, JobEnded, 0)
then 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.

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.

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)
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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Post by rajeev_prabhuat »

Hi Ray,

Thanks you Ray, that is really great.

I got the log summary log but as you told from the huge data that it gives i want only the part of the text data that describes wether the jobs is "sucessful" or "aborted" or "sucessful with warning" and if so aborted/Warning, what caused the Abort or Warning.

Regards,
Rajeev Prabhu
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 use

Code: Select all

LogEntries = DSGetLogSummary(JobHandle, DSJ.LOGINFO, JobStarted, JobEnded, 0)
then 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.

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.

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)
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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Post by rajeev_prabhuat »

Hi

Ray i got it, now i have to filter from that data only the needed information. Thank you very much.

Regards,
Rajeev Prabhu
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.
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Post by rajeev_prabhuat »

Hi io

I got the routine to execute, and it is giving me the result in the Result tab, but i want it to write it into a text file, how can i do that in the same code.

Regards,
Rajeev Prabhu
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
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You *could* use the OpenPath and Write technique you used earlier.

Better is to use OpenSeq, perhaps WeofSeq to truncate or Seek to append, WriteSeq to write one line, and CloseSeq to close.

Search for these in the forum, in on-line help, or in the DataStage BASIC manual.

However, my intent with the transform function routine was only to give you a tool with which to learn and experiment. I think you probably need to revert to a before/after subroutine, as you originally intended.
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