Search This Blog

Wednesday, September 16, 2009

Debug PeopleCode using GetFile

To debug a peoplecode, we can use File write very effectively.

Step 1

Declare a file variable
Local File &MYFILE;

Step 2
Add the following Code. replace ketan with your username to uniquely identify your name.

&MYFILE = GetFile("debugketan.txt", "W");
If &MYFILE.IsOpen Then
&MYFILE.WriteLine("your text");
&MYFILE.WriteLine("ketan");
&MYFILE.Close();
End-If;


Step 3:

This file will be created in unix under respective appserver

PS_HOME\APPSERV\files

For e.g. if peoplecode is running on hrdev appserver the file will be created on

/disk01/psoft/hr84x/appserv/hrdev/files directory.

The path is also determined by the following environment variables when we do not specify the path for the file name or specify a relative file path

If the code is running on Appserver then following environment variables are used and searched in this order.

1.  PS_FILEDIR[\relative_path]

2.  PS_SERVDIR\Files[\relative_path]


If the code is not running on Application Server, then following environment varialbes are used and searched in this order.

1.  PS_FILEDIR[\relative_path]

2.  PS_SERVDIR\Files[\relative_path]

3.  TEMP[\relative_path]

 

The PS_FILEDIR environmental variable is not initialized and set to a path automatically. If you want to use this environmental variable, you must set it yourself.

 

 

Syntax

 

GetFile(filename, mode [, charset] [, pathtype])

 

Mode

Descr

R

Read mode: opens the file for reading, starting at the beginning.

W

Write mode: opens the file for writing. Any existing content in the file is discarded.

A

Append mode: opens the file for writing, starting at the end. Any existing content is retained.

U

Update mode: opens the file for reading or writing, starting at the end. Any existing content is retained. Use this mode and the GetPosition and SetPosition file class methods to maintain checkpoints of the current read/write position in the file.

E

Conditional "exist" read mode: opens the file for reading only if it exists, starting at the beginning. If it doesn’t exist, Open has no effect.

N

Conditional "new" write mode: opens the file for writing, only if it doesn’t already exist. If a file by the same name already exists, Open has no effect.

Charset:

ASCII or A, UniCode or U, THAI, UTF8. Default is ASCII

 

Pathtype:

%FilePath_Relative (Default)

%FilePath_Absoulte

No comments:

Post a Comment