Archive

Posts Tagged ‘File object using Peoplecode’

Log file in Application Engine

September 15, 2008 2 comments

A typical example of Log file creation in application engine using peoplecode is given below.

local File &Log_file;

&Log_file = GetFile(“c:\temp\logfilename.txt”, “W”, %FilePath_Absolute);

&Log_file.WriteLine(“Begin Process : ” | %Datetime);

&Log_file.close()

But if you have to use the same log file across the sections within an application engine, then
Declare the file as global in one of the initial step as given below.

Global File &Log_file;

&Log_file = GetFile(“c:\temp\logfilename.txt”, “W”, %FilePath_Absolute);
&Log_file.WriteLine(“Begin Process : ” | %Datetime);

Then in any¬†following section’s peoplecode step, declare the global variable and start writing to the file.

Global File &Log_file;

&Log_file.WriteLine(“Write anything here”);

Don’t forget to close the log file at the end of application engine.

Global File &Log_file;

&Log_file.close()