PTS_CHCK_ROUTINE(System_Preference)
Back to current versionRestore this version

PL/SQL validation routine can be called to replace the default "submit" function on a timesheet. When a timesheet is submitted, if the timesheet does not meet the criteria of the validation routine, a customer defined message will appear as a pop up dialog and the timesheet will not change status.

Required Set up#

Maintain System Messages (IMMS)#

A user defined system message must be created on IMMS. The message should be prefixed with PTSV_###### When the PL/SQL function is created, the return value will be the ##### portion of the IMMS code. The "PTSV_" will be assumed by the process calling the custom code.

Function Definition #

The function must be defined in the data base as a PL/SQL function.

Form Definition (IMFDH)#

Once the function and system message has been established, all the functions that will use the routine must be set up. There are two steps required on each function in which the routine is to be called 1) On the Function Info tab, add the preference "PTS_CHK_ROUTINE". The value will be the name of the Function or Package to be called. 2) On the Form Layout tab, add the PTS.ACT_VALIDATE_SUBMIT_TIME_SHEET_NO_DLG to the form. If the form is "Pre-Loaded" use object security to remove the default PTS.ACT_SUBMIT_TIME_SHEET option (If custom, the PTS.ACT_SUBMIT_TIME_SHEET can be delete from the form).

Example#

The following function will take the ID of the P2K_PR_TIME_SHEETS record and return a null or the value on IMMS for the MESSAGE_CODE of "0001". Any exceptional condition (no records found, etc.) will result in NULL being returned.

create or replace
FUNCTION ACME_PADAYS (p_eem_id IN NUMBER) RETURN NUMBER AS
  v_return number(18,6);
BEGIN
  select AMOUNT 
    into v_return 
    from P2K_HR_STATISTICS 
   where eem_id = p_eem_id 
     and dsc_id = (select ID from p2k_cm_statistic_components 
                            where stat_code = 'STAT-PA-DAYS');
  return v_return;
  EXCEPTION
    WHEN OTHERS then return NULL;
END ACME_PADAYS;
/
The two slashes are an indicator to SQL to execute the lines preceding.

The creation of a Public Synonym means that users other than P2K (the schema owner) will have access to the function. The grant of the execute privilege is required so that other users (other than P2K) will be able to execute this. All users of the application must have the P2K_USER role granted in IMUS or IMUR.

create public synonym ACME_PADAYS for ACME_PADAYS;
grant execute on ACME_PADAYS to P2K_USER;

More User Formula Examples

This function can be tested with the following select statements:

Table Definition (IMCD)#

Once we have the function defined and working, we can extend the table (in our example P2K_HR_EMPLOYMENTS) to include this User Formula Column. This is done in the IMCD screen by adding a new column with the following fields filled in:
Sequence
It is recommended that you start your sequencing at 9000 and work down, so as to not collide with provided sequence numbers
Column Name
The name you wish to refer to this column in screen design. It is recommended that you start your column name with the same identifier as your function, so as to preclude confusion with provided values. (i.e. ACME_xxxx)
Prompt
This is optional, but recommended. Any prompt you provide here will be used in screen layouts, but can always be overridden at each usage.
Column Usage
Must be User Formula
Data Type
Must be the same type that the function returns (Number, Date, Varchar2)
Domain Name
Must be of the type indicated by the function return (DATE for date fields; VARCHARnn for character fields (e.g. VARCHAR30); NUMBERn for whole number fields; AMTnnVn for numeric fields with decimals, must be one of the standard set.
Length
Optional, but recommended
Format
Optional, but may be used for date or number variables
User Formula (Defaulted From)
Must contain the name of the PL/SQL Function
Note that once the field has been added to the table, you will not see this new field right away as this information is key to the application and thus will only be picked up on an instance restart.

Restart the application instance.

Screen Definition (IMFD)#

Now that we have a field on the table that will return to us the value we wish, we can add this field to any form that has access to the ID referred to in the function / table definition. This is performed on the IMFD screen's form layout tab.

It is important to note that any such fields added, must be added with:

Item Type
Display Only so end users are not given the impression that they can update this value on the screen indicated.
Item Usage
User Defined so it is not overlaid by a subsequent release.


Notes #

Click to create a new notes page