Archive

Archive for the ‘PeopleCode’ Category

Log file in Application Engine

September 15, 2008 balaglobal 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 balaglobal 8 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 balaglobal 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: