EBS - API创建客户联系人、联系方式和联系人职责

关于联系人和联系方式表结构的介绍,请参阅联系人数据结构联系方式数据结构

一、创建联系人

DECLARE
  x_person_party_id          NUMBER;
  x_person_party_number      NUMBER;
  x_org_contact_id           NUMBER;
  x_party_rel_id             NUMBER;
  x_org_contact_party_id     NUMBER;
  x_org_contact_party_number NUMBER;
  x_cust_account_role_id     NUMBER;
  x_profile_id               NUMBER;
  x_return_status            VARCHAR2(5);
  x_msg_data                 VARCHAR2(3000);

  l_person_rec hz_party_v2pub.person_rec_type;
  l_party_rec  hz_party_v2pub.party_rec_type;

  l_org_contact_rec hz_party_contact_v2pub.org_contact_rec_type;

  l_cr_cust_acc_role_rec hz_cust_account_role_v2pub.cust_account_role_rec_type;

  l_msg_count NUMBER;

  g_created_by_module VARCHAR2(20) := 'TCA_V2_API'; --注[1]
BEGIN
  fnd_global.apps_initialize(user_id      => 147026
                            ,resp_id      => 109434
                            ,resp_appl_id => 660);
  mo_global.init('ONT');

  /*Step 1: creat a person as a party*/
  l_person_rec.person_last_name  := 'Yusuf';
  l_person_rec.created_by_module := g_created_by_module;
  l_person_rec.party_rec         := l_party_rec;

  hz_party_v2pub.create_person(p_init_msg_list => fnd_api.g_false
                              ,p_person_rec    => l_person_rec
                              ,x_party_id      => x_person_party_id
                              ,x_party_number  => x_person_party_number
                              ,x_profile_id    => x_profile_id
                              ,x_return_status => x_return_status
                              ,x_msg_count     => l_msg_count
                              ,x_msg_data      => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Person Party ID : ' || x_person_party_id);
  END IF;

  /*Step 2: creat an org contact for the person*/
  l_org_contact_rec.created_by_module                := g_created_by_module;
  l_org_contact_rec.party_rel_rec.subject_id         := x_person_party_id; -- from Step 1
  l_org_contact_rec.party_rel_rec.subject_type       := 'PERSON';
  l_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
  l_org_contact_rec.party_rel_rec.object_id          := 8022293; /*cust party id*/
  l_org_contact_rec.party_rel_rec.object_type        := 'ORGANIZATION';
  l_org_contact_rec.party_rel_rec.object_table_name  := 'HZ_PARTIES';
  l_org_contact_rec.party_rel_rec.relationship_code  := 'CONTACT_OF';
  l_org_contact_rec.party_rel_rec.relationship_type  := 'CONTACT';
  l_org_contact_rec.party_rel_rec.start_date         := SYSDATE;
  l_org_contact_rec.party_rel_rec.status             := 'A';

  hz_party_contact_v2pub.create_org_contact(p_init_msg_list   => fnd_api.g_false
                                           ,p_org_contact_rec => l_org_contact_rec
                                           ,x_org_contact_id  => x_org_contact_id
                                           ,x_party_rel_id    => x_party_rel_id
                                           ,x_party_id        => x_org_contact_party_id
                                           ,x_party_number    => x_org_contact_party_number
                                           ,x_return_status   => x_return_status
                                           ,x_msg_count       => l_msg_count
                                           ,x_msg_data        => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Contact Party ID : ' || x_org_contact_party_id);
  END IF;

  /*Step 3: creat a account role for the org contact*/
  l_cr_cust_acc_role_rec.party_id          := x_org_contact_party_id; -- from Step 2;
  l_cr_cust_acc_role_rec.cust_account_id   := 6411689; /*cust account id*/
  l_cr_cust_acc_role_rec.cust_acct_site_id := 800474; /*cust acct site id*/ --注[2]
  l_cr_cust_acc_role_rec.primary_flag      := 'N';
  l_cr_cust_acc_role_rec.role_type         := 'CONTACT';
  l_cr_cust_acc_role_rec.application_id    := 660;
  l_cr_cust_acc_role_rec.created_by_module := g_created_by_module;

  hz_cust_account_role_v2pub.create_cust_account_role(p_init_msg_list         => fnd_api.g_true
                                                     ,p_cust_account_role_rec => l_cr_cust_acc_role_rec
                                                     ,x_cust_account_role_id  => x_cust_account_role_id
                                                     ,x_return_status         => x_return_status
                                                     ,x_msg_count             => l_msg_count
                                                     ,x_msg_data              => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Contact ID : ' || x_cust_account_role_id);
  END IF;
END;

二、创建联系方式

DECLARE
  x_contact_point_id  OUT NUMBER;
  x_return_status     OUT VARCHAR2(5);
  x_msg_data          OUT VARCHAR2(3000);
  l_contact_point_rec hz_contact_point_v2pub.contact_point_rec_type;
  l_phone_rec         hz_contact_point_v2pub.phone_rec_type;
  l_email_rec         hz_contact_point_v2pub.email_rec_type;
  l_web_rec           hz_contact_point_v2pub.web_rec_type;

  l_msg_count NUMBER;

  g_created_by_module VARCHAR2(20) := 'TCA_V2_API'; --注[1]
BEGIN
  fnd_global.apps_initialize(user_id      => 147026
                            ,resp_id      => 109434
                            ,resp_appl_id => 660);
  mo_global.init('ONT');

  /*Step 4: creat a gen phone number for the org contact*/
  l_contact_point_rec.contact_point_type := 'PHONE';
  l_contact_point_rec.owner_table_name   := 'HZ_PARTIES'; --注[3]
  l_contact_point_rec.primary_flag       := 'N';
  l_contact_point_rec.owner_table_id     := 8022303; /*org contact party id*/ -- from Step 2 --注[3]
  l_contact_point_rec.created_by_module  := g_created_by_module;

  l_phone_rec.phone_line_type := 'GEN'; --注[4]
  l_phone_rec.phone_number    := '15666886688';

  hz_contact_point_v2pub.create_phone_contact_point(p_init_msg_list     => fnd_api.g_true
                                                   ,p_contact_point_rec => l_contact_point_rec
                                                   ,p_phone_rec         => l_phone_rec
                                                   ,x_contact_point_id  => x_contact_point_id
                                                   ,x_return_status     => x_return_status
                                                   ,x_msg_count         => l_msg_count
                                                   ,x_msg_data          => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Contact Point ID : ' || x_contact_point_id);
  END IF;

  /*Step 5: creat an email for the org contact*/
  l_contact_point_rec.contact_point_type := 'EMAIL'; /*other information were set in Step 4*/

  l_email_rec.email_address := 'mryou@live.com';

  hz_contact_point_v2pub.create_email_contact_point(p_init_msg_list     => fnd_api.g_true
                                                   ,p_contact_point_rec => l_contact_point_rec
                                                   ,p_email_rec         => l_email_rec
                                                   ,x_contact_point_id  => x_contact_point_id
                                                   ,x_return_status     => x_return_status
                                                   ,x_msg_count         => l_msg_count
                                                   ,x_msg_data          => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Contact Point ID : ' || x_contact_point_id);
  END IF;

  /*Step 5: creat a url for the org contact*/
  l_contact_point_rec.contact_point_type := 'WEB'; /*other information were set in Step 4*/

  l_web_rec.url      := 'https://blog.csdn.net/liouzch';
  l_web_rec.web_type := 'TEXT';
  hz_contact_point_v2pub.create_web_contact_point(p_init_msg_list     => fnd_api.g_true
                                                 ,p_contact_point_rec => l_contact_point_rec
                                                 ,p_web_rec           => l_web_rec
                                                 ,x_contact_point_id  => x_contact_point_id
                                                 ,x_return_status     => x_return_status
                                                 ,x_msg_count         => l_msg_count
                                                 ,x_msg_data          => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Contact Point ID : ' || x_contact_point_id);
  END IF;
END;

三、创建联系人职责

联系人职责信息存储在HZ_ROLE_RESPONSIBILITY表

DECLARE
  x_responsibility_id NUMBER;
  x_return_status     OUT VARCHAR2(5);
  x_msg_data          OUT VARCHAR2(3000);

  l_role_responsibility_rec hz_cust_account_role_v2pub.role_responsibility_rec_type;

  l_msg_count NUMBER;

  g_created_by_module VARCHAR2(20) := 'TCA_V2_API'; --注[1]
BEGIN
  fnd_global.apps_initialize(user_id      => 147026
                            ,resp_id      => 109434
                            ,resp_appl_id => 660);
  mo_global.init('ONT');
  
  /*Step 6: creat a responsibility for the account role*/
  l_role_responsibility_rec.cust_account_role_id := 6782784; /*contact id*/ -- from Step 3
  l_role_responsibility_rec.responsibility_type  := 'BILL_TO'; --注[5]
  l_role_responsibility_rec.primary_flag         := 'N';
  l_role_responsibility_rec.application_id       := 660;
  l_role_responsibility_rec.created_by_module    := g_created_by_module;

  hz_cust_account_role_v2pub.create_role_responsibility(p_init_msg_list           => fnd_api.g_true
                                                       ,p_role_responsibility_rec => l_role_responsibility_rec
                                                       ,x_responsibility_id       => x_responsibility_id
                                                       ,x_return_status           => x_return_status
                                                       ,x_msg_count               => l_msg_count
                                                       ,x_msg_data                => x_msg_data);

  IF x_return_status <> 'S'
  THEN
    dbms_output.put_line(x_msg_data);
  ELSE
    dbms_output.put_line('Responsibility ID : ' || x_responsibility_id);
  END IF;
END;

注释

[1]:CREATED_BY_MODULE必须使用快速代码HZ_CREATED_BY_MODULES里的值;

[2]:创建客户地点层联系人时,CUST_ACCT_SITE_ID属性应写入对应客户地点ID,而创建客户账户层联系人时,此属性应为空;

[3]:创建联系人的联系方式时,OWNER_TABLE_NAME属性和OWNER_TABLE_ID属性分别为'HZ_PARTIES'和联系人的ORG CONTACT PARTY I(即AR_CONTACTS_V.REL_PARTY_ID),创建客户地点的联系方式时,此二属性分别为'HZ_PARTY_SITES'和客户地点的PARTY_SITE_ID;

[4]:PHONE_LINE_TYPE应为快速代码PHONE_LINE_TYPE里的值;

[5]:RESPONSIBILITY_TYPE应为快速代码SITE_USE_CODE里的值。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值