This record has following fields:
1. OPRID (Stores OPRID)
2. LOGIPADDRESS (Stores IP Address or System name)
3. LOGINDTTM ( Stores date login time).
4. LOGUOTDTTM (Stores date logout time).
5. PT_SIGNON_TYPE (Stores Signon Type).
Here are the few examples how to create EXCEL file and how to read EXCEL file using PeopleCode. This can be used in AppEngine And Online PeopleCode.
This can be used in Excel Reporting and Formatting Excel file (Like changing cell colour etc.… ).
/* Set up the Excel COM objects and open the template file */
Local object &oWorkApp, &oWorkBook;
&oWorkApp = CreateObject("COM", "Excel.Application");
&oWorkApp.DisplayAlerts = "False";
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open("C:\some_path_to\template.xls");
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&oWorkApp.ActiveWorkBook.SaveAs("C:\your_output_file.xls");
&oWorkSheet.Cells(1, 1).Value = "I'm adding stuff to be bolded";
&oWorkSheet.Cells(1, 1).Font.Bold = True;
&oWorkApp.ActiveWorkBook.Save();
&oWorkApp.ActiveWorkBook.Close();
&oWorkApp.DisplayAlerts = "True";
&oWorkApp.Quit();
/*Add data to cells of the first worksheet in the new workbook*/
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.add();
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&oWorkSheet.Range("A1").Value = "Last Name";
&oWorkSheet.Range("B1").Value = "First Name";
&oWorkSheet.Range("A1:B1").Font.Bold = True;
&oWorkSheet.Range("A2").Value = "Doe";
&oWorkSheet.Range("B2").Value = "John";
&oWorkApp.ActiveWorkbook.SaveAs("E:\Personal\dummy\TestXLS.xls");
/*How to read data from one cell and writes to another*/
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open("E:\Personal\dummy\TEST1.xls");
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&oData = &oWorkSheet.Range("A1").Value;
&oWorkSheet.Range("A2").Value = &oData;
&oWorkApp.ActiveWorkbook.SaveAs("E:\Personal\dummy\TestXLS.xls");
/*How to read data from one cell and writes to different sheet*/
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open("E:\Personal\dummy\TEST1.xls");
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&oData = &oWorkSheet.Range("A1").Value;
&oWorkSheet2 = &oWorkApp.Worksheets(2);
&oWorkSheet2.Range("A1").Value = &oData;
&oWorkApp.ActiveWorkbook.SaveAs("E:\Personal\dummy\TestXLS.xls");
/*Add data to cells of the first worksheet in the new workbook*/
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open("E:\Personal\dummy\TEST1.xls");
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&oWorkSheet.Range("A1").Value = "Last Name";
&oWorkSheet.Range("B1").Value = "First Name";
&oWorkSheet.Range("A1:B1").Font.Bold = True;
&oWorkSheet.Range("A2").Value = "Doe";
&oWorkSheet.Range("B2").Value = "John";
&oWorkApp.ActiveWorkbook.SaveAs("E:\Personal\dummy\TestXLS.xls");
/*Transfer the data to Excel from Rowset*/
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open("E:\Personal\dummy\TEST1.xls");
&oWorkBook = &oWorkApp.Workbooks.Add();
&rs_Awards = CreateRowset(Record.PERTBL);
&rs_Awards.Fill("WHERE FILL.YEAR = '2008' AND FILL.STATUS = 'C'");
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
For &ie = 1 To &rs_Awards.activerowcount
&oWorkSheet.Cells(&ie, 1).Value = &rs_Awards.getrow(&ie).PERTBL.ID.Value;
&oWorkSheet.Cells(&ie, 2).Value = &rs_Awards.getrow(&ie).PERTBL.COMP.Value;
End-For;
&oWorkApp.ActiveWorkbook.SaveAs("E:\Personal\dummy\TestXLS.xls");
/*Save an xls file as a CSV*/
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open("E:\Personal\dummy\TEST1.xls");
&oWorkApp.ActiveWorkbook.SaveAs("E:\Personal\dummy\TestXLS.csv", 6);
You get this error in an online page or while running a Application engine program. This error happens when you try to insert more than 254 characters in a long field using sqlexec and do not use %TextIn meta sql.
Resolution
Use %TextIn meta-sql for the bind variable that is used for inserting into a long field. For e.g. %TextIn(:1)
%TextIn is documented in peoplebooks and is mandatory for all insertions/update of LongChar fields using sqlexec for all database platforms.
Here are some resolutions that discusses this issue in Metalink – Oracle support site.
E-AE Application Engine PeopleCode Step with SQLExec Receives Error; return code 8015 "Bind value is too long" [ID 889806.1]
E-PC:"Bind value is too long" Error When Using SQLExec to Insert into Long Char Field [ID 620874.1]
Source: Some Blog.
PeopleSoft grids have the option of using a single or multi-row selection indicator. A single row selection indicator is a radio button (one option) while a multi-row selection indicator is a check box. You can use this functionality to get the user to select the row(s) they are interested in.
These settings are in the page field properties of the grid (under the Use tab):
This all works really well, but what is the event triggered by user when they use these selection indicators? Well, there isn't one — well not in the sense of a field change anyway. However, there is a Set Component Changed option in the grid properties, which, when set, will trigger a save event when the user sets or changes the selection indicator(s).
So, if a user selects a row in the grid (single selection radio button), when they press save, PeopleSoft will recognise this event and fire off any code in SaveEdit, SavePreChange, or SavePostChange
Here is a snippet of PeopleCode you could use to process the row(s) selected by the user and perform an action:
Local Rowset &rs_YOUR_RECORD;
Local integer &i;
&rs_YOUR_RECORD = GetLevel0()(1).GetRowset(Scroll.YOUR_RECORD);
For &i = 1 to &rs_YOUR_RECORD.ActiveRowCount
If &rs_YOUR_RECORD(&i).Selected = True Then
/* This is a row selected by the user, do something here */
End-If;
End-For;
Sometimes you would like to bypass the search page depending on the user's role. For some users, they need the ability to look at other employee’s time sheets, managers for example. However, for others, they should only be restricted to their own data. Below is PeopleCode example that will bypass the search page depending on users' role.
&FLAG_ROLE = "Y";
For &I = 1 To %Roles.Len;
If %Roles [&I] = "CSR" Or
%Roles [&I] = "Operations Service Centre" Then
&FLAG_ROLE = "N";
/*Allow this person to enter the search page*/
SetSearchDialogBehavior(1);
/*Unhide name for user to be able to search */
UnHide(your_search_record_onthe_component.NAME);
End-If;
End-For;
If &FLAG_ROLE = "Y" Then
your_search_record_onthe_component.EMPLID = %EmployeeId;
/*Hide emplid and name so user can not search*/
Hide(your_search_record_onthe_component.EMPLID);
Hide(your_search_record_onthe_component.NAME);
/* skip search page */
SetSearchDialogBehavior(0);
AllowEmplIdChg( True);
End-If;
The below function can be used to delete a PeopleSoft query from database.
Function DeleteQuery(&sQueryName As string)
SQLExec("DELETE FROM PSQRYDEFN WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYSELECT WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYRECORD WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYFIELD WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYFIELDLANG WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYCRITERIA WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYEXPR WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYBIND WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYBINDLANG WHERE QRYNAME=:1", &sQueryName);
/*Below tables are not available in older PS versions*/
SQLExec("DELETE FROM PSQRYSTATS WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYEXECLOG WHERE QRYNAME=:1", &sQueryName);
SQLExec("DELETE FROM PSQRYFAVORITES WHERE QRYNAME=:1", &sQueryName);
End-Function;
1. User, by using the OPRID field.
2. Primary permission list, by using the OPRCLASS field.
3. Row security permission list, by using the ROWSECCLASS field