SELECT poh.segment1, poh.currency_code,
TO_CHAR (TRUNC (poh.approved_date),
'dd.mm.yyyy'
) "Purchase_order_Date",
pov.vendor_name,
DECODE (pov.vendor_name,
NULL, NULL,
pov.vendor_name || CHR (10)
)
|| DECODE (pos.address_line1,
NULL, NULL,
pos.address_line1 || CHR (10)
)
|| DECODE (pos.address_line2,
NULL, NULL,
pos.address_line2 || CHR (10)
)
|| DECODE (pos.address_line3,
NULL, NULL,
pos.address_line3 || CHR (10)
)
|| DECODE (pos.city, NULL, NULL, pos.city || CHR (10))
|| DECODE (pos.state, NULL, NULL, pos.state || CHR (10))
|| DECODE (pos.zip, NULL, NULL, pos.zip || CHR (10)) vendor_address,
pol.line_num, pll.quantity, pol.unit_price,
(pll.quantity * pol.unit_price) "Value", pol.item_description,
pol.item_id, mum.uom_code, poh.org_id, plt.line_type,
pol.item_revision, pol.po_line_id, apt.NAME "Terms_Name",
INITCAP (poh.attribute1) "Insurance",
INITCAP (poh.attribute2) "Despatch Mode", poh.attribute3 "Freight",
poh.attribute4 "Addl.Oth Chrgs", poh.attribute5 "Delivery Terms",
DECODE (poh.freight_terms_lookup_code,
'N/A', 'Not Applicable',
poh.freight_terms_lookup_code
),
poh.ship_via_lookup_code, poh.note_to_vendor, poh.comments,
hrl.location_code, pol.note_to_vendor "Specifications",
poh.po_header_id, pll.line_location_id,
poh.attribute7 "Delievry_Date", poh.attribute8 "Inspetion"
FROM po_headers_all poh,
po_vendors pov,
po_vendor_sites_all pos,
hr_locations hrl,
po_lines_all pol,
po_line_locations_all pll,
mtl_units_of_measure_tl mum,
po_line_types plt,
ap_terms apt
WHERE 1 = 1
AND poh.po_header_id = pol.po_header_id
AND pol.po_header_id = pll.po_header_id
AND pol.po_line_id = pll.po_line_id
AND mum.unit_of_measure = pol.unit_meas_lookup_code
AND poh.vendor_id = pov.vendor_id
AND poh.vendor_site_id = pos.vendor_site_id
AND poh.ship_to_location_id = hrl.location_id
AND pol.line_type_id = plt.line_type_id
AND poh.terms_id = apt.term_id(+)
AND pol.org_id = NVL (:p_org_id, pol.org_id)
AND poh.segment1 = NVL (:purchase_order_number, poh.segment1)
AND poh.type_lookup_code = 'STANDARD'
AND poh.authorization_status IN ('APPROVED', 'PRE-APPROVED')
AND NVL (pol.cancel_flag, 'N') = 'N'
ORDER BY pol.po_line_id
TO_CHAR (TRUNC (poh.approved_date),
'dd.mm.yyyy'
) "Purchase_order_Date",
pov.vendor_name,
DECODE (pov.vendor_name,
NULL, NULL,
pov.vendor_name || CHR (10)
)
|| DECODE (pos.address_line1,
NULL, NULL,
pos.address_line1 || CHR (10)
)
|| DECODE (pos.address_line2,
NULL, NULL,
pos.address_line2 || CHR (10)
)
|| DECODE (pos.address_line3,
NULL, NULL,
pos.address_line3 || CHR (10)
)
|| DECODE (pos.city, NULL, NULL, pos.city || CHR (10))
|| DECODE (pos.state, NULL, NULL, pos.state || CHR (10))
|| DECODE (pos.zip, NULL, NULL, pos.zip || CHR (10)) vendor_address,
pol.line_num, pll.quantity, pol.unit_price,
(pll.quantity * pol.unit_price) "Value", pol.item_description,
pol.item_id, mum.uom_code, poh.org_id, plt.line_type,
pol.item_revision, pol.po_line_id, apt.NAME "Terms_Name",
INITCAP (poh.attribute1) "Insurance",
INITCAP (poh.attribute2) "Despatch Mode", poh.attribute3 "Freight",
poh.attribute4 "Addl.Oth Chrgs", poh.attribute5 "Delivery Terms",
DECODE (poh.freight_terms_lookup_code,
'N/A', 'Not Applicable',
poh.freight_terms_lookup_code
),
poh.ship_via_lookup_code, poh.note_to_vendor, poh.comments,
hrl.location_code, pol.note_to_vendor "Specifications",
poh.po_header_id, pll.line_location_id,
poh.attribute7 "Delievry_Date", poh.attribute8 "Inspetion"
FROM po_headers_all poh,
po_vendors pov,
po_vendor_sites_all pos,
hr_locations hrl,
po_lines_all pol,
po_line_locations_all pll,
mtl_units_of_measure_tl mum,
po_line_types plt,
ap_terms apt
WHERE 1 = 1
AND poh.po_header_id = pol.po_header_id
AND pol.po_header_id = pll.po_header_id
AND pol.po_line_id = pll.po_line_id
AND mum.unit_of_measure = pol.unit_meas_lookup_code
AND poh.vendor_id = pov.vendor_id
AND poh.vendor_site_id = pos.vendor_site_id
AND poh.ship_to_location_id = hrl.location_id
AND pol.line_type_id = plt.line_type_id
AND poh.terms_id = apt.term_id(+)
AND pol.org_id = NVL (:p_org_id, pol.org_id)
AND poh.segment1 = NVL (:purchase_order_number, poh.segment1)
AND poh.type_lookup_code = 'STANDARD'
AND poh.authorization_status IN ('APPROVED', 'PRE-APPROVED')
AND NVL (pol.cancel_flag, 'N') = 'N'
ORDER BY pol.po_line_id
No comments:
Post a Comment