You are html tracking Visitor

Saturday, July 11, 2009

Purchase Orders created on previous day

Purchase Orders created on previous day:-
-------------------------------------------------

You can use the following query to get all the Purchasing Orders created on previous day in any Instance.

You can filter-out based on category set or Inventory Organization etc.
I have commented out category_set_id and Organization ID conditions in the where clause.
You can modify as per your requirement.

Note: - This kind of information would be required for the Organization (Management) for the tracking the PO's created on daily bases.

Note:- There are some values I am getting from attribute columns. This values would vary in your Instance. These values depends on the DFF setup in your Instance.

SELECT mcb.segment1 "GMA"
, mcb.segment2 "Group"
, mcb.segment3 "Dept"
, mcb.segment4 "Cat"
, poh.segment1 "PO"
, fu.user_name "PO Created by(User_id)"
, fu.description "PO Created by(Name)"
, vs.vendor_site_code
, vn.vendor_name
, hou1.name
, hrl1.location_code "Ship To"
, poh.authorization_status "PO status"
, msi.segment1 "SKU"
, msi.description "Item Description"
, pll.quantity
, pll.quantity_received
, pll.quantity_cancelled
, fu1.user_name "Cancelled by"
, pll.cancel_reason
, poh.creation_date
, pll.promised_date
, pll.need_by_date
,(SELECT rsh.attribute8
FROM rcv_shipment_headers rsh
, rcv_shipment_lines rsl
WHERE rsl.shipment_header_id=rsh.shipment_header_id
AND rsl.po_header_id=poh.po_header_id
AND rsl.po_line_id=pol.po_line_id
AND ROWNUM=1) "Appointment Number"
,(SELECT rsh.attribute9
FROM rcv_shipment_headers rsh
, rcv_shipment_lines rsl
WHERE rsl.shipment_header_id=rsh.shipment_header_id
AND rsl.po_header_id=poh.po_header_id
AND rsl.po_line_id=pol.po_line_id
AND ROWNUM=1) "Appointment Date"
,pol.unit_price "Unit Cost"
,(pol.unit_price*pol.quantity) "Ext Cost"
FROM
po_headers_all poh
, po_lines_all pol
, po_line_locations_all pll
, mtl_system_items_b msi
, inv.mtl_item_categories mic
, inv.mtl_categories_b mcb
, fnd_user fu
, po_vendors vn
, po_vendor_sites_all vs
, hr_locations_all_tl hrl1
, hr_organization_units hou1
,fnd_user fu1
WHERE TRUNC(poh.creation_date)=TRUNC(SYSDATE-1)
AND poh.type_lookup_code='STANDARD'
--AND poh.attribute2 LIKE 'M%'
AND poh.po_header_id=pol.po_header_id
AND pol.po_line_id=pll.po_line_id
AND pol.po_header_id=pll.po_header_id
AND pol.item_id=msi.inventory_item_id
AND msi.organization_id = mic.organization_id
AND msi.inventory_item_id = mic.inventory_item_id
-- AND mic.category_set_id = 1
AND mcb.category_id = mic.category_id
-- AND msi.organization_id IN (Your Organization ID's)
AND poh.created_by=fu.user_id
AND poh.vendor_id=vn.vendor_id
AND vs.vendor_id = poh.vendor_id
AND vs.vendor_site_id = poh.vendor_site_id
AND hrl1.location_id(+) = poh.ship_to_location_id
AND hrl1.LANGUAGE(+) = USERENV ('LANG')
AND hrl1.location_id=hou1.location_id
AND fu1.user_id(+)=pll.cancelled_by

No comments: