DECLARE
--p_old_new_flag OLD 为导出 NEW 为导入
l_iface_rec inv.mtl_transactions_interface%ROWTYPE;
l_iface_lot_rec inv.mtl_transaction_lots_interface%ROWTYPE;
l_timeout NUMBER;
l_outcome BOOLEAN;
l_error_code VARCHAR2(100);
l_error_explanation VARCHAR2(100);
l_request_id NUMBER;
l_sqlerrm VARCHAR2(1000); l_inventory_item_id NUMBER;
l_organization_id NUMBER;
l_uom VARCHAR2(240);
l_disposition_id NUMBER;
l_subinventory_code VARCHAR2(240);
l_count NUMBER;
l_locator_id NUMBER;
l_error_msg VARCHAR2(32767); CURSOR cur IS
SELECT t.import_id,
t.organization_code,
t.item_number,
t.subinventory_code,
t.transaction_type transaction_type1,
decode(t.transaction_type,
'帐户别名接收',
41,
'帐户别名发放',
31,
NULL) transaction_type,
t.account_alias,
t.transaction_uom,
t.transaction_date,
t.lot_number,
decode(t.transaction_type,
'帐户别名接收',
t.transaction_quantity,
'帐户别名发放',
t.transaction_quantity * (-1),
NULL) transaction_quantity,
t.attribute1,
t.attribute2,
t.attribute3,
t.attribute4,
t.attribute5
FROM cux_inv_mmt_account_temp t
WHERE 1 = 1
--AND t.item_number = '1515453000051'
;
BEGIN mo_global.init('INV');
fnd_global.apps_initialize(user_id => 1318,
resp_id => 50559,
resp_appl_id => 222);
mo_global.set_policy_context('S',
83); l_count := 0;
FOR rec IN cur
LOOP l_error_msg := NULL;
l_iface_rec.last_update_date := SYSDATE;
l_iface_rec.last_updated_by := -1;
l_iface_rec.creation_date := SYSDATE;
l_iface_rec.created_by := -1;
l_iface_rec.last_update_login := -1;
l_iface_lot_rec.last_update_date := SYSDATE;
l_iface_lot_rec.last_updated_by := -1;
l_iface_lot_rec.creation_date := SYSDATE;
l_iface_lot_rec.created_by := -1;
l_iface_lot_rec.last_update_login := -1; SELECT mtl_material_transactions_s.nextval
INTO l_iface_rec.transaction_interface_id
FROM dual; BEGIN
SELECT msi.inventory_item_id,
msi.organization_id,
msi.primary_uom_code
INTO l_inventory_item_id, l_organization_id, l_uom
FROM mtl_system_items_b msi, org_organization_definitions ood
WHERE 1 = 1
AND msi.organization_id = ood.organization_id
AND ood.organization_code = rec.organization_code
AND msi.segment1 = rec.item_number;
EXCEPTION
WHEN OTHERS THEN
l_error_msg := l_error_msg || '物料' || rec.item_number || '不存在';
END; BEGIN
SELECT mgd.disposition_id
INTO l_disposition_id
FROM mtl_generic_dispositions mgd
WHERE 1 = 1
AND mgd.organization_id = l_organization_id
AND mgd.segment1 = rec.account_alias;
EXCEPTION
WHEN OTHERS THEN
l_error_msg := l_error_msg || '账户别名不存在';
END; BEGIN
SELECT msi.secondary_inventory_name
INTO l_subinventory_code
FROM mtl_secondary_inventories msi
WHERE 1 = 1
AND msi.organization_id = l_organization_id
AND msi.secondary_inventory_name = rec.subinventory_code;
EXCEPTION
WHEN OTHERS THEN
l_error_msg := l_error_msg || '子库存不存在';
END; IF (rec.attribute1 IS NOT NULL) THEN
BEGIN
SELECT mik.inventory_location_id
INTO l_locator_id
FROM mtl_item_locations_kfv mik
WHERE mik.concatenated_segments = rec.attribute1
AND mik.organization_id = l_organization_id
AND mik.subinventory_code = rec.subinventory_code;
EXCEPTION
WHEN no_data_found THEN
l_error_msg := l_error_msg || '货位不存在';
END;
END IF; --dbms_output.put_line('1!'); l_iface_rec.transaction_header_id := l_iface_rec.transaction_interface_id;
l_iface_rec.transaction_mode := 3;
l_iface_rec.process_flag := 1;
l_iface_rec.transaction_type_id := rec.transaction_type; --41 帐户别名接收 31 帐户别名发放
l_iface_rec.transaction_source_id := l_disposition_id; --来源
l_iface_rec.organization_id := l_organization_id;
l_iface_rec.inventory_item_id := l_inventory_item_id;
l_iface_rec.subinventory_code := rec.subinventory_code;
l_iface_rec.locator_id := l_locator_id;
l_iface_rec.transaction_quantity := rec.transaction_quantity; --出库数量为负数 入库数量为正数
l_iface_rec.primary_quantity := rec.transaction_quantity;
l_iface_rec.transaction_uom := l_uom;
l_iface_rec.transaction_date := rec.transaction_date;
l_iface_rec.source_code := '账户别名接收/发放';
l_iface_rec.source_header_id := to_number(to_char(SYSDATE,
'YYYYMMDDHH24MISS'));
l_iface_rec.source_line_id := to_number(to_char(SYSDATE,
'YYYYMMDDHH24MISS')); IF (l_error_msg IS NULL) THEN
INSERT INTO inv.mtl_transactions_interface VALUES l_iface_rec;
END IF; IF (rec.lot_number IS NOT NULL) THEN
l_iface_lot_rec.transaction_interface_id := l_iface_rec.transaction_interface_id;
l_iface_lot_rec.lot_number := rec.lot_number;
l_iface_lot_rec.transaction_quantity := l_iface_rec.transaction_quantity;
l_iface_lot_rec.source_code := l_iface_rec.source_code;
l_iface_lot_rec.source_line_id := l_iface_rec.source_line_id; IF (l_error_msg IS NULL) THEN
INSERT INTO inv.mtl_transaction_lots_interface
VALUES l_iface_lot_rec;
END IF;
END IF; IF (l_error_msg IS NULL) THEN
l_timeout := 10;
l_outcome := mtl_online_transaction_pub.process_online(p_transaction_header_id => l_iface_rec.transaction_header_id,
p_timeout => l_timeout,
p_error_code => l_error_code,
p_error_explanation => l_error_explanation); IF (l_outcome = FALSE) THEN
dbms_output.put_line('Failed*******Import_id:' || rec.import_id);
dbms_output.put_line('Failed!');
dbms_output.put_line('l_error_code:' || l_error_code);
dbms_output.put_line('l_error_explanation:' || l_error_explanation);
ELSIF (l_outcome = TRUE) THEN
l_count := l_count + 1;
END IF;
END IF; IF (l_error_msg IS NOT NULL) THEN
dbms_output.put_line('l_error_msg:' || l_error_msg);
END IF; END LOOP;
dbms_output.put_line('SuccessFul:' || l_count); EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Exception!' || SQLERRM);
END;

  

