1. DECLARE
  2. p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
  3. p_cust_site_use_rec hz_cust_account_site_v2pub.cust_site_use_rec_type;
  4. p_customer_profile_rec hz_customer_profile_v2pub.customer_profile_rec_type;
  5. x_site_use_id NUMBER;
  6. x_return_status VARCHAR2(20000);
  7. x_msg_count NUMBER;
  8. x_msg_data VARCHAR2(20000);
  9. x_cust_acct_site_id NUMBER;
  10. l_org_id NUMBER;
  11. l_party_site_id NUMBER;
  12. l_cust_account_id NUMBER;
  13. l_location_id NUMBER;
  14. l_error_msg VARCHAR2(32000);
  15. v_location_rec hz_location_v2pub.location_rec_type;
  16. v_location_clear hz_location_v2pub.location_rec_type;
  17. v_location_id NUMBER;
  18.  
  19. v_version_number NUMBER;
  20. CURSOR cur IS
  21. SELECT t.import_id,
  22. t.ou_name,
  23. t.party_name,
  24. t.party_site_number,
  25. t.error_flag,
  26. t.error_msg,
  27. t.attribute1,
  28. t.attribute2,
  29. t.attribute3,
  30. t.attribute4,
  31. t.attribute5
  32. FROM cux_party_site_import_temp t
  33. WHERE 1 = 1
  34. --AND t.party_name = '东莞市安德丰电池有限公司'
  35. -- and t.import_id=406
  36. ;
  37. -- AND t.error_flag = 'Y';
  38. BEGIN
  39. -- Setting the Context --
  40. mo_global.init('AR');
  41. fnd_global.apps_initialize(user_id => 1318,
  42. resp_id => 50559,
  43. resp_appl_id => 222);
  44.  
  45. l_error_msg := NULL;
  46. FOR rec IN cur
  47. LOOP
  48. l_error_msg := NULL;
  49. -- Initializing the Mandatory API parameters
  50. l_org_id := NULL;
  51. BEGIN
  52. SELECT hou.organization_id
  53. INTO l_org_id
  54. FROM hr_operating_units hou
  55. WHERE 1 = 1
  56. AND hou.name = rec.ou_name;
  57. EXCEPTION
  58. WHEN OTHERS THEN
  59. l_org_id := NULL;
  60. l_error_msg := l_error_msg || ' 业务实体不存在';
  61. END;
  62.  
  63. mo_global.set_policy_context('S',
  64. l_org_id);
  65. fnd_global.set_nls_context('AMERICAN');
  66.  
  67. BEGIN
  68. SELECT hps.party_site_id, hl.location_id
  69. INTO l_party_site_id, l_location_id
  70. FROM hz_party_sites hps, hz_parties hp, hz_locations hl
  71. WHERE hps.party_id = hp.party_id
  72. AND hps.location_id = hl.location_id(+)
  73. AND hps.party_site_number = rec.party_site_number
  74. AND hp.party_name = rec.party_name;
  75. EXCEPTION
  76. WHEN OTHERS THEN
  77. l_party_site_id := NULL;
  78. l_location_id := NULL;
  79. --l_error_msg := l_error_msg || ' 客户地址不存在';
  80. END;
  81.  
  82. IF (l_location_id IS NULL) THEN
  83. END IF;
  84.  
  85. BEGIN
  86. SELECT DISTINCT hca.cust_account_id
  87. INTO l_cust_account_id
  88. FROM hz_cust_acct_sites_all hcas,
  89. hz_cust_accounts_all hca,
  90. hz_parties hp
  91. WHERE hp.party_id = hca.party_id
  92. AND hca.cust_account_id = hcas.cust_account_id
  93. AND hcas.party_site_id = l_party_site_id
  94. AND hp.party_name = rec.party_name;
  95. EXCEPTION
  96. WHEN OTHERS THEN
  97. l_cust_account_id := NULL;
  98. l_error_msg := l_error_msg || ' 客户账户不存在 ';
  99. END;
  100.  
  101. IF (l_error_msg IS NULL) THEN
  102. --创建客户地点
  103. p_cust_acct_site_rec.org_id := l_org_id;
  104. p_cust_acct_site_rec.cust_account_id := l_cust_account_id;
  105. p_cust_acct_site_rec.party_site_id := l_party_site_id;
  106. p_cust_acct_site_rec.location_id := l_party_site_id;
  107. p_cust_acct_site_rec.created_by_module := 'HZ_CPUI';
  108.  
  109. dbms_output.put_line('Calling the API hz_cust_account_site_v2pub.create_cust_acct_site****************************');
  110.  
  111. hz_cust_account_site_v2pub.create_cust_acct_site(p_init_msg_list => fnd_api.g_true,
  112. p_cust_acct_site_rec => p_cust_acct_site_rec,
  113. x_cust_acct_site_id => x_cust_acct_site_id,
  114. x_return_status => x_return_status,
  115. x_msg_count => x_msg_count,
  116. x_msg_data => x_msg_data);
  117.  
  118. IF x_return_status = fnd_api.g_ret_sts_success THEN
  119.  
  120. l_error_msg := NULL;
  121. --COMMIT;
  122. dbms_output.put_line('Creation of Customer Account Site is Successful,Customer Account Site Id is = ' ||
  123. x_cust_acct_site_id);
  124.  
  125. --创建客户地点的业务用途(收单方,收货方)
  126. -- Initializing the Mandatory API parameters 111
  127. p_cust_site_use_rec.cust_acct_site_id := x_cust_acct_site_id;
  128. p_cust_site_use_rec.site_use_code := 'BILL_TO';
  129. --p_cust_site_use_rec.location := l_location_id;
  130. p_cust_site_use_rec.created_by_module := 'HZ_CPUI';
  131.  
  132. dbms_output.put_line('Calling the API hz_cust_account_site_v2pub.create_cust_site_use=============');
  133. x_site_use_id := NULL;
  134. hz_cust_account_site_v2pub.create_cust_site_use(p_init_msg_list => fnd_api.g_true,
  135. p_cust_site_use_rec => p_cust_site_use_rec,
  136. p_customer_profile_rec => p_customer_profile_rec,
  137. p_create_profile => fnd_api.g_true,
  138. p_create_profile_amt => fnd_api.g_true,
  139. x_site_use_id => x_site_use_id,
  140. x_return_status => x_return_status,
  141. x_msg_count => x_msg_count,
  142. x_msg_data => x_msg_data);
  143.  
  144. IF x_return_status = fnd_api.g_ret_sts_success THEN
  145.  
  146. l_error_msg := NULL;
  147. --COMMIT;
  148. dbms_output.put_line('Successful,Site Use Id = ' ||
  149. x_site_use_id || ',Site Use = ' ||
  150. p_cust_site_use_rec.site_use_code);
  151. ELSE
  152. dbms_output.put_line('Creation of Customer Accnt Site use got failed:' ||
  153. x_msg_data);
  154.  
  155. l_error_msg := l_error_msg || x_msg_data;
  156. ROLLBACK;
  157. FOR i IN 1 .. x_msg_count
  158. LOOP
  159. x_msg_data := fnd_msg_pub.get(p_msg_index => i,
  160. p_encoded => 'F');
  161. dbms_output.put_line(i || ') ' || x_msg_data);
  162. END LOOP;
  163. END IF;
  164.  
  165. p_cust_site_use_rec.cust_acct_site_id := x_cust_acct_site_id;
  166. p_cust_site_use_rec.site_use_code := 'SHIP_TO';
  167. --p_cust_site_use_rec.bill_to_site_use_id := x_site_use_id;
  168. --p_cust_site_use_rec.location := l_location_id;
  169. p_cust_site_use_rec.created_by_module := 'HZ_CPUI';
  170.  
  171. x_site_use_id := NULL;
  172. hz_cust_account_site_v2pub.create_cust_site_use(p_init_msg_list => fnd_api.g_true,
  173. p_cust_site_use_rec => p_cust_site_use_rec,
  174. p_customer_profile_rec => p_customer_profile_rec,
  175. p_create_profile => fnd_api.g_true,
  176. p_create_profile_amt => fnd_api.g_true,
  177. x_site_use_id => x_site_use_id,
  178. x_return_status => x_return_status,
  179. x_msg_count => x_msg_count,
  180. x_msg_data => x_msg_data);
  181.  
  182. IF x_return_status = fnd_api.g_ret_sts_success THEN
  183.  
  184. l_error_msg := NULL;
  185. --COMMIT;
  186. dbms_output.put_line('Successful,Site Use Id = ' ||
  187. x_site_use_id || ',Site Use = ' ||
  188. p_cust_site_use_rec.site_use_code);
  189. ELSE
  190. dbms_output.put_line('Creation of Customer Accnt Site use got failed:' ||
  191. x_msg_data);
  192. --ROLLBACK;
  193. FOR i IN 1 .. x_msg_count
  194. LOOP
  195. x_msg_data := fnd_msg_pub.get(p_msg_index => i,
  196. p_encoded => 'F');
  197. l_error_msg := l_error_msg || x_msg_data;
  198. dbms_output.put_line(i || ') ' || x_msg_data);
  199. END LOOP;
  200. END IF;
  201. ELSE
  202. dbms_output.put_line('Creation of Customer Account Site got failed:' ||
  203. x_msg_data);
  204. --ROLLBACK;
  205. FOR i IN 1 .. x_msg_count
  206. LOOP
  207. x_msg_data := fnd_msg_pub.get(p_msg_index => i,
  208. p_encoded => 'F');
  209. l_error_msg := l_error_msg || x_msg_data;
  210. dbms_output.put_line(i || ') ' || x_msg_data);
  211. END LOOP;
  212. END IF; --IF x_return_status = fnd_api.g_ret_sts_success THEN
  213.  
  214. ELSE
  215. dbms_output.put_line('l_error_msg:=' || l_error_msg);
  216. END IF; -- IF (l_error_msg IS NULL) THEN
  217.  
  218. IF (l_error_msg IS NOT NULL) THEN
  219. UPDATE cux_party_site_import_temp t
  220. SET t.error_flag = 'Y', t.error_msg = l_error_msg
  221. WHERE 1 = 1
  222. AND t.import_id = rec.import_id;
  223. ELSE
  224. UPDATE cux_party_site_import_temp t
  225. SET t.error_flag = 'N', t.error_msg = NULL
  226. WHERE 1 = 1
  227. AND t.import_id = rec.import_id;
  228. END IF;
  229. END LOOP;
  230.  
  231. --COMMIT;
  232.  
  233. EXCEPTION
  234. WHEN OTHERS THEN
  235. dbms_output.put_line('导入异常!');
  236. END;

  

  1. create table cux_party_site_import_temp
  2. (IMPORT_ID NUMBER,
  3. OU_NAME VARCHAR2(240),
  4. PARTY_NAME VARCHAR2(240),
  5. PARTY_SITE_NAME VARCHAR2(240),
  6. ADDRESS VARCHAR2(240),
  7. ERROR_FLAG VARCHAR2(240),
  8. ERROR_MSG VARCHAR2(4000),
  9. ATTRIBUTE1 VARCHAR2(240),
  10. ATTRIBUTE2 VARCHAR2(240),
  11. ATTRIBUTE3 VARCHAR2(240),
  12. ATTRIBUTE4 VARCHAR2(240),
  13. ATTRIBUTE5 VARCHAR2(240))
  14.  
  15. /*
  16. select * from hz_parties hps
  17. where hps.PARTY_NAME like '%惠州市伟江新能源有限公司%'*/

  

