Thursday 17 April 2014

PeopleSoft Permission List Queries


1. Component Permission List Query:
This query identify the permission lists and its description associated with component.
SELECT   menu.menuname, compdfn.pnlgrpname, auth.classid permission_list,
CLASS.classdefndesc permission_desc
FROM psauthitem auth,
psmenudefn menu,
psmenuitem menuitm,
pspnlgroup comp,
pspnlgrpdefn compdfn,
psclassdefn CLASS
WHERE menu.menuname = menuitm.menuname
AND menuitm.pnlgrpname = comp.pnlgrpname
AND compdfn.pnlgrpname = comp.pnlgrpname
AND compdfn.pnlgrpname LIKE UPPER (:component_name)
AND auth.menuname = menu.menuname
AND auth.barname = menuitm.barname
AND auth.baritemname = menuitm.itemname
AND auth.pnlitemname = comp.itemname
AND auth.classid = CLASS.classid
GROUP BY menu.menuname, compdfn.pnlgrpname, auth.classid, CLASS.classdefndesc
ORDER BY menu.menuname, compdfn.pnlgrpname, permission_list;

2. Content Reference accessed by a permission list:

This query identifies Content references accessed by Permission List.
SELECT   a.portal_label AS PORTAL_LINK_NAME, a.portal_objname, a.portal_name, a.portal_reftype
FROM psprsmdefn a, psprsmperm b, psclassdefn c
WHERE a.portal_reftype = 'C'
AND a.portal_cref_usgt = 'TARG'
AND a.portal_name = b.portal_name
AND a.portal_reftype = b.portal_reftype
AND a.portal_objname = b.portal_objname
AND c.classid = b.portal_permname
AND a.portal_uri_seg1 <> ' '
AND a.portal_uri_seg2 <> ' '
AND a.portal_uri_seg3 <> ' '
AND c.classid = :permissionlist
AND a.portal_name = :portalname
ORDER BY portal_label;



FRMT = Frame Template

HPGC = Pagelet

HPGT = Homepage Tab

HTMT = HTML template

LINK = Content Reference Link

3. Page Access By Permission List:

SELECT b.menuname, b.barname, b.baritemname, b.pnlitemname AS pagename,
       c.pageaccessdescr,
       DECODE (b.displayonly, 0, 'No', 1, 'Yes') AS displayonly
  FROM psclassdefn a, psauthitem b, pspgeaccessdesc c
WHERE a.classid = b.classid
   AND a.classid = :1
   AND b.baritemname > ' '
   AND b.authorizedactions = c.authorizedactions;

4. PeopleTools Accessed By a Permission List:
SELECT DISTINCT b.menuname
FROM psclassdefn a, psauthitem b
WHERE a.classid = b.classid
AND (   b.menuname = 'CLIENTPROCESS'
OR b.menuname = 'DATA_MOVER'
OR b.menuname = 'IMPORT_MANAGER'
OR b.menuname = 'APPLICATION_DESIGNER'
OR b.menuname = 'OBJECT_SECURITY'
OR b.menuname = 'QUERY'
)
AND a.classid = :PermissionList;

5. Roles Assigned to a Permission List:
SELECT b.rolename, b.classid AS permission_list
FROM psclassdefn a, psroleclass b
WHERE a.classid = b.classid AND a.classid = :permissionlist;

6. User IDs assigned to a Permission List:
SELECT   c.roleuser AS USER_IDs
FROM psclassdefn a, psroleclass b, psroleuser c
WHERE a.classid = b.classid
AND b.rolename = c.rolename
AND a.classid = :permissionlist
GROUP BY c.roleuser;

Department Security Tree and Query Security


Always create a department security tree with the name "DEPT_SECURITY" as it is hardcoded in various views and very important in implementing Row level security. If this naming is not followed then departments under newly created tree will not be available while setting up the security on "Security by Dept Tree" page.



Query Security:
 
  • PeopleSoft Query uses query access group trees to control the access of the tables in the PeopleSoft database.
  • You create and update query access group trees using Query Access Manager.
  • You should create query access group trees based on your organization’s needs and on any customizations you’ve made.
 
