Archive

Archive for the ‘PeopleCode’ Category

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()

Three level Rowset Peoplecode

December 26, 2007 9 comments

Here is a typical peoplecode example for reaching the level three reord using rowset peoplecode. 

/* Need to insert a row when a flag = ‘Y’ after graying all other fields in the row in correction mode */
PeopleCode Event : COMPONENT_NAME(Component).GBL.PostBuild(Component PeopleCode)

Local Rowset &TQ_Lvl0, &TQ_Lvl1, &TQ_Lvl2, &TQ_Lvl3;
Local number &insert_row, &lvl_1_row, &lvl_2_row, &lvl_3_row;

&TQ_Lvl0 = GetLevel0();
&TQ_Lvl1 = &TQ_Lvl0(1).GetRowset(Scroll.LEVEL1_SCROLL_NAME);
&insert_flag = “N”;

For &lvl_1_row = 1 To &TQ_Lvl1.ActiveRowCount
   &TQ_Lvl2 = &TQ_Lvl1(&lvl_1_row).GetRowset(Scroll.LEVEL2_SCROLL_NAME);
   For &lvl_2_row = 1 To &TQ_Lvl2.ActiveRowCount
      &TQ_Lvl3 = &TQ_Lvl2(&lvl_2_row).GetRowset(Scroll.LEVEL3_SCROLL_NAME);
      For &lvl_3_row = 1 To &TQ_Lvl3.ActiveRowCount
         &tq_adj_applied = &TQ_Lvl3(&lvl_3_row).LEVEL3_RECORD_NAME.FIELD_NAME.Value;
         If &tq_adj_applied = “Y” Then
            &TQ_Lvl3(&lvl_3_row).MPF_TINQ_LOG.EARNS_END_DT.Enabled = False;
            &TQ_Lvl3(&lvl_3_row).MPF_TINQ_LOG.MPF_ADD_SUBTRACT.Enabled = False;
            &TQ_Lvl3(&lvl_3_row).MPF_TINQ_LOG.MPF_HOURS_TYPE.Enabled = False;
            &TQ_Lvl3(&lvl_3_row).MPF_TINQ_LOG.MPF_HOURS_ADJ.Enabled = False;
            If %Mode = %Action_Correction Then
               &TQ_Lvl3.InsertRow(&TQ_Lvl3.ActiveRowCount);
            End-If;
         End-If;
      End-For
   End-For;
End-For;

Categories: PeopleCode Tags:

Signon PeopleCode modification

December 11, 2007 6 comments

We had a requirement to track unsuccessful login details. PeopleSoft delivered PSACCESSLOG table gives only successful login details. To get unsuccessful login details, I modified PASSWORD_CONTROLS() function in  FUNCLIB_PWDCNTL.PWDCNTL.FieldChangePeopleCode

To do this I created a record ACCESS_DET with OPRID, LOGGINDTTM etc fields. This record stores all unsuccessful log-ins data. Then Open the peoplecode (Record.FUNCLIB_PWDCNTL, Field.PWDCNTL, Peoplecode.FieldChange)  and added the below shown PeopleCode inside the password_controls() function, where the %PSAuthResult value is negative.

      Local Record &ACCESSREC;
      Local SQL &ACCESS_SQL;
     
      &ACCESSREC = CreateRecord(Record.ACCESS_DET);
      &ACCESS_SQL = CreateSQL(“%Insert(:1)”);
     
      &ACCESSREC.OPRID.Value = &USERID;
      &ACCESSREC.LOGIPADDRESS.Value = ” “;
      &ACCESSREC.LOGINDTTM.Value = %Datetime;
      &ACCESSREC.LOGOUTDTTM.Value = “”;
      &ACCESSREC.FF_SUCCESS_FLG.Value = “N”;
      &ACCESSREC.LOGINATTEMPTS.Value = &FailedNum;
     
      &ACCESS_SQL.Execute(&ACCESSREC);
      &ACCESS_SQL.Close();

Related articles in other blogs:

Carriage Return in PeopleCode

November 29, 2007 2 comments

Sometime back, I was writing an application engine using PeopleCode and I needed to insert a carriage return between two long strings getting concatenated so they look like two sentences one after the other. The below code explains how I achieved it.

&string1 = ‘Emplid xyz123 is terminated on 01/01/2008’
&string1 = ‘Emplid abc456 is terminated on 01/02/2008’

&mailString = &String1 | &String2;

/* This concatenation would lead &mailString look as shown below
Emplid xyz123 is terminated on 01/01/2008Emplid abc456 is terminated on 01/02/2008
*/

/* To put a CR/LF (both unix and DOS style linefeed, safe for all platforms), you would change the above line to read like this: */

&mailString = &String1 | char(10) | char (13) |&String2;

/* Now the &mailString will look like as shown below

Emplid xyz123 is terminated on 01/01/2008
Emplid abc456 is terminated on 01/02/2008
*/

Categories: PeopleCode Tags: ,