PO*创建标准采购订单
-- l_iface_rec po_headers_interface%ROWTYPE;
校验头相关信息
SELECT COUNT(1)
INTO l_po_count
FROM po_headers_all ph
WHERE 1 = 1
AND ph.segment1 = rec.po_number;
IF (l_po_count > 0) THEN
l_message := l_message || ' Po_number: ' || rec.po_number || ' Is Error';
log('Po_number: ' || rec.po_number || ' Is Error');
END IF; BEGIN
SELECT hou.organization_id
INTO l_org_id
FROM hr_operating_units hou
WHERE 1 = 1
AND hou.name = rec.ou;
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' OU: ' || rec.ou || ' Is Error';
log('OU: ' || rec.ou || ' Is Error');
END; BEGIN
SELECT podb.document_subtype
INTO l_type_code
FROM po_document_types_all_b podb,
po_document_types_all_tl podt
WHERE 1 = 1
AND podb.document_type_code = podt.document_type_code
AND podb.document_subtype = podt.document_subtype
AND podb.org_id = podt.org_id
AND podt.language = 'US'
AND podb.org_id = l_org_id
AND podb.document_type_code IN ('PO', 'PA')
AND podt.type_name = rec.type;
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Type: ' || rec.type || ' Is Error';
log('Type: ' || rec.type || ' Is Error');
END; BEGIN
SELECT pv.vendor_id
INTO l_vendor_id
FROM po_vendors pv
WHERE 1 = 1
AND pv.vendor_name = rec.suppiler;
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Suppiler: ' || rec.suppiler || ' Is Error';
log('Suppiler: ' || rec.suppiler || ' Is Error');
END; BEGIN
SELECT vs.vendor_site_id
INTO l_vendor_site_id
FROM po_vendor_sites_all vs
WHERE 1 = 1
AND vs.vendor_id = l_vendor_id
AND vs.vendor_site_code = rec.site;
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Site: ' || rec.site || ' Is Error';
log('Site: ' || rec.site || ' Is Error');
END; BEGIN
SELECT hl.location_id
INTO l_ship_to_location_id
FROM hr_locations_all_tl hl
WHERE 1 = 1
AND hl.location_code = rec.ship_to
AND hl.language = userenv('LANG');
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Ship_to: ' || rec.ship_to || ' Is Error';
log('Ship_to: ' || rec.ship_to || ' Is Error');
END; BEGIN
SELECT hl.location_id
INTO l_bill_to_location_id
FROM hr_locations_all_tl hl
WHERE 1 = 1
AND hl.location_code = rec.bill_to
AND hl.language = userenv('LANG');
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Bill_to: ' || rec.bill_to || ' Is Error';
log('Bill_to: ' || rec.bill_to || ' Is Error');
END; BEGIN
SELECT p.person_id
INTO l_agent_id
FROM per_people_f p
WHERE 1 = 1
AND p.full_name = rec.buyer;
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Buyer: ' || rec.buyer || ' Is Error';
log('Buyer: ' || rec.buyer || ' Is Error');
END; IF (l_message IS NOT NULL) THEN
dbms_output.put_line('Error l_message: ' || l_message);
RAISE fnd_api.g_exc_error;
END IF;
--插入头接口表
l_iface_rec.interface_header_id := po_headers_interface_s.nextval;
l_iface_rec.interface_source_code := 'XXPO_ONHAND_HEADER';
l_iface_rec.batch_id := g_session_id;
l_iface_rec.process_code := 'PENDING'; --PENDING, ACCEPTED, REJECTED, or NOTIFIED
l_iface_rec.action := 'ORIGINAL'; --ORIGINAL,REPLACE, or UPDATE
l_iface_rec.org_id := l_org_id;
l_iface_rec.document_num := rec.po_number;
l_iface_rec.document_type_code := l_type_code; --STANDARD, BLANKET, or QUOTATION
l_iface_rec.vendor_id := l_vendor_id;
l_iface_rec.vendor_site_id := l_vendor_site_id;
l_iface_rec.ship_to_location_id := l_ship_to_location_id;
l_iface_rec.bill_to_location_id := l_bill_to_location_id;
l_iface_rec.agent_id := l_agent_id;
l_iface_rec.approval_status := rec.status; --'INCOMPLETE'
l_iface_rec.currency_code := rec.currency;
--l_iface_rec.rate_date := to_date('22-MAR-2017', 'DD-MON-YYYY');
--l_iface_rec.rate_type := 'Corporate';
l_iface_rec.last_update_date := g_last_update_date;
l_iface_rec.last_updated_by := g_last_updated_by;
l_iface_rec.creation_date := rec.created_date;
l_iface_rec.created_by := g_created_by;
l_iface_rec.last_update_login := g_last_update_login;
l_iface_rec.program_application_id := g_program_appl_id;
l_iface_rec.program_id := g_program_id;
l_iface_rec.program_update_date := g_program_upd_date;
INSERT INTO po_headers_interface
VALUES l_iface_rec;
--l_iface_lines_rec po_lines_interface%ROWTYPE;
---校验行相关信息
BEGIN
SELECT msi.inventory_item_id,
msi.description
INTO l_item_id,
l_item_description
FROM mtl_system_items_b msi,
financials_system_params_all fsp
WHERE 1 = 1
AND nvl(msi.organization_id, fsp.inventory_organization_id) = fsp.inventory_organization_id
AND fsp.org_id = l_org_id
AND msi.segment1 = rec_po_line.item_number;
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Item_number: ' || rec_po_line.item_number || ' Is Error';
log('Item_number: ' || rec_po_line.item_number || ' Is Error');
END; BEGIN
SELECT t.category_id
INTO l_category_id
FROM mtl_categories_kfv t
WHERE t.concatenated_segments = 'DEFAULT|DEFAULT';
EXCEPTION
WHEN OTHERS THEN
l_message := l_message || ' Category Is Error';
log('Category Is Error');
END; IF (l_message IS NOT NULL) THEN
dbms_output.put_line('Error l_message: ' || l_message);
RAISE fnd_api.g_exc_error;
END IF;
--插入行接口表
l_iface_lines_rec := NULL;
l_iface_lines_rec.interface_header_id := l_iface_rec.interface_header_id;
l_iface_lines_rec.interface_line_id := po.po_lines_interface_s.nextval;
l_iface_lines_rec.process_code := 'PENDING';
l_iface_lines_rec.action := 'ORIGINAL';
l_iface_lines_rec.line_num := rec_po_line.line_num;
l_iface_lines_rec.shipment_num := 1;
l_iface_lines_rec.line_type_id := 1;
l_iface_lines_rec.line_type := rec_po_line.type;
l_iface_lines_rec.item_id := l_item_id;
l_iface_lines_rec.category_id := l_category_id;
l_iface_lines_rec.item_description := l_item_description;
l_iface_lines_rec.uom_code := rec_po_line.uom;
l_iface_lines_rec.quantity := rec_po_line.qty;
l_iface_lines_rec.unit_price := rec_po_line.price;
l_iface_lines_rec.need_by_date := rec_po_line.need_by;
l_iface_lines_rec.last_update_date := g_last_update_date;
l_iface_lines_rec.last_updated_by := g_last_updated_by;
l_iface_lines_rec.creation_date := g_creation_date;
l_iface_lines_rec.created_by := g_created_by;
l_iface_lines_rec.last_update_login := g_last_update_login;
l_iface_lines_rec.program_application_id := g_program_appl_id;
l_iface_lines_rec.program_id := g_program_id;
l_iface_lines_rec.program_update_date := g_program_upd_date;
INSERT INTO po_lines_interface
VALUES l_iface_lines_rec;
--l_iface_dis_rec po_distributions_interface%ROWTYPE;
l_iface_dis_rec.interface_header_id := po_headers_interface_s.currval; --;
l_iface_dis_rec.interface_line_id := po_lines_interface_s.currval;
l_iface_dis_rec.interface_distribution_id := po.po_distributions_interface_s.nextval; -- NULL;
l_iface_dis_rec.distribution_num := 1;
l_iface_dis_rec.org_id := l_org_id;
l_iface_dis_rec.quantity_ordered := rec_po_line.qty;
l_iface_dis_rec.destination_type_code := 'INVENTORY'; --类型(费用/库存)
l_iface_dis_rec.rate_date := SYSDATE;
l_iface_dis_rec.last_update_date := g_last_update_date;
l_iface_dis_rec.last_updated_by := g_last_updated_by;
l_iface_dis_rec.creation_date := g_creation_date;
l_iface_dis_rec.created_by := g_created_by;
l_iface_dis_rec.last_update_login := g_last_update_login;
l_iface_dis_rec.program_application_id := g_program_appl_id;
l_iface_dis_rec.program_id := g_program_id;
l_iface_dis_rec.program_update_date := g_program_upd_date;
INSERT INTO po_distributions_interface
VALUES l_iface_dis_rec;
--导入PO
po_docs_interface_sv5.process_po_headers_interface(x_selected_batch_id => l_iface_rec.batch_id,
x_buyer_id => NULL,
x_document_type => l_iface_rec.document_type_code,
x_document_subtype => NULL,
x_create_items => 'N',
x_create_sourcing_rules_flag => NULL,
x_rel_gen_method => NULL,
x_approved_status => l_iface_rec.approval_status,
x_commit_interval => 1,
x_process_code => 'PENDING',
x_interface_header_id => NULL,
x_org_id_param => NULL,
x_ga_flag => NULL)
--查看错误信息
ln_err_count := 0;
FOR c IN (SELECT t.document_num,
l.line_num,
d.distribution_num,
a.error_message,
l.interface_line_id,
d.interface_distribution_id,
a.interface_header_id
FROM po_interface_errors a,
po_headers_interface t,
po_lines_interface l,
po_distributions_interface d
WHERE a.interface_header_id = t.interface_header_id
AND l.interface_line_id(+) = a.interface_line_id
AND d.interface_distribution_id(+) = a.interface_distribution_id
AND t.batch_id = l_iface_rec.batch_id)
LOOP
ln_err_count := ln_err_count + 1;
log('Error: ' || c.error_message);
dbms_output.put_line('Error: ' || c.error_message); DELETE po_headers_interface ph
WHERE ph.interface_header_id = l_iface_rec.interface_header_id; DELETE po_lines_interface pl
WHERE pl.interface_header_id = l_iface_rec.interface_header_id; DELETE po_distributions_interface pd
WHERE pd.interface_header_id = l_iface_rec.interface_header_id; END LOOP;
IF (ln_err_count > 0) THEN
RAISE fnd_api.g_exc_error;
END IF;
PO*创建标准采购订单的更多相关文章
- 详解EBS接口开发之采购订单导入
采购订单常用标准表简介 1.1 常用标准表 如下表中列出了与采购订单导入相关的表和说明: 表名 说明 其他信息 po.po_headers_all 采购订单头 采购订单号,采购类型,供应商,地点, ...
- Oracle EBS-SQL (PO-5):采购订单控制信息查询.sql
select distinct pla.po_header_id, --pha.type_lookup_code, pha.segment1 采购订单号, appf.full_name ...
- SAP MM 标准采购组织的分配对于寄售采购订单收货的影响
SAP MM 标准采购组织的分配对于寄售采购订单收货的影响 PO 4100004022 是一个寄售的采购订单, 采购组织是CSAS, 工厂代码SZSP.采购信息记录也是有的, MIGO试图对该采购订单 ...
- SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了?
SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了? 正确答案是: 不允许,这是SAP标准逻辑. 那么问题来了!今日收到业务人员报说采购订单4300013979,完成了收货和IV, ...
- 【MM系列】SAP MM模块-收货自动创建采购订单
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-收货自动创建采购订 ...
- 【MM系列】SAP 根据采购订单创建外向交货单的BAPI
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP 根据采购订单创建外向交货单的 ...
- 标准IDOC同步采购订单
目录 1功能说明 4 2功能实现 4 2.1创建逻辑系统并分配集团(SALE) 4 2.2维护RFC目标(SM59) 5 2.3在发送端创建模型视图(BD64) 5 2. ...
- Oracle PO - 模块一揽子采购协议小结
本文总结oracle ebs采购订单(po)模块一揽子采购协议的相关知识,总结如下: 1.理论介绍 (1)名词术语 一揽子采购协议(Blanket Purchase Agreement,BPA)是指某 ...
- 转:oracle ebs po模块一揽子采购协议小结
转自:http://yedward.net/?id=193 oracle ebs po模块一揽子采购协议小结 本文总结oracle ebs采购订单(po)模块一揽子采购协议的相关知识,总结如下: 1. ...
随机推荐
- static关键字与方法区和类加载
1.static的作用 答:将成员变量或方法存储进方法区.因为方法区能保证数据只存在一份,只会加载一次(类加载器加载类的时候才加载一次) 注:static Object obj = new Objec ...
- struts2中的namespace意义
<package name="user" namespace="/user" extends="struts-default"> ...
- Ubuntu双系统安装
原文链接: http://www.jianshu.com/p/2eebd6ad284d 作者 Volcanoo 2016.01.31 00:07 字数 1737 阅读 141859评论 161喜欢 ...
- 第二十三章 springboot + 全局异常处理
一.单个controller范围的异常处理 package com.xxx.secondboot.web; import org.springframework.web.bind.annotation ...
- HttpClient 学习整理
HttpClient 是我最近想研究的东西,以前想过的一些应用没能有很好的实现,发现这个开源项目之后就有点眉目了,令人头痛的cookie问题还是有办法解决滴.在网上整理了一些东西,写得很好,寄放在这里 ...
- python 数据处理中的 LabelEncoder 和 OneHotEncoder
One-Hot 编码即独热编码,又称一位有效编码,其方法是使用N位状态寄存器来对N个状态进行编码,每个状态都由他独立的寄存器位,并且在任意时候,其中只有一位有效.这样做的好处主要有:1. 解决了分类器 ...
- Java 与 JavaScript 对websocket的使用
ebsocket,HTML5中新一代全双工通信协议.其底层仍然是http协议. 传统 HTTP 请求响应客户端服务器交互图 WebSocket 请求响应客户端服务器交互图 WebSocket 客户端支 ...
- 20个代码生成框架 (.NET JAVA)
1.1 CodeSmith 一款人气很旺国外的基于模板的dotnet代码生成器 官方网站:http://www.codesmithtools.com 官方论坛:http://forum.codesmi ...
- vue-router登录校验后跳转到之前指定页面如何实现
两个需求:1.用户点击购买需要下单,并跳转到订单页面,但是如果用户没有登录的话,中间有登录验证,会拦截:2.点击购买的时候,登录校验成功了,跳转到订单页面时,订单已创建,去付款即可.3.处理拦截至登录 ...
- python3 使用openpyxl库读写excel(续)
官网:https://openpyxl.readthedocs.io/en/stable/