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.
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 |
| List of Values | No |
| Hair Color | Character | None |
| 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 |
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. |
Select Person Profiles as the entity to extend.
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> |
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 |
Create a function to calculate the body mass index.
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;
Run the PL/SQL package in your custom schema and create a synonym for this package in the APPS schema.
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
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 |
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:
Sequence: 1
Action Name: Calculate BMI
Function: Calculate BMI
Execution Method: User Action
Display Style: Button
Prompt Application: Customers Online
Prompt Message Name: XX_CALC_BMI_MSG
Note: You need to define the message to use as the prompt, in this case, the text that appears on the button. See: Define Your Messages.
Visible: Yes
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 |
Create a page and assign both attribute groups to it. For this example, you enter:
Display Name: Person Physical Information
Internal Name: PERSON_PHYSICAL_INFO
Sequence: 10
Data Level: Person Profiles
Attribute Groups
Sequence: 10, Display Name: Physical Characteristics
Sequence: 20, Display Name: Body Measurements