--   l_iface_rec       po_headers_interface%ROWTYPE;

校验头相关信息

  1 SELECT COUNT(1)
  2         INTO l_po_count
  3         FROM po_headers_all ph
  4        WHERE 1 = 1
  5          AND ph.segment1 = rec.po_number;
  6       IF (l_po_count > 0) THEN
  7         l_message := l_message || ' Po_number: ' || rec.po_number || ' Is Error';
  8         log('Po_number: ' || rec.po_number || ' Is Error');
  9       END IF;
 10
 11       BEGIN
 12         SELECT hou.organization_id
 13           INTO l_org_id
 14           FROM hr_operating_units hou
 15          WHERE 1 = 1
 16            AND hou.name = rec.ou;
 17       EXCEPTION
 18         WHEN OTHERS THEN
 19           l_message := l_message || ' OU: ' || rec.ou || ' Is Error';
 20           log('OU: ' || rec.ou || ' Is Error');
 21       END;
 22
 23       BEGIN
 24         SELECT podb.document_subtype
 25           INTO l_type_code
 26           FROM po_document_types_all_b  podb,
 27                po_document_types_all_tl podt
 28          WHERE 1 = 1
 29            AND podb.document_type_code = podt.document_type_code
 30            AND podb.document_subtype = podt.document_subtype
 31            AND podb.org_id = podt.org_id
 32            AND podt.language = 'US'
 33            AND podb.org_id = l_org_id
 34            AND podb.document_type_code IN ('PO', 'PA')
 35            AND podt.type_name = rec.type;
 36       EXCEPTION
 37         WHEN OTHERS THEN
 38           l_message := l_message || ' Type: ' || rec.type || ' Is Error';
 39           log('Type: ' || rec.type || ' Is Error');
 40       END;
 41
 42       BEGIN
 43         SELECT pv.vendor_id
 44           INTO l_vendor_id
 45           FROM po_vendors pv
 46          WHERE 1 = 1
 47            AND pv.vendor_name = rec.suppiler;
 48       EXCEPTION
 49         WHEN OTHERS THEN
 50           l_message := l_message || ' Suppiler: ' || rec.suppiler || ' Is Error';
 51           log('Suppiler: ' || rec.suppiler || ' Is Error');
 52       END;
 53
 54       BEGIN
 55         SELECT vs.vendor_site_id
 56           INTO l_vendor_site_id
 57           FROM po_vendor_sites_all vs
 58          WHERE 1 = 1
 59            AND vs.vendor_id = l_vendor_id
 60            AND vs.vendor_site_code = rec.site;
 61       EXCEPTION
 62         WHEN OTHERS THEN
 63           l_message := l_message || ' Site: ' || rec.site || ' Is Error';
 64           log('Site: ' || rec.site || ' Is Error');
 65       END;
 66
 67       BEGIN
 68         SELECT hl.location_id
 69           INTO l_ship_to_location_id
 70           FROM hr_locations_all_tl hl
 71          WHERE 1 = 1
 72            AND hl.location_code = rec.ship_to
 73            AND hl.language = userenv('LANG');
 74       EXCEPTION
 75         WHEN OTHERS THEN
 76           l_message := l_message || ' Ship_to: ' || rec.ship_to || ' Is Error';
 77           log('Ship_to: ' || rec.ship_to || ' Is Error');
 78       END;
 79
 80       BEGIN
 81         SELECT hl.location_id
 82           INTO l_bill_to_location_id
 83           FROM hr_locations_all_tl hl
 84          WHERE 1 = 1
 85            AND hl.location_code = rec.bill_to
 86            AND hl.language = userenv('LANG');
 87       EXCEPTION
 88         WHEN OTHERS THEN
 89           l_message := l_message || ' Bill_to: ' || rec.bill_to || ' Is Error';
 90           log('Bill_to: ' || rec.bill_to || ' Is Error');
 91       END;
 92
 93       BEGIN
 94         SELECT p.person_id
 95           INTO l_agent_id
 96           FROM per_people_f p
 97          WHERE 1 = 1
 98            AND p.full_name = rec.buyer;
 99       EXCEPTION
100         WHEN OTHERS THEN
101           l_message := l_message || ' Buyer: ' || rec.buyer || ' Is Error';
102           log('Buyer: ' || rec.buyer || ' Is Error');
103       END;
104
105       IF (l_message IS NOT NULL) THEN
106         dbms_output.put_line('Error l_message: ' || l_message);
107         RAISE fnd_api.g_exc_error;
108       END IF;
109     

