Granular API Features, Parameters, Attributes and Messages

This chapter describes the features, parameters, attributes and messages that are part of the Oracle Trading Community Architecture granular APIs.

This chapter covers the following topics:

Major Features and Solution Outline

Setting Applications Context

You must set the Applications Context in a database session, before calling any Trading Community Architecture application programming interfaces (API). The APIs rely on global variables and profiles that are part of this Applications Context. For details on setting Applications Context, please refer to Note 209185.1 on OracleMetaLink (http://metalink.oracle.com).

Modular Approach

The TCA API has been designed in a highly modular fashion, giving you code that is easy to understand, easy to maintain and easy to extend.

The modular approach defaults and validates user-entered information, defaults information not provided by the user, and calls the appropriate entity handler to perform the business related tasks.

Exception Handling and Results Messages

The APIs provide an extensive set of error-handling and error-reporting mechanisms so that errors encountered in the different phases of API execution are reported and put on the message stack. The calling program has the option of looking up all the error messages or the first error message on the stack. If there is only one error in the message stack, the error is displayed as one of the output parameters of the API routine. You do not have to fetch that message from the stack.

There are three types of information that the TCA APIs provide to their calling programs:

Return Status

The return status (x_return_status) of the API informs the caller about the result of the operation or operations performed by the API. The possible return status values and their meanings are:

Success

FND_API. G_RET_STS_SUCCESS (PL/SQL API)
HzConstant.getGRetStsSuccess() (Java API)

A success return status indicates that the API performed all of the operations requested by its caller. A success return status can be accompanied by informative messages in the API message list.

Error

FND_API. G_RET_STS_ERROR (PL/SQL API)
HzConstant.getGRetStsError() (Java API)

An error return status indicates that the API failed to perform some or all of the operations requested by its caller. An error return status is usually accompanied by messages describing any errors and how to resolve them.

In most cases, you should be able to correct normal, expected errors such as missing attributes or invalid date ranges.

Unexpected Error

FND_API. G_RET_STS_UNEXP_ERROR (PL/SQL API)
HzConstant.getGRetStsUnexpError() (Java API)

An unexpected error status indicates that the API encountered an unexpected error condition that it could not handle. In this case, the API cannot continue its regular processing. Examples of such errors are irrecoverable data inconsistency errors, memory errors, and programming errors such as attempting to divide by zero.

In most cases, an end user will not be able to correct unexpected errors. These errors usually require resolution by a system administrator or an application developer.

Messages

The APIs put result messages into a message list. Programs calling these APIs can then get the messages from the list and process those messages by issuing them, loading them into a database table, or writing them to a log file.

The APIs store messages in an encoded format so that the API callers can use standard functions provided by the message dictionary to find message names. With the message dictionary you can also store these messages in database tables and generate reports from these tables in different languages.

The API message list must be initialized every time a program calls an API. API callers can either call the message list utility function, FND_MSG_PUB.Initialize, or request that the API do the initialization by setting the p_init_msg_list parameter to T (TRUE).

The program calling the API can retrieve messages from the message stack using the existing FND API functions FND_MSG_PUB.Count_Msg (or standard output parameter x_msg_count) and FND_MSG_PUB.Get. You can see examples of these in the sample code in the appendix.

Robust Validation

The TCA APIs perform robust validations. The APIs collect all the validation errors encountered and put them on the message stack. The relevant entity handler is called only if no errors are reported during the validation phases.

Locking Mechanism

The TCA public APIs provide a new locking mechanism for update procedures, based on the new OBJECT_VERSION_NUMBER column, which has been included in all HZ tables. For this reason, OBJECT_VERSION_NUMBER is a mandatory attribute for all update APIs.

The locking mechanism works as follows:

Standard Parameters and Missing Attributes (PL/SQL API)

The TCA APIs have been developed to conform to the Oracle Applications API standards. The parameters below are common to all of the APIs. Brief descriptions are provided for some of the important features of the API.

Standard IN or IN/OUT Parameters

This parameter is either called p_object_version_number or p_<entity>_object_version_number. For example, for the hz_party_v2pub.update_organization API, this parameter is called p_party_object_version_number because organization is a type of party. The parameter value must match the version number in the database of the record being updated. An error will be returned if the calling program passes an object version number that is not identical to the one in the database for the existing record.

The default is FND_API.G_FALSE. If set to true, the API calls fnd_msg_pub.initialize to initialize the message stack. If it set to false, then the calling program must initialize the message stack. The initialization must only be done once in the case where more than one API is being called.

Caution: Do not use the rec.parameter for the OUT parameter. For example, do not use "p_organization _rec.party_rec.party_id", instead use "x_party_id".

Standard OUT Parameters

The names of all output parameters begin with "x_"

The Out parameter returns the status of the API. The returned value is one of the following :

The x_msg_count column contains the number of messages in the message list. If the count is one, then the x_msg_data column holds the encoded message.

Nested Record Types

PL/SQL record types are used in all of the create and update APIs. In some cases, nested record types have been used as well.

For example, in the Create_Person API, the p_person_rec input parameter is of the person_rec_type record type. The person_rec_type has party_rec as one of its elements, which itself is of party_rec_type record type.

The reason for doing this is that the attributes of the Person party type include attributes of a party, because Person is a subtype of Party.

Primary Key Generation

The Create APIs handle both sequence-generated and manually-passed primary keys, which can be generated on a device from an Oracle Mobile application. In order to prevent duplicate primary keys, the Create APIs handle exceptions to the unique key violation.

Missing Attributes

Optional IN parameters do not have default values. An attribute value that is not passed in is assumed to have a default of null for a Create API. For an Update API, if a particular attribute value is not passed into the API, then the database retains the existing value. In order to set a database value to null, the calling program must explicitly set the attribute value to one of the following constants, based on the data type of the attribute.

These are pre-defined values in the FND_API Package (fndapis.pls)

Debug Messages (PL/SQL API)

Use the extensive debug messages to trouble shoot in case of unexpected problems. These debugging messages are extremely useful because an API would be difficult to debug otherwise. You can turn on debug messages by the use of a certain profile option. These messages can be written to a log file as well.

The profiles for controlling the debug mechanism are:

If the HZ_API_FILE_DEBUG_ON profile is set to Y when any APIs are called, then debug messages are written to the file specified in HZ_API_DEBUG_FILE_PATH and HZ_API_DEBUG_FILE_NAME. If the HZ_API_FILE_DEBUG_ON profile is set to N, no debug messages are generated. The value of the HZ_API_DEBUG_FILE_PATH profile specifies a directory file path that the database has write access to, as provided in init.ora. You can find path information by querying: select value from v$parameter where name equals 'utl_file_dir'. If you turn the file debug mode on, but did not set a proper value for the HZ_API_DEBUG_FILE_PATH profile or the HZ_API_DEBUG_FILE_NAME profile is null, the API errors out.

Debug messages accumulate in the debug file. After collecting any debug messages, you must reset the HZ_API_FILE_DEBUG_ON profile back to N. If you do not, you might cause an exceeded file size error.

There are two ways to run APIs in the debug mode:

This example assumes that the directory, /sqlcom/out/tca115, has write access that is specified by the utl_file_dir parameter in the init.ora for the relevant database.

From SQLPLUS

exec fnd_profile.put('HZ_API_DEBUG_FILE_PATH', '/sqlcom/out/tca115/');
exec fnd_profile.put('HZ_API_DEBUG_FILE_NAME', 'api_debug');
exec fnd_profile.put('HZ_API_FILE_DEBUG_ON', 'Y');

From PL/SQL code

fnd_profile.put('HZ_API_DEBUG_FILE_PATH', '/sqlcom/out/tca115/');
fnd_profile.put('HZ_API_DEBUG_FILE_NAME', 'api_debug');
fnd_profile.put('HZ_API_FILE_DEBUG_ON', 'Y');

This debug strategy is provided as a public utility procedure that you can include in your custom code.

Please refer to the HZ_UTILITY_V2PUB package for further details.

Standard Parameters and Missing Attributes (Java API)

The TCA APIs have been developed to conform to the Oracle Applications API standards. The parameters below are common to all of the APIs. Brief descriptions are provided of some of the important features of the API.

Comments that are the same for PL/SQL API are repeated in this section.

Declare all parameters or member variables as BigDecimal if it is PL/SQL NUMBER type, String if it is PL/SQL VARCHAR2 type, or Timestamp if it is PL/SQL DATE type. To access these parameters or variables you must import

IN OUT/OUT Parameters

In PL/SQL the caller's value can be modified by the called procedure, if a parameter is declared OUT or IN OUT. For example, PL/SQL routines calling this procedure:

      procedure p1(n1 in out number, n2 number);

might find that the first variable passed to p1 was modified by the time the program's call to p1 is completed, because the parameter is declared IN OUT. The value the programs pass to n2 cannot possibly be modified.

A PL/SQL procedure can declare any parameter to be OUT or IN OUT. The caller must be prepared in case the PL/SQL procedure has modified any data, and that it is therefore part of the value returned from the procedure.

Java has no clear analogue to the concept of declaring parameters as OUT or IN OUT. Instead, in Java, there are certain types of objects that are immutable (changes by the called procedure which cannot be seen by the caller) and other types which are mutable.

For this reason, if there are any arguments to PL/SQL which are OUT or IN OUT, the Java API for it must be of a mutable type. This is why arrays are mutable APIs. For example, the Java API for procedure p1 above might look like:

  public static void p1 (BigDecimal [ ] n1, BigDecimal n2) {...}

The first parameter is an array and the second is not, even through, in PL/SQL, both parameters are simply NUMBER. In the case where p1 modifies n1, you can identify the new value. You can get the value by referencing, for instance, n1[0].

Standard IN or IN/OUT Parameters

String p_init_msg_list Optional

If HzConstant.getGTrue() is set to true, the API makes a call to fnd_msg_pub.initialize to initialize the message stack. If HzConstant.getGFalse() is set to false, then the calling program must initialize the message stack. This initialization is required only once when more than one API is called.

Standard OUT Parameters

The names of all output parameters begin with "x_"

Nested Record Types

PL/SQL record types are used in all Create and Update APIs. In some cases nested record types are used as well. Correspondingly, the Java Inner Class (for example, Record Class) is defined for each PL/SQL record type.

For example, in the HzPartyV2Pub.createPerson() method, the p_person_rec input parameter is of type HzPartyV2Pub.PersonRec. The HzPartyV2Pub.PersonRec parameter has party_rec as one of its elements which itself is of type HzPartyV2Pub.PartyRec.

The reason for doing this is that the attributes of the Person party type include attributes of a party, because Person is a subtype of Party.

Primary Key Generation

The Create APIs handle both sequence-generated and manually-passed primary keys, which can be generated on a device from an Oracle Mobile application. In order to prevent duplicate primary keys, the Create APIs handle exceptions to the unique key violation.

Missing Attributes

Each record class has two constructors:

Unlike the PL/SQL APIs, Java APIs take whatever values you pass in to create or update records.

Debug Messages (Java API)

Use the extensive debug messages to trouble shoot in case of unexpected problems. These debugging messages are extremely useful because an API would be difficult to debug otherwise. You can turn on debug messages by the use of a certain profile option. These messages can be written to a log file as well.

The profiles for controlling the debug mechanism are:

If the HZ_API_FILE_DEBUG_ON profile is set to Y when any APIs are called, then debug messages are written to the file specified in HZ_API_DEBUG_FILE_PATH and HZ_API_DEBUG_FILE_NAME. If the HZ_API_FILE_DEBUG_ON profile is set to N, no debug messages are generated.

The value of the HZ_API_DEBUG_FILE_PATH profile specifies a directory file path that the database has write access to, as provided in init.ora. You can find this path information by querying: select value from v$parameter where the name equals 'utl_file_dir'.

If you turn the file debug mode on, but did not set a proper value for the HZ_API_DEBUG_FILE_PATH profile or the HZ_API_DEBUG_FILE_NAME profile is null, the API errors out.

Debug messages accumulate in the debug file. After collecting any debug messages, you must reset the HZ_API_FILE_DEBUG_ON profile back to N. If you do not you might cause an exceeded file size error.

You can call FND_PROFILE.Put to set profile value.

This example assumes that the directory, /sqlcom/out/tca115, has write access, that is specified by the utl_file_dir parameter in the init.ora for the relevant database.

OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall(
"begin fnd_profile.put('HZ_API_DEBUG_FILE_PATH', '/sqlcom/out/tca115/'); end;");
ocs.execute();
ocs = (OracleCallableStatement)conn.prepareCall(
"begin fnd_profile.put('HZ_API_DEBUG_FILE_NAME', 'api_debug'); end;");
ocs.execute();
ocs = (OracleCallableStatement)conn.prepareCall(
"begin fnd_profile.put(fnd_profile.put('HZ_API_FILE_DEBUG_ON', 'Y'); end;");
ocs.execute();

Security of Oracle Human Resources Data

You can use the TCA APIs to access data about people after the data is entered and stored using Oracle Human Resources (HR) applications. The security, integrity, and validity of HR data must be maintained due to the sensitivity of personal information.

TCA's Security of HR Person Data feature enables Oracle applications to share data entered and stored with Oracle HR applications. With this feature other Oracle applications can access information about a person without compromising the security, integrity, or validity of the HR information. Although other Oracle applications can access information in the HR tables, only properly authorized users of HR applications can modify data about any person entered by using an Oracle HR application.

Third Party Data Integration

The following PL/SQL and Java APIs support third-party data integration:

General Overview

The integration of third-party data, from providers such as D&B, enables users to acquire data from external sources and then use that data to populate the HZ tables. The data in these HZ tables can then be viewed and used across the Oracle e-Business suite.

From an API, you can populate the actual_content_source column to identify the third party data source. The content_source_type attribute is obsolete. You should use the actual_content_source attribute for third- party data integration applications. If necessary, you can use the content_source_type attribute to maintain backward compatibility.

Default values for the actual_content_source and content_source_type attributes are taken from the actual_content_source column, unless you have overwritten the default value in either column.

Party API

In the Organization and Person record types; the values in the actual_content_source column default to SST and the values in the content_source_type column default to user_entered.

Create Organization API and Create Person API

These APIs first determine the data source based on the values in the actual_content_source and content_source_type columns. If the data source is either SST or user_entered, the API errors out if the same party ID exists in the HZ_PARTIES table. Otherwise, the API will create new party profiles and parties.

If the data source is a third-party data source and if we create profiles for existing parties by passing a party ID, the API errors out if the parties have profiles from the same data source. Otherwise, the API creates the third-party profiles for the parties. If you set up Advanced Third Party Data Integration and select the third party data source as one of the ranked data sources, the API creates or updates the third-party profiles, SST or single source of truth, and denormalizes the SST profiles to HZ_PARTIES. Users can only see SST profiles.

Update Organization API and Update Person API

These APIs first determine the data source based on the values in the actual_content_source and content_source_type columns. If the data came from a third-party source, but the user does not have permission to overwrite third party data, then the API triggers an error message; "You do not have permission to overwrite the information in the &COLUMN column, which comes from a third party data source. Please contact your system administrator."

Location API

The values in both the actual_content_source and content_source_type columns default to user_entered. Unless the privilege is provided through the user create and update rule for Other entities, users cannot update third-party locations, except for data populated in descriptive flexfields.

Party Site API

The values in both the actual_content_source and content_source_type columns default to user_entered. You can control whether third party data for a site is active or inactive.

Contact Point API

The values in both the actual_content_source and content_source_type columns default to user_entered. You can control whether third party data for a contact point site is active or inactive

Phone component information from data sources other than USER_ENTERED cannot be updated if the user does not have update privilege specified through rules. D&B data is always nonupdateable, as update rules cannot be set for PURCHASED systems.

Relationship API

The values in both the actual_content_source and content_source_type columns default to user_entered.

You can control whether third-party data for a contact point site is active or inactive. For example, the value of the actual_content_source attribute is other than user_entered.