CompShack Blogs

Function to Increment a Date Field

The function increments a date field using the AddToDate function and sets a weekday field to the corresponding weekday. You can increment date value by year, month or day.

   If All(&DATE) Then
      &DATE = AddToDate(&DATE, &YEAR_INC, &MONTH_INC, &DAY_INC);
      /*get day value for the incremented date*/
      &WEEKDAY = String(Weekday(&DATE));

Function to Add Leading Characters to a Value or Field

A function to facilitate the addition of a leading character to a field value. The function takes three parameters:
- &LEADCHAR: The character you want to append to your value.
- &FIELDZISE: The over all size of your value after appending your desired character.
- &FIELDVALUE: The value you want to append the character to.


Content References Accessed by a Permission List

Another permission list query to list Content References accessed by a specific 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

PeopleTools Objects Accessed by a Permission List

A query that will list all peopletools objects (Query, Application Designer, Data Mover) that a specific permission list could access.

           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'

Pages Accessed by a Permission List

A query to identify pages that could be accessed by a specific permission list.

SELECT b.menuname, b.barname, b.baritemname, b.pnlitemname AS pagename,
       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;

Roles Assigned to a Permission List

A query to help you identify Roles that are assigned to a specific permission list.

SELECT b.rolename, b.classid AS permission_list
  FROM psclassdefn a, psroleclass b
 WHERE a.classid = b.classid AND a.classid = :permissionlist;

Identify Records with a Specific Subrecord

A subrecord in PeopleSoft is a way to group fields together and place them on a record, view, or a temp table. Here is a query you can use to identify records that have a specific subrecord.

SELECT a.recname, a.fieldname, b.rectype, b.objectownerid
  FROM psrecfield a, psrecdefn b
 WHERE a.recname = b.recname
   AND a.fieldname = 'SUB-RECORD-NAME';

User IDs assigned to a Permission List

A query to list all user IDs that are assigned to a specific 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;

Database Table Space Statistics (Free, Used, and Percent Used)

An SQL to help gathering storage tablespace statistics. The SQL will list all tablespace names in a particular database along with available, used and percent used storage space in MB.

SELECT   a.tablespace_name, (a.BYTES / 1024) || 'MB' AS used,
         (b.BYTES / 1024) || 'MB' AS free,
         (b.largest / 1024) || 'MB' AS largest_block,
         ROUND (((a.BYTES - b.BYTES) / a.BYTES) * 100, 2) AS percent_used
    FROM (SELECT   tablespace_name, SUM (BYTES) BYTES
              FROM dba_data_files
          GROUP BY tablespace_name) a,

PeopleCode to AutoIncrement an AlphaNumeric Transaction Number

I have code to auto-increment an alphanumeric field, using SQL calls. It is specific to a 4-character field, but can easily be adapted to different length fields.

SQLExec("SELECT decode(substr(oldvalue,2,3),'ZZZ', TRANSLATE(UPPER(SUBSTR(oldvalue,1,1)),'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0'),substr(oldvalue,1,1)) ||decode(substr(oldvalue,3,2),'ZZ',TRANSLATE(UPPER(SUBSTR(oldvalue,2,1)), '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0'),substr(oldvalue,2,1))||decode(substr(oldvalue,4,1),'Z', TRANSLATE(UPPER(SUBSTR(oldvalue,3,1)), '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0'),substr(oldvalue,3,1))||TRANSLATE(UPPER(SUBSTR(oldvalue,4,1)), '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0') FROM dual, (select :1 as oldvalue from dual)", &priorvalue, &newvalue);
If &newvalue = "0000" Then
   &bOverrun_Error = True;