Relationship between row-level security and Query security record definitions:
 
  • PeopleSoft applications implement row-level security by using a SQL view that joins the data table with an authorization table.
 
  • To apply row level security:
  • Open the record on which you want to apply row-level security. Click the Properties button, and select the Use tab from the Record Properties dialog box.
  • Select the security record definition (usually a view) in the Query Security Record list box.
 
  • Row-Level (Data Permission) Security Views:
  1. Using PeopleSoft row-level security views enables you to restrict users from seeing certain rows of data.
  2. You can restrict data by:
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
    1.             3.   To implement row-level security through a security view:
  1. In Application Designer, insert one of the three row-level security fields(OPRID, OPRCLASS, ROWSECCLASS) into the record definition.
  2. Configure the field as a Key, but not a List Box Item.
  3. Save the record and build the view.
  4. Use the record as the search record or query security record.
  • Steps for creating query security record:
          1. Create a view depending on your security need.
 
Example: create a view which has oprid, rowsecclass and the parent key field and in sql editor write the following sql:
 
SELECT DISTINCT opr.oprid,
                
opr.rowsecclass,
                
dtl.t_cust_id FROM   psoprdefn opr,
       
ps_t_sjt_class cls,
       
ps_t_sjt_class_dtl dtl WHERE  cls.rowsecclass = dtl.rowsecclass
       
AND cls.t_cust_id = dtl.t_cust_id
       
AND opr.rowsecclass = cls.rowsecclass 
 
2. Attach the above view to the record in record properties (query security record).
 
  1.            3. Grant security to that record to which the query security view is attached.
  2.            4. In PIA, traverse to query access manager (Oracle PS Tools ->people tools –> Query  Security -. Query Access Manager). Then CLICK ON CREATE NEW TREE.
 
 
  1. 5. If access group is already present, then search for that access group in the prompt. 
  2. 6. If you want create a new access group then enter the access group name and PRESS ENTER, it will be redirected to the below page where you can create your own access group.       
  3. 7. Then insert the child records to the access group.
 
step 7.1
Step 7.2   
Step 7.3
 
  1. 8. Go to permission list and traverse to query. (People Tools -> Security -> Permission & Roles -> Permission list (Select the permission list)).
 
  1. 9. In access group permissions, assign the tree name and access group.
 
 
  1. 10. In query manager, add the record to which the query security view is attached.
 
 

NOTE: You should consider adding record definitions to the query trees in a hierarchy that matches the parent/child relationship of records in your database.

Move and Delete files using PeopleCode

Move and Delete files using PeopleCode

We can use the below java object and code to move or deleting files from some location.
Moving file:

Local JavaObject &source = CreateJavaObject("java.io.File", "/source/file.txt");
Local JavaObject &target = CreateJavaObject("java.io.File", "/target/file.txt");

&source.renameTo(&target); 



Deleting file:
Local JavaObject &DelLoc = CreateJavaObject("java.io.File", "/source/file.txt");
&DelLoc.delete(); 
Alternate code for deleting file:
&tmpfile = GetFile(“c:\temp\file.txt”, “W”, “A”, %FilePath_Absolute);
&tmpfile.Delete();

Accessing Application Package class object using CreateObject method.

Let’s say we have 2 application package.
1. UserID and
2. Notification.
Here Notification application package uses dynamic changing application package say based on setup.
For our example we are using UserID application package as setup driven application package and it has UserID as Class.
clip_image002
Structure of UserID application package.
class UserID
   method GetOpridsByApplicationPack() Returns array of string;
   property array of string oprid_arr;
end-class;

method UserID
  
end-method;

method GetOpridsByApplicationPack
   /+ Returns Array of String +/
   
   %This.oprid_arr = CreateArrayRept("", 0);
   Local string &SupervisorId, &ReportsTo;
    
   %This.oprid_arr.push('PS'); /* Logic to populate data in array. */

   Return %This.oprid_arr;

end-method;


Below is “Notification” application package structure. 
In this application package we are using CreateObject to access “GetOpridsByApplicationPack” method of UserID class of UserID application package . 
We are passing Package name and Class Name while calling so they are variable for us. (In this case its UserID and UserID). 
class NotificationManager
method GetOpridsByApplicationPack(&PkgRoot As string, &Appcls_Path As string) Returns array of string;

end-class;

method NotificationManager

end-method;

method GetOpridsByApplicationPack
   /+ &PkgRoot as String, +/
   /+ &Appcls_Path as String +/
   /+ Returns Array of String +/
   Local array of string &aryOpridTo;
   Local string &Classname;
   Local object &u;
   &aryOpridTo = CreateArrayRept(" ", 0);
   &Classname = &PkgRoot | ":" | &Appcls_Path;
   &u = CreateObject(&Classname);
   ObjectDoMethod(&u, "GetOpridsByApplicationPack");
   &aryOpridTo = &u.oprid_arr;
   Return &aryOpridTo;
end-method;

Object–Based PeopleCode

What is Object – Based PeopleCode:
• Introduced in PeopleTools 8
• Evolution of procedural-based PeopleCode
• Provides for complex object definitions
• Overcomes procedural data scope limitations
• Similar to Visual Basic notation
• Interpreted (like VB)
• Not completely object oriented (like C++), but it’s getting there!
• Does not support polymorphisms
• Does support multiple inheritance
• Backwards compatible
Why do we need Object Based PeopleCode:
• Greater ability to write generic code
• Release 8 Integration
                       1. Component Interface
                       2. Application Messaging
                       3. Business Interlinks
• Ability to define custom classes (Release 8.4)
                       1. Application Classes/Packages
                       2. Replaces FUNCLIB Processing
Advantage of Object and Methods:
• Tight code
• Syntax is validated*
• No or low maintenance required
Object – Based PeopleCode Rule:
• DECLARE the object
• INSTANTIATE the object

Object–Based Code to avoid use of SQLEXEC

Below code can be used to avoid use of SQLExec.
SQLExec Code:
SQLExec to copy a row from ORD_HDR to ORD_HDR_EXT.
&ORD_NO = &NEW_ORD_NO;

SQLExec("select %timeout(order_dt), training_loc, vendor_cd, order_status, status_dt, deliver_method from ps_ord_hdr
where order_nbr = :1", &ORD_NO, &ORD_DT, &TRAIN_LOC,&VEND_CD, &ORD_STAT, &STAT_DT, &SHIP_VIA);

SQLExec("delete from ps_ord_hdr_ext where order_nbr = :1", &ORD_NO);

SQLExec("insert into ps_ord_hdr_ext (order_nbr, order_dt,training_loc, vendor_cd, order_status, status_dt,
deliver_method) values(:1,%datein(:2),:3,:4,:5,:6,:7)",&ORD_NO, &ORD_DT, &TRAIN_LOC, &VEND_CD, &ORD_STAT, &STAT_DT,&SHIP_VIA);

Same logic using Object Based code:
Local Record &REC1, &REC2;
&REC1 = GetRecord(RECORD.ORD_HDR);
&REC2 = CreateRecord(RECORD.ORD_HDR_EXT);
&REC1.ORD_NO = &NEW_ORD_NO;
&REC1.SelectByKey();
&REC1.CopyFieldsTo(&REC2);
&REC2.Delete();
&REC2.Insert();

Hiding Delivered Buttons based on condition

One way to hide PeopleSoft delivered component events buttons (Save, ReturnToList, Add, UpdateDisplay…. etc.) by using JavaScript. Follow the below steps to hide the delivered buttons.
This way can be used if we have Many pages in component and we don’t want delivered buttons on some pages. Here are steps.
Step1: Place HTML area in page and assign derived and work record (Say: HIDE_WRK)and field (Say: HTMLAREA) to it.
Create HTML Definition(Say: HIDE_BT_HTML) and Add following JavaScript.
<input type="hidden" name="USERJSINJECTION" value=""/>
<script type="text/javascript">
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
   window.onload = func;
  } else {
   window.onload = function() {
     oldonload();
     func();
   }
  }
}
 
function appsDisablePTControls() { 

var aPTButtons = ['#ICSave', '#ICList', '#ICNextInList', '#ICPrevInList', '#ICSendNotify', '#ICNext', '#ICSpellCheck', '#ICRefresh', '#ICAdd', '#ICUpdateAll', '#ICCorrection', '#ICUpdate']; 

appsDisableTable(aPTButtons,true); 
} 
function appsDisableTable(aPTControls,bButtons) { 

var aControls, oTableNode; 

var bFound = false; 

var i=0; 

while (i < aPTControls.length && !bFound) 

{ 

aControls = document.getElementsByName(aPTControls[i]); 

if (aControls != null && aControls.length > 0) 

{ 

oTableNode = aControls[aControls.length-1].parentNode.parentNode.parentNode.parentNode; 

if (oTableNode != null && oTableNode.id != 'RBTBHEADER' && oTableNode.id != 'RBTBFOOTER') 

{ 

if (bButtons) 

oTableNode = oTableNode.parentNode; 

oTableNode.style.display='none'; 

bFound = true; 

} 

} 

i++; 

} 
} 
addLoadEvent(function() {
  %bind(:1)
});
</script>
Then assign the following code to Page Activated event:
HIDE_WRK.HTMLAREA.Value = GetHTMLText(HTML.HIDE_BT_HTML, "appsDisablePTControls()");
 
Note: Refer the post for how to use Html Area: http://pawan-mundhra.blogspot.com/2011/05/run-javascript-on-your-peoplesoft-pages.html

Run JavaScript on your PeopleSoft pages conditionally

Here, PeopleCode sets the logic that determines when the JavaScript code will run.
This is not as simple as dropping a HTML Area on your page and setting the script in PeopleCode. This is because the value in the HTML Area field remains and the JavaScript code will keep executing at subsequent page refreshes.
Steps:
Lets have a derived/work record TEST_WRK And field HTMLAREA (TEST_WRK – HTMLAREA).
1. Create a HTML definition as your javascript template. Include all the necessary user-defined javascript functions that you need. Eg Html Definition is TESTJS
<input type="hidden" name="USERJSINJECTION" value=""/>
<script type="text/javascript">
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
   window.onload = func;
  } else {
   window.onload = function() {
     oldonload();
     func();
   }
  }
}
 
function user_function1() {
  window.open("","toolbar = no");
}
function user_function2() {
  alert('Hello from user javascript');
}
 
addLoadEvent(function() {
  %bind(:1)
});
</script>
 

2. At the scroll level 0 of your PS page, insert a HTML Area control. Assign this to the TEST_WRK.HTMLAREA field.

3. Again at scroll level 0 of your page, insert an editbox and assign this again to TEST_WRK.HTMLAREA. And Set the Following Field Property


a. On the Use tab, check Invisible and Modifiable by JavaScript.

b. On the General tab, set Page Field Name to USERJSINJECTION.

4. Now in PeopleCode, to execute your javascript function.

GetLevel0()(1).TEST_WRK.HTMLAREA.Value = GetHTMLText(HTML.TESTJS, "user_function1()");
 

Creating MS EXCEL Using CreateObject in PeopleSoft


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

Dynamic Prompt / Edittable Prompt

The following steps help to make Dynamic prompt (Edit Table Prompt).
Lets consider a scenario, based on selection Criteria the Character value prompt need to change.
For Department Character value prompt should be DEPT_TBL and for Job Code the Character value prompt should be JOBCODE_TBL.
image
Now consider the design.
image
The Selection Criteria, Character Value, Process are fields in SQL Record (May change in different case) and Edit Table(EDITTABLE field) is from DERIVED (delivered) derived and work record.
in the above  example your need a record(e.g GR_CRI_TBL) has following fields
SELECTION_TYPE
CHAR_VALUE
PROCESS
CHAR_VALUE should have %EDITTABLE Prompt Table Edit Type
image
Write the following function in any FIELDFORMULA and call the function as given below.
Local string &Type;
Function hide_unhide_popfields(&Row As Row);
   &Type = &Row.GetRecord(Record.GR_CRI_TBL).SELECTION_TYPE.Value;
   Evaluate &Type
   When "D" /* Department */
      &Row.GetRecord(Record.DERIVED).EDITTABLE.Value = Record.DEPT_TBL;
      Break;
   When "J" /* Job Code */
      &Row.GetRecord(Record.DERIVED).EDITTABLE.Value = Record.JOBCODE_TBL;
      Break;
   When "L" /* Location */
      &Row.GetRecord(Record.DERIVED).EDITTABLE.Value = Record.LOCATION_TBL;
      Break;
   End-Evaluate;
End-Function;
Call the above function based on FieldChange and RowInit.
 
Declare Function hide_unhide_popfields PeopleCode GR_CRI_TBL.SELECTION_TYPE FieldFormula;
SetDefault(GR_CRI_TBL.CHAR_VALUE);
hide_unhide_popfields(GetRow());

Changing/Selecting Grid value based on Condition

The following PeopleCode can be used to change the grid value based on condition.
Local Rowset &rsGrid, &rsDataSource;

&rsGrid = GetLevel0().GetRow(1).GetRowset(SCROLL.TEST_VW);
&rsGrid.Flush();

&rsDataSource = CreateRowset(Record.TEST_VW);
&rsDataSource.Flush();
&rsDataSource.Fill(" WHERE EMPLID = :1 AND EMPL_RCD = :2 " &sEmplId,&nEmplRcd);
&rsDataSource.CopyTo(&rsGrid);



The following code can be used to Select grid value based on FieldChange(any condition) event.
&LVL1 = GetLevel0().GetRow(1).GetRowset(Scroll.PER_CHECKLIST);
&LVL2 = &LVL1(CurrentRowNumber()).GetRowset(Scroll.PER_CHKLST_ITM);

If &LVL2.ActiveRowCount = 1 And
      &LVL2(1).IsNew And
      Not &LVL2(1).IsChanged Then
Else
   For &i = &LVL2.ActiveRowCount To 1 Step - 1
      &LVL2.DeleteRow(&i);
   End-For;
End-If;

If All(PER_CHECKLIST.CHECKLIST_CD) Then
   
   &LVL2.SelectNew(Record.CHECKLIST_ITEM, "WHERE CHECKLIST_CD = :1 and EFFDT = (SELECT MAX(A.EFFDT) FROM PS_CHECKLIST_ITEM A WHERE A.CHECKLIST_CD = PS_CHECKLIST_ITEM.CHECKLIST_CD AND A.EFFDT <= %DateIn(:2))", PER_CHECKLIST.CHECKLIST_CD, PER_CHECKLIST.CHECKLIST_DT);
   
End-If;

PSPCMPROG - Table stores PeopleCode of the objects | Explanation

Below information about the table that stores PSPCMPROG the PeopleCode of objects.
PSPCMPROG - 
Key Fields :OBJECTID1, OBJECTID2, OBJECTID3, OBJECTID4, OBJECTID5, OBJECTID6, OBJECTID7 
ObjectID values reference 

1Record
2Field
3Menu
4Bar Name
5Item Name
9Page
10Component
12Event
20Database Type
21Effective Date
39Market
60Message
66Application Engine Program
74Component Interface
77Section
78Step
87Subscription
104Application Package
105Class
106Class
107Class

Key FieldsOBJECTVALUE1, OBJECTVALUE2, OBJECTVALUE3, OBJECTVALUE4, OBJECTVALUE5, OBJECTVALUE6, OBJECTVALUE7 
Refers to object name. 
Key FieldPROGSEQ 
Refers to Program sequence number 
Non Key Fields
VERSION                 Version  
NAMECOUNT           ??  
PROGLEN                 PeopleCode Program Length  
PROGRUNLOC           Program Run Location  
PROGFLAGS             ??  
LICENSE_CODE         License Code  
LASTUPDDTTM         the date and time of the last update to the entry 
LASTUPDOPRID        the OPRID which made the last update to the entry  
PROGEXTENDS         ??  
PROGTXT                 PeopleCode Program