--插入头接口表

 1       l_iface_rec.interface_header_id   := po_headers_interface_s.nextval;
 2       l_iface_rec.interface_source_code := 'XXPO_ONHAND_HEADER';
 3       l_iface_rec.batch_id              := g_session_id;
 4       l_iface_rec.process_code          := 'PENDING'; --PENDING, ACCEPTED, REJECTED, or NOTIFIED
 5       l_iface_rec.action                := 'ORIGINAL'; --ORIGINAL,REPLACE, or UPDATE
 6       l_iface_rec.org_id                := l_org_id;
 7       l_iface_rec.document_num          := rec.po_number;
 8       l_iface_rec.document_type_code    := l_type_code; --STANDARD, BLANKET, or QUOTATION
 9       l_iface_rec.vendor_id             := l_vendor_id;
10       l_iface_rec.vendor_site_id        := l_vendor_site_id;
11       l_iface_rec.ship_to_location_id   := l_ship_to_location_id;
12       l_iface_rec.bill_to_location_id   := l_bill_to_location_id;
13       l_iface_rec.agent_id              := l_agent_id;
14       l_iface_rec.approval_status       := rec.status; --'INCOMPLETE'
15       l_iface_rec.currency_code         := rec.currency;
16       --l_iface_rec.rate_date              := to_date('22-MAR-2017', 'DD-MON-YYYY');
17       --l_iface_rec.rate_type              := 'Corporate';
18       l_iface_rec.last_update_date       := g_last_update_date;
19       l_iface_rec.last_updated_by        := g_last_updated_by;
20       l_iface_rec.creation_date          := rec.created_date;
21       l_iface_rec.created_by             := g_created_by;
22       l_iface_rec.last_update_login      := g_last_update_login;
23       l_iface_rec.program_application_id := g_program_appl_id;
24       l_iface_rec.program_id             := g_program_id;
25       l_iface_rec.program_update_date    := g_program_upd_date;
26       INSERT INTO po_headers_interface
27       VALUES l_iface_rec;

--l_iface_lines_rec po_lines_interface%ROWTYPE;

---校验行相关信息

 1 BEGIN
 2           SELECT msi.inventory_item_id,
 3                  msi.description
 4             INTO l_item_id,
 5                  l_item_description
 6             FROM mtl_system_items_b           msi,
 7                  financials_system_params_all fsp
 8            WHERE 1 = 1
 9              AND nvl(msi.organization_id, fsp.inventory_organization_id) = fsp.inventory_organization_id
10              AND fsp.org_id = l_org_id
11              AND msi.segment1 = rec_po_line.item_number;
12         EXCEPTION
13           WHEN OTHERS THEN
14             l_message := l_message || ' Item_number: ' || rec_po_line.item_number || ' Is Error';
15             log('Item_number: ' || rec_po_line.item_number || ' Is Error');
16         END;
17
18         BEGIN
19           SELECT t.category_id
20             INTO l_category_id
21             FROM mtl_categories_kfv t
22            WHERE t.concatenated_segments = 'DEFAULT|DEFAULT';
23         EXCEPTION
24           WHEN OTHERS THEN
25             l_message := l_message || ' Category Is Error';
26             log('Category Is Error');
27         END;
28
29         IF (l_message IS NOT NULL) THEN
30           dbms_output.put_line('Error l_message: ' || l_message);
31           RAISE fnd_api.g_exc_error;
32         END IF;

--插入行接口表

 1         l_iface_lines_rec                        := NULL;
 2         l_iface_lines_rec.interface_header_id    := l_iface_rec.interface_header_id;
 3         l_iface_lines_rec.interface_line_id      := po.po_lines_interface_s.nextval;
 4         l_iface_lines_rec.process_code           := 'PENDING';
 5         l_iface_lines_rec.action                 := 'ORIGINAL';
 6         l_iface_lines_rec.line_num               := rec_po_line.line_num;
 7         l_iface_lines_rec.shipment_num           := 1;
 8         l_iface_lines_rec.line_type_id           := 1;
 9         l_iface_lines_rec.line_type              := rec_po_line.type;
