訂單綜合查詢之sql
說明
1, BOM 是指bom筆數,1為正常,0為未建,2及以上為有重複,bom不正常在訂單裡無法發工單與出貨
2, inv扣帳 是指inv是否有扣帳, 大於0為正常, 0為未扣帳(庫存), 出貨後沒扣帳的要查原因並處理
3, 在ar介面 是指目前在ar的interfaced的筆數
4, 立ar 是指ar是否已立帳,大於0為正常, 0則為未立帳,如正式訂單已出貨正常的話要立ar或在ar介面,否則為異常
5, line type 為 ship only 的 不會立ar
6, replenish_to_order_flag不為Y無法撿料出貨的,要重copy模板.
7, 如item最後異動日在訂單建立日期之後,則可能會導至當前訂單未出貨的訂單無法出貨,無法出貨的時候要把訂單line取消後重建方可出貨
8. oe_intf與inv_intf 如出貨後依然為n,則是出貨不成功的,這時要用trip_name重run: Order Management Interface - SRS / Inventory Interface - SRS / Interface Trip Stop - SRS
9, RESERVABLE_TYPE 等於2,表示料號屬性的保留屬性沒打V, 等於1的方可保留. 能保留方可撿料與出貨.
10, 沒有ship no的說明還沒有做編排箱號[@more@]select oh.order_number,oh.org_id,oh.header_id,oh.transactional_curr_code curr,
oh.cust_po_number,
(SELECT count(*)
FROM BOM_BILL_OF_MATERIALS bom
WHERE 1=1
AND ASSEMBLY_ITEM_ID = ol.INVENTORY_ITEM_ID
and bom.ORGANIZATION_ID=nvl(ol.ship_from_org_id,ol.org_id)
) bom_flag,
(select count(*) from mtl_material_transactions mmT
WHERE 1=1
and mmt.TRANSACTION_REFERENCE=to_char(ol.HEADER_ID)
and mmt.TRX_SOURCE_LINE_ID=ol.LINE_ID
and mmt.ORGANIZATION_ID=nvl(ol.ship_from_org_id,ol.org_id)
and mmt.SOURCE_CODE='ORDER ENTRY'
) inv_flag,
(select count(*) from RA_INTERFACE_lines_all ril
where ril.INTERFACE_LINE_CONTEXT='ORDER ENTRY'
and ril.INTERFACE_LINE_ATTRIBUTE1=to_char(oh.order_number)
and ril.INTERFACE_LINE_ATTRIBUTE6=to_char(ol.line_id)
and ril.org_id=ol.org_id
) ri_flag,
(select count(*) from ra_customer_trx_lines_all rtl
where rtl.INTERFACE_LINE_ATTRIBUTE6=to_char(ol.line_id)
and rtl.sales_order=to_char(oh.order_number)
and rtl.INTERFACE_LINE_CONTEXT='ORDER ENTRY'
and rtl.org_id=ol.org_id
) ar_flag,
--gobo_get_ship_no(ol.line_id) ship_no,
ol.line_number,
ol.line_id,
lt.name line_type,
ol.inventory_item_id,
ol.ordered_item,
msi.segment1 fac_item,
ol.CREATION_DATE oeol_creation,
msi.last_update_date item_last_update,
MSI.INVENTORY_ITEM_STATUS_CODE item_status,
msi.REPLENISH_TO_ORDER_FLAG,
msi.ITEM_TYPE,
MSI.RESERVABLE_TYPE,
ol.ordered_quantity,
ol.shipped_quantity,
ol.unit_selling_price ,
ol.flow_status_code,
ol.SCHEDULE_SHIP_DATE,
ol.ACTUAL_SHIPMENT_DATE,
ol.ACTUAL_FULFILLMENT_DATE,
ol.FULFILLED_QUANTITY,
ol.FULFILLMENT_DATE,
gobo_get_ship_no(ol.line_id) ship_no,
wda.delivery_id,
wdd.delivery_detail_id,
wdd.subinventory pick_sub,
wdd.revision pick_rev,
wdd.released_status,
flv.MEANING pick_mean,
flv.description pick_desc,
wdd.OE_INTERFACED_FLAG,
wdd.INV_INTERFACED_FLAG,
wdd.picked_quantity,
wdt.name trip_name,
(select osf.organization_code||'_'||fh.order_number||'_'||fl.line_number||'.'||fl.shipment_number pi
from oe_ship_from_orgs_v osf,oe_order_headers_all fh,oe_order_lines_all fl
where osf.organization_id=fh.org_id
and fh.header_id=fl.header_id
and to_char(fl.line_id)=ol.attribute12
and to_char(fl.header_id)=ol.attribute11
) att_pi,
(select osf.organization_code||'_'||fh.order_number||'_'||fl.line_number||'.'||fl.shipment_number pi
from oe_ship_from_orgs_v osf,oe_order_headers_all fh ,otc_orders_all ooa,oe_order_lines_all fl
where osf.organization_id=fh.org_id
and fh.header_id=fl.header_id
and fl.line_id=ooa.line_id
and ol.orig_sys_line_ref=ooa.orig_sys_line_ref
and ol.orig_sys_document_ref=ooa.orig_sys_document_ref
--and ooa.dest_line=ol.line_id
) ooa_pi
from mtl_system_items_b msi,
FND_LOOKUP_VALUES_VL flv,
WSH_DELIVERABLE_TRIPS_V wdT,
wsh_delivery_assignments wda,
wsh_delivery_details wdd,
oe_order_lines_all ol,
oe_transaction_types_tl lt,
oe_order_headers_all oh
where 1=1
and msi.inventory_item_id=ol.inventory_item_id
and msi.organization_id=nvl(ol.ship_from_org_id,ol.org_id)
and msi.segment1=nvl(:p_item,msi.segment1)
and wda.delivery_detail_id(+)=wdd.delivery_detail_id
and flv.VIEW_APPLICATION_ID(+)=665
and flv.LOOKUP_TYPE(+)='PICK_STATUS'
and flv.lookup_code(+)=wdd.released_status
and wdD.DELIVERY_DETAIL_ID = wdT.DELIVERY_DETAIL_ID(+)
and wdd.source_line_id(+)=ol.line_id
and wdd.source_header_id(+)=ol.header_id
and ol.line_type_id = lt.transaction_type_id
--and upper(lt.name) not like '%SHIP%ONLY%'
AND lt.LANGUAGE = 'US'
and ol.line_number=nvl(:p_line_no,ol.line_number)
and ol.header_id=oh.header_id
and ol.org_id=oh.org_id
and oh.order_number=nvl(:p_order_number,-1)
and oh.org_id=nvl(:p_org_id,-1)
order by ol.LINE_NUMBER
1, BOM 是指bom筆數,1為正常,0為未建,2及以上為有重複,bom不正常在訂單裡無法發工單與出貨
2, inv扣帳 是指inv是否有扣帳, 大於0為正常, 0為未扣帳(庫存), 出貨後沒扣帳的要查原因並處理
3, 在ar介面 是指目前在ar的interfaced的筆數
4, 立ar 是指ar是否已立帳,大於0為正常, 0則為未立帳,如正式訂單已出貨正常的話要立ar或在ar介面,否則為異常
5, line type 為 ship only 的 不會立ar
6, replenish_to_order_flag不為Y無法撿料出貨的,要重copy模板.
7, 如item最後異動日在訂單建立日期之後,則可能會導至當前訂單未出貨的訂單無法出貨,無法出貨的時候要把訂單line取消後重建方可出貨
8. oe_intf與inv_intf 如出貨後依然為n,則是出貨不成功的,這時要用trip_name重run: Order Management Interface - SRS / Inventory Interface - SRS / Interface Trip Stop - SRS
9, RESERVABLE_TYPE 等於2,表示料號屬性的保留屬性沒打V, 等於1的方可保留. 能保留方可撿料與出貨.
10, 沒有ship no的說明還沒有做編排箱號[@more@]select oh.order_number,oh.org_id,oh.header_id,oh.transactional_curr_code curr,
oh.cust_po_number,
(SELECT count(*)
FROM BOM_BILL_OF_MATERIALS bom
WHERE 1=1
AND ASSEMBLY_ITEM_ID = ol.INVENTORY_ITEM_ID
and bom.ORGANIZATION_ID=nvl(ol.ship_from_org_id,ol.org_id)
) bom_flag,
(select count(*) from mtl_material_transactions mmT
WHERE 1=1
and mmt.TRANSACTION_REFERENCE=to_char(ol.HEADER_ID)
and mmt.TRX_SOURCE_LINE_ID=ol.LINE_ID
and mmt.ORGANIZATION_ID=nvl(ol.ship_from_org_id,ol.org_id)
and mmt.SOURCE_CODE='ORDER ENTRY'
) inv_flag,
(select count(*) from RA_INTERFACE_lines_all ril
where ril.INTERFACE_LINE_CONTEXT='ORDER ENTRY'
and ril.INTERFACE_LINE_ATTRIBUTE1=to_char(oh.order_number)
and ril.INTERFACE_LINE_ATTRIBUTE6=to_char(ol.line_id)
and ril.org_id=ol.org_id
) ri_flag,
(select count(*) from ra_customer_trx_lines_all rtl
where rtl.INTERFACE_LINE_ATTRIBUTE6=to_char(ol.line_id)
and rtl.sales_order=to_char(oh.order_number)
and rtl.INTERFACE_LINE_CONTEXT='ORDER ENTRY'
and rtl.org_id=ol.org_id
) ar_flag,
--gobo_get_ship_no(ol.line_id) ship_no,
ol.line_number,
ol.line_id,
lt.name line_type,
ol.inventory_item_id,
ol.ordered_item,
msi.segment1 fac_item,
ol.CREATION_DATE oeol_creation,
msi.last_update_date item_last_update,
MSI.INVENTORY_ITEM_STATUS_CODE item_status,
msi.REPLENISH_TO_ORDER_FLAG,
msi.ITEM_TYPE,
MSI.RESERVABLE_TYPE,
ol.ordered_quantity,
ol.shipped_quantity,
ol.unit_selling_price ,
ol.flow_status_code,
ol.SCHEDULE_SHIP_DATE,
ol.ACTUAL_SHIPMENT_DATE,
ol.ACTUAL_FULFILLMENT_DATE,
ol.FULFILLED_QUANTITY,
ol.FULFILLMENT_DATE,
gobo_get_ship_no(ol.line_id) ship_no,
wda.delivery_id,
wdd.delivery_detail_id,
wdd.subinventory pick_sub,
wdd.revision pick_rev,
wdd.released_status,
flv.MEANING pick_mean,
flv.description pick_desc,
wdd.OE_INTERFACED_FLAG,
wdd.INV_INTERFACED_FLAG,
wdd.picked_quantity,
wdt.name trip_name,
(select osf.organization_code||'_'||fh.order_number||'_'||fl.line_number||'.'||fl.shipment_number pi
from oe_ship_from_orgs_v osf,oe_order_headers_all fh,oe_order_lines_all fl
where osf.organization_id=fh.org_id
and fh.header_id=fl.header_id
and to_char(fl.line_id)=ol.attribute12
and to_char(fl.header_id)=ol.attribute11
) att_pi,
(select osf.organization_code||'_'||fh.order_number||'_'||fl.line_number||'.'||fl.shipment_number pi
from oe_ship_from_orgs_v osf,oe_order_headers_all fh ,otc_orders_all ooa,oe_order_lines_all fl
where osf.organization_id=fh.org_id
and fh.header_id=fl.header_id
and fl.line_id=ooa.line_id
and ol.orig_sys_line_ref=ooa.orig_sys_line_ref
and ol.orig_sys_document_ref=ooa.orig_sys_document_ref
--and ooa.dest_line=ol.line_id
) ooa_pi
from mtl_system_items_b msi,
FND_LOOKUP_VALUES_VL flv,
WSH_DELIVERABLE_TRIPS_V wdT,
wsh_delivery_assignments wda,
wsh_delivery_details wdd,
oe_order_lines_all ol,
oe_transaction_types_tl lt,
oe_order_headers_all oh
where 1=1
and msi.inventory_item_id=ol.inventory_item_id
and msi.organization_id=nvl(ol.ship_from_org_id,ol.org_id)
and msi.segment1=nvl(:p_item,msi.segment1)
and wda.delivery_detail_id(+)=wdd.delivery_detail_id
and flv.VIEW_APPLICATION_ID(+)=665
and flv.LOOKUP_TYPE(+)='PICK_STATUS'
and flv.lookup_code(+)=wdd.released_status
and wdD.DELIVERY_DETAIL_ID = wdT.DELIVERY_DETAIL_ID(+)
and wdd.source_line_id(+)=ol.line_id
and wdd.source_header_id(+)=ol.header_id
and ol.line_type_id = lt.transaction_type_id
--and upper(lt.name) not like '%SHIP%ONLY%'
AND lt.LANGUAGE = 'US'
and ol.line_number=nvl(:p_line_no,ol.line_number)
and ol.header_id=oh.header_id
and ol.org_id=oh.org_id
and oh.order_number=nvl(:p_order_number,-1)
and oh.org_id=nvl(:p_org_id,-1)
order by ol.LINE_NUMBER
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-929515/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 微信支付訂單、退款訂單、轉款訂單的查詢
- 兩個B1相關的SQL,訂單查詢SQL
- 【SQL查詢】集合查詢之INTERSECTSQL
- 從微信查詢訂單狀況
- 微信支付開發(5) 訂單查詢
- 快遞鳥查詢訂單例項單例
- javascript事件查詢綜合JavaScript事件
- sql之20再看查詢SQL
- 如何一鍵查詢淘寶訂單物流資訊
- ATM-簡單SQL查詢SQL
- sql之20高階查詢SQL
- 查詢當天的系統訂單記錄
- 訂單銷貨收款之報表sqlSQL
- 「SAP技術」SAP SD微觀研究之根據銷售訂單查詢到該訂單發貨的批次
- 綜合資訊查詢系統IISS
- MySQL訂單分庫分表多維度查詢MySql
- EBS:訂單事務型別查詢之流程分配型別
- 【SQL】Oracle查詢轉換之 OR用法SQLOracle
- 十七、Mysql之SQL優化查詢MySql優化
- SQL Server之查詢檢索操作SQLServer
- 簡單實現微信小程式支付+php後端(回撥、查詢訂單、訂單資訊入庫)微信小程式PHP後端
- 【SQL】Oracle查詢轉換之物化檢視查詢重寫SQLOracle
- SQL Server-簡單查詢語句SQLServer
- SQL單表查詢語句總結SQL
- SQL面試題 三(單表、多表查詢)SQL面試題
- SSH綜合查詢的兩種方式
- SQL查詢的:子查詢和多表查詢SQL
- SAP MM ME1P查詢採購訂購訂單價格歷史
- ORACLE_OCP之SQL_子查詢OracleSQL
- MySQL之SQL邏輯查詢順序MySql
- elasticsearch之單請求多查詢Elasticsearch
- Spring Data Jpa 的簡單查詢多表查詢HQL,SQL ,動態查詢, QueryDsl ,自定義查詢筆記SpringSQL筆記
- sed+awk模擬簡單sql查詢SQL
- 查詢任意訂單中三種以上訂單產品總價超過15 的使用者
- 查詢之折半查詢
- 對比SQL中簡單巢狀查詢與非巢狀查詢CFSQL巢狀
- Hibernate綜合查詢解決方案 (轉)
- 原生SQL查詢SQL