SELECT DISTINCT ph.segment1, pv.segment1 "Vendor Code ",
ph.po_header_id,
pll.ship_to_organization_id,
pv.vendor_name "VENDOR NAME ",
pvs.address_line1 "ADDRESS Line 1 ",
pvs.address_line2 "ADDRESS Line 2 ",
pvs.city "CITY ",
pvs.state "STATE ",
pvs.zip "PIN CODE ",
(pvc.first_name || pvc.last_name) "Supplier's Contact Person ",
pvs.phone "Mobile No. / Phone No",
pvc.fax "Fax no. ",
pvc.email_address "EMAIL ID ",
(ph.segment1 || '/' || ph.revision_num) "PO/REV No.",
ph.creation_date "Date of PO ",
(prel.release_num || '/' || ph.revision_num) "Rel/REV No.",
ph.attribute1 "Your Ref ",
ph.currency_code "Currency ",
ppf.full_name "Buyer Name ",
h.address_line_1 "Address Line 1 ",
h.address_line_2 "Address Line 1 ",
(SELECT a.segment1
FROM po_requisition_headers_all a,
po_requisition_lines_all b,
po_req_distributions_all c
WHERE a.requisition_header_id(+) = b.requisition_header_id
AND b.requisition_line_id(+) = c.requisition_line_id
AND c.distribution_id IN
(SELECT B.req_distribution_id
FROM PO_HEADERS_ALL A,
PO_DISTRIBUTIONS_ALL B
WHERE A.PO_HEADER_ID = PH.PO_HEADER_ID
AND A.PO_HEADER_ID = B.PO_HEADER_ID
AND ROWNUM = 1
AND B.req_distribution_id IS NOT NULL)
AND ROWNUM = 1)
"PR No.",
h.location_code || h.town_or_city "CITY /STATE",
h.telephone_number_1 "PHONE No./ Fax no.",
( pll.quantity
|| 'nos.within'
|| pll.need_by_date
|| 'balance by'
|| pll.need_by_date)
"DETAILED DELIVERY SCHEDULE ",
term.name "PAYMENT TERMS",
ppf.first_name,
pts.cst_reg_no "CST No",
pts.vat_reg_no "VAT/ TIN No.",
pts.ec_code "ECC No.",
(d1.title || d1.description) "attachement",
hou.NAME "operating unit",
ph.segment4,
ph.segment5,
(SELECT A.TAX_AMOUNT
FROM JAI_PO_TAXES A
WHERE A.po_header_id = PH.PO_HEADER_ID
AND A.tax_type = 'Excise'
AND ROWNUM = 1)
"Excise Duty",
(SELECT SUM (A.tax_amount)
FROM jai_po_taxes A
WHERE A.po_header_id = PH.po_header_id
AND A.tax_type IN
('EXCISE_EDUCATION_CESS',
'SERVICE_EDUCATION_CESS',
'CUSTOMS_EDUCATION_CESS',
'CVD_EDUCATION_CESS'))
"EDUCATION_CESS",
(SELECT SUM (A.TAX_AMOUNT)
FROM jai_po_taxes A
WHERE A.po_header_id = PH.po_header_id
AND A.tax_type IN
('SERVICE_SH_EDU_CESS',
'CVD_SH_EDU_CESS',
'EXCISE_SH_EDU_CESS',
'CUSTOMS_SH_EDU_CESS'))
"Higher Education Cess ",
(SELECT A.TAX_AMOUNT
FROM JAI_PO_TAXES A
WHERE A.po_header_id = PH.PO_HEADER_ID
AND A.tax_type = 'VALUE ADDED TAX'
AND ROWNUM = 1)
"SALES TAX/VAT ",
(SELECT A.TAX_AMOUNT
FROM JAI_PO_TAXES A
WHERE A.po_header_id = PH.PO_HEADER_ID
AND A.tax_type = 'Service'
AND ROWNUM = 1)
"service tax ",
(SELECT A.TAX_AMOUNT
FROM JAI_PO_TAXES A
WHERE A.po_header_id = PH.PO_HEADER_ID
AND A.tax_type = 'Freight'
AND ROWNUM = 1)
"TRANSPORTATION CHARGES "
FROM po_distributions_all pd,
po_line_locations_all pll,
po_lines_all pl,
po_headers_all ph,
ap_terms_tl term,
fnd_documents_tl d1,
fnd_attached_documents d2,
JAI_CMN_VENDOR_SITES pts,
po_releases_all prel,
ap_suppliers pv,
ap_supplier_sites_all pvs,
ap_supplier_contacts pvc,
hr_locations_all h,
hr_all_organization_units hu,
hr_operating_units hou,
per_all_people_f ppf,
mtl_system_items_b msi
WHERE 1 = 1
AND pd.line_location_id(+) = pll.line_location_id
AND pll.po_line_id(+) = pl.po_line_id
AND pl.po_header_id = ph.po_header_id
AND term.term_id(+) = ph.terms_id
AND prel.po_release_id(+) = pd.po_release_id
AND h.location_id = hu.location_id(+)
AND h.location_id(+) = pll.ship_to_location_id
AND h.inventory_organization_id = hu.organization_id(+)
AND hou.organization_id(+) = ph.org_id
AND ppf.person_id(+) = ph.agent_id
AND pv.vendor_id(+) = ph.vendor_id
AND pvs.vendor_site_id(+) = ph.vendor_site_id
AND ph.vendor_contact_id = pvc.vendor_contact_id(+)
AND pts.vendor_site_id(+) = pvs.vendor_site_id
AND d2.pk1_value(+) = TO_CHAR (ph.po_header_id)
AND d1.document_id(+) = d2.document_id
AND msi.inventory_item_id(+) = pl.item_id
AND msi.organization_id = h.inventory_organization_id
AND ph.segment1 >= :from_po AND ph.segment1 <= :to_po
/* AND TO_NUMBER(ph.segment1) BETWEEN :from_po
AND :to_po */
AND ph.AUTHORIZATION_STATUS =
NVL (:P_PO_STATUS, ph.AUTHORIZATION_STATUS)
AND NVL (prel.release_num, 1) BETWEEN NVL (
NVL (:from_release,
prel.release_num),
1
)
AND NVL (
NVL (:to_release,
prel.release_num),
1
)
AND ppf.person_id = NVL (:P_PERSON_ID, ppf.person_id)
AND pll.quantity IS NOT NULL
AND ph.org_id=fnd_profile.value('ORG_ID')
GROUP BY pv.segment1,
ph.po_header_id,
pv.vendor_name,
pvs.address_line1,
pvs.address_line2,
pvs.city,
pvs.state,
pvs.zip,
pvc.first_name,
pvc.last_name,
pvs.phone,
pvc.fax,
pvc.email_address,
ph.segment1,
ph.revision_num,
ph.creation_date,
prel.release_num,
ph.revision_num,
ph.attribute1,
ph.currency_code,
ppf.full_name,
h.address_line_1,
h.address_line_2,
h.location_code,
h.town_or_city,
h.telephone_number_1,
pll.tax_name,
ph.fob_lookup_code,
ph.freight_terms_lookup_code,
term.name,
ppf.first_name,
pts.cst_reg_no,
pts.vat_reg_no,
pts.ec_code,
d1.title,
d1.description,
hou.NAME,
ph.segment4,
ph.segment5,
pll.ship_to_organization_id,
pll.quantity,
pll.need_by_date
order by to_number(ph.segment1)
No comments:
Post a Comment