Home > BaaN, Infor > Error Logging DLL (Baan / Infor LN)

Error Logging DLL (Baan / Infor LN)


Baan handles error logging very well, you must be using ttstperrlog session frequently to verify the logged errors. In many scenarios, we need additional error logging for write/process programs. It is really time consuming to create create traditional baan reports for error logging. So most of the times we prefer writing to a log file. Many of you must have already written the dlls to write your errors to the log file.

While going through the archives, I found one of my very first program for error logging, you may use it without any restrictions & enhance the same based on your needs. I will definately like to know the changes you have done, so request you to share the modifications & enhancements done.

This is no different, the DLL uses report name as an argument and passes the error string to the report. This gives you the flexibility to save the reports in any format you want based on the availibility of the devices in your environment.

The DLL lifecycle have three stages init, log & end.

The details are as below

init.log()

The function init.log will initialise the “error log report”, The user can provide the report code or pass a empty string as a parameter to the function,  In case of empty string the default report “rXXXXXXXXXXX” will open. The user can optionally pass the Report Title in the second argument under DSNtitle.

As a first step the developer will need to change the DEFAULT_REPORT & DEFAULT_TITLE values to the desired ones. There should be one report with the field error_desc with string datatype.

The init function will initialize & open the report. The init function will return the report id which is of type long.

log.error()

The log.error() function takes two parameters report id & error details. This can be called inside a loop multiple times provided the log is initiated.
The log.error() function will pass the error details to the report. The report id, which is the first parameter for the function is the id returned by init.log() function.

end.log()

This function will end the log by closing the report.

|******************************************************************************
|* Title                : Error Logging
|* Description:         : This DLL is used for logging errors
|* Original Author      : Niraj N. S. Kakodkar
|* Date                 : 16/02/2007
|******************************************************************************
|* Category             : Utility
|* Platform             : Independent
|*
|* License for Error Logging DLL
|*
|* Copyright 2007 - 2011 by Niraj N S kakodkar
|*
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* NIRAJ KAKODKAR , Baanboard or Techbuzz (nirajsk.wordpress.com) DISCLAIM ALL
|* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
|* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NIRAJ KAKODKAR nor Baanboard
|* BE LIABLE FOR ANYSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
|******************************************************************************
|******************************************************************************

extern	domain 	tcmcs.s999m	error.desc
extern	domain 	tcmcs.str50	rep.name

|* Change the default report code & Title
#define DEFAULT_REPORT	"rxxxxxxxxxxx"
#define DEFAULT_TITLE	"ERROR REPORT"

function extern long init.log(	domain tcmcs.str15 _report, ...)
{
	DllUsage
		Input: 		Report Code or empty string as first argument
				DsNtitle -> Report Title
		Output:		Report Id
		Description:	The function init.log will initialise the "error log report", The user can
				provide the report code or pass a empty string, in case of empty string
				the default report "rxxxxxxxxxxxx" will open. The user can optionally pass the
				Report Title.
	EndDllUsage

	long    brp_id
	long	arg_count
	long	i
	long	long_value
	string	string_value(200)

	arg_count = get.argc()

	if arg_count > 1 then
		for i = 3 to arg_count step 2
			on case get.long.arg(i-1)
			case DsNtitle:
				string_value = get.string.arg(i)
				rep.name = shiftl$(strip$(string_value))
				break
			default:
				break
			endcase
		endfor
	else
		rep.name = DEFAULT_TITLE
	endif

	if(isspace(_report)) then
		_report = DEFAULT_REPORT
	endif

	brp_id = brp.open(strip$(_report)," ",1)

	if	(brp_id  2 then
		for i = 3 to arg_count step 1
			error_desc = " --------> " & get.string.arg(i)
			break
		endfor
	endif

	error.desc = ""
	if(rep.id > 0) then
		error.desc = record & error_desc
		brp.ready(rep.id)
	endif
}

function extern end.log(long rep.id)
{
	DllUsage
		Input: 		Report Id
		Output:		Void
		Description:	The function closes the report of which id is provided.
	EndDllUsage

	if(rep.id > 0) then
		brp.close(rep.id)
	endif
}

You can also find the code posted on baanboard at Error Log

 

Try http://meamapa.com , a google maps V3 application with added features. Use it, its free & developed by me. Waiting for your valuable comments & feedback to improve it.

Categories: BaaN, Infor Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment