PeopleSoft - PeopleTools Configurations Records or Meta Tables

PeopleSoft - PeopleTools Configurations Records or Meta Tables PeopleSoft records/metadata tables, often referred to as "meta tables," store information about various PeopleSoft objects and configurations.  1. Object Definition Tables: PSRECDEFN : Contains definitions of records (tables) used in the application, including details like record type and description. PSDBFIELD : Stores field definitions, detailing the attributes of each field such as data type and length. PSPNLGROUP : Holds information about components, which are collections of pages that function together. PSPNLDEFN : Contains definitions of pages (interfaces) within the application. PSMENUDEFN : Stores menu definitions, organizing how components are presented to users. 2. Security Tables: PSOPRDEFN : Maintains user profile information, including user IDs and associated roles. PSROLEDEFN : Defines roles that group together permissions for easier security management. PSCLASSDEFN : Holds permission li...

Best PeopleCode Examples | PeopleCode Hacks | Learn PeopleSoft Coding | How to PeopleCode | PeopleSoft Appdesigner Coding

Best PeopleCode Examples | PeopleCode Hacks | Learn PeopleSoft Coding | How to PeopleCode | PeopleSoft Appdesigner Coding

Creating MSExcel with new sheets through peoplecode:

Local object &oWorkApp, &oWorkBook;

&sFilePath = "C:\temp\TEST_FL.xlsx";

&sFileDestPath = "C:\temp\Test.xlsx";

&oWorkApp = CreateObject("COM", "Excel.Application");

&oWorkApp.DisplayAlerts = "False";

ObjectSetProperty(&oWorkApp, "Visible", True);

&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");

&oWorkBook.Open(&sFilePath);

&oWorkSheet = &oWorkApp.Worksheets("Sheet1");

&oWorkSheet.Range("A1:C5").Font.Bold = True;

&oWorkApp.WorkSheets.Add().Name = "Test";

&oWorkSheet = &oWorkApp.Worksheets("Test");

&oWorkSheet.Range("A1:C5").Font.Bold = True;

&oWorkSheet.Cells(1, 1).Value = "I'm adding stuff to be bolded";

&oWorkSheet.Cells(1, 1).Font.Bold = True;

&oWorkSheet.Cells(1, 1).Font.Size = 24;

&oWorkSheet.Cells(1, 1).Font.ColorIndex = 3;

&oWorkApp.ActiveWorkbook.SaveAs(&sFileDestPath);

&oWorkApp.ActiveWorkBook.Close();

&oWorkApp.DisplayAlerts = "True";

&oWorkApp.Quit(); 


Save Project Peoplecode into file:

If you want to save the entire peoplecode of your project you can do it through application designer.

Bellow are the steps to save peoplecode to file.

In application designer

1.Go to Edit->Find In option.

2.Enter find character as semicolon(;) and select your project.

3.Check the Save PeopleCode to file option.

4.Click Find button it will ask a file name.

5.Provide the file name and location where you want to save the file.

Then the peoplecode of your project stored into file.


Check whether user belongs to a role: 

IsUserInRole(rolename1 [, rolename2]. . .)

Returns a Boolean value: True if the current user belongs to one or more of the roles in the user role array, False otherwise. 

Example:

     &flag=IsUserInRole("Admin");


Passing values while transfer to another page:

 &queryString = "&SOURCE=R";

            /* generate a url */

            &url = GenerateComponentRelativeURL(%Portal, %Node, MENUNAME.MenuName, MARKET.marketname,COMPONENT.componentname,PAGE.pagename,action);

           /* Append parameters */

            &url = &url | &queryString;

            ViewURL(&url, False);

Syntax:

  GenerateComponentRelativeURL(PORTAL.portalname, NODE.nodename, MENUNAME.menuname, MARKET.marketname,COMPONENT.componentname, PAGE.pagename, action, [, keylist])

   ViewURL(URL_str | URL.URL_ID [, NewWindow])

   ViewContentURL(URL_str | URL.URL_ID)


Use the ViewContentURL function to launch a new browser window

   ViewContentURL(URL_str | URL.URL_ID);


Use the ViewURL function to launch the default browser

example:

&queryString = "&SOURCE=R";

&url=GenerateComponentRelativeURL(%Portal, %Node, MENUNAME.CH_MENU,"GBL",COMPONENT.CH_COMPONENT,PAGE.CH_PAGE,"U");

 &url = &url | &queryString;

 ViewURL(&url, False);


Check whether user belongs to a role through peoplecode:

IsUserInRole(rolename1 [, rolename2]. . .)

IsUserInRole() function is used to check whether current user has  the role in his profile or not.

This function returns  a Boolean value:

         True if the current user belongs to one or more of the roles in the user role array,

         False otherwise.

Example:

 local boolean &hasRole;

 &hasRole= IsUserInRole(CH_ROLE_EMPLOYEE);

&hasRole contains true if the currnet user has CH_ROLE_EMPLOYEE in his profile.


SQLEXEC () in RowInit PeopleCode

We cannot perform INSERT,UPDATE statement's through SQLEXEC( ) in Rowinit PeopleCode event. 

Below is the alternative to perform insertion and updation in rowinit .

Creating a stroed procedure, that perform's the insertion or updation.