AR*客户地点分配OU的更多相关文章

  1. 客户地点分配多OU

    DECLARE l_num_user_id NUMBER; l_num_appl_id NUMBER; l_num_resp_id NUMBER; cust_account_rec_type hz_c ...

  2. Oracle EBS 更新客户地点

    --更新客户地点 declare x_return_status ); x_msg_count NUMBER; x_msg_data ); x_profile_id NUMBER; l_locatio ...

  3. Oracle EBS AR 客户API

    ------------------------------------ 1. Set Environment ------------------------------------ -- 1a. ...

  4. Oracle EBS AR 客户取数SQL

    SELECT acct.cust_account_id, acct.party_id, acct.account_number, party.party_name, lkp1.meaning part ...

  5. AR 应收 表

    AR 应收 应收事务处理相关表 SELECT * FROM ar.ar_batches_all;                  --事务处理批 SELECT * FROM ar.ra_custom ...

  6. 在EBS里新建一个OU的步骤

    http://blog.csdn.net/kevingao/archive/2010/09/11/5877092.aspx 在EBS里新建一个OU的步骤1. 建立OU组织,关联SOB,LE2. 系统管 ...

  7. AR自动开票主程序导入发票的时候,出现错误提示''不能获取汇款地址''

    问题:AR自动开票主程序,出现错误不能获取汇款地址 解决:AR>设置-打印-汇入地址,汇入地址要增加此客户地点对应的国家:

  8. Oracel数据库连接时出现:ORA-12518:监听程序无法分发客户机连

    在连接Oracel数据库时,每隔一段时间就会出现:ORA-12518:监听程序无法分发客户机连接,如图 上网查了资料原因和解决方案如下: 一.[问题描述] 最近,在系统高峰期的时候,会提示如上的错误, ...

  9. XShell提示Connection closed by foreign host的问题 和 路由器分配IP的规则

    情况是这样的: VMware中有三个Linux机器分别是crxy99(192.168.1.99),crxy100(192.168.1.100),crxy101(192.168.1.101),crxy1 ...

