• Peoplesoft Functions

    Posted on October 25, 2012 by in Other Programming, People Soft

    A function is a named section of a program that performs a specific task that can be reused. The main advantages of functions are resusability and ease of maintainance.

    Peoplesoft functions

    Listed below are types of Peoplesoft functions

    1. Builtin functions
    2. Internal peoplecode functions
    3. External peoplecode functions
    4. External non peoplecode functions

    Declaration of function in peoplesoft

    Declaring a function using PeopleCode is pretty straight forward and this is how you can do that:

    Declare Function delete_attachment PeopleCode FILE_ATTACH_WRK.ATTACHDELETE FieldFormula;
    

    delete_attachment is the function name you want to declare. FILE_ATTACH_WRK is the record where the function has been stored, and ATTACHDELETE is the field the function is under, and finally FieldFormula is where the function is located within the “ATTACHDELETE” field.

    Built-in Functions

    These are peoplesoft delivered functions. These functions do not required declaration, We can directly use the functions.

      Hide(<RECORD.fieldname>);
      SQLEXEC(<sql string>);
    

    Internal peoplecode functions

    We call these function at the same place or program we define. For example, we can write a function in RowInit of a field and call it in same event. Declaration is not Required. Given below is an example

    RECORD1.FIELD1 = add_preceding_zeros("my_value");
    RECORD1.FIELD2 = add_preceding_zeros("my_value");
    
    Rem this function returns a 10 character string with preceeding zeros,if len of the variable passed is less than 10
    Function add_preceding_zeros(&STR_ID) Returns string
       Return Substring("0000000000", 1, 10 - Len(&STR_ID)) | &STR_ID;
    End-Function;
    

    External peoplecode functions

    There functions are defined under other records/fields or libraries. Declaration is required for this type of functions. Some records that come with people soft installation come with some of this functions, For Example, FILE_ATTACH_WRK record has function in its FieldChange that is generally used in file attachments.
    Using the add_attachment function under FILE_ATTACH_WRK.ATTACHADD FieldChange event is given Below. The Below code should be used on your record and not on FILE_ATTACH_WRK. In this case the code is written in ComponentRecord FieldChange Event of my record

    Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange;
    
    &uniquefilename = %OperatorId | "_" | String(Month(%Date)) | "_" | String(Day(%Date)) | "_" | String(Year(%Date)) | "_" | String(Hour(%Time)) | "_" | String(Minute(%Time)) | "_" | String(Second(%Time));
    
    &ATTACHSYSFILENAME = &uniquefilename;
    &RECNAME = "Record." | Record.DLYATTCH;rem YOUR RECORD NAME HERE
    
    add_attachment(URL.GL_FILE_IMPORT, "", "", 0, False, &RECNAME, &ATTACHSYSFILENAME, &ATTACHUSERFILE, 2, &Return_Code);
    
    

    External Non peoplecode functions

    These functions are defined under the external third party systems libraries. Declaration is required for this functions.

    Be Sociable, Share!
      Post Tagged with

    Written by

    Vanamali Juvvadi is a Web enthusiast and loves all things design and technology. Founded qnownow with a group of friends to share anything/everything they know/find on the internet.

    View all articles by

    Email : [email protected]

    Leave a Reply