采购至库存所经历的表
select * from PO_REQUISITIONS_INTERFACE_ALL;--请购接口表 select * from PO_REQUISITION_HEADERS_ALL;--请购单头信息 select * from PO_REQUISITION_LINES_ALL;--请购单行信息 select * from PO_REQ_DISTRIBUTIONS_ALL;--请购单分配信息 select * from po_headers_all;--采购订单头信息 select * from po_lines_all;--采购订单行信息 select * from po_line_locations_all;--采购订单行的发送表 select * from po_distributions_all;--采购订单 select * from po_releases_all;-- 订单发放 select * from RCV_TRANSACTIONS;--接收事务处理
--采购到入库所经历的表 --0.请购单 --创建请购单方式有 --a.从外挂系统导入请购的接口表PO_REQUISITIONS_INTERFACE_ALL,并允许请求(名称:导入申请) SELECT * FROM PO_REQUISITIONS_INTERFACE_ALL WHERE INTERFACE_SOURCE_CODE = 'TEST KHJ'; --b.在系统中创建请购单(路径:PO/申请/申请) --请购单头信息 SELECT PRH.REQUISITION_HEADER_ID, PRH.AUTHORIZATION_STATUS --未审批时为INCOMPLETE,审批完后为 FROM PO_REQUISITION_HEADERS_ALL PRH WHERE PRH.SEGMENT1 = '600000' AND PRH.TYPE_LOOKUP_CODE = 'PURCHASE'; --请购单行信息 SELECT PRL.REQUISITION_LINE_ID, PRL.* FROM PO_REQUISITION_LINES_ALL PRL WHERE PRL.REQUISITION_HEADER_ID IN (SELECT PRH.REQUISITION_HEADER_ID FROM PO_REQUISITION_HEADERS_ALL PRH WHERE PRH.SEGMENT1 = '600000' AND PRH.TYPE_LOOKUP_CODE = 'PURCHASE'); --请购单分配行 SELECT * FROM PO_REQ_DISTRIBUTIONS_ALL PRDA WHERE PRDA.REQUISITION_LINE_ID IN (SELECT PRL.REQUISITION_LINE_ID FROM PO_REQUISITION_LINES_ALL PRL WHERE PRL.REQUISITION_HEADER_ID IN (SELECT PRH.REQUISITION_HEADER_ID FROM PO_REQUISITION_HEADERS_ALL PRH WHERE PRH.SEGMENT1 = '600000' AND PRH.TYPE_LOOKUP_CODE = 'PURCHASE')); --1.采购订单的创建(路径:PO/采购订单/采购订单) --po_headers_all 采购订单头表 SELECT PHA.PO_HEADER_ID, PHA.SEGMENT1, PHA.AGENT_ID, PHA.TYPE_LOOKUP_CODE, --标准采购单为STANDARD,一揽子协议为BLANKET DECODE(PHA.APPROVED_FLAG, 'R', PHA.APPROVED_FLAG, NVL(PHA.AUTHORIZATION_STATUS, 'INCOMPLETE')), --审批,未审批时为INCOMPLETE,审批后为APPROVED PO_HEADERS_SV3.GET_PO_STATUS(PHA.PO_HEADER_ID) --刚下完采购单,未审批时,po状态为未完成,审批后,状态为批准 FROM PO_HEADERS_ALL PHA WHERE SEGMENT1 = 300446; --采购单号码 --po_lines_all 采购订单行表 SELECT PLA.PO_LINE_ID, PLA.LINE_TYPE_ID FROM PO_LINES_ALL PLA WHERE PO_HEADER_ID = (SELECT PO_HEADER_ID FROM PO_HEADERS_ALL WHERE SEGMENT1 = 300446); --po_line_locations_all 采购订单行的发送表(路径:PO/采购订单/采购订单/发运(T)) --po_line_id=po_lines_all.po_line_id --当点击发运按钮时,系统会自动创建第一行发运行,可根据需要手工创建新的发运行 --(例如同一采购订单行的物料可能会发往不同的地点,此表记录物料发送情况) --下面为取订单与其发运的关系(可能存在多次发运) SELECT * FROM PO_LINE_LOCATIONS_ALL PLLA WHERE PLLA.PO_LINE_ID = (SELECT PLA.PO_LINE_ID FROM PO_LINES_ALL PLA WHERE PO_HEADER_ID = (SELECT PO_HEADER_ID FROM PO_HEADERS_ALL WHERE SEGMENT1 = 300446)); --或者 SELECT * FROM PO_LINE_LOCATIONS_ALL PLLA WHERE PLLA.PO_HEADER_ID = (SELECT PO_HEADER_ID FROM PO_HEADERS_ALL WHERE SEGMENT1 = 300446); --4、po_distributions_all 采购订单发送行的分配表(路径:PO/采购订单/采购订单/发运(T)/分配(T)) --line_location_id=po_line_location_all.line_location_id --发往同一地点的物料也可能放在不同的子库存,此表记录物料分配情况 SELECT * FROM PO_DISTRIBUTIONS_ALL PDA WHERE PDA.LINE_LOCATION_ID IN (SELECT PLLA.LINE_LOCATION_ID FROM PO_LINE_LOCATIONS_ALL PLLA WHERE PLLA.PO_LINE_ID = (SELECT PLA.PO_LINE_ID FROM PO_LINES_ALL PLA WHERE PO_HEADER_ID = (SELECT PO_HEADER_ID FROM PO_HEADERS_ALL WHERE SEGMENT1 = 300446))); --或者 SELECT * FROM PO_DISTRIBUTIONS_ALL WHERE PO_HEADER_ID = (SELECT PO_HEADER_ID FROM PO_HEADERS_ALL WHERE SEGMENT1 = 300446); --或者 SELECT * FROM PO_DISTRIBUTIONS_ALL PDA WHERE PDA.PO_LINE_ID = (SELECT PLA.PO_LINE_ID FROM PO_LINES_ALL PLA WHERE PO_HEADER_ID = (SELECT PO_HEADER_ID FROM PO_HEADERS_ALL WHERE SEGMENT1 = 300446)); --对于po_distribution_all 表而言,如果其SOURCE_DISTRIBUTION_ID 有值, 其对应于计划采购单发放 --po_releases_all 订单发放 --该表包含一揽子协议以及计划采购单的release,对于每一张发放的一揽子协议或者计划采购单都有相关行与之对应 --其包含采购员,日期,释放状态,释放号码,每一个释放行都有至少一条的采购单的发运信息与之对应(PO_LINE_LOCATIONS_ALL). --每做一次Realese,PO_distributions_all就会新增一条记录。这是计划订单的特性。 -- SELECT * FROM PO_RELEASES_ALL WHERE PO_HEADER_ID =供应商) --a.库存退货至接收 SELECT RT.DESTINATION_TYPE_CODE, RT.INTERFACE_SOURCE_CODE, RT.* FROM RCV_TRANSACTIONS RT WHERE RT.INTERFACE_SOURCE_CODE IS NULL AND RT.TRANSACTION_TYPE = 'RETURN TO RECEIVING' --先退货至接收 AND RT.SOURCE_DOCUMENT_CODE = 'PO' AND RT.DESTINATION_TYPE_CODE = 'INVENTORY' AND PO_HEADER_ID = 4105; --b.接收退货至供应商 SELECT RT.DESTINATION_TYPE_CODE, RT.INTERFACE_SOURCE_CODE, RT.* FROM RCV_TRANSACTIONS RT WHERE RT.INTERFACE_SOURCE_CODE IS NULL AND RT.TRANSACTION_TYPE = 'RETURN TO VENDOR' --退货至供应商 AND RT.SOURCE_DOCUMENT_CODE = 'PO' AND RT.DESTINATION_TYPE_CODE = 'RECEIVING' AND PO_HEADER_ID = 4105; SELECT MMT.* FROM MTL_MATERIAL_TRANSACTIONS MMT WHERE MMT.TRANSACTION_SOURCE_ID = 4105 AND MMT.TRANSACTION_TYPE_ID = 36 --向供应商退货 AND MMT.TRANSACTION_ACTION_ID = 1 --从库存发放 AND MMT.TRANSACTION_SOURCE_TYPE_ID = 1 --采购订单;