10         l_iface_lines_rec.item_id                := l_item_id;
11         l_iface_lines_rec.category_id            := l_category_id;
12         l_iface_lines_rec.item_description       := l_item_description;
13         l_iface_lines_rec.uom_code               := rec_po_line.uom;
14         l_iface_lines_rec.quantity               := rec_po_line.qty;
15         l_iface_lines_rec.unit_price             := rec_po_line.price;
16         l_iface_lines_rec.need_by_date           := rec_po_line.need_by;
17         l_iface_lines_rec.last_update_date       := g_last_update_date;
18         l_iface_lines_rec.last_updated_by        := g_last_updated_by;
19         l_iface_lines_rec.creation_date          := g_creation_date;
20         l_iface_lines_rec.created_by             := g_created_by;
21         l_iface_lines_rec.last_update_login      := g_last_update_login;
22         l_iface_lines_rec.program_application_id := g_program_appl_id;
23         l_iface_lines_rec.program_id             := g_program_id;
24         l_iface_lines_rec.program_update_date    := g_program_upd_date;
25         INSERT INTO po_lines_interface
26         VALUES l_iface_lines_rec;
27       

--l_iface_dis_rec   po_distributions_interface%ROWTYPE;

 1   l_iface_dis_rec.interface_header_id       := po_headers_interface_s.currval; --;
 2         l_iface_dis_rec.interface_line_id         := po_lines_interface_s.currval;
 3         l_iface_dis_rec.interface_distribution_id := po.po_distributions_interface_s.nextval; -- NULL;
 4         l_iface_dis_rec.distribution_num          := 1;
 5         l_iface_dis_rec.org_id                    := l_org_id;
 6         l_iface_dis_rec.quantity_ordered          := rec_po_line.qty;
 7         l_iface_dis_rec.destination_type_code     := 'INVENTORY'; --类型(费用/库存)
 8         l_iface_dis_rec.rate_date                 := SYSDATE;
 9         l_iface_dis_rec.last_update_date          := g_last_update_date;
10         l_iface_dis_rec.last_updated_by           := g_last_updated_by;
11         l_iface_dis_rec.creation_date             := g_creation_date;
12         l_iface_dis_rec.created_by                := g_created_by;
13         l_iface_dis_rec.last_update_login         := g_last_update_login;
14         l_iface_dis_rec.program_application_id    := g_program_appl_id;
15         l_iface_dis_rec.program_id                := g_program_id;
16         l_iface_dis_rec.program_update_date       := g_program_upd_date;
17         INSERT INTO po_distributions_interface
18         VALUES l_iface_dis_rec;

--导入PO

 1       po_docs_interface_sv5.process_po_headers_interface(x_selected_batch_id          => l_iface_rec.batch_id,
 2                                                          x_buyer_id                   => NULL,
 3                                                          x_document_type              => l_iface_rec.document_type_code,
 4                                                          x_document_subtype           => NULL,
 5                                                          x_create_items               => 'N',
 6                                                          x_create_sourcing_rules_flag => NULL,
 7                                                          x_rel_gen_method             => NULL,
 8                                                          x_approved_status            => l_iface_rec.approval_status,
 9                                                          x_commit_interval            => 1,
10                                                          x_process_code               => 'PENDING',
11                                                          x_interface_header_id        => NULL,
12                                                          x_org_id_param               => NULL,
13                                                          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_idFROM po_interface_errors        a,po_headers_interface       t,po_lines_interface         l,po_distributions_interface dWHERE a.interface_header_id = t.interface_header_idAND l.interface_line_id(+) = a.interface_line_idAND d.interface_distribution_id(+) = a.interface_distribution_idAND t.batch_id = l_iface_rec.batch_id)LOOPln_err_count := ln_err_count + 1;log('Error: ' || c.error_message);dbms_output.put_line('Error: ' || c.error_message);DELETE po_headers_interface phWHERE ph.interface_header_id = l_iface_rec.interface_header_id;DELETE po_lines_interface plWHERE pl.interface_header_id = l_iface_rec.interface_header_id;DELETE po_distributions_interface pdWHERE pd.interface_header_id = l_iface_rec.interface_header_id;END LOOP;IF (ln_err_count > 0) THENRAISE fnd_api.g_exc_error;END IF;

转载于:https://www.cnblogs.com/wang-chen/p/6605963.html

