Extensions Example

You need to store eye color, hair color, and body measurements for persons in the TCA Registry, for a UI in which users can update person profiles. You also need to let users calculate the body mass index based on the entered weight and height.

Prerequisites

  1. Plan out the attributes, including data type, range of values, specific values, and UI display method. These tables show the planning for this example.

    Physical Characteristics Attribute Group

    Attribute Data Type Values Range Values Display Required
    Eye Color Character None
    • Black

    • Brown

    • Blue

    • Green

    • Violet

    List of Values No
    Hair Color Character None
    • Black

    • Brown

    • Blonde

    • Gray

    • Red

    • Other

    List of Values No

    Body Measurements Attribute Group

    Attribute Data Type Values Range Values Display Required
    Height Number 1 - 100 None Text No
    Weight Number 1 - 1000 None Text No
    Body Mass Index Number 1 - 100 None Text No
  2. Plan out the function and action for calculating the body mass index. This table shows the questions and answers for this example.

    Question Answer for This Example
    Which attributes are functions of other attributes? The Body Mass Index attribute is a function of the Height and Weight attributes.
    What type of function is this: Java, PL/SQL, or URL? PL/SQL.

Procedure

  1. Select Person Profiles as the entity to extend.

  2. Create value sets for the attributes. This table shows what you define for this example.

    Value Set Name Data Type Maximum Size Validation Type Display Type Value Range
    EyeColor Char 6 Independent List of Values Not Applicable
    HairColor Char 6 Independent List of Values Not Applicable
    Height Number 3 None <Not Applicable> Minimum Value: 1
    Maximum Value: 100
    Weight Number 4 None <Not Applicable> Minimum Value: 1
    Maximum Value: 1000

    This table shows what you add as specific values for the HairColor value set. You would accordingly enter values for EyeColor, based on your plan.

    Value Enabled Sequence Start Date
    Black Yes 1 <System date>
    Brown Yes 2 <System date>
    Blonde Yes 3 <System date>
    Gray Yes 4 <System date>
    Red Yes 5 <System date>
    Other Yes 6 <System date>
  3. Create the attribute groups. This table shows what you define for this example.

    Internal Name Display Name Multi-Row
    PHYSICAL_CHAR Physical Characteristics No
    BODY_MEASURE Body Measurements No

    Add attributes to each group, as presented in these tables.

    Attributes in Physical Characteristics Attribute Group

    Internal Name Display Name Sequence Data Type Column Enabled Required Display As Value Set Default Value
    EYE_COLOR Eye Color 1 Char C_EXT_ATTR1 Yes No Text Field EyeColor Brown
    HAIR_COLOR Hair Color 2 Char C_EXT_ATTR2 Yes No Text Field HairColor Brown

    Attributes in Body Measurements Attribute Group

    Internal Name Display Name Sequence Data Type Column Enabled Required Display As Value Set Default Value
    HEIGHT Height 1 Number N_EXT_ATTR1 Yes No Text Field Height None
    WEIGHT Weight 2 Number N_EXT_ATTR2 Yes No Text Field Weight None
    BMI Body Mass Index 3 Number N_EXT_ATTR3 Yes No Text Field None None
  4. Create a function to calculate the body mass index.

    1. Write the custom PL/SQL for the calculation. For this example:

      PACKAGE XX_EXT_TEST AS
        FUNCTION CALC_BMI
          (p_weight in NUMBER,
           p_height in NUMBER)
        RETURN NUMBER;
      END XX_EXT_TEST;
      
      PACKAGE BODY XX_EXT_TEST AS
        FUNCTION CALC_BMI
          (p_weight in NUMBER,
           p_height in NUMBER)
        RETURN NUMBER
        IS
          l_bmi number;
        BEGIN
          l_bmi := trunc((p_weight*703) / (p_height*p_height));
          dbms_output.put_line('BMI = '||l_bmi);  -- for testing
          return l_bmi;
        END;
      END XX_EXT_TEST;
      
    2. Run the PL/SQL package in your custom schema and create a synonym for this package in the APPS schema.

    3. Define the function in the extensions administration.

      • Internal Name: CALC_BMI

      • Display Name: Calculate BMI

      • Function Type: PL/SQL

      • Package: XX_EXT_TEST

      • Procedure: CALC_BMI

    4. Enter function parameters as shown in this table.

      Sequence Internal Name Display Name Data Type Parameter Type
      1 p_weight Weight Number Input
      2 p_height Height Number Input
      3 x_bmi Body Mass Index Number Return Value
  5. Add both attribute groups and associate them with the Person Profiles data level.

    For the Body Measurements attribute group, create an action for calculating the body mass index:

    Attention: The PLM security privileges are not used for extending TCA attributes.

    Map the function parameters to attributes, as shown in this table.

    Parameter Name Mapped To Mapped Attribute
    Weight Attribute Group Weight
    Height Attribute Group Height
    Body Mass Index Attribute Group Body Mass Index
  6. Create a page and assign both attribute groups to it. For this example, you enter:

Related Topics