Wednesday, March 30, 2016

Create Party of type Organization in Oracle TCA using API hz_party_v2pub.create_organization

                                                                                                         
Purpose of the API          : CREATE ORGANIZATION API
API Package Used            : HZ_PARTY_V2PUB
PL/SQL Procedure used : CREATE_ORGANIZATION
Base Tables Affected      : HZ_PARTIES , HZ_ORGANIZATION_PROFILES
Notes:
1.       Ensure that the Profile Option HZ : Generate Party Number is Set to ‘Yes’ at Site Level.
Value for created_by_module must be a value defined in lookup type HZ_CREATED_BY_MODULES in the table FND_LOOKUP_VALUES
SCRIPT:

SET SERVEROUTPUT ON;
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 Organization';
p_organization_rec.created_by_module := 'BO_API';

DBMS_OUTPUT.PUT_LINE('Calling the API hz_party_v2pub.create_organization');

hz_party_v2pub.create_organization
             (
              p_init_msg_list    => FND_API.G_TRUE,
              p_organization_rec => p_organization_rec,
              x_return_status    => x_return_status,
              x_msg_count        => x_msg_count,
              x_msg_data         => x_msg_data,
              x_party_id         => x_party_id,
              x_party_number     => x_party_number,
              x_profile_id       => x_profile_id
                   );

IF x_return_status = fnd_api.g_ret_sts_success THEN
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Creation of Organization is Successful ');
    DBMS_OUTPUT.PUT_LINE('Output information ....');
    DBMS_OUTPUT.PUT_LINE('Party Id         ='|| x_party_id);
    DBMS_OUTPUT.PUT_LINE('Party_Number     ='|| x_party_number);
    DBMS_OUTPUT.PUT_LINE('Profile Id       ='|| x_profile_id);
ELSE
    DBMS_OUTPUT.put_line ('Creation of Organization 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;
/

No comments:

Post a Comment

Types of animations

Animation is a diverse and creative field with a variety of styles that artists and filmmakers use to bring their visions to life. Here are ...