Execute the procedure using SQLEXEC( ) in rowinit.

Example:

1.Creating the stored procedures in Oracle

CREATE OR REPLACE PROCEDURE CH_SAMPLE_PROCEDURE

AS

BEGIN

    UPDATE PS_CH_TEST_TBL

            SET  COUNT=100;

    COMMIT;

END CH_SAMPLE_PROCEDURE;

2.Execute the procedure

EXECUTE CH_SAMPLE_PROCEDURE;

Sample code in ROWINIT:

1.Create a sql object,that contains the sql for creating stored procedure.

    SQLEXEC(SQL.CH_TESTPROCEDURE_SQL);

   Here CH_TESTPROCEDURE_SQL contains a sql for creating stored procedure.

2.Execute procedure.

    SQLEXEC("EXECUTE CH_SAMPLE_PROCEDURE");

Note:

1. To create a stored procedure , you need to have permissions in database level.

2. If you want to check whether the stored procedure is created or not use the below sql.

SELECT * FROM ALL_PROCEDURES WHERE OBJECT_NAME='CH_SAMPLE_PROCEDURE'

 

Preventing user from making changes to the field

Gray function: 

      Gray( ) is used to make the field unavailable to change in page.

      Syntax:

                 Gray(scrollpath,targetrow,Record.Fieldname);

      Example:

                 Gray(Record.CH_EMPSTATE, &i, CH_EMPSTATE.STATE);


Add Drop-down values through peoplecode

/* Get the field reference into &field variable */

&field = GetRecord(Record.CH_EMPTYPE).GetField(Field.CH_EMPMAIN);

/* Delete all the values from dropdown list */

&field.cleardropdownlist();

/* Add values to the dropdown list */

&field.adddropdownitem(Descr, Value);

   [Value]: It is actual value which is mapped to the dropdown item

   [Descr]: It is actual text which is visible as a dropdown item

Examples:

&field.adddropdownitem("A", "A");

&field.adddropdownitem("B", "B");

&field.adddropdownitem("C", "C");


Handling files in PeopleCode 

/*********************** To move file data****************************/

Exec("cmd /c move " | &file1 | " " | &file2, %Exec_Asynchronous %FilePath_Absolute);

/*********************** To copy file data****************************/

Exec("cmd /c copy " | &file1 | " " | &file2, %Exec_Asynchronous %FilePath_Absolute);

/*************************** To delete the file**************************/

Exec("cmd /c del " | &file1, %Exec_Asynchronous %FilePath_Absolute);

*****************************OR************************************* 

/**************** Create java objects corresponds to files *******************/                          

Local JavaObject &f = CreateJavaObject("java.io.File", "/the/path/to/the/file.txt");

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

&f.renameTo(&target);

Local JavaObject &f = CreateJavaObject("java.io.File", "/the/path/to/the/file");

&f.delete(); /* delete the file from source */


PeopleCode for disable the row delete option in scroll and grid 

For &i = 1 To &Asmfloor.ActiveRowCount

   &Asmwing = &Asmfloor(&i).GetRowset(Scroll.ASM_WING_TBL);

   For &j = 1 To &Asmwing.ActiveRowCount

      &Asmcabin = &Asmwing(&j).GetRowset(Scroll.ASM_CABIN_TBL);

      If &Asmcabin.ActiveRowCount = 1 Then

         &Asmwing.DeleteEnabled = True; /* to enable the row delete option */

         If &Asmwing.ActiveRowCount = 1 Then

            &Asmfloor.DeleteEnabled = True;

         Else

            &Asmfloor.DeleteEnabled = False; /* to disable the row delete option */

         End-If;

         rem &Asmfloor.DeleteEnabled = True;

      Else

         &Asmwing.DeleteEnabled = False;

         &Asmfloor.DeleteEnabled = False;

      End-If;

   End-For; /* end-of wing */

End-For; /* end-of floor */

 

PeopleCode to find special characters in file other than ASCII characters

Local string &File_path, &File_path1;

&File_path = "C:\temp\ascii.xml";

&bud_rep = GetFile(&File_path, "r", %FilePath_Absolute);

&File_path1 = "C:\temp\ascii_1.txt";

&bud_rep1 = GetFile(&File_path1, "a", %FilePath_Absolute);

&count = 0;

While &bud_rep.readline(&line)

   &line1 = Len(&line);

   &count = &count + 1;

   For &i = 1 To &line1

      &char = Substring(&line, &i, 1);

      &naciichar = Code(&char); /* returns the number corresponds to character */

      /* check whether the character is in the range of ascii char's or not */

      If &naciichar >= 128 Or

            &naciichar < 0 Then

         &bud_rep1.writeline(&count | " " | &char); /* write special character to file */

      End-If;

   End-For;

End-While;


Keep Learning, Keep Sharing.
If you like this blog and want more codes please comment and follow.
If you like to use these codes as example, please bookmark my blogsite.
Thank you for visiting, keep checking it for new interesting posts.


Comments

Popular posts from this blog

PeopleSoft Meta Tables

Peoplesoft Application Package, Application Class and Application Method Implementation

Peoplesoft Application Package - Application Class/Application Package peoplecode and Calling them anywhere