1.5.7 Validation Rule

This topic describes how to define the validation rule.

This is the PL/SQL validation code based on which the system will check the value of the new field and validates at the time of transaction processing. Entry to this field is mandatory if you have checked against ‘Validation Allowed’.

For example, at the time of processing a contract for a customer, the bank wants to add a new field to enter the first nominee that the customer has specified in his account. The names of the nominees of a customer are maintained in the Customer Accounts Maintenance screen. The bank wants the system to check that the name of the nominee that is entered in the new field and the name of the first nominee that is maintained in the Customer Accounts Maintenance screen are the same.

To do this, you need to:
  • Create a new user defined field of type ‘Text’,
  • Specify ‘Usage Allowed’ as ‘Product’,
  • Check against ‘Validation Allowed’, and
  • Write a code to validate the value entered in the new field. In the validation rule, you write a code to check that the value of the first nominee specified in the Customer Accounts Maintenance screen for the customer for whom you are processing a contract and the value entered at the time of processing a contract are same.
Syntax to be used in Derivation and Validation Rules (@FIELD_VAL): (@FIELD_VAL) holds the Value UDF. This is s mandatory for Derivation Logic and it can be used in Validation logic to get the value of the field.

For example,

(@FIELD_VAL): = ‘USD’;
Select ccy_code into (@FIELD_VAL) from
CYTMS_CCY_DEFN where country = ‘USA’;

(@RECORD_KEY): (@RECORD_KEY) behaves differently for UDFs’ linked to Product and different for UDFs’ linked to Function ID.

(@RECORD_KEY) When UDF is linked to FUNCTION_ID: To use (@Record_key) in UDFs’ where Usage allowed is ‘Function_id’ you have to maintain Function Key Mapping, which will be used to determine the record key before you define the UDF.

1.5.7 Specify the UD Function Key Mapping Details

Through the Function Key Mapping screen you can define the Record Key items that are used for the Function ID. This maintenance becomes mandatory if you have to use an UDF in all or any of the Functions.
Specify User ID and Password and login to Home screen.
  1. On Home screen, type UDDFNMPT in the text box, and click next.
    User Defined Fields Function Key Mapping Maintenance screen displays.

    Figure 1-5 User Defined Fields Function Key Mapping Maintenance

    Description of Figure 1-5 follows
    Description of "Figure 1-5 User Defined Fields Function Key Mapping Maintenance"
  2. On User Defined Fields Function Key Mapping Maintenance screen, specify the fields.

    Note:

    The fields which are marked in red asterisk are mandatory.
    For more information on fields, refer to the field description table.

    Table 1-4 User Defined Fields Function Key Mapping Maintenance - Field Description

    Field Description
    Function you must identify the function ID to which you need to link user-defined fields.
    Description The system displays the description of the function.

    For example, the Function STDCIF is based on the STTM_CUSTOMER table. The primary key maintained for this table is CUSTOMER_NO. From the STDCIF.FMB, check the block name for the item and then enter the BLK Name (block name in the Form for the Item), ITM_NAME (Item name in the Form) and the Order Number in this screen (Order number cannot be Duplicated and Should be sequential).

  3. After completing the Function Key maintenance you can continue defining the UDF for the Function ID.

    You will be prompted to link the Function ID (e.g. STDCIF) to the Field at the Definition of the UDF.

    (@RECORD_KEY) will hold the value of a combination of all item name values separated by ‘~’ that are mapped in the UD function key mapping screen in the same order of order_no. The Record key can be used only in the select statement.

    For example, select country into (@FIELD_VAL) from

    STTM_CUSTOMER WHERE(@RECORD_KEY) and default_media = ‘MAIL’;

    (@RECORD_KEY) When UDF is linked to PRODUCT: (@RECORD_KEY) in product level takes the value of the Contract Reference Number (transaction reference number). You need not maintain the function key mapping. You can use the (@RECORD_KEY) in any statements in the Derivation rule and Validation Rule.

    For example, select book_date into (@FIELD_VAL) from
    CSTBS_CONTRACT WHERE CONTRACT_REF_NO = (@RECORD_KEY);
    L_prod_code := substr((@RECORD_KEY),4,4);
    (@FIELD_VAL) := substr((@RECORD_KEY),4,4);
    (@RETURN_VAL): This syntax can be used only in validation logic. You can Assign TRUE or FALSE Values to this parameter. Example is given below.
    (@RETURN_VAL) := TRUE;
    if (@FIELD_VAL) = ‘USD’ then
    (@RETURN_VAL) := TRUE;
    else
    (@RETURN_VAL) := FALSE;
    err_code := ‘UD-UDF-01’;
    err_param := (@FIELD_VAL);
    end if;
    The ‘err_code’ and ‘err_param’ parameters can also be assigned, and will be displayed if the validation fails in population of values.

    (@UDF_field_name): We can use another UDF that is already defined in the derivation logic of a UDF.

    For example, we have another UDF DDD
    (@FIELD_VAL): = (@UDF_DDD);
  4. After writing the PL/SQL code, click ‘X’ button to execute the code.
    The derivation/validation code is validated by the system. If any checks fail, you must alter the statement so that the validation/derivation can be made successfully.
  5. Click E button to view the errors.

    Note:

    You are allowed to Use any syntax in the pl/sql code other than DML statements (INSERT, DELETE, UPDATE) and DBMS package. You will not be allowed to USE any package, function, and procedures other than GLOBAL, DEBUG and CSPKE_MISC.
  6. Click the Exit button to close the screen.