109
Using TCA APIs Including Examples – V2 An Oracle White Paper May 2002 Author : Viswanathan Rajagopalan Creation Date : April 2002 Last Updated : May 2002 Version : 1.0

Oracle Customers APIs.PDF

Embed Size (px)

DESCRIPTION

Oracle Customers APIs.PDF

Citation preview

  • Using TCA APIs Including Examples V2

    An Oracle White Paper May 2002 Author : Viswanathan Rajagopalan Creation Date : April 2002 Last Updated : May 2002 Version : 1.0

  • Using TCA APIs including Examples V2

    Introduction To API .........................................................................................3 API Components...........................................................................................4 Advantages of Using TCA API...................................................................4

    Features of TCA API ........................................................................................5 Exception Handling and Results Messages ...............................................5 Messages .........................................................................................................5 Robust Validation..........................................................................................6 Locking Mechanism ......................................................................................6 Debug Messages (PL/SQL API) ................................................................7

    Location of API in Oracle Applications DirectoryError! Bookmark not defined. Identification of the Package Name and Version of an API.................... 10 Uploading Data Using API............................................................................ 10 APIs Available For Trading Community Architecture ............................. 11 Example on running TCA API..................................................................... 13

    Example 1 : Running The Create Organization API ............................ 13 Example 2 : Running The Create Person API ....................................... 16 Example 3 : Running The Create Group API........................................ 19 Example 4 : Create Org Contact API...................................................... 22 Example 5 : Create Location API ............................................................ 26 Example 6 : Update Location API........................................................... 29 Example 7 : Create Party Site API ........................................................... 32 Example 8 : Create Party Site Use API ................................................... 35 Example 9 : Create Party Site API ........................................................... 37 Example 10 : Create Relationship Type API.......................................... 41 Example 11 : Create Relationship API................................................... 45 Example 12 : Create Class Category API................................................ 50 Example 13 : Create Code Assignment API .......................................... 53 Example 14 : Create Customer Account API ........................................ 57 Example 15 : Update Customer Account API....................................... 61 Example 16 : Create Customer Account API ........................................ 64 Example 17 : Update Customer Account Site Use API ....................... 67 Example 18 : Create Customer Profile API ........................................... 70 Example 19 : Update Customer Profile API.......................................... 73 Example 20 : Create Location Assignment API .................................... 76

    PL/SQL Record Structures Used by TCA APIs ....................................... 79 PL/SQL Record Structure for Organization ......................................... 79 PL/SQL Record Structure for Person .................................................... 82 PL/SQL Record Structure for Group..................................................... 83 PL/SQL Record Structure for Organization Contact .......................... 83

    Documentation on using TCA APIs - V2 Page 1

  • PL/SQL Record Structure for Location................................................. 84 PL/SQL Record Structure for Party Site................................................ 86 PL/SQL Record Structure for Party Site Use........................................ 87 PL/SQL Record Structure for Contact Point........................................ 87 PL/SQL Record Structure for Phone ..................................................... 88 PL/SQL Record Structure for Create Relationship Type API............ 88 PL/SQL Record Structure for Create Relationship API...................... 89 PL/SQL Record Structure for Create Class Category API.................. 90 PL/SQL Record Structure for Create Code Assignment API ............ 91 PL/SQL Record Structure for Customer Account............................... 91 PL/SQL Record Structure for Customer Account Site ....................... 93 PL/SQL Record Structure for Customer Account Site Use ............... 95 PL/SQL Record Structure for Create Customer Profile API ............. 97

    Messages for the TCA API.......................................................................... 100

    Documentation on using TCA APIs - V2 Page 2

  • Using TCA APIs including Examples V2

    INTRODUCTION TO API Application Programming Interface (API) is a PL/SQL packaged procedure which can be used as an alternative to traditional Application online form.

    Using APIs give users an advantage of adding data to the system is that user can enter new information or alter existing data without entering information manually into the application.

    APIs insures the integrity of the interrelationship of Oracle Applications tables. User can modify application information without being aware of every feature of the database structure. It also depends on the API to update all the interrelated tables.

    Continuous utilization of APIs helps to protect customer-specific data from database structural changes. As the table structures changes, the APIs can be modified to those same structural changes so that data can continue to be modified without any error or need to update coding.

    The APIs available in Oracle Receivables have been written to fulfill business needs like Create Customer, Update Customer Contact etc. and can be used in many other ways like :

    a) Data Uploads - Bulk transfer of data from an existing system into Oracle Receivables. b) Interfacing - Regular interface from, for example, a Third party Personnel system into Oracle

    Receivables. c) Spreadsheets - Uploading data via ADE. d) Forms - standard interface, standard or web forms.

    While the API package contains many procedures to insert, modify, or delete application data, the API is not executed on its own. The API must be called, or executed, by other pl/sql modules, by a direct SQL*Plus call, or through a front end such as the Data Pump.

    The API package should never be modified for specific custom use. If modified, Oracle will not be able to support them. If user needs additional functionality, APIs can be used as building blocks, to be called within a more extensive package that user may build to address the unique functionality desired.

    PL/SQL Public API , JAVA Public API and Forms API are the three categories of APIs. The discussion in this document will be on PL/SQL V2 Public API for TCA.

    Documentation on using TCA APIs - V2 Page 3

  • INTRODUCTION TO TCA API

    The TCA API is an integrated set of code designed in a highly modular fashion, resulting in code that are easy to understand, maintain and extend.

    The modular approach defaults and validates users who enter infromation, defauts information not provided by the user and calls the appropriate entity handler to perform the business related tasks.

    Customers, consultants, and Oracle internal development teams can use Version 2 of the public TCA application programming interfaces (APIs). Version 1 of the APIs are only made available to Oracle internal development teams. The Version 2 Public API feature is available from HZ Patchset E.

    The Trading Community Architecture (TCA) datamodel is the foundation for the 11i Oracle e-Business Suite of Applications via PL/SQL APIs. These APIs (version 2) will be supported for use by customers and consultants and are available for use by internal product teams in ERP and CRM. This is a step forward from the version 1 APIs that are available only for use by internal product teams.

    API Components API category PL/SQL package PL/SQL record structure PL/SQL procedure Parameter description Validations

    Advantages of Using TCA API Flexible, easy to understand and modular. Extensive debugging capability. Extensive error handling and reporting capability. Robust validation in all of the APIs. A new locking mechanism based on the OBJECT_VERSION_NUMBER field, which has been

    included in all of the HZ entities for which the public APIs have been provided. Standard signature and availability of common parameters

    The following main categories of entities are covered : Parties - person, organization, group Locations Party sites, party site use Organization contact, organization contact role Contact points Contact preferences Relationship types Relationships Classification Customer accounts Account sites and site uses Customer account role, role responsibility Customer profile and customer profile amount

    Documentation on using TCA APIs - V2 Page 4

  • FEATURES OF TCA API

    Exception Handling and Results Messages The APIs provide an extensive set of error-handling and error-reporting mechanisms. The errors that are encountered in the different phases of the API execution are reported and put on the message stack. The calling program has the option of displaying 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. User need not fetch that message from the stack. There are three types of information that the TCA APIs provide to their calling programs:

    Overall status Messages describing the operations performed or errors encountered by the API Output values that the program making the call to the API might need to use

    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 return status values are: Success FND_API. G_RET_STS_SUCCESS (PL/SQL API)

    A success return status indicates that the API performed all the operations requested by its caller. A success return status can be accompanied by informative messages in the API message list. Failure FND_API. G_RET_STS_ERROR (PL/SQL API)

    An error return status indicates that the API failed to perform some or all 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, user 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) An unexpected error status indicates that the API encounteres 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 is unable 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, users can store these messages in database tables and generate reports from these tables in different languages. For more information, see List of Messages.

    Documentation on using TCA APIs - V2 Page 5

  • 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. For examples of these functions, see Sample Code.

    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:

    Whenever a new record is created, the value in the OBJECT_VERSION_NUMBER column is set to 1.

    Whenever a record is updated, the value in the OBJECT_VERSION_NUMBER column is reset to OBJECT_VERSION_NUMBER plus 1.

    For records that existed in the HZ tables prior to introduction of this locking mechanism, the API sets the value in the OBJECT_VERSION_NUMBER column to null.

    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 Parameters IN or IN/OUT Parameters p__object_version_number IN/OUT NUMBER Required This parameter is either called p_object_version_number or p__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. p_init_msg_list IN VARCHAR2 Optional 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. OUT Parameters The names of all output parameters begin with x_.

    Documentation on using TCA APIs - V2 Page 6

  • x_return_status OUT VARCHAR2(1) The Out parameter returns the status of the API. The returned value is one of the following : x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 FND_API.G_RET_STS_SUCCESS - Success FND_API.G_RET_STS_ERROR - Expected error, validation or missing data FND_API.G_RET_STS_UNEXP_ERROR - Unexpected error, cannot be corrected by the calling program 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 have been 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.

    FND_API.G_MISS_NUM for NUMBER type. FND_API.G_MISS_CHAR for VARCHAR2 type. FND_API.G_MISS_DATE for DATE type.

    These are pre-defined values in the FND_API Package (fndapis.pls) G_MISS_NUM CONSTANT NUMBER:= 9.99E125 G_MISS_CHAR CONSTANT VARCHAR2(1):= chr(0) G_MISS_DATE CONSTANT DATE:= TO_DATE('1','j') ;

    Debug Messages (PL/SQL API) Use the extensive debug messages to troubleshoot in case of unexpected problems. These debugging messages are useful because an API would be difficult to debug otherwise. User can turn on debug messages with a certain profile option. These messages can be written to a log file as well. The profiles for controlling the debug mechanism are:

    Name - HZ_API_FILE_DEBUG_ON User Profile Name - HZ: Turn On File Debug

    Documentation on using TCA APIs - V2 Page 7

  • Name - HZ_API_DEBUG_FILE_NAME User Profile Name - HZ: API Debug File Name Name - HZ_API_DEBUG_FILE_PATH User Profile Name - HZ: API Debug File Directory Name - HZ_API_DBMS_DEBUG_ON User Profile Name - HZ: Turn On Development Debug.

    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. User can find path information by querying: select value from v$parameter where name equals utl_file_dir. If user 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, user must reset the HZ_API_FILE_DEBUG_ON profile back to N. If user do not, system might cause an exceeded file size error. User should only use the HZ_API_DBMS_DEBUG_ON profile during the development phase or in SQLPLUS because of limitation of dbms_output. There are two ways to run APIs in the debug mode: From Oracle Applications the debug mode can be enabled or disabled by setting HZ_API_FILE_DEBUG_ON to Y or N, respectively. The default value is N. When the profile is set Y, user must set the proper values for the HZ_API_DEBUG_FILE_NAME and HZ_API_DEBUG_FILE_PATH profiles. With SQLPLUS or server side PL/SQL custom code - user can enable or disable the debug mode by calling FND_PROFILE API. 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'); Follow the same strategy for dbms debug mode, but be sure to use the set serveroutput on option. From SQLPLUS set serveroutput on exec fnd_profile.put('HZ_API_DBMS_DEBUG_ON', 'Y'); From PL/SQL set serveroutput on fnd_profile.put('HZ_API_DBMS_DEBUG_ON', 'Y');

    Documentation on using TCA APIs - V2 Page 8

  • This debug strategy is provided as a public utility procedure that can include in custom code. Refer to the HZ_UTILITY_PUB package for further details. The following portion of the document will discuss about using V2 Public TCA APIs which are available both to the users and the internal development team. Some Salient Features of the V2 Public APIs Flexible, easy to understand, modular with new API signatures as compared to V1 version of the APIs, that is after a major data model cleanup project several attributes from the API signatures that are obsolete and have not been used in a consistent manner were eliminated. Appropriate data migration has also been provided.

    Major Performance Improvements over the previous version of the APIs API Hooks using the new Business Event System (BES) provided by Application

    Technology Group New Locking Mechanism based in an OBJECT_VERSION_NUMBER field that has been

    included in all the HZ entities for which the V2 APIs are provided An extensive error handling and reporting capability An extensive debugging capability that was not available in the V1 version of the APIs V2 APIs are now PUBLIC, that is, Will be supported by World Wide Support. Customers

    and consultants can now use these APIs and log tars/bugs to get support on these which was not possible with the V1 version of the APIs

    The following are main categories of entities that are covered in TCA APIs :

    Parties - Person, Organization, Relationship, Group. Locations, Party Sites, Party Site Uses Contact Points, Contact Preferences Customer Accounts, Account Sites and Site Uses Classification Relationships Relationship, Relationship types and Groups

    Documentation on using TCA APIs - V2 Page 9

  • IDENTIFICATION OF THE PACKAGE NAME AND VERSION OF AN API To identify the package name of an API as compiled into the Oracle database, in SQL*Plus enter the following select statement (logged in as APPS)

    sql>SELECT text FROM all_source WHERE name like '%user_api_name%' (example: HZ_CUSTOMER_ACCOUNT_PUB API) AND text like '%Header%'; A header line of the package and package body showing the package name and version number is returned.

    To compare the version of the API package in users operating system directory to the one compiled in users database, execute the following from the command line from the API directory:

    prompt>strings -a packagename | grep Header All occurrences of the package, package body, and the version number of the file. Version numbers should match what is compiled in the database.

    UPLOADING DATA USING API While the API package contains many procedures to insert, modify, or delete application data, the API is not executed on its own. The API must be called, or executed, by other PL/SQL modules, by a direct SQL*Plus call, or through a front end such as the Data Pump.

    The API package should never be modified for specific custom use. If modified, Oracle will not be able to support them. If user need additional functionality, APIs can be used as building blocks, to be called within a more extensive package that user may build to address the unique functionality desired.

    Documentation on using TCA APIs - V2 Page 10

  • APIS AVAILABLE FOR TRADING COMMUNITY ARCHITECTURE Party APIs

    Create Organization API Update Organization API Create Person API Update Person API Create Group API Update Group API

    Party Contact APIs

    Create Org Contact API Update Org Contact API Create Org Contact Role API Update Org Contact Role API

    Person Info API

    Create Person Language API Update Person Language API

    Location API

    Create Location API Update Location API

    Party Site API

    Create Party Site API Update Party Site API Create Party Site Use API Update Party Site Use API

    Contact Point API

    Create Contact Point API Update Contact Point API

    Relationship Type API

    Create Relationship Type API Update Relationship Type API

    Relationship API

    Create Relationship API Update Relationship API

    Classification APIs

    Create Class Category API Update Class Category API Create Class Code Relation API Update Class Code Relation API Create Code Assignment API Update Code Assignment API

    Documentation on using TCA APIs - V2 Page 11

  • Create Class Category Use API Update Class Category Use API

    Contact Preference API

    Create Contact Preference API Update Contact Preference API

    Customer Account APIs

    Create Customer Account API (Person or Organization) Update Customer Account API Create Customer Account Relationship API Update Customer Account Relationship API

    Customer Account Site APIs

    Create Customer Account Site API Update Customer Account Site API Create Customer Account Site Use API Update Customer Account Site Use API

    Customer Profile APIs

    Create Customer Profile API Update Customer Profile API Create Customer Profile Amount API Update Customer Profile Amount API

    Customer Account Role API

    Create Customer Account Role API Update Customer Account Role API Create Role Responsibility API Update Role Responsibility API

    Tax Assignment API

    Create Location Assignment API Update Location Assignment API

    Documentation on using TCA APIs - V2 Page 12

  • EXAMPLE ON RUNNING TCA API

    Example 1 : Running The Create Organization API Name of the API : CREATE ORGANIZATION API

    Base Tables Affected : HZ_PARTIES HZ_ORGANIZATION_PROFILES

    PL/SQL Procedure used : CREATE_ORGANIZATION

    Package Used : HZ_PARTY_V2PUB

    Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_organization_rec IN ORGANIZATION_REC_TYPE x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 x_party_id OUT NUMBER x_party_number OUT VARCHAR2 x_profile_id OUT NUMBER Procedure

    PROCEDURE create_organization ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_organization_rec IN ORGANIZATION_REC_TYPE, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2, x_party_id OUT NUMBER, x_party_number OUT VARCHAR2, x_profile_id OUT NUMBER )

    General Tips for Running the Create Organization API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN createorg.txt) b) Enter the values for the Parameters from inside the script file itself unless it is

    required to Enter some value from the SQL Prompt. c) Set the organization id before running the script as : d) EXEC fnd_client_info.set_org_context('');

    Ensure that the Profile Option HZ : Generate Party Number is Set to Yes at Site Level.

    Code for Create Organization API

    Documentation on using TCA APIs - V2 Page 13

  • DECLARE p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); x_party_id NUMBER; x_party_number VARCHAR2(2000); x_profile_id NUMBER;

    BEGIN p_organization_rec.organization_name := New TCA Corporation; p_organization_rec.created_by_module := INDIA_ISC_ORGANIZATION; hz_party_v2pub.create_organization ( T, p_organization_rec, x_return_status, x_msg_count, x_msg_data, x_party_id, x_party_number, x_profile_id); dbms_output.put_line('return_status='|| SUBSTR (x_return_status,1,255)); dbms_output.put_line('count='||TO_CHAR(x_msg_count)); dbms_output.put_line('Msg_data = '|| SUBSTR (x_msg_data,1,255)); dbms_output.put_line('Party Id='|| SUBSTR (x_party_id,1,255)); dbms_output.put_line('Party_Number='|| SUBSTR (x_party_number,1,255)); dbms_output.put_line('Organization_Name='||SUBSTR(p_organization_rec.organization_name,1,255)); dbms_output.put_line('CreatedBy='||SUBSTR (p_organization_rec.created_by_module,1,255)); dbms_output.put_line('Profile Id='|| SUBSTR (x_profile_id,1,255));

    IF x_msg_count > 1 THEN FOR I IN 1..x_msg_count LOOP dbms_output.put_line('I.'|| SUBSTR (FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); END LOOP; END IF; END; Sample Output of the Create Organization Script return_status=S count=0 Msg_data = Party Id=4104 Party_Number=2448 Organization_Name=New TCA Corporation Created By=INDIA_ISC_ORGANIZATION Profile Id=2021

    Documentation on using TCA APIs - V2 Page 14

  • Script To Verify whether the Create Organization API is successful SELECT party_id, SUBSTR(party_number,1,5), SUBSTR(party_name,1,20), SUBSTR (object_version_number,1,1), SUBSTR (created_by_module,1,25) FROM hz_parties WHERE party_id = 4104; party_id = 4104

    party_number = 2448 party_name = New TCA Corpporation obj_ver = 1 created_by_mod = INDIA_ISC_ORGANIZATION

    SELECT organization_profile_id, party_id, organization_name, object_version_number, created_by_module FROM hz_organization_profiles WHERE party_id = 4104;

    org_profile_id = 2021 party_id = 4104 organization_name = New TCA Corporation obj_ver_num = 1 created_by_mod = INDIA_ISC_ORGANIZATION

    Documentation on using TCA APIs - V2 Page 15

  • Example 2 : Running The Create Person API Name of the API : CREATE PERSON API Base Tables Affected : HZ_PARTIES HZ_PERSON_PROFILES PL/SQL Procedure used : CREATE_PERSON Package Used : HZ_PARTY_V2PUB HZ_CUST_ACCOUNT_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_person_rec IN PERSON_REC_TYPE x_party_id OUT NUMBER, x_party_number OUT VARCHAR2 x_prof i l e_i d OUT NUMBER x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_person ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_person_rec IN PERSON_REC_TYPE, x_party_id OUT NUMBER, x_party_number OUT VARCHAR2, x_prof i l e_i d OUT NUMBER, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Person API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN createperson.txt) b) Enter the values for the Parameters from inside the script file itself unless it is

    required to Enter some value from the SQL Prompt. c) Set the organization id before running the script as :

    EXEC fnd_client_info.set_org_context(''); d) Ensure that the Profile Option HZ : Generate Party Number is Set to Yes

    at Site Level. Code for Create Person API DECLARE

    Documentation on using TCA APIs - V2 Page 16

  • p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE; p_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE; p_customer_profile_rec HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE; x_cust_account_id NUMBER; x_account_number VARCHAR2(2000); x_party_id NUMBER; x_party_number VARCHAR2(2000); x_profile_id NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN Fnd_client_info.set_org_context('&Org_Id'); p_cust_account_rec.account_name := '&Customer_Name'; p_cust_account_rec.created_by_module := 'TCA_EXAMPLE'; p_person_rec.person_first_name := '&First_Name'; p_person_rec.person_last_name := '&Last_Name'; hz_cust_account_v2pub.create_cust_account( 'T', p_cust_account_rec, p_person_rec, p_customer_profile_rec, 'F', x_cust_account_id, x_account_number, x_party_id, x_party_number, x_profile_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '|| SUBSTR (x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Party Id = '||TO_CHAR(x_party_id)); dbms_output.put_line('Party Number = '||x_party_number); dbms_output.put_line('Profile Id = '||TO_CHAR(x_profile_id)); dbms_output.put_line('x_msg_data = '|| SUBSTR (x_msg_data,1,255)); IF x_msg_count >1 THEN

    FOR I IN 1..x_msg_count LOOP dbms_output.put_line(I||'. '|| SUBSTR (FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); END LOOP;

    END IF; END;

    Documentation on using TCA APIs - V2 Page 17

  • Sample Output of the Create Person Script x_return_status = S x_msg_count = 0 Party Id = 7860 Party Number = 6245 Profile Id = 4955 x_msg_data = Script To Verify whether the Create Person API is successful SELECT party_id, SUBSTR (party_number,1,5), SUBSTR (party_name,1,20), SUBSTR (person_last_name,1,20), SUBSTR(person_first_name,1,20), SUBSTR (object_version_number,1,1), SUBSTR (created_by_module,1,25) FROM hz_parties WHERE party_id = '7860';

    Party_id = 7860 Party_number = 6245 Party_name = Oracle India Person_last_name = India Person_first_name = Oracle Object_version_number = 1 Created_by_module = TCA_EXAMPLE

    SELECT person_profile_id, party_id, effective_start_date, object_version_number, SUBSTR (created_by_module,1,20) FROM hz_person_profiles WHERE person_profile_id = 4955;

    person_profile_id = 4955 party_id = 7860 effective_start_date = 12-MAY-02 object_version_number = 1 created_by_module = TCA_EXAMPLE

    Documentation on using TCA APIs - V2 Page 18

  • Example 3 : Running The Create Group API Name of the API : CREATE GROUP API Base Tables Affected : HZ_PARTIES PL/SQL Procedure used : CREATE_GROUP Package Used : HZ_PARTY_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_group_rec IN GROUP_REC_TYPE x_party_id OUT NUMBER x_party_number OUT VARCHAR2 x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_group ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_group_rec IN GROUP_REC_TYPE, x_party_id OUT NUMBER, x_party_number OUT VARCHAR2, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Group API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN create_party_group.txt) b) Enter the values for the Parameters from inside the script file itself unless it is

    required to Enter some value from the SQL Prompt. c) Set the organization id before running the script as :

    EXEC fnd_client_info.set_org_context(''); d) Ensure that the Profile Option HZ : Generate Party Number is Set to Yes

    at Site Level. Code for Create Group API DECLARE

    p_group_rec HZ_PARTY_V2PUB.GROUP_REC_TYPE; x_party_id NUMBER; x_party_number VARCHAR2(2000); x_return_status VARCHAR2(2000);

    Documentation on using TCA APIs - V2 Page 19

  • x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN Fnd_client_info.set_org_context(&Org_Id); P_group_rec.group_name := &Group_Name; P_group_rec.group_type := &Group_Type; p_group_rec.created_by_module := 'TCA_EXAMPLE'; hz_party_v2pub.create_group( T, p_group_rec, x_party_id, x_party_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line(x_return_status = ||SUBSTR(x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(Party Id = ||TO_CHAR(x_party_id)); dbms_output.put_line(Party Number = ||x_party_number); dbms_output.put_line(Group Name = ||SUBSTR (p_group_rec.group_name,1,50)); dbms_output.put_line(x_msg_data = ||SUBSTR (x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP dbms_output.put_line(I||. ||SUBSTR (FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); END LOOP; END IF;

    END; Sample Output of the Create Group Script x_return_status = S x_msg_count = 0 Party Id = 7861 Party Number = 6246 Group Name = ISC Group x_msg_data =

    Script To Verify whether the Create Group API is successful SELECT party_id, SUBSTR (party_number,1,5), SUBSTR(party_name,1,20), SUBSTR (object_version_number,1,1), SUBSTR (created_by_module,1,25) FROM hz_parties WHERE party_id = 7861; Party_id = 7861

    Party_number = 6246 Party_name = ISC Group Obj_ver = 1

    Documentation on using TCA APIs - V2 Page 20

  • Created_by_module = TCA_EXAMPLE

    Documentation on using TCA APIs - V2 Page 21

  • Example 4 : Create Org Contact API Name of the API : CREATE ORG CONTACT Base Tables Affected : HZ_ORG_CONTACTS HZ_RELATIONSHIPS PL/SQL Procedure used : CREATE_ORG_CONTACT Package Used : HZ_PARTY_CONTACT_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_org_contact_rec IN ORG_CONTACT_REC_TYPE x_org_contact_id OUT NUMBER x_party_rel_id OUT NUMBER x_party_id OUT NUMBER x_party_number OUT VARCHAR2 x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_org_contact ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_org_contact_rec IN ORG_CONTACT_REC_TYPE, x_org_contact_id OUT NUMBER, x_party_rel_id OUT NUMBER, x_party_id OUT NUMBER, x_party_number OUT VARCHAR2, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Organization Contact API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN contactphone.txt) b) To get the value for Department Parameter run the query:

    SELECT DISTINCT department FROM hz_org_contacts; To get the value for Job Title Parameter run the query : SELECT DISTINCT job_title FROM hz_org_contacts; To get the Decision Make Flag Parameter run the query : SELECT DISTINCT decision_maker_flag FROM hz_org_contacts; To get the Job Title Code Parameter run the query:

    Documentation on using TCA APIs - V2 Page 22

  • SELECT DISTINCT job_title_code FROM hz_org_contacts; To get the Subject Id Parameter run the query: SELECT subject_id FROM hz_relationships; To get the Subject Type Parameter run the query: SELECT DISTINCT subject_type FROM hz_relationships; To get the Object Id Parameter run the query: SELECT DISTINCT object_id FROM hz_relationships; To get the Object Type Parameter run the query: SELECT DISTINCT object_type FROM hz_relationships; To get the Relationship Code Parameter run the query: SELECT DISTINCT relationship_code FROM hz_relationships; To get the Relationship Type Parameter run the query : SELECT DISTINCT relationship_type FROM hz_relationships;

    c) Set the organization id before running the script as : EXEC fnd_client_info.set_org_context('');

    Example For Running a Create Org Contact API DECLARE

    p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE; x_org_contact_id NUMBER; x_party_rel_id NUMBER; x_party_id NUMBER; x_party_number VARCHAR2(2000); x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN p_org_contact_rec.department_code := INITCAP(&Department_Code); p_org_contact_rec.job_title := INITCAP(&Job_Title); p_org_contact_rec.decision_maker_flag := UPPER(&Decision_Maker_Flag); p_org_contact_rec.job_title_code := UPPER(&Job_Title_Code); p_org_contact_rec.created_by_module := 'TCA_EXAMPLE'; p_org_contact_rec.party_rel_rec.subject_id := &Subject_Id; p_org_contact_rec.party_rel_rec.subject_type := UPPER(&Subject_Type); p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES'; p_org_contact_rec.party_rel_rec.object_id := &Object_Id; p_org_contact_rec.party_rel_rec.object_type := UPPER(&Object_Type); p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES'; p_org_contact_rec.party_rel_rec.relationship_code := UPPER(&Relation_Code); p_org_contact_rec.party_rel_rec.relationship_type := UPPER(&Relation Type); p_org_contact_rec.party_rel_rec.start_date := SYSDATE; hz_party_contact_v2pub.create_org_contact( 'T', p_org_contact_rec, x_org_contact_id, x_party_rel_id,

    Documentation on using TCA APIs - V2 Page 23

  • x_party_id, x_party_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line(Subject Id=||p_org_contact_rec.party_rel_rec.subject_id); dbms_output.put_line(Subject Type=||UPPER(p_org_contact_rec.party_rel_rec.subject_Type)); dbms_output.put_line(Object Id=||p_org_contact_rec.party_rel_rec.object_id); dbms_output.put_line(Object Type=||UPPER(p_org_contact_rec.party_rel_rec.object_type)); dbms_output.put_line('x_msg_data = '||SUBSTR(x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP

    dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded =>FND_API.G_FALSE), 1, 255));

    END LOOP; END IF; END; Sample Output of the Create Org Contact Script old 11: p_org_contact_rec.department_code := INITCAP('&Department_Code'); new 11: p_org_contact_rec.department_code := INITCAP ('Finance'); old 12: p_org_contact_rec.job_title := INITCAP ('&Job_Title'); new 12: p_org_contact_rec.job_title := INITCAP ('Accounting Manager'); old 13: p_org_contact_rec.decision_maker_flag := UPPER('&Decision_Maker_Flag'); new 13: p_org_contact_rec.decision_maker_flag := UPPER('n'); old 14: p_org_contact_rec.job_title_code := UPPER('&Job_Title_Code'); new 14: p_org_contact_rec.job_title_code := UPPER('aps'); old 16: p_org_contact_rec.party_rel_rec.subject_id := &Subject_Id; new 16: p_org_contact_rec.party_rel_rec.subject_id := 1006; old 17: p_org_contact_rec.party_rel_rec.subject_type := UPPER('&Subject_Type'); new 17: p_org_contact_rec.party_rel_rec.subject_type := UPPER('organization'); old 19: p_org_contact_rec.party_rel_rec.object_id := &Object_Id; new 19: p_org_contact_rec.party_rel_rec.object_id := 3610; old 20: p_org_contact_rec.party_rel_rec.object_type := UPPER('&Object_Type'); new 20: p_org_contact_rec.party_rel_rec.object_type := UPPER('person');

    Documentation on using TCA APIs - V2 Page 24

  • old 22: p_org_contact_rec.party_rel_rec.relationship_code := UPPER('&Relation_Code); new 22: p_org_contact_rec.party_rel_rec.relationship_code := UPPER('contact'); x_return_status = S x_msg_count = 0 Subject Id=1006 Subject Type=ORGANIZATION Object Id=3610 Object Type=PERSON x_msg_data = Script To Verify whether the Org Contact Point API is successful SELECT org_contact_id, party_relationship_id, department_code FROM hz_org_contacts WHERE party_relationship_id = 3284 ;

    org_contact_id = 3248 party_relationship_id = 3284 department_code = FINANCE

    SELECT relationship_id, subject_id, subject_type, subject_table_name, object_id, object_type, directional_flag , relationship_type, relationship_code, party_id FROM hz_relationships WHERE relationship_id = 3284 ;

    relationship_id = 3284 subject_id = 3610 subject_type = person subject_table_name = HZ_PARTIES object_id = 1006 object_type = ORGANIZATION directional_flag = F relationship_type = EMPLOYMENT relationship_code = EMPLOYEE_OF party_id = 3611

    SELECT party_id, party_number, party_name, party_type FROM hz_parties WHERE Party_id = 3611;

    Party_id = 3611 Party_number = 3611 Party_name = Paul Cheng-Computer Service Party_type = PARTY_RELATIONSHIP

    Documentation on using TCA APIs - V2 Page 25

  • Example 5 : Create Location API Name of the API : CREATE LOCATION API Base Tables Affected : HZ_LOCATIONS PL/SQL Procedure used : CREATE_LOCATION Package Used : HZ_LOCATION_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_location_rec IN LOCATION_REC_TYPE x_location_id OUT NUMBER x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_location ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_location_rec IN LOCATION_REC_TYPE, x_location_id OUT NUMBER, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Location API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN createloc.txt) b) Enter the values for the Parameters from inside the script file itself unless it is

    required to Enter some value from the SQL Prompt c) Set the organization id before running the script as :

    EXEC fnd_client_info.set_org_context(''); d) Ensure that the Profile Option Default Country is Set to

    at Site Level.

    Documentation on using TCA APIs - V2 Page 26

  • Example For Running a Create Location API DECLARE

    P_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE; X_location_id number; X_return_status varchar2(2000); X_msg_count number; X_msg_data varchar2(2000);

    BEGIN p_location_rec.country := 'US'; p_location_rec.address1 := '4th Floor Cyber Towers'; p_location_rec.address2 := 'Hitec City'; p_location_rec.city := 'Madhapur'; p_location_rec.postal_code := '500083'; p_location_rec.state := 'Andhra Pradesh'; p_location_rec.created_by_module := 'TCA_EXAMPLE'; hz_location_v2pub.create_location( 'T', p_location_rec, x_location_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Location Id = '||TO_CHAR(x_location_id)); dbms_output.put_line('Country = '|| SUBSTR(p_location_rec.country,1,255)); dbms_output.put_line('Address1 = '|| SUBSTR(p_location_rec.Address1,1,255)); dbms_output.put_line('State = '|| SUBSTR(p_location_rec.state,1,255)); dbms_output.put_line('Created By = '|| SUBSTR(p_location_rec.created_by_module,1,255)); dbms_output.put_line('x_msg_data = '|| SUBSTR(x_msg_data,1,255)); IF x_msg_count > 1 THEN FOR I IN 1..x_msg_count LOOP

    dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded=> FND_API.G_FALSE ),1, 255)); END LOOP; END IF; END; Sample Output of the Create Location Script x_return_status = S x_msg_count = 0 Location Id = 3220 Country = US Address1 = 4th Floor Cyber Towers State = Andhra Pradesh Created By = TCA_EXAMPLE

    Documentation on using TCA APIs - V2 Page 27

  • x_msg_data = Script To Verify whether the Create Location API is successful SELECT SUBSTR(location_id,1,5), SUBSTR(address1,1,25), SUBSTR(address2,1,10), SUBSTR(city,1,10), SUBSTR(state,1,10), SUBSTR(Postal_code,1,7), SUBSTR(country,1,10), SUBSTR(object_version_number,1,1), SUBSTR(created_by_module,1,10) FROM hz_locations WHERE location_id = 3220;

    Location_id = 3220 Address1 = 4th Floor Cyber Towers Address2 = Hitec City City = Madhapur State = Andhara Pra Postal_code = 500083 Country = US Object_version_number = 1 Created_by_module = TCA_EXAMPLE

    Documentation on using TCA APIs - V2 Page 28

  • Example 6 : Update Location API Name of the API : UPDATE LOCATION API Base Tables Affected : HZ_LOCATIONS PL/SQL Procedure used : UPDATE_LOCATION Package Used : HZ_LOCATION_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_location_rec IN LOCATION_REC_TYPE p_object_version_number IN OUT NUMBER x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE update_location ( p_init_msg_list IN VARCHAR2:=FND_API.G_FALSE, p_location_rec IN LOCATION_REC_TYPE, p _ object_version_number IN OUT NUMBER, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Update Location API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN updateloc.txt) b) Enter the new value for the Parameters Address1 which has to be changed, from

    the SQL Prompt. c) Set the organization id before running the script as :

    EXEC fnd_client_info.set_org_context('');

    Documentation on using TCA APIs - V2 Page 29

  • Example For Running a Update Location API DECLARE

    p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE; p_object_version_number NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN p_location_rec.location_id := &Location_Id; p_location_rec.address2 := FND_API.G_MISS_CHAR; p_location_rec.address1 := '&New_Address1'; p_object_version_number := 1; hz_location_v2pub.update_location( 'T', p_location_rec, p_object_version_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Changed Address1 = '||SUBSTR(p_location_rec.address1,1,255)); dbms_output.put_line('x_msg_data = '||SUBSTR(x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP

    dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded=> FND_API.G_FALSE ), 1, 255)); END LOOP; END IF; END; Sample Output of the Update Location Script old 8: p_location_rec.location_id := &Location_Id; new 8: p_location_rec.location_id := 3211; Enter value for new_address1: 4th Floor Cyber Gateway old 10: p_location_rec.address1 := '&New_Address1'; new 10: p_location_rec.address1 := '4th Floor Cyber Gateway'; x_return_status = S x_msg_count = 0 Changed Address1 = 4th Floor Cyber Gateway x_msg_data = Script To Verify whether Update Location API is successful SELECT address1, address2, county, object_version_number

    Documentation on using TCA APIs - V2 Page 30

  • FROM hz_locations WHERE location_id = 3211; address1 = 4TH FLOOR CYBER GATEWAY address2 = county = TEST object_version_number = 2

    Documentation on using TCA APIs - V2 Page 31

  • Example 7 : Create Party Site API Name of the API : CREATE PARTY SITE Base Tables Affected : HZ_PARTY_SITES PL/SQL Procedure used : CREATE_PARTY_SITE Package Used : HZ_PARTY_SITE_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_party_site_rec IN PARTY_SITE_REC_TYPE x_party_site_id OUT NUMBER x_party_site_number OUT VARCHAR2 x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_party_site ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_party_site_rec IN PARTY_SITE_REC_TYPE, x_party_site_id OUT NUMBER, x_party_site_number OUT VARCHAR2, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Party Site API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN createpsite.txt) b) Enter the values for the Parameters Party Id and Location Id from the SQL

    prompt itself as hard coding these two parameters means the script has to be changed for the value of these two parameters each time a new Party Site is created.

    c) Enter the values for Party Id and Location Id as valid values from HZ_PARTIES and HZ_LOCATIONS respectively. SELECT party_id FROM hz_parties; SELECT location_id FROM hz_locations;

    d) Set the organization id inside the script as : EXEC fnd_client_info.set_org_context('');

    Documentation on using TCA APIs - V2 Page 32

  • Example For Running a Create Party Site API DECLARE

    p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE; x_party_site_id NUMBER; x_party_site_number VARCHAR2(2000); x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN p_party_site_rec.party_id := &Party_Id; p_party_site_rec.location_id := &Location_Id; p_party_site_rec.identifying_address_flag := 'Y'; p_party_site_rec.created_by_module := 'TCA_EXAMPLE'; hz_party_site_v2pub.create_party_site( 'T', p_party_site_rec, x_party_site_id, x_party_site_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Party Site Id = '||TO_CHAR(x_party_site_id)); dbms_output.put_line('Party Site Number = '||SUBSTR(x_party_site_number,1,255)); dbms_output.put_line('x_msg_data = '||SUBSTR(x_msg_data,1,255)); IF x_msg_count >1 THEN

    FOR I IN 1..x_msg_count LOOP dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded=> FND_API.G_FALSE), 1, 255)); END LOOP; END IF;

    END;

    Sample Output of the Create Party Site Script old 9: p_party_site_rec.party_id := &Party_Id; new 9: p_party_site_rec.party_id := 4102; old 10: p_party_site_rec.location_id := &Location_Id; new 10: p_party_site_rec.location_id := 3220; x_return_status = S x_msg_count = 0 Party Site Id = 3615 Party Site Number = 2248

    Documentation on using TCA APIs - V2 Page 33

  • x_msg_data = Script To Verify whether the Create Party Site API is successful SELECT SUBSTR(party_site_id,1,6), SUBSTR (party_id,1,5), SUBSTR (location_id,1,6), SUBSTR (party_site_number,1,7) FROM hz_party_sites WHERE party_site_id = 3615;

    party_site_id = 3615 party_id = 4102 location_id = 3220 party_site_number = 2248

    SELECT SUBSTR(ADDRESS1,1,20), SUBSTR(ADDRESS2,1,15), SUBSTR(CITY,1,10), SUBSTR(STATE,1,10), SUBSTR(POSTAL_CODE,1,6), SUBSTR(COUNTRY,1,10) FROM HZ_PARTIES WHERE PARTY_ID = 4102;

    address1 = 4th Floor Cyber Towe address2 = Hitec City city = Madhapur state = Andhra Pra postal_code = 500083 country = US

    Documentation on using TCA APIs - V2 Page 34

  • Example 8 : Create Party Site Use API Name of the API : CREATE PARTY SITE USE Base Tables Affected : HZ_PARTY_SITE_USES PL/SQL Procedure used : CREATE_PARTY_SITE_USE Package Used : HZ_PARTY_SITE_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_party_site_use_rec IN PARTY_SITE_USE_REC_TYPE x_party_site_use_id OUT NUMBER x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER Procedure

    PROCEDURE create_party_site_use ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_party_site_use_rec IN PARTY_SITE_USE_REC_TYPE, x_party_site_use_id OUT NUMBER, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Party Site Use API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN createpsiteuse.txt) b) Enter the values for the Parameters Party Site Use and Party Site Id from SQL

    Prompt itself as hard coding these two parameters means the script has to be changed for the value of these two parameters each time a new Party Site Use is created.

    c) The Parameter Party Site Use can be entered in either lower case or upper case as the system will take care of changing the case to upper. That is The Site use can be entered as bill_to or BILL_TO or Bill_To.

    d) Enter the value for Party Site Id as a valid value from HZ_PARTY_SITES table. SELECT party_site_id FROM hz_party_sites;

    e) Set the organization id before running the script as : EXEC fnd_client_info.set_org_context('');

    Example For Running a Create Party Site Use API DECLARE

    p_party_site_use_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_USE_REC_TYPE;

    Documentation on using TCA APIs - V2 Page 35

  • x_party_site_use_id NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN p_party_site_use_rec.site_use_type := upper('&Party_Site_Use'); p_party_site_use_rec.party_site_id := &Party_Site_Id; p_party_site_use_rec.created_by_module := 'TCA_EXAMPLE'; hz_party_site_v2pub.create_party_site_use( 'T', p_party_site_use_rec, x_party_site_use_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||substr(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Site Use Id = '||TO_CHAR(x_party_site_use_id)); dbms_output.put_line(SubStr('x_msg_data = '||x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP

    dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded=> FND_API.G_FALSE ), 1, 255));

    END LOOP; END IF; END; Sample Output of the Create Party Site Use Script old 8: p_party_site_use_rec.site_use_type := upper('&Party_Site_Use'); new 8: p_party_site_use_rec.site_use_type := upper('bill_to'); old 9: p_party_site_use_rec.party_site_id := &Party_Site_Id; new 9: p_party_site_use_rec.party_site_id := 3614; x_return_status = S x_msg_count = 0 Site Use Id = 2022 x_msg_data = Script To Verify whether the Create Party Site Use API is successful SELECT party_site_use_id, party_site_id, site_use_type, primary_per_type FROM hz_party_site_uses WHERE party_site_use_id = 2022;

    party_site_use_id = 2022 party_site_id = 3614 use_type = BILL_TO primary_per_type = Y

    Documentation on using TCA APIs - V2 Page 36

  • Example 9 : Create Party Site API

    Name of the API : CREATE CONTACT POINT Base Tables Affected : HZ_CONTACT_POINTS PL/SQL Procedure used : CREATE_CONTACT_POINT Package Used : HZ_CONTACT_POINT_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type

    p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_contact_point_rec IN CONTACT_POINT_REC_TYPE p_edi_rec IN EDI_REC_TYPE:= G_MISS_EDI_REC p_email_rec IN EMAIL_REC_TYPE:= G_MISS_EMAIL_REC p_phone_rec IN PHONE_REC_TYPE:= G_MISS_PHONE_REC p_telex_rec IN TELEX_REC_TYPE:= G_MISS_TELEX_REC p_web_rec IN WEB_REC_TYPE:= G_MISS_WEB_REC x_contact_point_id OUT NUMBER x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_contact_point ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_contact_point_rec IN CONTACT_POINT_REC_TYPE, p_edi_rec IN EDI_REC_TYPE:= G_MISS_EDI_REC, p_email_rec IN EMAIL_REC_TYPE:= G_MISS_EMAIL_REC, p_phone_rec IN PHONE_REC_TYPE:= G_MISS_PHONE_REC, p_telex_rec IN TELEX_REC_TYPE:= G_MISS_TELEX_REC, p_web_rec IN WEB_REC_TYPE:= G_MISS_WEB_REC, x_contact_point_id OUT NUMBER, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Contact Point API (Phone) a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN contactphone.txt) b) Enter the values for the Parameters Primary Flag, Contact Point Purpose, Phone

    Area Code, Phone Country Code, Phone Number and Phone Line Type from SQL Prompt itself as hard coding these parameters means the script has to be changed for

    Documentation on using TCA APIs - V2 Page 37

  • the value of these parameters each time a new Contact Point ( Phone ) is created. c) The Parameter Primary Flag, Contact Point Purpose and Phone Line Type can be

    entered in either lower case or upper case as the system will take care of changing the case to upper.

    d) The values for owner_table_id and owner_table_name parameters can be seen from HZ_PARTIES table using the query : SELECT owner_table_id, owner_table_name FROM hz_contact_points WHERE owner_table_name LIKE %HZ_PARTIES%;

    e) Enter the value for phone_country_code as a valid value from from hz_phone_country_codes using the query : SELECT territory_code, phone_country_code FROM hz_phone_country_codes WHERE UPPER(territory_code) LIKE %US%;

    f) Enter the value of area code using the query : SELECT UPPER(area_code) FROM hz_timezone_mapping;

    g) Set the organization id before running the script as : EXEC fnd_client_info.set_org_context('');

    Example For Running a Create Contact Point API (Phone) DECLARE

    p_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE; p_edi_rec HZ_CONTACT_POINT_V2PUB.EDI_REC_TYPE; p_email_rec HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE; p_phone_rec HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE; p_telex_rec HZ_CONTACT_POINT_V2PUB.TELEX_REC_TYPE; p_web_rec HZ_CONTACT_POINT_V2PUB.WEB_REC_TYPE; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); x_contact_point_id NUMBER;

    BEGIN p_contact_point_rec.contact_point_type := 'PHONE'; p_contact_point_rec.owner_table_name := 'HZ_PARTIES'; p_contact_point_rec.owner_table_id := '3804'; p_contact_point_rec.primary_flag := UPPER('&Primary_Flag'); p_contact_point_rec.contact_point_purpose := UPPER('&Contact_Purpose'); p_phone_rec.phone_area_code := '&Phone_Area_Code'; p_phone_rec.phone_country_code := UPPER('&Phone_Country_Code'); p_phone_rec.phone_number := '&Phone_Number'; p_phone_rec.phone_line_type := UPPER('&Phone_Line_Type'); p_contact_point_rec.created_by_module := 'TCA_EXAMPLE'; hz_contact_point_v2pub.create_contact_point( 'T', p_contact_point_rec, p_edi_rec, p_email_rec,

    Documentation on using TCA APIs - V2 Page 38

  • p_phone_rec, p_telex_rec, p_web_rec, x_contact_point_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line(SUBSTR('x_return_status = '||x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line(SUBSTR('x_msg_data = '||x_msg_data,1,255)); IF x_msg_count >1 THEN

    FOR I IN 1..x_msg_count LOOP dbms_output.put_line(I||'. '||SUBSTR(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); END LOOP; END IF; END;

    Sample Output of the Create Contact Point (Phone) Script old 16: p_contact_point_rec.primary_flag := UPPER('&Primary_Flag'); new 16: p_contact_point_rec.primary_flag := UPPER('y'); old 17: p_contact_point_rec.contact_point_purpose := UPPER('&Contact_Purpose'); new 17: p_contact_point_rec.contact_point_purpose := UPPER('business'); old 18: p_phone_rec.phone_area_code := '&Phone_Area_Code'; new 18: p_phone_rec.phone_area_code := '650';

    old 19: p_phone_rec.phone_country_code := UPPER('&Phone_Country_Code');

    new 19: p_phone_rec.phone_country_code := UPPER('1'); old 20: p_phone_rec.phone_number := '&Phone_Number'; new 20: p_phone_rec.phone_number := '7000-200'; old 21: p_phone_rec.phone_line_type := UPPER('&Phone_Line_Type'); new 21: p_phone_rec.phone_line_type := UPPER('gen'); x_return_status = S x_msg_count = 0 Contact Point Id = 6330 Phone Number = 7000-200 x_msg_data =

    Script To Verify whether the Contact Point API (Phone) is successful SELECT contact_point_id, contact_point_type, owner_table_name, owner_table_id,

    Documentation on using TCA APIs - V2 Page 39

  • primary_flag, phone_area_code, phone_country_code, phone_number, phone_line_type, raw_phone_number FROM hz_contact_points WHERE contact_point_id = 6330 ;

    contact_point_id = 6330 contact_point_phone = PHONE owner_table_name = HZ_PARTIES owner_table_id = 3804 primary_flag = Y phone_area_code = 650 phone_country_code = 1 phone_number = 7000-200 phone_line_type = GEN raw_phone_num = 650-7000-200

    Documentation on using TCA APIs - V2 Page 40

  • Example 10 : Create Relationship Type API Name of the API : CREATE RELATIONSHIP TYPE Base Tables Affected : HZ_RELATIONSHIP_TYPES PL/SQL Procedure used : CREATE_RELATIONSHIP_TYPE Package Used : HZ_RELATIONSHIP_TYPE_V2PUB Mandatory Parameters :

    Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_relationship_type_rec IN RELATIONSHIP_TYPE_REC_TYPE x_relationship_type_id OUT NUMBER x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_relationship_type ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_relationship_type_rec IN RELATIONSHIP_TYPE_REC_TYPE, x_relationship_type_id OUT NUMBER, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Relationship Type API a) Save the API in a script file and then run the script from the SQL Prompt

    1. (Example : RUN createrelationtype.txt) b) The Value for Organization Id is accepted as a Parameter. c) Enter the Values of the Parameters :

    Relationship_Type, Forward_Relationship_Code, Backward_Relationship_Code, Direction_Code, Subject_Type, Object_Type, Created_By_Moudle either from inside the API or at the SQL Prompt.

    i. The value for Parameter Relationship_Type should be one of the Values defined for the Look Up Code PARTY_RELATIONS_TYPE .

    ii. The Value for Parameter Forward_Relationship_Code should be one of the Values for the Look Up Code PARTY_RELATIONS_TYPE .

    Documentation on using TCA APIs - V2 Page 41

  • iii. The Value for Parameter Backward_Relationship_Code should be one of the Values for the Look Up Code PARTY_RELATIONS_TYPE .

    iv. The Value of Direction_Code should be either : P - Parent, C Child, N Non-Directional.

    v. If the values of the parameters Forward_Relationship_Code and Backward_Relationship_Code are same then the Direction_Code should be N only.

    vi. The Value for Parameter Subject_Type should be one of the Values from the Column INSTANCE_SET_NAME from the table FND_OBJECT_INSTANCE_SETS .

    vii. The Value for Parameter Object_Type should be one of the Values from the Column INSTANCE_SET_NAME from the table FND_OBJECT_INSTANCE_SETS .

    viii. The combination of relationship type, forward relationship code, backward relationship code, subject type, and object_type should be unique.

    ix. The combination of forward relationship code, subject type, and object type should be able to identify an unique backward relationship code. Thus, a second record with same combination of these three should have same backward relationship code.

    x. The direction code will be used to determine if a backward relationship type should be created. If the direction code is P or C, we will create a second relationship type. If the forward relationship code is the same as the backward relationship code, the direction code should be N - Non directional.

    General Tips for Running the Create Relationship Type API DECLARE

    p_relationship_type_rec_type HZ_RELATIONSHIP_TYPE_V2PUB.RELATIONSHIP_TYPE_REC_TYPE; x_relationship_type_id NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN fnd_client_info.set_org_context('&Org_Id'); p_relationship_type_rec_type.relationship_type := upper('&Relationship_Type'); p_relationship_type_rec_type.forward_rel_code := upper('&Forward_Relationship_Code'); p_relationship_type_rec_type.backward_rel_code := upper('&Backward_Relationship_Code'); p_relationship_type_rec_type.direction_code := upper('&Rel_Direction'); p_relationship_type_rec_type.subject_type := upper('&Subject_Type'); p_relationship_type_rec_type.object_type := upper('&Object_Type'); p_relationship_type_rec_type.created_by_module := 'TCA_Example'; hz_relationship_type_v2pub.create_relationship_type( 'T', p_relationship_type_rec_type, x_relationship_type_id, x_return_status,

    Documentation on using TCA APIs - V2 Page 42

  • x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Relationship Id ='||TO_CHAR(x_relationship_type_id)); dbms_output.put_line('x_msg_data = '||SUBSTR(x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP dbms_output.put_line(I||'. '||SUBSTR(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); END LOOP; END IF;

    END; Sample Output of the Create Relationship Type Script Enter value for org_id: 204 old 9: fnd_client_info.set_org_context('&Org_Id'); new 9: fnd_client_info.set_org_context('204'); Enter value for relationship_type: contact old 10: p_relationship_type_rec_type.relationship_type := UPPER('&Relationship_Type'); new 10: p_relationship_type_rec_type.relationship_type := UPPER ('contact'); Enter value for forward_relationship_code: contact_of old 11: p_relationship_type_rec_type.forward_rel_code := UPPER ('&Forward_Relationship_Code'); new 11: p_relationship_type_rec_type.forward_rel_code := UPPER ('contact_of'); Enter value for backward_relationship_code: contact_of old 12: p_relationship_type_rec_type.backward_rel_code := UPPER ('&Backward_Relationship_Code'); new 12: p_relationship_type_rec_type.backward_rel_code := UPPER ('contact_of'); Enter value for rel_direction: n old 13: p_relationship_type_rec_type.direction_code := UPPER ('&Rel_Direction'); new 13: p_relationship_type_rec_type.direction_code := UPPER ('n'); Enter value for subject_type: organization old 14: p_relationship_type_rec_type.subject_type := UPPER ('&Subject_Type'); new 14: p_relationship_type_rec_type.subject_type := UPPER ('organization'); Enter value for object_type: organization old 15: p_relationship_type_rec_type.object_type := UPPER ('&Object_Type'); new 15: p_relationship_type_rec_type.object_type := UPPER ('organization'); x_return_status = S x_msg_count = 0 Relationship Id =1024

    Documentation on using TCA APIs - V2 Page 43

  • x_msg_data = Script To Verify whether Create Relationship Type API is successful SELECT relationship_type_id, relationship_type, forward_rel_code, backward_rel_code, direction_code, subject_type, object_type, status, created_by_module FROM hz_relationship_types WHERE relationship_type_id = '1024';

    relationship_type_id = 1024 relationship_type = CONTACT forward_rel_code = CONTACT_OF backward_rel_code = CONTACT_OF direction_code = N subject_type = ORGANIZATION object_type = ORGANIZATION status = A created_by_module = TCA_EXAMPLE

    Documentation on using TCA APIs - V2 Page 44

  • Example 11 : Create Relationship API Name of the API : CREATE RELATIONSHIP Base Tables Affected : HZ_RELATIONSHIPS PL/SQL Procedure used : CREATE_RELATIONSHIP Package Used : HZ_RELATIONSHIP_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_relationship_rec IN RELATIONSHIP_REC_TYPE x_relationship_id OUT NUMBER x_party_id OUT NUMBER x_party_number OUT VARCHAR2 x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 Procedure

    PROCEDURE create_relationship ( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_relationship_rec IN RELATIONSHIP_REC_TYPE, x_relationship_id OUT NUMBER, x_party_id OUT NUMBER, x_party_number OUT VARCHAR2, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Relationship API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN createrelation.txt) b) The Value for Organization is accepted as a Parameter. c) Enter the Values of the Parameters :

    Relationship_Type, Relationship_Code, Subject_Id, Subject_Table_Name, Subject_Type, Object_Id, Object_Table_Name, Object_Type, Start_Date,

    Documentation on using TCA APIs - V2 Page 45

  • Created_By_Moudle either from inside the API or at the SQL Prompt.

    i. The value for Parameter Relationship_Type should be one of the Values defined for the Look Up Code PARTY_RELATIONS_TYPE .

    ii. The Value for Parameter Relationship_Code should be one of the Values for the Look Up Code PARTY_RELATIONS_TYPE .

    iii. The Value for Parameter Subject_Id should be one of the Values from the Column Object_Id in FND_OBJECT_INSTANCE_SETS .

    iv. The Value for Parameter Subject_Table_Name should be one of the values from the Column Obj_Name from table FND_OBJECTS.

    v. The Value for Parameter Subject_Type should be one of the Values from the Column INSTANCE_SET_NAME from the table FND_OBJECT_INSTANCE_SETS .

    vi. The Value for Parameter Object_Id should be one of the Values from the Column Object_Id from table FND_OBJECTS.

    vii. The Value for Parameter Object_Table_Name should be one of the Values from the Column Obj_Name from table FND_OBJECTS.

    viii. The Value for Parameter Object_Type should be one of the Values from the Column INSTANCE_SET_NAME from the table FND_OBJECT_INSTANCE_SETS .

    ix. When user call the create relationship procedure, two new records will be created in HZ_RELATIONSHIPS table.

    x. Users are required to specify a subject id, an object id, a subject type, an object type, a subject table name (where the subject belongs to, for example, HZ_PARTIES for subject type of PERSON, ORGANIZATION), an object table name, a relationship type, a relationship code, and start date to create a relationship.

    xi. The relationship code must be either a forward or backward relationship code defined in active records in the HZ_RELATIONSHIP_TYPES table for the relationship type.

    xii. The end date will be default to '31-DEC-4712' if not specified. The end date must be greater than the start date.

    xiii. For a given subject_id, object_id, relationship_code, there can be no overlap of the start date and the end date.

    xiv. The subject type and the object type will be used to do the foreign key check for the subject id and the object id column. The subject id should be a valid object instance defined in the object instance set which is specified as the subject type. The object id should be a valid object instance defined in the object instance set which is specified as the object type.

    xv. The subject id and the object id cannot be the same value unless the self related flag of the relationship type is set to yes.

    xvi. It will check the denormalized to party flag in the HZ_RELATIONSHIP_ TYPES table to see if a denormalized party is necessary. If the flag is set to yes, a party will be created for the relationship. Only the relationship with both subject_table_name and object_table_name as 'HZ_PARTIES' can be denormalized to HZ_PARTIES table.

    xvii. A record will be created in the HZ_RELATIONSHIPS table with the relationship

    Documentation on using TCA APIs - V2 Page 46

  • code Entered as input parameter. xviii. It will find the 2 nd relationship code from the HZ_RELATIONSHIP_TYPES

    table, and use it to create a second relationship. The 2 nd relationship will have the same relationship_id and party_id as the first relationship. The requested relationship will be created with directional_code value F (meaning forward) and the reciprocal relationship will be created with directional_code value B (meaning backward).

    Example For Running Create Relationship API DECLARE

    p_relationship_rec_type HZ_RELATIONSHIP_V2PUB.RELATIONSHIP_REC_TYPE; x_relationship_id NUMBER; x_party_id NUMBER; x_party_number VARCHAR2(2000); x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN fnd_client_info.set_org_context('&Org_Id'); p_relationship_rec_type.relationship_type := UPPER('&Relationship_Type'); p_relationship_rec_type.relationship_code := UPPER ('&Relationship_Code'); p_relationship_rec_type.subject_id := '&Subject_Id'; p_relationship_rec_type.subject_table_name := UPPER ('&Subject_Table_Name'); p_relationship_rec_type.subject_type := UPPER ('&Subject_Type'); p_relationship_rec_type.object_id := '&Object_Id'; p_relationship_rec_type.object_table_name := UPPER ('&Object_Table_Name'); p_relationship_rec_type.object_type := UPPER ('&Object_Type'); p_relationship_rec_type.start_date := '&Start_Date'; p_relationship_rec_type.created_by_module := 'TCA_Example'; hz_relationship_v2pub.create_relationship( 'T', p_relationship_rec_type, x_relationship_id, x_party_id, x_party_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '|| SUBSTR (x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Relationship Id ='||TO_CHAR(x_relationship_id)); dbms_output.put_line('Party Id = '||TO_CHAR(x_party_id)); dbms_output.put_line('Party Number = '|| SUBSTR (x_party_number,1,255)); dbms_output.put_line('x_msg_data = '|| SUBSTR (x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP

    Documentation on using TCA APIs - V2 Page 47

  • dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded=> FND_API.G_FALSE ), 1, 255)); END LOOP; END IF;

    END; Sample Output of the Create Relationship Script Enter value for org_id: 204 old 11: fnd_client_info.set_org_context('&Org_Id'); new 11: fnd_client_info.set_org_context('204'); Enter value for relationship_type: contact old 12: p_relationship_rec_type.relationship_type := UPPER('&Relationship_Type'); new 12: p_relationship_rec_type.relationship_type := UPPER ('contact'); Enter value for relationship_code: contact_of old 13: p_relationship_rec_type.relationship_code := UPPER ('&Relationship_Code'); new 13: p_relationship_rec_type.relationship_code := UPPER ('contact_of'); Enter value for subject_id: 3906 old 14: p_relationship_rec_type.subject_id := '&Subject_Id'; new 14: p_relationship_rec_type.subject_id := '3906'; Enter value for subject_table_name: hz_parties old 15: p_relationship_rec_type.subject_table_name := UPPER ('&Subject_Table_Name') new 15: p_relationship_rec_type.subject_table_name := UPPER ('hz_parties'); Enter value for subject_type: person old 16: p_relationship_rec_type.subject_type := UPPER ('&Subject_Type'); new 16: p_relationship_rec_type.subject_type := UPPER ('person'); Enter value for object_id: 3903 old 17: p_relationship_rec_type.object_id := '&Object_Id'; new 17: p_relationship_rec_type.object_id := '3903'; Enter value for object_table_name: hz_parties old 18: p_relationship_rec_type.object_table_name := UPPER ('&Object_Table_Name'); new 18: p_relationship_rec_type.object_table_name := UPPER ('hz_parties'); Enter value for object_type: person old 19: p_relationship_rec_type.object_type := UPPER ('&Object_Type'); new 19: p_relationship_rec_type.object_type := UPPER ('person'); Enter value for start_date: 01-JAN-1952 old 20: p_relationship_rec_type.start_date := '&Start_Date'; new 20: p_relationship_rec_type.start_date := '01-JAN-1952';

    Documentation on using TCA APIs - V2 Page 48

  • x_return_status = S x_msg_count = 0 Relationship Id =3593 Party Id = 3949 Party Number = 1881 x_msg_data = Script To Verify whether Create Relationship API is successful SELECT relationship_id, subject_id, subject_type, subject_table_name, object_id, object_type, object_table_name, relationship_code, relationship_type, start_date FROM hz_relationships WHERE relationship_id = 3593;

    Relationship_id = 3593 Subject_id = 3903 Subject_type = PERSON Subject_table_name = HZ_PARTIES Object_id = 3906 Object_type = PERSON Object_table_name = HZ_PARTIES Relationship_code = CONTACT Relationship_type = CONTACT Start_date = 01-JAN-52

    Relationship_id = 3593 Subject_id = 3906 Subject_type = person Subject_table_name = HZ_PARTIES Object_id = 3903 Object_type = PERSON Object_table_name = HZ_PARTIES Relationship_code = CONTACT Relationship_type = CONTACT Start_date = 01-JAN-52

    Documentation on using TCA APIs - V2 Page 49

  • Example 12 : Create Class Category API Name of the API : CREATE CLASS CATEGORY Base Tables Affected : HZ_CLASS_CATEGORIES PL/SQL Procedure used : CREATE_CLASS_CATEGORY Package Used : HZ_CLASSIFICATION_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_class_category_rec IN CLASS_CATEGORY_REC_TYPE x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2

    Procedure PROCEDURE create_class_category( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_class_category_rec IN CLASS_CATEGORY_REC_TYPE, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2 )

    General Tips for Running the Create Class Category API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN create_class_category.txt) b) The Value for Organization Id is accepted as a Parameter. c) Enter the values for the Parameters :

    Class_Category Allow_Multi_Parent_Flag Allow_Multi_Assign_Flag Allow_Leaf_Node_Flag

    from the SQL Prompt. The Value of the Parameter Class_Category must belong to a Lookup Code YES/NO. The Value for Parameter Allow_Multi_Parent_Flag must belong to a Lookup Code YES/NO. The Value for Parameter Allow_Leaf_Node_Flag must belong to a Lookup Code YES/NO.

    Example For Running Create Class Category API DECLARE

    Documentation on using TCA APIs - V2 Page 50

  • p_class_category_rec HZ_CLASSIFICATION_V2PUB.CLASS_CATEGORY_REC_TYPE; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000);

    BEGIN fnd_client_info.set_org_context('&Org_Id'); p_class_category_rec.class_category := UPPER('&Class_Category'); p_class_category_rec.allow_multi_assign_flag := UPPER ('&Multi_Assign_Flag'); p_class_category_rec.allow_multi_parent_flag := UPPER ('&Multi_Parent_Flag'); p_class_category_rec.allow_leaf_node_only_flag := UPPER ('&Leaf_Node_Flag'); p_class_category_rec.created_by_module := 'TCA_Example'; hz_classification_v2pub.create_class_category( 'T', p_class_category_rec, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Class Category = '||p_class_category_rec.class_category); dbms_output.put_line('Allow Multi Parent Flag = '||p_class_category_rec.allow_multi_parent_flag); dbms_output.put_line('x_msg_data = '|| SUBSTR (x_msg_data,1,255)); IF x_msg_count >1 THEN FOR I IN 1..x_msg_count LOOP dbms_output.put_line(I||'.'||SUBSTR(FND_MSG_PUB.Get(p_encoded=> FND_API.G_FALSE ), 1, 255)); END LOOP; END IF;

    END; Sample Output of the Create Class Category Script Enter value for org_id: 204 old 8: fnd_client_info.set_org_context('&Org_Id'); new 8: fnd_client_info.set_org_context('204'); Enter value for class_category: account_classes old 9: p_class_category_rec.class_category := UPPER('&Class_Category'); new 9: p_class_category_rec.class_category := UPPER ('account_classes'); Enter value for multi_assign_flag: y old 10: p_class_category_rec.allow_multi_assign_flag := UPPER ('&Multi_Assign_Flag'); new 10: p_class_category_rec.allow_multi_assign_flag := UPPER ('y'); Enter value for multi_parent_flag: y old 11: p_class_category_rec.allow_multi_parent_flag := UPPER ('&Multi_Parent_Flag');

    Documentation on using TCA APIs - V2 Page 51

  • new 11: p_class_category_rec.allow_multi_parent_flag := UPPER ('y'); Enter value for leaf_node_flag: y old 12: p_class_category_rec.allow_leaf_node_only_flag := UPPER ('&Leaf_Node_Flag'); new 12: p_class_category_rec.allow_leaf_node_only_flag := UPPER ('y'); x_return_status = S x_msg_count = 0 Class Category = ACCOUNT_CLASSES Allow Multi Parent Flag = Y x_msg_data = Script To Verify whether the Create Class Category API is successful SELECT Class_Category, Allow_Multi_Parent_Flag, Allow_Multi_Assign_Flag, Allow_Leaf_Node_Only_Flag FROM hz_class_categories WHERE class_category = Account_Classes;

    class_category = ACCOUNT_CLASSES allow_multi_parent_flag = Y allow_multi_assign_flag = Y allow_leaf_node_only_flag = Y

    Documentation on using TCA APIs - V2 Page 52

  • Example 13 : Create Code Assignment API Name of the API : CREATE CODE ASSIGNMENT Base Tables Affected : HZ_CODE_ASSIGNMENTS PL/SQL Procedure used : CREATE_CODE_ASSIGNMENT Package Used : HZ_CLASSIFICATION_V2PUB Mandatory Parameters : Parameter Name Parameter Type Data Type p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE p_code_assignment_rec IN CODE_ASSIGNMENT_REC_TYPE x_return_status OUT VARCHAR2 x_msg_count OUT NUMBER x_msg_data OUT VARCHAR2 x_code_assignment_id OUT NUMBER Procedure

    PROCEDURE create_code_assignment( p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE, p_code_assignment_rec IN CODE_ASSIGNMENT_REC_TYPE, x_return_status OUT VARCHAR2, x_msg_count OUT NUMBER, x_msg_data OUT VARCHAR2, x_code_assignment_id OUT NUMBER )

    General Tips for Running the Create Code Assignment API a) Save the API in a script file and then run the script from the SQL Prompt

    (Example : RUN create_code_assignment.txt) b) The Value for Organization Id is accepted as a Parameter. c) Enter the values for the Parameters :

    Owner_Table_Name Owner_Table_Id Class_Category Class_Code Primary_Flag Start_Date from the SQL Prompt.

    i. The Value of the Parameter Owner_Table_Name must belong to a Lookup Code Code_Assign_Owner_Table.

    ii. The Value for Parameter Owner_Table_Id must belong to a Column value of the Table_Name selected in Owner_Table_Name.

    iii. For example if the value of the Parameter Owner_Table_Name is HZ_PARTIES then the

    Documentation on using TCA APIs - V2 Page 53

  • value of the Parameter Owner_Table_Id shall one of the values of the column PARTY_ID . iv. The Value for Parameter Class_Category must belong to the Column CLASS_CATEGORY

    from the table HZ_CLASS_CATEGORIES. v. The Value for Parameter Class_Code must be one of the values given

    for the Lookup Code selected in (iii) above. vi. The Value for Parameter Primary_Flag must be Validated against the LookUp Code YES_NO .

    Example For Running Create Code Assignment API DECLARE

    p_code_assignment_rec_type HZ_CLASSIFICATION_V2PUB.CODE_ASSIGNMENT_REC_TYPE; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); x_code_assignment_id NUMBER;

    BEGIN fnd_client_info.set_org_context('&Org_Id'); p_code_assignment_rec_type.owner_table_name := UPPER('&Owner_Table_Name'); p_code_assignment_rec_type.owner_table_id := &Owner_Table_Id; p_code_assignment_rec_type.class_category := UPPER ('&Class_Category'); p_code_assignment_rec_type.class_code := UPPER ('&Class_Code'); p_code_assignment_rec_type.Primary_Flag := v('&Primary_Flag'); p_code_assignment_rec_type.start_date_active := '&Start_Date_Active'; p_code_assignment_rec_type.created_by_module := 'TCA_Example'; hz_classification_v2pub.create_code_assignment( 'T', p_code_assignment_rec_type, x_return_status, x_msg_count, x_msg_data, x_code_assignment_id); dbms_output.put_line('x_return_status = '||SUBSTR(x_return_status,1,255)); dbms_output.put_line('x_msg_count = '||TO_CHAR(x_msg_count)); dbms_output.put_line('Owner Ta