Tuesday, March 8, 2011

hz_party_contact_v2pub.create_org_contact - API to create a Contact person for an organization in Oracle TCA

                                                                                                                        

API : hz_party_contact_v2pub.create_org_contact
TEST INSTANCE: R12.1.3
DETAILS OF THE ROUTINE:
This API is used to create a Contact person for an organization or person. The API creates a record in the HZ_ORG_CONTACTS table. It additionally creates a relationship record in the HZ_RELATIONSHIPS table using the contact person as the subject, the organization or person as object and relationship type and code passed by the caller. A reverse relationship record is also created at the same time. There is a de-normalized party record of type PARTY_RELATIONSHIP created for the relationship depending on relationship type set up for the relationship that is being used for the org contact.
NOTES:
  • Value for department_code must be a value defined in lookup type DEPARTMENT_TYPE
  • Subject_id. Please enter person id value from HZ_PARTIES
  • Object_id. Please enter organization id value from HZ_PARTIES
  • Check the HZ_RELATIONSHIP_TYPES Table for details related to relationship_type,relationship_code


SCRIPT:


SET SERVEROUTPUT ON;
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
-- Setting the Context --
mo_global.init('AR');
fnd_global.apps_initialize ( user_id      => 1318
                            ,resp_id      => 50559
                            ,resp_appl_id => 222);
mo_global.set_policy_context('S',204);
fnd_global.set_nls_context('AMERICAN');

-- Initializing the Mandatory API parameters
p_org_contact_rec.department_code                  := 'OPERATIONS';
p_org_contact_rec.job_title                        := 'Chief Financial';
p_org_contact_rec.decision_maker_flag              := 'Y';
p_org_contact_rec.job_title_code                   := 'CFO';
p_org_contact_rec.created_by_module                := 'BO_API';
p_org_contact_rec.party_rel_rec.subject_id         :=  530684;
p_org_contact_rec.party_rel_rec.subject_type       := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id          :=  530682;
p_org_contact_rec.party_rel_rec.object_type        := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name  := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code  := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type  := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date         :=  SYSDATE;

DBMS_OUTPUT.PUT_LINE('Calling the API hz_party_contact_v2pub.create_org_contact');

hz_party_contact_v2pub.create_org_contact
             (
              p_init_msg_list    => FND_API.G_TRUE,
              p_org_contact_rec  => p_org_contact_rec,
              x_org_contact_id   => x_org_contact_id,
              x_party_rel_id     => x_party_rel_id,
              x_party_id         => x_party_id,
              x_party_number     => x_party_number,
              x_return_status    => x_return_status,
              x_msg_count        => x_msg_count,
              x_msg_data         => x_msg_data
                   );



IF x_return_status = fnd_api.g_ret_sts_success THEN
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Creation of Org contact is Successful ');
    DBMS_OUTPUT.PUT_LINE('Output information ....');
    DBMS_OUTPUT.PUT_LINE('x_party_rel_id   = '||x_party_rel_id);
    DBMS_OUTPUT.PUT_LINE('x_org_contact_id = '||x_org_contact_id);
    DBMS_OUTPUT.PUT_LINE('x_party_id       = '||x_party_id);
    DBMS_OUTPUT.PUT_LINE('x_party_number   = '||x_party_number);
     
ELSE
    DBMS_OUTPUT.PUT_LINE ('Creation of Org Contact failed:'||x_msg_data);
    ROLLBACK;
    FOR i IN 1 .. x_msg_count
    LOOP
      x_msg_data := FND_msg_pub.get( p_msg_index => i, p_encoded => 'F');
      dbms_output.put_line( i|| ') '|| x_msg_data);
    END LOOP;
END IF;

DBMS_OUTPUT.PUT_LINE('Completion of API hz_party_contact_v2pub.create_org_contact');
END;
/

0 Responses to “hz_party_contact_v2pub.create_org_contact - API to create a Contact person for an organization in Oracle TCA”

Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.