You are on page 1of 8

2.3.

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

The above API shall create an address record in hz_locations table.

2.3.1.3. Create a Party site

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;

2.3.1.5. Create a Contact Point ( of type Phone)


DECLARE p_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE; p_edi_rec HZ_CONTACT_POINT_V2PUB.EDI_REC_TYPE; p_email_rec HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE; p_phone_rec HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE;

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;

2.3.1.6. Create an Org Contact


DECLARE p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE; x_org_contact_id NUMBER; x_party_rel_id NUMBER; x_party_id NUMBER; x_party_number VARCHAR2(2000); x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); BEGIN p_org_contact_rec.department_code := ACCOUNTING; p_org_contact_rec.job_title := ACCOUNTS OFFICER; p_org_contact_rec.decision_maker_flag := Y; p_org_contact_rec.job_title_code := APC;

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.

2.3.1.8. Create a Cust Account Site using an Existing Party Site


DECLARE p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type; x_return_status VARCHAR2(2000); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); x_cust_acct_site_id NUMBER; BEGIN p_cust_acct_site_rec.cust_account_id := 3472; p_cust_acct_site_rec.party_site_id := 1024; p_cust_acct_site_rec.language := US; p_cust_acct_site_rec.created_by_module := TCA-EXAMPLE; hz_cust_account_site_v2pub.create_cust_acct_site( T, p_cust_acct_site_rec, x_cust_acct_site_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.9. Create a Customer A/C Site Use Code

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

HZ_PARTY_INFO_V2PUB.create_credit_rating JTF_RS_SALESREPS_PUB.CREATE_SALESREP JTF_RS_SRP_TERRITORIES_PUB.CREATE_RS_SRP_TERRITORIES HZ_CUST_ACCOUNT_ROLE_V2PUB.CREATE_CUST_ACCOUNT_ROLE HZ_CUST_ACCOUNT_ROLE_V2PUB.create_role_responsibility