PO*创建标准采购订单相关推荐

  1. PO: Purchase Order采购订单关键知识点

    基础业务学习 PO模块概述首先,PO解决了企业采购的基本管理问题:何时向何供应商以何价格采购何物料,采购信息与仓库.质检.财务高度共享. 何时何物:手工指定.MRP运算结果.内部请购.Dropship ...

  2. Oracle EBS Interface/API(18) - 标准采购订单、PBA和一揽子发放等等审批API

    一.标准采购订单和PBA审批API: DECLARELv_Ret_Status VARCHAR2(30);Ln_Org_Id NUMBER := 101; --业务实体标识Ln_Preparer_Id ...

  3. SAP MM初阶创建服务采购订单时订购单位和物料组的缺省值

    SAP MM初阶创建服务采购订单时订购单位和物料组的缺省值 执行事务代码ME21N 创建采购订单,输入了单据类型,供应商,组织结构相关的数据,账户分配类别指定为K.如下图, 当把item catego ...

  4. SAP RETAIL 如何根据分配表查到根据它创建的采购订单?

    SAP RETAIL 如何根据分配表查到根据它创建的采购订单? 在SAP RETAIL系统中,我们可以创建好分配表,然后通过分配表可以批量创建采购订单.这个功能在零售行业里会使用到,当有新的门店要营业 ...

  5. 标准采购订单的计算方案确定

    标准采购订单的计算方案通过采购组织方案组和供应商方案组确定: 1)定义计算方案SE16N:V_T683 用途A,应用程序M. 2)维护方案组,供应商方案组SM30:V_TMKK,采购组织方案组SM30 ...

  6. 【MM小贴士】SAP创建成本中心采购订单带出默认会计科目和成本中心

    在实施SAP项目梳理MM模块业务需求的时候,很多公司都会有这样需求,就是在创建成本中心采购订单的时候,因为成本中心和会计科目是必须输的,所以用户希望系统能够自动带出默认的会计科目和成本中心(如下图). ...

  7. Excel VBA + GUI Script 创建SAP采购订单-ME21N

    之前使用VBA写过几个GUI Script,这个是用来使用T-Code ME21N自动创建采购订单,这个脚本的难点在于获取SAP GUI的PO的Item的表格名,多次运行获得的表格名称可能会不一致,因 ...

  8. 创建管理采购订单、集成ERP与MES系统、在库管理……制造商们正在应用软件机器人实现流程自动化

    一直以来,制造业使用工业机器人提高生产效率.而博为小帮软件机器人的出现,则为制造商实现降本增效提供了补充方案,它能帮助制造商将重复规则的工作流程实现自动化,加快日常工作和任务的速度与准确性,如实现数据 ...

  9. sap 采购订单 bapi (创建外协采购订单-组件为手工输入)

    其实则不然,只要把U改成 'E' 即可 另外:采购价格问题. 如果采购订单凭证日期决定的信息记录有效就会取信息记录,不会取EXCEL . 处理方法:1 保证取不到信息记录. 2 或者 修改后台配置(取 ...

最新文章

  1. mybatis结合log4j打印SQL日志
  2. Alpha冲刺——day1
  3. linux oraclerman自动备份,Linux平台下的Oracle自动备份案例(使用RMAN)
  4. Git 分支 - rebase 变基
  5. 编译Bitcoin BCH configure: error: libdb_cxx headers missing ,终于解决了
  6. 关于 p3p ie 跨域 问题
  7. 1.6编程基础之一维数组_09向量点积计算
  8. 公共基础知识计算机,事业单位考试公共基础知识:计算机基础知识
  9. 【图像隐写】基于matlab高斯模型JPEG图像隐写【含Matlab源码 367期】
  10. mysql_query的返回值
  11. lua32位和64位字符串和Uint之间的转换
  12. Python熵权法确定权重
  13. python变量名包括_python中变量的命名以及使用
  14. 带孔的打印纸怎么设置_针式打印机纸张的格式大小该怎么设置?
  15. Java文件传输带宽控制_如何限制Java中的带宽?
  16. mysql数据库管理工具 h_几款桌面MYSQL管理工具
  17. td-agent windows 安装步骤
  18. Python 网络爬虫及数据可视化
  19. 运算库之numpy(数组的切片操作和数组shape的转换)
  20. 马来西亚央行抨击使用误导性Logo的ICO项目

热门文章

  1. Gensim库的使用——Gensim库的核心概念介绍
  2. android主线程报ANR的问题!
  3. 照片实现3D光影效果
  4. flex effect
  5. 小程序流量主怎么赚钱?小程序流量主怎么变现?
  6. 23模式--建造者模式
  7. 微信小程序中商品列表 不显示
  8. Java设计模式之外观模式(门面模式,迪米特法则的具体实现,抽象外观类改进)
  9. Python爬虫实战(02)—— 爬取诗词名句三国演义
  10. 算法【哈希】 | 哈希表