SELECT DISTINCT ooh.order_number, wdd.source_header_type_name,
wdd.cust_po_number, wdd.organization_id,
wdd.src_requested_quantity, wdd.requested_quantity,
wdd.released_status, flv.meaning,
wdd.oe_interfaced_flag,
wdd.inv_interfaced_flag, wdd.mvt_stat_status,
wdd.creation_date, wdd.org_id, wdd.inventory_item_id,
wnd.status_code,flv1.meaning,flv1.description, mtrl.pick_slip_date, mtrl.primary_quantity,
mtrh.request_number, ool.flow_status_code,
ooh.flow_status_code,mil.segment5 Position
FROM wsh.wsh_trips wt,
wsh.wsh_trip_stops wtt,
wsh.wsh_delivery_legs wdl,
wsh.wsh_new_deliveries wnd,
wsh.wsh_delivery_assignments wda,
wsh.wsh_delivery_details wdd,
ont.oe_order_headers_all ooh,
ont.oe_order_lines_all ool,
inv.mtl_txn_request_lines mtrl,
inv.mtl_txn_request_headers mtrh,
apps.fnd_lookup_values flv,
apps.fnd_lookup_values flv1,
inv.mtl_material_transactions mmt,
inv.mtl_item_locations MIL
WHERE wt.trip_id(+) = wtt.trip_id
AND wtt.stop_id(+) = wdl.pick_up_stop_id
AND wnd.delivery_id = wdl.delivery_id(+)
AND wnd.delivery_id(+) = wda.delivery_id
AND wdd.delivery_detail_id = wda.delivery_detail_id(+)
AND ooh.header_id = wdd.source_header_id
AND ooh.header_id = ool.header_id(+)
AND ool.line_id = mtrl.txn_source_line_id(+)
AND ool.line_id = wdd.source_line_id(+)
AND mtrh.header_id(+) = mtrl.header_id
--and flv.view_application_id =665
and wdd.released_status = flv.lookup_code
and flv.lookup_type='PICK_STATUS'
and flv1.view_application_id =665
and wnd.status_code = flv1.lookup_code
and flv1.lookup_type='DELIVERY_STATUS'
AND wdd.source_code = 'OE'
--AND wt.name = --'142310'
AND mmt.trx_source_line_id = ool.line_id
and mmt.organization_id = ool.ship_from_org_id
AND mmt.locator_id = mil.inventory_location_id
And mmt.inventory_item_id = ool.inventory_item_id
AND mmt.transaction_quantity < 0
AND mmt.transaction_type_id = 52
And mmt.MOVE_ORDER_LINE_ID = mtrl.LINE_ID
AND wnd.name = '147190'
AND ooh.order_number = '&order_number'
SELECT distinct ooha.ORDER_NUMBER ORDER_NUMBER,wnd.delivery_id delivery_id,ooha.header_id header_id
FROM OE_ORDER_HEADERS_ALL OOHA,
OE_ORDER_LINES_ALL OOLA,
WSH_DELIVERY_ASSIGNMENTS WDA,
WSH_DELIVERY_DETAILS WDD,
WSH_NEW_DELIVERIES WND
WHERE OOHA.HEADER_ID = OOLA.HEADER_ID
AND WND.DELIVERY_ID(+) = WDA.DELIVERY_ID
AND WDD.DELIVERY_DETAIL_ID = WDA.DELIVERY_DETAIL_ID(+)
AND OOLA.LINE_ID = WDD.SOURCE_LINE_ID
-- AND WDD.SOURCE_CODE = 'OE'
-- AND WDD.RELEASED_STATUS IN ('C', 'I', 'Y')
Select customer_trx_line_id ,rct.customer_trx_id ,rct.trx_number
From ra_customer_trx_lines_all rctl, ra_customer_trx_all rct
Where rct.customer_trx_id = rctl.customer_trx_id
and nvl(rct.interface_header_context,'X') in ('ORDER ENTRY','PROJECTS INVOICES')
and rct.org_id = 82
and rct.trx_date between to_date('01-JAN-2009', 'DD-MON-YYYY') and to_date('31-JAN-2009', 'DD-MON-YYYY')
and exists (select 1 from ra_cust_trx_line_gl_dist_all rctlgd where rctlgd.customer_trx_id = rct.customer_trx_id
and rctlgd.account_class ='REC' and rctlgd.latest_rec_flag ='Y' and rctlgd.org_id = rct.org_id
No comments:
Post a Comment