Page 1 of 1

Read log files and write custom messages in Exception file.

Posted: Wed Jun 06, 2007 2:36 am
by bikan
Hi All,

In this job I am working at I have to write custom messages in the exception report file.

Messages like "Output file failed to open"
No of records parsed in each link
No of records parsed with a particular field being NULL
On completion of output file write it shoul mention that the output file has been closed and end with a end timestamp.

ANy suggestions or ideas on how to contruct such a file.

Thanks
PIyush

Re: Read log files and write custom messages in Exception fi

Posted: Wed Jun 06, 2007 3:28 am
by JoshGeorge
After the job completes you can call your routine and generate this report.
If the file failed to open your job would have aborted, in that case your first field can be job status. Here you can capture the specific fatal error reason and state user specific messages for the ones you can anticipate (Else a default one or the real fatal message from the log) in case of failure. (Ex: Messages like "Output file failed to open"). Link row counts can be retrieved using the respective functions after job handling.
No of records parsed with a particular field being NULL - This can be written to a file or user status using a counter inside the job and retrieved inside the routine. For end timestamp again use any function call of your preference.

Posted: Wed Jun 06, 2007 8:39 pm
by ray.wurlod
Use DSGetLogSummary() to determine whether there were any warnings. Presumably, if there were none, you don't want to write to the exceptions file. You can obtain the row counts from "active stage finishing" messages in the log.

Statements OpenSeq, WeofSeq or Seek, WriteSeq and CloseSeq will allow you to work with a text file from a routine. To save a lot of work and to obviate the first three, search the forum for a function called OpenSequentialFile.

Posted: Thu Jun 07, 2007 2:19 am
by bikan
Could any one provide me with some code on how to actually do it as it would be very helpful. I am trying to make a after job routine for the same but am unable to achieve the desired functionality.

Posted: Thu Jun 07, 2007 2:36 am
by ray.wurlod
That, my friend, is called consulting, and is how some of us make our living.

If you would like to post what you have attempted, and why you believe it does not fulfil expectations (with error messages if any exist), then we would certainly comment upon that.

Make sure your code is nicely formatted and commented, and enclose it in Code tags.