Example of Log file in PeopleSoft PeopleCode

Consideration:
  •  GetFile Method automatically post files to repository if report node set to post repository
  • If you don’t want to post in repository then use different ext (like .tmp) that should exist in system setting of schedule

local File &Log_file;
&Log_file = GetFile(“c:\test\logfilename.txt”, “W”, %FilePath_Absolute);
&Log_file.WriteLine(“ heading : ” | %Date);
&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:\test\logfilename.txt”, “W”, %FilePath_Absolute);
&Log_file.WriteLine(“ heading : ” | %Date);
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()