Schedule Application Engine through Peoplecode

The following sample code can be used to Schedule App Engine through PeopleCode.
Code to Schedule App Engine thru PeopleCode:
Local ProcessRequest &MYRQST;
   
   &MyAppName = "MY_APP";
   &MYRQST = CreateProcessRequest("Application Engine", &MyAppName);
   &MYRQST.RunControlID = "TEST";
   &MYRQST.RunLocation = "PSUNX";       
   &MYRQST.Schedule();
   
   If &MYRQST.Status = 0 Then /* if Schedule status is success */
 
  End-If;
Code to know whether the scheduled App Engine ran to success or not:
If &MYRQST.Status = 0 Then /* if Schedule status is success */

      &LOOP = 0;
      While &LOOP = 0
         SQLExec("SELECT A.DISTSTATUS, A.RUNSTATUSDESCR FROM PS_PMN_PRCSLIST A WHERE A.PRCSNAME = :1 AND A.PRCSINSTANCE = (SELECT MAX(B.PRCSINSTANCE) FROM PS_PMN_PRCSLIST B WHERE B.PRCSNAME = A.PRCSNAME)", &MyAppName, &POSTED, &STATUS);
         
         If &STATUS = "Success" And
               &POSTED = 5 Then /* Posted */
            &LOOP = 1
         End-If;
         
         If &STATUS = "Success" And /* Not Posted */
               &POSTED = 4 Then
            &LOOP = 2
         End-If;
         
         If &STATUS = "No Success" Or
               &STATUS = "Error" Then
            &LOOP = 3;
         End-If;
         
      End-While;
      
      If &LOOP = 1 Then
            MessageBox(0, "", 27333, 594, "");  /* Success Msg */
      Else
         If &LOOP = 2 Or
               &LOOP = 3 Then
            MessageBox(0, "", 27333, 595, "");  /* Failed Error Msg */
         End-If;
      End-If; /* If &LOOP = 1 Then */ 
End-If;
 
The below function can also be used for schedule application engine: (Alternative Function)
Function ScheduleSetupAEProcess(&RESULT_SET_COMP)
   &RUN_SETUP_AE_REQST = CreateProcessRequest("Application Engine", "PTLT_SETUP");
   &REC_IMPL_RUN = CreateRecord(Record.PTLT_PROJ_RUN);
   
   /* Run Control ID = Configuration Set Name */
   &RUN_CNTL_ID = &RESULT_SET_COMP;
   
   &RUN_SETUP_AE_REQST.RunControlID = &RUN_CNTL_ID;
   &RUN_SETUP_AE_REQST.Schedule();
   
   If &RUN_SETUP_AE_REQST.Status = 0 Then
      &PROCESS_INSTANCE = &RUN_SETUP_AE_REQST.ProcessInstance;
      /* Insert into Setup Manager Run Control Record */
      &REC_IMPL_RUN.OPRID.Value = %OperatorId;
      &REC_IMPL_RUN.RUN_CNTL_ID.Value = &RUN_CNTL_ID;
      &REC_IMPL_RUN.PTLT_PROJ_NAME.Value = &RESULT_SET_COMP;
      &REC_IMPL_RUN.PROCESSINSTANCE.Value = &PROCESS_INSTANCE;
      
      If Not &REC_IMPL_RUN.Update() Then
         &REC_IMPL_RUN.Insert();
      End-If;
   Else
      Error MsgGet(218, 154, "Process cannot be scheduled");
   End-If;
End-Function;


The following code can be used to schedule App Engine Through PeopleCode.
Local ProcessRequest &MYRQST;
&MyAppName = "TEST_AE";
&MYRQST = CreateProcessRequest("Application Engine", &MyAppName);
&MYRQST.RunControlID = "TEST";
&MYRQST.RunLocation = "PSUNX";
&MYRQST.Schedule();
If &MYRQST.Status = 0 Then /* if Schedule status is success */
End-If;