To define your own custom logic, you can add user-defined functions and actions to existing pages in the Item Catalog and in Change Management without having to customize the entire page. By first setting up user-defined attributes, you can then execute user-defined functions with those attributes.
Using different algorithms, you can calculate values by passing attribute values to functions. User-defined functions can be Java, URL, or PL/SQL functions. Functions use input and/or output parameters of various data types such as string, integer, or Boolean. You can also map these parameters to attributes and object primary key values. Actions are trigger points for functions displayed as buttons or links on the page. You can determine the conditional visibility of the button and the label displayed on the button itself. You can also prompt the user based on the user's input. See: Adding Actions to an Attribute Group
Additional Information: You can import functions using open interface tables and the concurrent program EGO Import Metadata (EGOIMDCP). For more information, refer to Importing Item Catalog Metadata
User-defined functions can be Java, URL, or PL/SQL functions. Prior to setting up user-defined functions and actions you should:
Set up user defined attributes. See: Defining Item Attributes and Attribute Groups
Create item pages associated with item catalog categories. See: Creating Pages for an Item Catalog Category
Determine which attributes are functions of other attributes. Create user-defined functions to perform the necessary calculations (for example, summation of costs, efforts, ratings).
Create custom privileges and roles if you need to secure access and control who can/cannot execute the function/action. See: To implement attribute group security
Determine the conditions for displaying or changing the prompt of the button/link that executes the function. For example, the button may not be displayed until certain required attributes have values entered. The name of the button may change depending on the values of certain attributes. See: Adding Actions to an Attribute Group
In the Applications tree menu, click the "Setup Workbench" link.
On the Search: Item Catalog Categories page, click the Functions tab.
On the Search and Select: Functions page, click Create Function.
On the Create Function page, enter the following information:
Internal Name
The internal name of the function.
Display Name
The name of the function as it appears in the user interface.
Description
The description of the function.
Function Type
Whenever you define a function, there must be an underlying implementation of that function. The type specifies the manner of implementation to which the function maps. The supported function types are:
Java
Specifies that the implementation is via a Java method. When you select Java, the page refreshes and you must specify the following:
Class
The class in which the method resides.
Method
The method that implements your custom logic.
Note: Place the Java class files in any directory and append this directory to the Apache servlet classpath.
PL/SQL
Specifies that the implementation is via a PL/SQL stored procedure. When you select PL/SQL, the page refreshes and you must specify the following:
Package
The package in which the procedure resides.
Procedure
The procedure that implements your custom logic.
Note: Run the PL/SQL package in your custom schema and then create a synonym for this package in the APPS schema.
URL
Specifies that the implementation is a simple URL link. When you select URL, the page refreshes and you must specify the following:
URL
Specify either absolute or relative URLs. For absolute URLs, begin the URL with the protocol (in most cases, the protocol will be http://).
Click Apply.
Note: You can only delete a function when it is no longer associated with an action.
After creating a user-defined function, specify the parameters to pass when that function is called.
On the Search and Select: Functions page, click the name of the function you just created.
On the Function Details page, click Add.
On the Create Function Parameter page, enter the following information:
Internal Name
The internal name of the parameter.
Display Name
The name of the parameter as it appears in the user interface.
Sequence
The order in which this parameter appears relative to other parameters associated with this function. Sequence must be unique among all parameters associated with this function.
Specify the order sequence of the function parameters; this is the order in which the parameters are passed to a function or procedure. For example, you need to calculate time duration in days by using the attribute group "Duration in days" where Duration = End Date - Start Date.
| Sequence | Attribute Group: Duration in Days | Attribute Group: Duration in Days | Mapping Attribute & Parameters | Java Function: Duration | Java Function: Duration | Java Function: Duration |
| Sequence | Attribute Name | Data Type | ---------@-------- | Parameter Name | Data Type | Parameter Type |
| 1 | Start Date | Standard Date | ---------@-------- | Date 1 | Date | Input |
| 2 | End Date | Standard Date | ---------@-------- | Date 2 | Date | Input |
| 3 | Duration | Number | ---------@-------- | Result | Integer | Return Value |
Data Type
Lists the available data types. The values available are dependent on the type of function for which you are defining parameters.
Parameter Type
Select the parameter type for each parameter based on whether the corresponding attribute is providing an input parameter to the function or expecting a return value from the function (for example, input, output, input/output).
The parameter options for a parameter depend on the function type and parameter data type you have already selected. For example, if the Function Type is URL, then the Data Type is constrained to String, and the Parameter type is constrained to Input.
The valid parameters for Java functions are:
Boolean
Standard Date
Error Array
Float
Integer
Long
Double
Transaction
String
Standard Date Time
The valid parameters for PL/SQL functions are:
Date
Error Array
Number
Varchar
The valid parameter for URL function is:
String
The system supports Java function parameters to be used as input, output, input/output or return. For output or input/output parameter types, you have to pass back the changed value as the same object. But you cannot change the values for immutable data types. Therefore, wrapper classes are created for these data types.
Boolean - oracle.apps.ego.common.EgoBoolean
Double - oracle.apps.ego.common.EgoDouble
Float - oracle.apps.ego.common.EgoFloat
Integer - oracle.apps.ego.common.EgoInteger
Long - oracle.apps.ego.common.EgoLong
Date - oracle.apps.ego.common.EgoDate
Timestamp - oracle.apps.ego.common.EgoTimestamp
All these wrapper classes have getValue () and setValue () that return/take the basic parameters respectively. For example, EgoInteger - setValue(Integer i) Integer getValue()
Other Java parameters supported are:
String - java.lang.StringBuffer
Transaction - oracle.jbo.Transaction
Additional Information: ErrorArray data type is a java.util.Vector to which you can add translated Error messages. This is an output parameter and the errors are displayed on the rendering page.
While writing Java Custom functions, use the above data types. When a user enters a decimal value for an attribute and this attribute is mapped to EgoInteger or EgoLong, the value is truncated before it passes to the function. For EgoBoolean, the value "Y" is considered TRUE. All other values are considered FALSE.
Click Apply.