随机推荐

  1. [NPM + React] Prepare a Custom React Hook to be Published as an npm Package

    Before we publish our package, we want to make sure everything is set up correctly. We’ll cover vers ...

  2. 简易配置中心Confd入手

    改成动态更新配置文件,如下每五秒重新生成配置文件 confd与etcd的使用 Add keys This guide assumes you have a working etcd, or consu ...

  3. 洛谷 P4779 【模板】单源最短路径(标准版) 题解

    P4779 [模板]单源最短路径(标准版) 题目背景 2018 年 7 月 19 日,某位同学在 NOI Day 1 T1 归程 一题里非常熟练地使用了一个广为人知的算法求最短路. 然后呢? 100 ...

  4. 【UVA11134】传说中的车

    横纵坐标互不影响,所以问题转化到一维:在n个区间中每个区间选一个数,n个数都被选一次 将区间按右端点排序,枚举区间,每个区间选最靠左的没被选过的点 #include<algorithm> ...

  5. c语言博客作业03--循环结构

    0.展示PTA总分 1.本章学习总结 1.1学习内容总结 循环语句 for语句: for( 表达式1; 表达式2; 表达式3 ) { // 需要执行的语句; } 其执行过程是:表达式 1 首先执行且只 ...

  6. linux(deepin) 下隐藏firefox标题栏

    1. 右上角菜单 -> 定制 -> 左下角 "标题栏" 取消打钩 2. 如果上面无法解决,在firefox的启动前插入一个环境变量,具体修改 /usr/share/ap ...

  7. Java两个数的和

    给你一个整数数组, 返回两个数的指数,使他们加起来等于给定的数. 你可以假设只有一个解, 并且相同的元素不会用两次. 比如: 给定数组 = [2, 7, 11, 15], 目标数 = 9, 因为[0] ...

  8. Java 自定义异常

    新建类CustomException继承 Exception /** * Create by on 2019-07-30 * 自定义类需要继承Exception * @author lsw */ pu ...

  9. IDEA把spring-boot项目打包成jar

    1.打开项目,然后右击项目选中‘Open Module Settings’进入project Structure( 快捷键 Ctrl+Shift+Alt+S或者File->Project Str ...

  10. A3C 算法资料收集

    A3C 算法资料收集 2019-07-26 21:37:55 Paper: https://arxiv.org/pdf/1602.01783.pdf Code: 1. 超级马里奥:https://gi ...