DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
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(20000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(20000);
x_cust_acct_site_id NUMBER;
l_org_id NUMBER;
l_party_site_id NUMBER;
l_cust_account_id NUMBER;
l_location_id NUMBER;
l_error_msg VARCHAR2(32000);
v_location_rec hz_location_v2pub.location_rec_type;
v_location_clear hz_location_v2pub.location_rec_type;
v_location_id NUMBER; v_version_number NUMBER;
CURSOR cur IS
SELECT t.import_id,
t.ou_name,
t.party_name,
t.party_site_number,
t.error_flag,
t.error_msg,
t.attribute1,
t.attribute2,
t.attribute3,
t.attribute4,
t.attribute5
FROM cux_party_site_import_temp t
WHERE 1 = 1
--AND t.party_name = '东莞市安德丰电池有限公司'
-- and t.import_id=406
;
-- AND t.error_flag = 'Y';
BEGIN
-- Setting the Context --
mo_global.init('AR');
fnd_global.apps_initialize(user_id => 1318,
resp_id => 50559,
resp_appl_id => 222); l_error_msg := NULL;
FOR rec IN cur
LOOP
l_error_msg := NULL;
-- Initializing the Mandatory API parameters
l_org_id := NULL;
BEGIN
SELECT hou.organization_id
INTO l_org_id
FROM hr_operating_units hou
WHERE 1 = 1
AND hou.name = rec.ou_name;
EXCEPTION
WHEN OTHERS THEN
l_org_id := NULL;
l_error_msg := l_error_msg || ' 业务实体不存在';
END; mo_global.set_policy_context('S',
l_org_id);
fnd_global.set_nls_context('AMERICAN'); BEGIN
SELECT hps.party_site_id, hl.location_id
INTO l_party_site_id, l_location_id
FROM hz_party_sites hps, hz_parties hp, hz_locations hl
WHERE hps.party_id = hp.party_id
AND hps.location_id = hl.location_id(+)
AND hps.party_site_number = rec.party_site_number
AND hp.party_name = rec.party_name;
EXCEPTION
WHEN OTHERS THEN
l_party_site_id := NULL;
l_location_id := NULL;
--l_error_msg := l_error_msg || ' 客户地址不存在';
END; IF (l_location_id IS NULL) THEN
END IF; BEGIN
SELECT DISTINCT hca.cust_account_id
INTO l_cust_account_id
FROM hz_cust_acct_sites_all hcas,
hz_cust_accounts_all hca,
hz_parties hp
WHERE hp.party_id = hca.party_id
AND hca.cust_account_id = hcas.cust_account_id
AND hcas.party_site_id = l_party_site_id
AND hp.party_name = rec.party_name;
EXCEPTION
WHEN OTHERS THEN
l_cust_account_id := NULL;
l_error_msg := l_error_msg || ' 客户账户不存在 ';
END; IF (l_error_msg IS NULL) THEN
--创建客户地点
p_cust_acct_site_rec.org_id := l_org_id;
p_cust_acct_site_rec.cust_account_id := l_cust_account_id;
p_cust_acct_site_rec.party_site_id := l_party_site_id;
p_cust_acct_site_rec.location_id := l_party_site_id;
p_cust_acct_site_rec.created_by_module := 'HZ_CPUI'; dbms_output.put_line('Calling the API hz_cust_account_site_v2pub.create_cust_acct_site****************************'); hz_cust_account_site_v2pub.create_cust_acct_site(p_init_msg_list => fnd_api.g_true,
p_cust_acct_site_rec => p_cust_acct_site_rec,
x_cust_acct_site_id => x_cust_acct_site_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data); IF x_return_status = fnd_api.g_ret_sts_success THEN l_error_msg := NULL;
--COMMIT;
dbms_output.put_line('Creation of Customer Account Site is Successful,Customer Account Site Id is = ' ||
x_cust_acct_site_id); --创建客户地点的业务用途(收单方,收货方)
-- Initializing the Mandatory API parameters 111
p_cust_site_use_rec.cust_acct_site_id := x_cust_acct_site_id;
p_cust_site_use_rec.site_use_code := 'BILL_TO';
--p_cust_site_use_rec.location := l_location_id;
p_cust_site_use_rec.created_by_module := 'HZ_CPUI'; dbms_output.put_line('Calling the API hz_cust_account_site_v2pub.create_cust_site_use=============');
x_site_use_id := NULL;
hz_cust_account_site_v2pub.create_cust_site_use(p_init_msg_list => fnd_api.g_true,
p_cust_site_use_rec => p_cust_site_use_rec,
p_customer_profile_rec => p_customer_profile_rec,
p_create_profile => fnd_api.g_true,
p_create_profile_amt => fnd_api.g_true,
x_site_use_id => x_site_use_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data); IF x_return_status = fnd_api.g_ret_sts_success THEN l_error_msg := NULL;
--COMMIT;
dbms_output.put_line('Successful,Site Use Id = ' ||
x_site_use_id || ',Site Use = ' ||
p_cust_site_use_rec.site_use_code);
ELSE
dbms_output.put_line('Creation of Customer Accnt Site use got failed:' ||
x_msg_data); l_error_msg := l_error_msg || x_msg_data;
ROLLBACK;
FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get(p_msg_index => i,
p_encoded => 'F');
dbms_output.put_line(i || ') ' || x_msg_data);
END LOOP;
END IF; p_cust_site_use_rec.cust_acct_site_id := x_cust_acct_site_id;
p_cust_site_use_rec.site_use_code := 'SHIP_TO';
--p_cust_site_use_rec.bill_to_site_use_id := x_site_use_id;
--p_cust_site_use_rec.location := l_location_id;
p_cust_site_use_rec.created_by_module := 'HZ_CPUI'; x_site_use_id := NULL;
hz_cust_account_site_v2pub.create_cust_site_use(p_init_msg_list => fnd_api.g_true,
p_cust_site_use_rec => p_cust_site_use_rec,
p_customer_profile_rec => p_customer_profile_rec,
p_create_profile => fnd_api.g_true,
p_create_profile_amt => fnd_api.g_true,
x_site_use_id => x_site_use_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data); IF x_return_status = fnd_api.g_ret_sts_success THEN l_error_msg := NULL;
--COMMIT;
dbms_output.put_line('Successful,Site Use Id = ' ||
x_site_use_id || ',Site Use = ' ||
p_cust_site_use_rec.site_use_code);
ELSE
dbms_output.put_line('Creation of Customer Accnt Site use got failed:' ||
x_msg_data);
--ROLLBACK;
FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get(p_msg_index => i,
p_encoded => 'F');
l_error_msg := l_error_msg || x_msg_data;
dbms_output.put_line(i || ') ' || x_msg_data);
END LOOP;
END IF;
ELSE
dbms_output.put_line('Creation of Customer Account Site got failed:' ||
x_msg_data);
--ROLLBACK;
FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get(p_msg_index => i,
p_encoded => 'F');
l_error_msg := l_error_msg || x_msg_data;
dbms_output.put_line(i || ') ' || x_msg_data);
END LOOP;
END IF; --IF x_return_status = fnd_api.g_ret_sts_success THEN ELSE
dbms_output.put_line('l_error_msg:=' || l_error_msg);
END IF; -- IF (l_error_msg IS NULL) THEN IF (l_error_msg IS NOT NULL) THEN
UPDATE cux_party_site_import_temp t
SET t.error_flag = 'Y', t.error_msg = l_error_msg
WHERE 1 = 1
AND t.import_id = rec.import_id;
ELSE
UPDATE cux_party_site_import_temp t
SET t.error_flag = 'N', t.error_msg = NULL
WHERE 1 = 1
AND t.import_id = rec.import_id;
END IF;
END LOOP; --COMMIT; EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('导入异常!');
END;

  

create table cux_party_site_import_temp
(IMPORT_ID NUMBER,
OU_NAME VARCHAR2(240),
PARTY_NAME VARCHAR2(240),
PARTY_SITE_NAME VARCHAR2(240),
ADDRESS VARCHAR2(240),
ERROR_FLAG VARCHAR2(240),
ERROR_MSG VARCHAR2(4000),
ATTRIBUTE1 VARCHAR2(240),
ATTRIBUTE2 VARCHAR2(240),
ATTRIBUTE3 VARCHAR2(240),
ATTRIBUTE4 VARCHAR2(240),
ATTRIBUTE5 VARCHAR2(240)) /*
select * from hz_parties hps
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. linux下递归删除目录下所有exe文件---从删库到跑路篇

    linux下递归删除目录下所有exe文件 find . -name '*.exe' -type f -print -exec rm -rf {} \; (1) "." 表示从当前目 ...

  2. [USACO14MAR] Sabotage 二分答案 分数规划

    [USACO14MAR] Sabotage 二分答案 分数规划 最终答案的式子: \[ \frac{sum-sum[l,r]}{n-len[l,r]}\le ans \] 转换一下: \[ sum[1 ...

  3. 54、Spark Streaming:DStream的transformation操作概览

    一. transformation操作概览 Transformation Meaning map 对传入的每个元素,返回一个新的元素 flatMap 对传入的每个元素,返回一个或多个元素 filter ...

  4. HTML页面之间的参数传递

    HTML 与 HTML 的跳转中如何在HTML之中实现参数的传递?主要代码如下:request为方法名称,params 为要获取的参数. function request(params) { var ...

  5. es6学习4:async和await

    async async函数返回一个 Promise 对象,可以使用then方法添加回调函数.当函数执行的时候,一旦遇到await就会先返回,等到异步操作完成,再接着执行函数体内后面的语句. funct ...

  6. Fiddler导出JMX文件配置

    (1)安装fiddler jmeter(免安装) 注意事项!fiddler版本必须在v4.6.2以上(插件支持的是4.6版本), jmeter版本最好在v3.0以上,版本太低容易导致导出不成功 这里我 ...

  7. java正则表达式备忘

    最近框架和爬虫上常要处理字符串匹配和替换的场景,备忘. 非贪婪模式 比如要匹配html文本中的连接,例如a href="www.abc.com/xyz/o"需要替换为a href= ...

  8. springcloud添加自定义的endpoint来实现平滑发布

    在我之前的文章  springcloud如何实现服务的平滑发布 里介绍了基于pause的发布方案. 平滑发布的核心思想就是:所有服务的调用者不再调用该服务了就表示安全的将服务kill掉. 另外actu ...

  9. Java与.net 关于URL Encode 的区别

    在c#中,HttpUtility.UrlEncode("www+mzwu+com")编码结果为www%2bmzwu%2bcom,在和Java开发的平台做对接的时候,对方用用url编 ...

  10. UltraEdit 的“查看方式”着色类项型

    UltraEdit 的“查看方式”着色类项型 2011年06月22日 13:16:00 cnki_ok 阅读数 5722   版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请 ...