Blogs

Get PeopleSoft Home (PS_HOME) Using PeopleCode

PeopleCode to get PS Home from your server:

&PS_HOME = LTrim(RTrim(GetEnv("PS_HOME"), "/"), "/");

Easy and straight to the point :)

Delete Multiple Files Using PeopleCode

Deleting files sitting on a server using PeopleCode is one thing I'm sure you will be doing sometime during your PeopleSoft career. The code below should help you out and get you started!

Stop Inserting Grid Rows Using PeopleCode

You can do the following to stop inserting grid rows via people code. This should work in a RowInsert event.

&Rowset.InsertEnabled = False;

Auto Increment a Number in PeopleSoft

Use the GetNextNumber function to increment the value in a record for the field you specify by one.

Syntax:
GetNextNumber ({record.field | record_name, field_name}, max_number)

Best place to add such code is in SavePostChange event.

Example:
My_Field = GetNextNumber(My_Record.My_Field, 99999999);

PeopleCode Field Reference Short Cut

When you are developing with PeopleCode, You can refer to any field on any record definition. All fields references MUST be in the buffer while the program is being executed.

If referred to by just field name, PeopleCode assumes you are dealing with the current record.

If coming from another record you must qualify the field with RECORD.FIELDNAME

However, if you are coding your PeopleCode program from within the field you want reference, you can Press the SHIFT+6 keys which gives you the ^ character.

Scheduling a Process in PeopleCode

Here is a great example of how to schedule a process and email the results from within PeopleCode. You can do this within an App Engine Program or even by placing a push button with FieldChange peoplecode.

Local ProcessRequest &RQST;
Local string &Subject;
Local string &Text;

Display Text Catalog on a PeopleSoft Page

A new functionality in PeopleSoft is the ability to use Text Catalog instead of Message Catalog and display the text on the page. Some main advantages, as I’ve noticed, by using Text Catalog is the ability to use HTML and make text effective dated.

So, lets get right into it and see how is this done!

Navigate to Set Up HRMS > Common Definitions > Text Catalog and Notepad > Maintain Text Catalog then go ahead and create your text catalog that we will be using.

%Concat Meta-SQL in PeopleCode

%Concat resolves to the database-specific concatenation operator so you don't have to guess which way it is done.

The following PeopleCode uses the %Concat meta-sql meta-variable:

SELECT INSTRUCTOR, FIRST_NAME %Concat ' ' %Concat LAST_NAME
FROM %Table(PSU_INSTR_TBL)

On SQL Server, this code resolves to:
SELECT INSTRUCTOR, FIRST_NAME + ' ' + LAST_NAME
FROM PS_PSU_INSTR_TBL

Defining PeopleCode Events

Every PeopleCode program is associated with a PeopleSoft Application Designer definition and with an event. Events are predefined exit points in the component processor flow. As each point is encountered, the event runs PeopleCode for that event each definition.

The below is an attempt to map the 17 Component Processor PeopleCode events to the Component Process Flow:

Search Action Events:
SearchInit, SearchSave

Add to Date using PeopleCode

I came across the below PeopleCode built-in function when trying to find a way to add a month to %date. So, here it is as PeopleSoft explaines it.
My code ended up being like this :

/*Adding one month to system date*/
AddToDate(%date, 0,1,0);

Syntax
AddToDate(date, num_years, num_months, num_days)
Description
Use the AddToDate function to add the specified number of years, months, and days to the date provided.