Professional Documents
Culture Documents
Customer API
2.3.1. Customer APIs
2.3.1.1. Create an Organization 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 := ABC Corporation; p_organization_rec.created_by_module := TCA_EXAMPLE; 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('party id '||x_party_id); dbms_output.put_line(SubStr(x_return_status = ||x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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;
The above API creates a record in hz_parties table and one record in hz_organization_profiles table. Similarly you can call hz_party_v2pub.create_person to create a record in the HZ_PARTIES and one record in HZ_PERSON_PROFILES tables.
2.3.1.2. Create a Location
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 := 300 Oracle Parkway; p_location_rec.address2 := 13th Floor; p_location_rec.city := Redwood Shores; p_location_rec.postal_code := 94065; p_location_rec.state := CA; p_location_rec.created_by_module := TCA_EXAMPLE; hz_location_v2pub.create_location( T, p_location_rec, x_location_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('location id '||x_location_id); dbms_output.put_line(SubStr(x_return_status = ||x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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
Use the organization_id and location_id created above and create a party site.
DECLARE p_party_site_rec HZ_PARTY_SITE_V2PU B.PARTY_SITE_REC_TYPE; x_party_site_id NUMBER; x_party_site_number VARCHAR2(2000); x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); BEGIN p_party_site_rec.party_id := 1272023; p_party_site_rec.location_id := 359086; p_party_site_rec.identifying_address_flag := Y; p_party_site_rec.created_by_module := TCA_EXAMPLE; hz_party_site_v2pub.create_party_site( T, p_party_site_rec, x_party_site_id, x_party_site_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line('party site id '||x_party_site_id);
dbms_output.put_line(SubStr(x_return_status = ||x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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;
The above API creates a record in hz_party_sites table. 2.3.1.4. Create a Party Site UseUsing the above party site create a party site use.
DECLARE p_party_site_use_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_USE_RE C_TYPE; x_party_site_use_id NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); BEGIN p_party_site_use_rec.site_use_type := SHIP_TO; p_party_site_use_rec.party_site_id := 349327; p_party_site_use_rec.created_by_module := TCA_EXAMPLE; hz_party_site_v2pub.create_party_site_use( T, p_party_site_use_rec, x_party_site_use_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line(SubStr(x_return_status = ||x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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;
p_telex_rec HZ_CONTACT_POINT_V2PUB.TELEX_REC_TYPE; p_web_rec HZ_CONTACT_POINT_V2PUB.WEB_REC_TYPE; x_return_status VARCHAR2(2000); x_msg_coun t NUMBER; x_msg_data VARCHAR2(2000); x_contact_point_id NUMBER; BEGIN p_contact_point_rec.contact_point_type := PHONE; p_contact_point_rec.owner_table_name := HZ_PARTIES; p_contact_point_rec.owner_table_id := 1272023; p_contact_point_rec.primary_flag := Y; p_contact_point_rec.contact_point_purpose := BUSINESS; p_phone_rec.phone_area_code := 650; p_phone_rec.phone_country_code := 1; p_phone_rec.phone_number := 506-7000; p_phone_rec.phone_line_type := GEN; p_contact_point_rec.created_by_module := TCA_EXAMPLE; hz_contact_point_v2pub.create_contact_point( T, p_contact_point_rec, p_edi_rec, p_email_rec, p_phone_rec, p_telex_rec, p_web_rec, x_contact_point_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line(SubStr(x_return_status = ||x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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;
p_org_contact_rec.created_by_module := TCA_EXAMPLE; p_org_contact_rec.party_rel_rec.subject_id := 16077; p_org_contact_rec.party_rel_rec.subject_type := PERSON; p_org_contact_rec.party_rel_rec.subject_table_name := HZ_PARTIES; p_org_contact_rec.party_rel_rec.object_id := 1272023; p_org_contact_rec.party_rel_rec.object_type := ORGANIZATION; p_org_contact_rec.party_rel_rec.object_table_name := HZ_PARTIES; p_org_contact_rec.party_rel_rec.relationship_code := CONTACT_OF; p_org_contact_rec.party_rel_rec.relationship_type := CONTACT; p_org_contact_rec.party_rel_rec.start_date := SYSDATE; hz_party_contact_v2pub.create_org_contact(T, p_org_contact_rec, x_org_contact_id, x_party_rel_id, x_party_id, x_party_number, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line(SubStr(x_return_status = ||x_return_status,1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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
The above API creates a record in hz_org_contacts table and one record in hz_relationships table. When a contact is created, a record in hz_parties table gets created with party_type as 'PARTY_RELATIONSHIP'. 2.3.1.7. Create a Customer Account
DECLARE p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE; p_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE; p_customer_profile_rec HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE REC_TYPE; x_cust_account_id NUMBER; x_account_number VARCHAR2(2000); x_party_id NUMBER; x_party_number VARCHAR2(2000); x_profile_id NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); BEGIN p_cust_account_rec.account_name := Johns A/c; p_cust_account_rec.created_by_module := TCA_EXAMPLE; p_person_rec.person_first_name := John; p_person_rec.person_last_name := Smith; hz_cust_account_v2pub.create_cust_account( T, p_cust_account_rec, p_person_rec, p_customer_profile_rec, F, x_cust_account_id, x_account_number, x_party_id, x_party_number, x_profile_id, x_return_status, x_msg_count, x_msg_data);
dbms_output.put_line(SubStr(x_return_status = ||x_return_status, 1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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;
This routine is used to create a Customer Account. The API creates a record in the HZ_CUST_ACCOUNTS table for party type Person or Organization. Account can be created for an existing party by passing party_id of the party. Alternatively, this routine creates a new party and an account for the party. Customer profile record in the HZ_CUSTOMER_PROFILES can also be created while calling this routine based on value passed in p_customer_profile_rec. The routine is overloaded for Person and Organization.
END;
DECLARE p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB. CUST_SITE_USE_REC_TYPE; p_customer_profile_rec HZ_CUSTOMER_PROFILE_V2PUB. CUSTOMER_PROFILE _REC_TYPE; x_site_use_id NUMBER; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); BEGIN p_cust_site_use_rec.cust_acct_site_id := 3580; p_cust_site_use_rec.site_use_code := INV; p_cust_site_use_rec.location := TCA; p_cust_site_use_rec.created_by_module := TCA_EXAMPLE; hz_cust_account_site_v2pub.create_cust_site_use( T, p_cust_site_use_rec, p_customer_profile_rec, , , x_site_use_id, x_return_status, x_msg_count, x_msg_data); dbms_output.put_line(SubStr(x_return_status = ||x_return_status, 1,255)); dbms_output.put_line(x_msg_count = ||TO_CHAR(x_msg_count)); dbms_output.put_line(SubStr(x_msg_data = ||x_msg_data,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;
2.3.1.10. Other Customer related APIs Org Contact Role Relationships Customer Profile Customer Profile Amount
Hz_party_contact_v2pub.Create_Org_Contact_Role HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCT_RELATE HZ_CUSTOMER_PROFILE_V2PUB. create_customer_profile HZ_CUSTOMER_PROFILE_V2PUB. create_cust_profile_amt
Customer Credit Rating Sales Person Sales reps Territories Customer contacts Customer Contact Role