--   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*创建标准采购订单的更多相关文章

  1. 详解EBS接口开发之采购订单导入

    采购订单常用标准表简介 1.1   常用标准表 如下表中列出了与采购订单导入相关的表和说明: 表名 说明 其他信息 po.po_headers_all 采购订单头 采购订单号,采购类型,供应商,地点, ...

  2. Oracle EBS-SQL (PO-5):采购订单控制信息查询.sql

    select distinct pla.po_header_id, --pha.type_lookup_code, pha.segment1       采购订单号, appf.full_name   ...

  3. SAP MM 标准采购组织的分配对于寄售采购订单收货的影响

    SAP MM 标准采购组织的分配对于寄售采购订单收货的影响 PO 4100004022 是一个寄售的采购订单, 采购组织是CSAS, 工厂代码SZSP.采购信息记录也是有的, MIGO试图对该采购订单 ...

  4. SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了?

    SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了? 正确答案是: 不允许,这是SAP标准逻辑. 那么问题来了!今日收到业务人员报说采购订单4300013979,完成了收货和IV, ...

  5. 【MM系列】SAP MM模块-收货自动创建采购订单

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-收货自动创建采购订 ...

  6. 【MM系列】SAP 根据采购订单创建外向交货单的BAPI

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP 根据采购订单创建外向交货单的 ...

  7. 标准IDOC同步采购订单

    目录 1功能说明    4 2功能实现    4 2.1创建逻辑系统并分配集团(SALE)    4 2.2维护RFC目标(SM59)    5 2.3在发送端创建模型视图(BD64)    5 2. ...

  8. Oracle PO - 模块一揽子采购协议小结

    本文总结oracle ebs采购订单(po)模块一揽子采购协议的相关知识,总结如下: 1.理论介绍 (1)名词术语 一揽子采购协议(Blanket Purchase Agreement,BPA)是指某 ...

  9. 转:oracle ebs po模块一揽子采购协议小结

    转自:http://yedward.net/?id=193 oracle ebs po模块一揽子采购协议小结 本文总结oracle ebs采购订单(po)模块一揽子采购协议的相关知识,总结如下: 1. ...

随机推荐

  1. Xsolla和Crytek合作,对游戏战争前线推出全新支付方式

    新闻稿: Sherman Oaks, 加州 (美国) –2014年 10月 15日-计费提供商Xsolla今日正式宣布.和著名游戏开发商以及发行商 Crytek.这次合作意味着玩家能够期待大量的游戏内 ...

  2. android 管理手机短信

    为了看代码方便,一边在网上google资料,一边看Android java 源代码. 偶然发现了一个类MmsSmsDatabaseHelper.java,原来android将所有的短信信息都存入了mm ...

  3. 解决eclipse安装maven的问题:Unable to update index for central|http://repo1.maven.org/maven2

    问题产生如下:因为单位使用了过滤,访问Internet时,超过10M的内容就拒绝.因为maven插件在初始时,需要下载Maven的index文件,这个文件比较大,有38M多,下载不成功.所以造成使用M ...

  4. [翻译] MCProgressView 使用自定义图片做进度显示

    MCProgressView 使用自定义图片做进度显示 https://github.com/Baglan/MCProgressView Progress bar view with custom i ...

  5. vs 默认的INC和LIB

    用户环境变量添加 INCLUDE=C:\inc;c:\inc2 LIB=c:\lib 编辑文件C:\Users\Administrator\AppData\Local\Microsoft\MSBuil ...

  6. [Linux] Linux 守护进程的启动方法

    reference : http://www.ruanyifeng.com/blog/2016/02/linux-daemon.html "守护进程"(daemon)就是一直在后台 ...

  7. 让QT/Embedded支持国际化

    让QT/Embedded支持国际化 环境配置: Qt/Embedded ,在主机和目标板上存放路径都为:/root/qt-embedded-free- Qt/X11 3.3 (主要用到其中的lupda ...

  8. 【BZOJ】【3653】谈笑风生

    dfs序+可持久化线段树 好吧……是我too naive 这题……$$ans=min(dep[x],k)×(size[x]-1)+\sum_{y在x的子树中,且dis(x,y)<=k}(size ...

  9. 第一章 HttpClient的使用

    1.http协议(这一块儿有时间的话会做记录) 2.常用的两种RPC方式 基于http协议:HttpClient和JDK自己的Http操作类 基于TCP或UDP协议:mina2和netty(这一部分以 ...

  10. Jenkins——应用篇——插件使用——Publish over SSH

    本文是jenkins应用系统文章的一部分,大部分来自工作和学习中的实践,部分内容来自官方文档和网友的文章,引用的文章会在"參考资料"部分附上原始链接,如无意中侵犯您的权利.请联系Q ...