Thursday, March 10, 2016

API to Create a Customer Site TCA R12 (HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE)

API to Create a Customer Site TCA R12 (HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE)


                                                                                                                                
DESCRIPTION:
This procedure creates a site for the customer account using an existing site.

API:   HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE
BASE TABLES AFFECTED :  HZ_CUST_ACCT_SITES
TEST INSTANCE : R12.1.3
NOTE:  
·         The language column is obsolete.  You are not allowed to pass a value to this column.
·         To Select the Customer Account Id run the query:
SELECT cust_account_id
FROM   hz_cust_accounts;
·         To Select the Party Site Id run the Query :
SELECT party_site_id
FROM   hz_party_sites;


SCRIPT:

SET SERVEROUTPUT ON;
DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
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_cust_acct_site_rec.cust_account_id   := 150734;
p_cust_acct_site_rec.party_site_id     := 291634;
p_cust_acct_site_rec.created_by_module := 'BO_API';

DBMS_OUTPUT.PUT_LINE('Calling the API hz_cust_account_site_v2pub.create_cust_acct_site');

HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE
                   (
                     p_init_msg_list         => FND_API.G_TRUE,
                     p_cust_acct_site_rec    => p_cust_acct_site_rec,
                     x_cust_acct_site_id     => x_cust_acct_site_id,
                     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 Customer Account Site is Successful ');
    DBMS_OUTPUT.PUT_LINE('Output information ....');    
    DBMS_OUTPUT.PUT_LINE('Customer Account Site Id is = '||x_cust_acct_site_id);   
ELSE
    DBMS_OUTPUT.put_line ('Creation of Customer Account Site got 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');
END;
/

VERIFICATION SCRIPT:
SELECT cust_acct_site_id,
       cust_account_id,
       party_site_id,
       org_id
FROM   hz_cust_acct_sites_all
WHERE  cust_acct_site_id = 1452;


No comments:

Post a Comment

How to improve blog performance

Improving the performance of a blog can involve a variety of strategies, including optimizing the website's technical infrastructure, im...