API to create customer Addresses in TCA R12 (HZ_LOCATION_V2PUB.CREATE_LOCATION)

API to create customer Addresses in TCA R12 (HZ_LOCATION_V2PUB.CREATE_LOCATION)




                                                                                                                                 
Below wrapper script will help you create a valid Location in the table HZ_LOCATIONS.
Test Instance: R12.1.3
API: HZ_LOCATION_V2PUB.CREATE_LOCATION
Note: Value for created_by_module must be a value defined in lookup type HZ_CREATED_BY_MODULES in the tableFND_LOOKUP_VALUES

SCRIPT:
SET SERVEROUTPUT ON;
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          := 'Shareoracleapps';
 p_location_rec.city              := 'san Mateo';
 p_location_rec.postal_code       := '94401';
 p_location_rec.state             := 'CA';
 p_location_rec.created_by_module := 'BO_API';

 DBMS_OUTPUT.PUT_LINE('Calling the API hz_location_v2pub.create_location');

 HZ_LOCATION_V2PUB.CREATE_LOCATION
           (
             p_init_msg_list => FND_API.G_TRUE,
             p_location_rec  => p_location_rec,
             x_location_id   => x_location_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 Location is Successful ');
    DBMS_OUTPUT.PUT_LINE('Output information ....');
    DBMS_OUTPUT.PUT_LINE('x_location_id: '||x_location_id);
    DBMS_OUTPUT.PUT_LINE('x_return_status: '||x_return_status);
    DBMS_OUTPUT.PUT_LINE('x_msg_count: '||x_msg_count);
    DBMS_OUTPUT.PUT_LINE('x_msg_data: '||x_msg_data);   
ELSE
    DBMS_OUTPUT.put_line ('Creation of Location failed:'||x_msg_data);
    ROLLBACK;
    FOR i IN 1 .. x_msg_count
    LOOP
      x_msg_data := oe_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;
/


Post a Comment