--期初数据导入,创建表存储

create table cux_inv_mmt_account_temp(
IMPORT_ID NUMBER,
ORGANIZATION_CODE VARCHAR2(),
ITEM_NUMBER VARCHAR2(),
SUBINVENTORY_CODE VARCHAR2(),
TRANSACTION_TYPE VARCHAR2(),
ACCOUNT_ALIAS VARCHAR2(),
TRANSACTION_UOM VARCHAR2(),
TRANSACTION_DATE DATE,
LOT_NUMBER VARCHAR2(),
TRANSACTION_QUANTITY NUMBER,
ATTRIBUTE1 VARCHAR2(),
ATTRIBUTE2 VARCHAR2(),
ATTRIBUTE3 VARCHAR2(),
ATTRIBUTE4 VARCHAR2(),
ATTRIBUTE5 VARCHAR2()
)

INV*账户别名接收发放的更多相关文章

  1. 物料事务处理接口表 MTL_TRANSACTIONS_INTERFACE 账户别名使用 及 提示无效的分配账户字段

    实例: PROCEDURE MAIN(P_ORGANIZATION_ID NUMBER, P_PERIOD_NAME VARCHAR2, XV_STATUS OUT VARCHAR, XV_MESG ...

  2. 所有标准API

    序号 系统版本 模块 应用场景 类型 API/接口 参数规格 样例代码 备注 登记者 登记时间 关键字 1 12.1.3 AP 付款核销 API ap_pay_invoice_pkg.ap_pay_i ...

  3. Oracle EBS-SQL (INV-2):检查帐户别名发放记录.sql

    SELECT FU.description                 操作者,         ITM.SEGMENT1               物料编码,         ITM.DESC ...

  4. ORACLE EBS常用表及查询语句(最终整理版)

    建议去看参考二 参考一:                                                              call fnd_global.APPS_INITI ...

  5. PMS与orcalebs结合之字段

    call fnd_global.APPS_INITIALIZE(1318,50583,401) select fnd_profile.VALUE('ORG_ID') FROM DUAL select ...

  6. Oracle常用标准表

    一.INV(库存) 子库存:mtl_secondary_inventories 事物处理:mtl_material_transactions mmt 事务处理来源类型:mtl_txn_source_t ...

  7. EBS常用表_Dictionary

    EBS常用表:转载于 https://blog.csdn.net/xiariqingcao/article/details/8775827 . OU.库存组织 SELECT hou.organizat ...

  8. 具体解释EBS接口开发之WIP模块接口

    整体说明 文档目的 本文档针对WIP模块业务功能和接口进行分析和研究,对採用并发请求方式和调用API方式分别进行介绍 内容 WIP模块经常使用标准表简单介绍 WIP事物处理组成 WIP相关业务流程 W ...

  9. 详解EBS接口开发之WIP模块接口

    总体说明 文档目的 本文档针对WIP模块业务功能和接口进行分析和研究,对采用并发请求方式和调用API方式分别进行介绍 内容 WIP模块常用标准表简介 WIP事物处理组成 WIP相关业务流程 WIP相关 ...

随机推荐

  1. rsync提权

    介绍:Rsync是linux下一款数据备份工具,默认开启873端口 利用条件:rsync未授权 列出模板 rsync rsync://目标ip:873/ 列出模块src下的文件 rsync rsync ...

  2. [Dart] Mixin

    Docs Mixins are a way of reusing a class’s code in multiple class hierarchies. void main() { Animal ...

  3. LeetCode 428. Serialize and Deserialize N-ary Tree

    原题链接在这里:https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree/ 题目: Serialization is the ...

  4. 第12组 Alpha事后诸葛亮

    Header 组长博客 Postmortem 设想和目标 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 要解决的是喜欢记录分享旅游生活的人群的行迹记录和分享问题, ...

  5. restframework之节流

    基本思路(原生Django而言): 在django2.x中,若出现节流(访问频率控制)的需求,我们首先想到的是使用一个字典(dict类型)来存储所有IP地址的访问时间记录,这是针对于匿名用户(IP)而 ...

  6. ICEM-R-b

    原视频下载地址:https://pan.baidu.com/s/1i4JGk8d ;密码: 4xr2

  7. 第10组 Beta冲刺(3/5)

    链接部分 队名:女生都队 组长博客: 博客链接 作业博客:博客链接 小组内容 恩泽(组长) 过去两天完成了哪些任务 描述 新增修改用户信息.任务完成反馈等功能API 服务器后端部署,API接口的bet ...

  8. 运行OpenGL红宝书第9版源码时Visual Studio提示“无法启动程序...ALL_BUILD。拒绝访问“的问题的解决办法

    问题描述: OpenGL红宝书第9版源码采用CMake编译后,用相应的Visual Studio(如VS2012)打开“vermilion9.sln”解决方案,并运行时Visual Studio提示“ ...

  9. 利用C++ STL的vector模拟邻接表的代码

    关于vector的介绍请看 https://www.cnblogs.com/zsq1993/p/5929806.html https://zh.cppreference.com/w/cpp/conta ...

  10. 【Redis】Redis 发布订阅

    Redis 发布订阅介绍 Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. Redis 客户端可以订阅任意数量的频道. 下图展示了频道 c ...