Write message in Log or Out file

on Thursday, February 26, 2009

PROCEDURE write(p_type IN VARCHAR2, p_message IN VARCHAR2)IS
/************************************************************************
Purpose : Procedure writes to the log file or output file based on type.
O=Output File, L=Log File
*************************************************************************/
BEGIN
IF p_type = 'L' THEN
fnd_file.put_line (fnd_file.log, p_message);
ELSIF p_type = 'O' THEN
fnd_file.put_line (fnd_file.output, p_message);
END IF;
END write;
The above write procedure can be used in other Procedure/Function in the package to write any information in the Log or Out files.
PROCEDURE main(errbuf OUT VARCHAR2, retcode OUT NUMBER, p_par1 IN NUMBER)
IS
v_errbuf VARCHAR2(1000) := NULL;
v_retcode NUMBER := 0;
v_file_name VARCHAR2(100);
BEGIN
v_retcode := 0;
v_file_name := fnd_profile.value('XYZ');
IF v_file_name IS NULL THEN
write('O','Profile XYZ is not defined or the value is not set');
retcode := 2;
RETURN;
END IF;
END;
Note:- In the above Procedure, I am using the write Procedure and returning 2 for the retcode (0 - Complete, 1- Warning and 2 will be for Error).
This is one time process and you will realise, how much helpful it will be when ever you have to right something in log or out file.

No comments: