Write message in Log or Out file
The following is the Procedure which I use it in any package. This is standard in some companies coding. This save a lot of time and this makes easy to other people who goes through your program.
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).
Note:- 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.
More then information, this post is more of suggestion. Hope this post will help you make your code easy.
Leave a Reply
Want to join the discussion?Feel free to contribute!