Thursday, March 10, 2016

API to Create a Customer Profile TCA R12 (HZ_CUSTOMER_PROFILE_V2PUB.CREATE_CUSTOMER_PROFILE)

API to Create a Customer Profile TCA R12 (HZ_CUSTOMER_PROFILE_V2PUB.CREATE_CUSTOMER_PROFILE)

                                                                                                        
DESCRIPTION: This routine is used to create aCustomer Profile. The API creates a record in the HZ_CUSTOMER_PROFILES table. The profile can be created at party level, at customer level, or at customer site level. It also creates profile amounts based on the value passed for p_create_profile_amt. If the credit_hold parameter value is Y, then records are inserted into OE_HOLD_SOURCES and OE_ORDER_HOLDS to keep these tables synchronized
API:   HZ_CUSTOMER_PROFILE_V2PUB.CREATE_CUSTOMER_PROFILE
BASE TABLES AFFECTED :  HZ_CUSTOMER_PROFILES
TEST INSTANCE : R12.1.3

SCRIPT:

SET SERVEROUTPUT ON;
DECLARE
p_customer_profile_rec_type HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_profile_id   NUMBER;
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_customer_profile_rec_type.cust_account_id   :=  150734;
p_customer_profile_rec_type.created_by_module := 'BO_API';

DBMS_OUTPUT.PUT_LINE('Calling the API hz_customer_profile_v2pub.create_customer_profile');

HZ_CUSTOMER_PROFILE_V2PUB.CREATE_CUSTOMER_PROFILE
                  (
                    p_init_msg_list             => FND_API.G_TRUE,
                    p_customer_profile_rec      => p_customer_profile_rec_type,
                    p_create_profile_amt        => FND_API.G_TRUE,
                    x_cust_account_profile_id   => x_cust_account_profile_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 Profile is Successful ');
    DBMS_OUTPUT.PUT_LINE('Output information ....');   
    dbms_output.put_line('Cust Account Id         = '||TO_CHAR(p_customer_profile_rec_type.cust_account_id));
    dbms_output.put_line('Cust Account Profile Id = '||TO_CHAR(x_cust_account_profile_id));
    dbms_output.put_line('Status                  = '||p_customer_profile_rec_type.status);
    dbms_output.put_line('Credit Checking         = '||p_customer_profile_rec_type.credit_checking);
    dbms_output.put_line('Interest Charges        = '||p_customer_profile_rec_type.interest_charges);
ELSE
    DBMS_OUTPUT.put_line ('Creation of Customer Profile 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;


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...