Running the Create Organization API
Name of the API: CREATE ORGANIZATION API
Base Tables Affected: HZ_PARTIES
HZ_ORGANIZATION_PROFILES
PL/SQL Procedure used: CREATE_ORGANIZATION
Package Used: HZ_PARTY_V2PUB
Mandatory Parameters:p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE
p_organization_rec IN ORGANIZATION_REC_TYPE
x_return_status OUT VARCHAR2
x_msg_count OUT NUMBER
x_msg_data OUT VARCHAR2
x_party_id OUT NUMBER
x_party_number OUT VARCHAR2
x_profile_id OUT NUMBER
Procedure
PROCEDURE create_organization (
p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE,
p_organization_rec IN ORGANIZATION_REC_TYPE,
x_return_status OUT VARCHAR2,
x_msg_count OUT NUMBER,
x_msg_data OUT VARCHAR2,
x_party_id OUT NUMBER,
x_party_number OUT VARCHAR2,
x_profile_id OUT NUMBER
)
General Tips for Running the Create Organization API
a) Save the API in a script file and then run the script from the SQL Prompt (Example : RUN createorg.txt)
b) Enter the values for the Parameters from inside the script file itself unless it is required to Enter some value from the SQL Prompt.
c) Set the organization id before running the script as :
d) EXEC fnd_client_info.set_org_context('<orgid>');
Ensure that the Profile Option HZ : Generate Party Number is Set to ‘Yes’ at Site Level.
Code for Create Organization API
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 Corporation';
p_organization_rec.created_by_module := ’INDIA_ISC_ORGANIZATION’;
hz_party_v2pub.create_organization (’T’,
p_organization_rec,
x_return_status,
x_msg_count,
x_msg_data,
x_party_id,
x_party_number,
x_profile_id);
DBMS_OUTPUT.put_line (
'return_status=' || SUBSTR (x_return_status, 1, 255));
DBMS_OUTPUT.put_line ('count=' || TO_CHAR (x_msg_count));
DBMS_OUTPUT.put_line ('Msg_data = ' || SUBSTR (x_msg_data, 1, 255));
DBMS_OUTPUT.put_line ('Party Id=' || SUBSTR (x_party_id, 1, 255));
DBMS_OUTPUT.put_line ('Party_Number=' || SUBSTR (x_party_number, 1, 255));
DBMS_OUTPUT.put_line (
'Organization_Name='
|| SUBSTR (p_organization_rec.organization_name, 1, 255));
DBMS_OUTPUT.put_line (
'CreatedBy=' || SUBSTR (p_organization_rec.created_by_module, 1, 255));
DBMS_OUTPUT.put_line ('Profile Id=' || SUBSTR (x_profile_id, 1, 255));
IF x_msg_count > 1
THEN
FOR I IN 1 .. x_msg_count
LOOP
DBMS_OUTPUT.put_line (
'I.'
|| SUBSTR (FND_MSG_PUB.Get (p_encoded => FND_API.G_FALSE), 1, 255));
END LOOP;
END IF;
END;
Sample Output of the Create Organization Script
return_status=S
count=0
Msg_data =
Party Id=4104
Party_Number=2448
Organization_Name=New TCA Corporation
Created By=INDIA_ISC_ORGANIZATION
Profile Id=2021
Script To Verify whether the Create Organization API is successful
SELECT party_id,
SUBSTR (party_number, 1, 5),
SUBSTR (party_name, 1, 20),
SUBSTR (object_version_number, 1, 1),
SUBSTR (created_by_module, 1, 25)
FROM hz_parties
WHERE party_id = 4104;
party_id = 4104
party_number = 2448
party_name = 'New TCA Corporation'
obj_ver = 1
created_by_mod = INDIA_ISC_ORGANIZATION
SELECT organization_profile_id,
party_id,
organization_name,
object_version_number,
created_by_module
FROM hz_organization_profiles
WHERE party_id = 4104;
org_profile_id = 2021
party_id = 4104
organization_name = New TCA Corporation
obj_ver_num = 1
created_by_mod = INDIA_ISC_ORGANIZATION