查詢ATO流程中SO與WIP Job的相關資訊的SQL
select we.wip_entity_name wo,
wdj.organization_id,
wdj.creation_date,
wdj.scheduled_start_date,
wdj.date_released,
wdj.date_completed,
wdj.date_closed,
wdj.start_quantity,
wr.segment1 so,
ool.line_number,
ool.ordered_item,
ool.ordered_quantity
from apps.wip_discrete_jobs wdj,
apps.wip_reservations_v wr,
apps.wip_entities we,
apps.oe_order_lines_all ool
where wdj.source_line_id = wr.demand_source_line_id(+)
and wdj.wip_entity_id = we.wip_entity_id
and wr.demand_source_line_id = ool.line_id(+)
--and we.wip_entity_name ='186540'
and wdj.organization_id = 1032
and trunc(wdj.creation_date) = trunc(sysdate)
========================================================
select wip_so.sale_order_number so_num,
wip_so.line_number so_line_num,
------------------------------------------
wdj.rowid row_id,
wdj.organization_id,
wdj.wip_entity_id,
we.wip_entity_name,
wdj.primary_item_id,
msik.segment1 fg_item_number,
msik.description fg_item_desc,
msik.primary_uom_code fg_uom_code,
wdj.completion_subinventory,
wdj.scheduled_start_date,
wdj.scheduled_completion_date,
wdj.creation_date job_creation_date,
wdj.created_by job_created_by,
wdj.last_update_date job_last_update_date,
wdj.last_updated_by job_last_updated_by,
wdj.description job_desc,
wdj.status_type,
wdj.job_type,
lu3.meaning job_type_name,
wdj.wip_supply_type comp_supply_type,
wdj.class_code,
wdj.date_released,
wdj.date_completed,
wdj.date_closed,
wdj.start_quantity,
decode(wdj.quantity_completed, 0, null, wdj.quantity_completed) "QUANTITY_COMPLETED",
decode(wdj.start_quantity - wdj.quantity_completed -
wdj.quantity_scrapped,
0,
null,
wdj.start_quantity - wdj.quantity_completed -
wdj.quantity_scrapped) "QUANTITY_REMAINING",
decode(wdj.quantity_scrapped, 0, null, wdj.quantity_scrapped) "QUANTITY_SCRAPPED",
wdj.net_quantity,
wdj.common_bom_sequence_id,
wdj.common_routing_sequence_id,
wdj.bom_revision,
wdj.routing_revision,
wdj.bom_revision_date,
wdj.routing_revision_date,
wdj.completion_locator_id,
decode(wdj.completion_subinventory, null, 1, msub.locator_type) sub_locator_control,
wdj.demand_class,
wsg.schedule_group_name,
wdj.schedule_group_id,
wdj.build_sequence,
wl.line_code,
wdj.line_id,
--WDJ.ATTRIBUTE1,
--WDJ.ATTRIBUTE2,
--WDJ.ATTRIBUTE3,
lu1.meaning status_type_disp,
lu2.meaning wip_supply_type_disp,
wdj.overcompletion_tolerance_type,
wdj.overcompletion_tolerance_value,
wdj.priority,
we.entity_type,
-----------------------------------------------
wro.rowid comp_row_id,
wro.inventory_item_id com_item_id,
msik1.segment1 comp_item_code,
msik1.description comp_item_desc,
msik1.item_type comp_item_type,
msik1.primary_uom_code comp_item_uom,
msik1.attribute9 supplier_name,
msik1.buyer_id,
wro.operation_seq_num,
wro.repetitive_schedule_id,
wro.last_update_date comp_last_update_date,
wro.last_updated_by comp_last_updated_by,
wro.creation_date comp_creation_date,
wro.created_by comp_created_by,
wro.department_id,
bd.department_code,
wro.wip_supply_type,
ml1.meaning wip_supply_meaning,
wro.date_required,
wro.required_quantity,
decode(wro.quantity_issued, 0, null, wro.quantity_issued) quantity_issued,
decode((wro.required_quantity - wro.quantity_issued),
0,
null,
decode(sign(wro.required_quantity),
-1 * sign(wro.quantity_issued),
(wro.required_quantity - wro.quantity_issued),
decode(sign(abs(wro.required_quantity) -
abs(wro.quantity_issued)),
-1,
null,
(wro.required_quantity - wro.quantity_issued)))) quantity_open,
wro.quantity_per_assembly,
wro.supply_subinventory,
wro.supply_locator_id,
t.long_description,
msik1.dimension_uom_code,
msik1.unit_length,
msik1.unit_width,
msik1.unit_height,
decode(msik1.unit_length, null, null, 'D') || '' ||
msik1.unit_length ||
decode(msik1.unit_length,
null,
null,
decode(msik1.unit_width, null, null, ' x ')) ||
decode(msik1.unit_width, null, null, 'W') || msik1.unit_width ||
decode(msik1.unit_length || msik1.unit_width,
null,
null,
decode(msik1.unit_height, null, null, ' x ')) ||
decode(msik1.unit_height, null, null, 'H') || msik1.unit_height comp_item_dimension
from mtl_secondary_inventories msub,
mfg_lookups lu1,
mfg_lookups lu2,
mfg_lookups lu3,
wip_entities we,
wip_discrete_jobs wdj,
wip_requirement_operations wro,
bom_departments bd,
wip_lines wl,
wip_schedule_groups wsg,
mtl_system_items_b msik,
mtl_system_items_b msik1,
mfg_lookups ml1,
mtl_system_items_tl t,
(select mr.reservation_id,
mr.organization_id org_id,
mr.demand_source_type_id,
mr.demand_source_name,
mr.demand_source_header_id,
mr.demand_source_line_id,
ool.line_number,
mso.segment1 sale_order_number,
mso.segment2, /* 10 */
mso.segment3
from mtl_reservations mr,
oe_order_lines_all ool,
mtl_sales_orders mso
where mso.sales_order_id = mr.demand_source_header_id
and mr.demand_source_line_id = ool.line_id
and mr.demand_source_type_id in (2, 8) /* INV_RESERVATION_GLOBAL.G_SOURCE_TYPE_OE */
and mr.supply_source_type_id = 5) wip_so --,
--MTL_ITEM_CATEGORIES MIC,
--MTL_CATEGORIES_B MCB
where we.wip_entity_id = wdj.wip_entity_id
and wdj.wip_entity_id = wro.wip_entity_id
and wdj.status_type = 3 --Job Status:Released
and msub.secondary_inventory_name(+) = wdj.completion_subinventory
and msub.organization_id(+) = wdj.organization_id
and wsg.schedule_group_id(+) = wdj.schedule_group_id
and wl.line_id(+) = wdj.line_id
and wl.organization_id(+) = wdj.organization_id
and lu2.lookup_type = 'WIP_SUPPLY'
and lu1.lookup_type = 'WIP_JOB_STATUS'
and lu3.lookup_type = 'WIP_DISCRETE_JOB'
and lu1.lookup_code = wdj.status_type
and lu2.lookup_code = wdj.wip_supply_type
and lu3.lookup_code = wdj.job_type
and msik.inventory_item_id = wdj.primary_item_id
and msik.organization_id = wdj.organization_id
and msik1.inventory_item_id = wro.inventory_item_id
and msik1.organization_id = wro.organization_id
and bd.department_id(+) = wro.department_id
and ml1.lookup_code = wro.wip_supply_type
and ml1.lookup_type = 'WIP_SUPPLY'
and msik1.inventory_item_id = t.inventory_item_id
and msik1.organization_id = t.organization_id
and t.language = userenv('LANG')
and wdj.source_line_id = wip_so.demand_source_line_id(+)
--AND MSIK.INVENTORY_ITEM_ID = MIC.INVENTORY_ITEM_ID
--AND MSIK.ORGANIZATION_ID = MIC.ORGANIZATION_ID
--AND MIC.CATEGORY_SET_ID = 63 --CATEGORY_SET_NAME ='MEW_WIP_CLASS'
--AND MIC.CATEGORY_ID = MCB.CATEGORY_ID
--AND MCB.SEGMENT1 = '886'
--AND MCB.SEGMENT2 = 'S'
--AND MCB.SEGMENT3 = '2200'
--AND WE.WIP_ENTITY_ID = 910797
--AND WE.WIP_ENTITY_NAME = '1009469'
and wdj.organization_id = 112
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/93880/viewspace-1031316/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 鎖表的相關資訊查詢
- sql語法相關子查詢與非相關子查詢SQL
- 什麼是SQL 語句中相關子查詢與非相關子查詢SQL
- SQL中查詢語句內的相關應用SQL
- ORACLE查詢JOB資訊及JOB建立Oracle
- sql-server相關子查詢SQLServer
- Oracle 表空間查詢相關sqlOracleSQL
- 相關子查詢&非相關子查詢概念
- 查詢當前執行的sql及相關內容SQL
- 兩個B1相關的SQL,訂單查詢SQL
- MS SQL SERVER索引優化相關查詢SQLServer索引優化
- SQL聯合查詢中的關鍵語法SQL
- 查詢資料庫物件所屬的filegroup及相關SQL資料庫物件SQL
- sql查詢語句流程SQL
- v$session/v$process檢視涉及的相關會話資訊的查詢Session會話
- UNDO相關查詢
- MySQL索引的最左字首原理與查詢的相關優化MySql索引優化
- 在ubuntu中查詢與某指令碼或某裝置相關的程序Ubuntu指令碼
- 車輛資訊查詢 - 高效快捷地獲取車輛相關資訊的利器
- sql查詢當前使用者所有表、欄位及相關注釋資訊SQL
- 查詢基表的相關檢視
- SQL 查詢中的 NULL 值SQLNull
- SQL SERVER 查詢鎖資訊SQLServer
- CURL查詢ES相關
- MySQL 相關子查詢MySql
- [20160815]查詢相關表的sql語句.txtSQL
- 探究MySQL中SQL查詢的成本MySql
- 在關聯子查詢中in與exists的區別
- 【SQL】使用分析函式與關聯子查詢的比較SQL函式
- MySQL 之慢查詢相關操作MySql
- 表空間相關查詢
- oracle job_相關Oracle
- sql中查詢目錄中的檔名SQL
- SQL查詢的:子查詢和多表查詢SQL
- 看板中的WIP限制思想
- 查詢中的distinct與group by
- Oracle查詢優化器的相關引數Oracle優化
- SQL 查詢 exist join in 的用法和相應的適用場景 (最佳化查詢)SQL