|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
库存的供应存在于表:MTL_SUPPLY,核准的请购单,核准的采购单数据,采购接收,入库,都将影响这个表里面的数据。下面将MTL_SUPPLY与请购单,采购订单,采购接收的关联关系如下:
select ms.SUPPLY_TYPE_CODE "供应类型代码",
ms.SUPPLY_SOURCE_ID "供应来源ID",
ms.REQ_HEADER_ID "请购单头ID",
ms.REQ_LINE_ID "请购单行ID",
ms.PO_HEADER_ID "采购订单头ID",
ms.PO_RELEASE_ID "发放ID",
ms.PO_LINE_ID "采购订单行ID",
ms.PO_LINE_LOCATION_ID "发运行ID",
ms.PO_DISTRIBUTION_ID "PO分配ID",
ms.SHIPMENT_HEADER_ID "接收头ID",
ms.SHIPMENT_LINE_ID "接收行ID",
ms.RCV_TRANSACTION_ID "接收交易ID",
ms.ITEM_ID "物料ID",
ms.ITEM_REVISION "物料版本",
ms.CATEGORY_ID "分类ID",
ms.QUANTITY "数量",
ms.UNIT_OF_MEASURE "单位",
ms.TO_ORG_PRIMARY_QUANTITY "组织主单位数量",
ms.TO_ORG_PRIMARY_UOM "组织主单位",
ms.RECEIPT_DATE "接收日期",
ms.NEED_BY_DATE "需求日期",
ms.EXPECTED_DELIVERY_DATE "例外交付日期",
ms.DESTINATION_TYPE_CODE "目的类型代码",
ms.LOCATION_ID "地址ID",
ms.FROM_ORGANIZATION_ID "来源组织ID",
ms.FROM_SUBINVENTORY "来源仓库",
ms.TO_ORGANIZATION_ID "到组织ID",
ms.TO_SUBINVENTORY "到仓库",
ms.INTRANSIT_OWNING_ORG_ID "在途所属组织ID",
ms.MRP_PRIMARY_QUANTITY "MRP主数量",
ms.MRP_PRIMARY_UOM "MRP主单位",
ms.MRP_EXPECTED_DELIVERY_DATE "MRP例外交付日期",
ms.MRP_DESTINATION_TYPE_CODE "MRP目的类型代码",
ms.MRP_TO_ORGANIZATION_ID "MRP到组织ID",
ms.MRP_TO_SUBINVENTORY "MRP仓库",
ms.CHANGE_FLAG "更改标志",
ms.CHANGE_TYPE "更改类型",
ms.COST_GROUP_ID "成本组ID",
---头
PRH.ORG_ID "组织ID",
PRH.REQUISITION_HEADER_ID "头ID",
PRH.SEGMENT1 "单号",
to_number('') "发放号",
PRH.TYPE_LOOKUP_CODE "单据类型代码",
pdtav.type_name "单据类型",
PRH.AUTHORIZATION_STATUS "单据状态代码",
PLC1.DISPLAYED_FIELD "单据状态",
--行
msi.segment1 "物料编码",
msi.description "物料描述",
PRL.UNIT_MEAS_LOOKUP_CODE "单位",
PRL.QUANTITY "数量",
---
ms.LAST_UPDATED_BY ,
ms.LAST_UPDATE_DATE ,
ms.LAST_UPDATE_LOGIN ,
ms.CREATED_BY ,
ms.CREATION_DATE ,
ms.REQUEST_ID ,
ms.PROGRAM_APPLICATION_ID ,
ms.PROGRAM_ID ,
ms.PROGRAM_UPDATE_DATE
from MTL_SUPPLY ms,
PO_REQUISITION_HEADERS_ALL prh,
Po_Document_Types_All_Vl pdtav,
PO_LOOKUP_CODES PLC1,
PO_REQUISITION_LINES_ALL prl,
org_organization_definitions ood,
mtl_system_items_vl msi
where 1 = 1
and ms.SUPPLY_TYPE_CODE = 'REQ'
and ms.REQ_HEADER_ID = prh.REQUISITION_HEADER_ID
and pdtav.org_id = prh.org_id
and pdtav.document_type_code in ('REQUISITION')
and pdtav.DOCUMENT_SUBTYPE = prh.TYPE_LOOKUP_CODE
AND PLC1.LOOKUP_CODE = NVL(PRH.AUTHORIZATION_STATUS, 'INCOMPLETE')
AND PLC1.LOOKUP_TYPE = 'AUTHORIZATION STATUS'
and ms.REQ_LINE_ID = prl.REQUISITION_LINE_ID
and prh.org_id = ood.operating_unit
and msi.organization_id = ood.organization_id
and msi.inventory_item_id = prl.item_id
and ood.organization_id <> 86
union all
select ms.SUPPLY_TYPE_CODE "供应类型代码",--6557
ms.SUPPLY_SOURCE_ID "供应来源ID",
ms.REQ_HEADER_ID "请购单头ID",
ms.REQ_LINE_ID "请购单行ID",
ms.PO_HEADER_ID "采购订单头ID",
ms.PO_RELEASE_ID "发放ID",
ms.PO_LINE_ID "采购订单行ID",
ms.PO_LINE_LOCATION_ID "发运行ID",
ms.PO_DISTRIBUTION_ID "PO分配ID",
ms.SHIPMENT_HEADER_ID "接收头ID",
ms.SHIPMENT_LINE_ID "接收行ID",
ms.RCV_TRANSACTION_ID "接收交易ID",
ms.ITEM_ID "物料ID",
ms.ITEM_REVISION "物料版本",
ms.CATEGORY_ID "分类ID",
ms.QUANTITY "数量",
ms.UNIT_OF_MEASURE "单位",
ms.TO_ORG_PRIMARY_QUANTITY "组织主单位数量",
ms.TO_ORG_PRIMARY_UOM "组织主单位",
ms.RECEIPT_DATE "接收日期",
ms.NEED_BY_DATE "需求日期",
ms.EXPECTED_DELIVERY_DATE "例外交付日期",
ms.DESTINATION_TYPE_CODE "目的类型代码",
ms.LOCATION_ID "地址ID",
ms.FROM_ORGANIZATION_ID "来源组织ID",
ms.FROM_SUBINVENTORY "来源仓库",
ms.TO_ORGANIZATION_ID "到组织ID",
ms.TO_SUBINVENTORY "到仓库",
ms.INTRANSIT_OWNING_ORG_ID "在途所属组织ID",
ms.MRP_PRIMARY_QUANTITY "MRP主数量",
ms.MRP_PRIMARY_UOM "MRP主单位",
ms.MRP_EXPECTED_DELIVERY_DATE "MRP例外交付日期",
ms.MRP_DESTINATION_TYPE_CODE "MRP目的类型代码",
ms.MRP_TO_ORGANIZATION_ID "MRP到组织ID",
ms.MRP_TO_SUBINVENTORY "MRP仓库",
ms.CHANGE_FLAG "更改标志",
ms.CHANGE_TYPE "更改类型",
ms.COST_GROUP_ID "成本组ID",
---
POH.ORG_ID "组织ID",
POH.po_header_id "头ID",
POH.SEGMENT1 "单号",
pra.RELEASE_NUM "发放号",
POH.type_lookup_code "单据类型代码",
pdtav.type_name "单据类型",
poh.authorization_status "单据状态代码",
plc1.DISPLAYED_FIELD "单据状态",
--行
msi.segment1 "物料编码",
msi.description "物料描述",
pla.UNIT_MEAS_LOOKUP_CODE "单位",
pla.QUANTITY "数量",
---
ms.LAST_UPDATED_BY ,
ms.LAST_UPDATE_DATE ,
ms.LAST_UPDATE_LOGIN ,
ms.CREATED_BY ,
ms.CREATION_DATE ,
ms.REQUEST_ID ,
ms.PROGRAM_APPLICATION_ID ,
ms.PROGRAM_ID ,
ms.PROGRAM_UPDATE_DATE
from MTL_SUPPLY ms,
PO_HEADERS_all poh,
Po_Document_Types_All_Vl pdtav,
po_lookup_codes plc1,
po_releases_all pra,
po_lines_all pla,
po_line_locations_all plla,
org_organization_definitions ood,
mtl_system_items_vl msi
where 1 = 1
and ms.SUPPLY_TYPE_CODE = 'PO'
and poh.PO_HEADER_ID = ms.PO_HEADER_ID
and plc1.LOOKUP_TYPE(+) = 'AUTHORIZATION STATUS'
and plc1.lookup_code(+) = poh.AUTHORIZATION_STATUS
and pdtav.org_id = poh.org_id
and pdtav.document_type_code in ('PO', 'PA')
and pdtav.DOCUMENT_SUBTYPE = POH.TYPE_LOOKUP_CODE
and pra.PO_HEADER_ID(+) = ms.PO_HEADER_ID
and pra.PO_RELEASE_ID(+) = ms.PO_RELEASE_ID
and pla.po_line_id = ms.po_line_id
and plla.line_location_id = ms.po_line_location_id
and pla.org_id = ood.operating_unit
and msi.organization_id = ood.organization_id
and msi.inventory_item_id = pla.item_id
and ood.organization_id <> 86
union all
select ms.SUPPLY_TYPE_CODE "供应类型代码",--278
ms.SUPPLY_SOURCE_ID "供应来源ID",
ms.REQ_HEADER_ID "请购单头ID",
ms.REQ_LINE_ID "请购单行ID",
ms.PO_HEADER_ID "采购订单头ID",
ms.PO_RELEASE_ID "发放ID",
ms.PO_LINE_ID "采购订单行ID",
ms.PO_LINE_LOCATION_ID "发运行ID",
ms.PO_DISTRIBUTION_ID "PO分配ID",
ms.SHIPMENT_HEADER_ID "接收头ID",
ms.SHIPMENT_LINE_ID "接收行ID",
ms.RCV_TRANSACTION_ID "接收交易ID",
ms.ITEM_ID "物料ID",
ms.ITEM_REVISION "物料版本",
ms.CATEGORY_ID "分类ID",
ms.QUANTITY "数量",
ms.UNIT_OF_MEASURE "单位",
ms.TO_ORG_PRIMARY_QUANTITY "组织主单位数量",
ms.TO_ORG_PRIMARY_UOM "组织主单位",
ms.RECEIPT_DATE "接收日期",
ms.NEED_BY_DATE "需求日期",
ms.EXPECTED_DELIVERY_DATE "例外交付日期",
ms.DESTINATION_TYPE_CODE "目的类型代码",
ms.LOCATION_ID "地址ID",
ms.FROM_ORGANIZATION_ID "来源组织ID",
ms.FROM_SUBINVENTORY "来源仓库",
ms.TO_ORGANIZATION_ID "到组织ID",
ms.TO_SUBINVENTORY "到仓库",
ms.INTRANSIT_OWNING_ORG_ID "在途所属组织ID",
ms.MRP_PRIMARY_QUANTITY "MRP主数量",
ms.MRP_PRIMARY_UOM "MRP主单位",
ms.MRP_EXPECTED_DELIVERY_DATE "MRP例外交付日期",
ms.MRP_DESTINATION_TYPE_CODE "MRP目的类型代码",
ms.MRP_TO_ORGANIZATION_ID "MRP到组织ID",
ms.MRP_TO_SUBINVENTORY "MRP仓库",
ms.CHANGE_FLAG "更改标志",
ms.CHANGE_TYPE "更改类型",
ms.COST_GROUP_ID "成本组ID",
---
rsh.SHIP_TO_ORG_ID "组织ID",
rsh.SHIPMENT_HEADER_ID "头ID",
rsh.receipt_num "单号",
to_number('') "发放号",
'recived' "单据类型代码",
'接收' "单据类型",
'' "单据状态代码",
'' "单据状态",
--行
msi.segment1 "物料编码",
msi.description "物料描述",
rsl.UNIT_OF_MEASURE "单位",
rsl.QUANTITY_received "数量",
---
ms.LAST_UPDATED_BY ,
ms.LAST_UPDATE_DATE ,
ms.LAST_UPDATE_LOGIN ,
ms.CREATED_BY ,
ms.CREATION_DATE ,
ms.REQUEST_ID ,
ms.PROGRAM_APPLICATION_ID ,
ms.PROGRAM_ID ,
ms.PROGRAM_UPDATE_DATE
from MTL_SUPPLY ms,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
mtl_system_items_vl msi
where 1 = 1
and ms.SUPPLY_TYPE_CODE = 'RECEIVING'
and ms.SHIPMENT_HEADER_ID = rsh.SHIPMENT_HEADER_ID
and ms.SHIPMENT_LINE_ID = rsl.SHIPMENT_LINE_ID
and msi.organization_id = rsl.to_organization_id
and msi.inventory_item_id = rsl.item_id |
|