You are on page 1of 3

/* Blanket PO Line Location details for Price Break*/

SELECT pha.segment1
|| '-'
|| pla.line_num
|| '-'
|| plla.shipment_num
interface_line_location_key,
pha.segment1 || '-' || pla.line_num interface_line_key,
-- plla.price_override price_break,
plla.shipment_num,
(SELECT decode(location_code , 'ZHO_SEMINOLE', 'Seminole-Manufacturing',
location_code)
FROM hr_locations
WHERE location_id = plla.ship_to_location_id)
ship_to_location,
nvl((select (output_value1) from xxdzs_fnd_conv_map , mtl_parameters mp
where mapping_type_code = 'CLOUD_INV_ORG_MAP'
and input_value1 =mp.organization_code
and mp.organization_id = plla.ship_to_organization_id),
(SELECT organization_code
FROM mtl_parameters
WHERE organization_id = plla.ship_to_organization_id)
) ship_to_organization_code,
-- nvl(plla.quantity,0) - nvl(plla.quantity_billed,0)-
nvl(plla.quantity_cancelled,0) amount,
-- nvl(plla.quantity,0) - nvl(plla.quantity_received,0) -
nvl(plla.quantity_cancelled,0) quantity,
nvl(plla.quantity,0) - nvl(plla.quantity_cancelled,0) quantity, --<<<???
>>>
plla.price_override price_break,
NULL dis_per,
NULL price_break_start_date,
NULL price_break_end_date
-- (plla.quantity * pla.unit_price) amount,--<<<
-- pla.unit_price,
/*
CASE
WHEN plla.receipt_required_flag = 'Y' AND plla.need_by_date IS NULL
THEN
TO_CHAR (SYSDATE, 'YYYY/MM/DD')
ELSE
TO_CHAR (plla.need_by_date, 'YYYY/MM/DD')
END
need_by_date,
TO_CHAR (plla.promised_date, 'YYYY/MM/DD') promised_date,
plla.accrue_on_receipt_flag,
plla.allow_substitute_receipts_flag,
NULL assessable_value,
plla.days_early_receipt_allowed,
plla.days_late_receipt_allowed,
plla.enforce_ship_to_location_code,
plla.inspection_required_flag,
plla.receipt_required_flag,
plla.invoice_close_tolerance,
plla.receive_close_tolerance,
plla.qty_rcv_tolerance,
plla.qty_rcv_exception_code,
plla.receipt_days_exception_code,
(SELECT DECODE (routing_name,
'Direct Delivery', 'Direct delivery',
routing_name)
FROM rcv_routing_headers
WHERE routing_header_id = plla.receiving_routing_id)
receiving_routing,
NULL input_tax_classification_code,
NULL line_intended_use,
NULL product_category,
NULL product_fisc_classification,
NULL product_type,
NULL trx_business_category,
NULL user_defined_fisc_class,
NULL attribute_category,
NULL attribute1,
NULL attribute2,
NULL attribute3,
NULL attribute4,
NULL attribute5,
NULL attribute6,
NULL attribute7,
NULL attribute8,
NULL attribute9,
NULL attribute10,
NULL attribute11,
NULL attribute12,
NULL attribute13,
NULL attribute14,
NULL attribute15,
NULL attribute16,
NULL attribute17,
NULL attribute18,
NULL attribute19,
NULL attribute20,
NULL attribute_date1,
NULL attribute_date2,
NULL attribute_date3,
NULL attribute_date4,
NULL attribute_date5,
NULL attribute_date6,
NULL attribute_date7,
NULL attribute_date8,
NULL attribute_date9,
NULL attribute_date10,
NULL attribute_number1,
NULL attribute_number2,
NULL attribute_number3,
NULL attribute_number4,
NULL attribute_number5,
NULL attribute_number6,
NULL attribute_number7,
NULL attribute_number8,
NULL attribute_number9,
NULL attribute_number10,
NULL attribute_timestamp1,
NULL attribute_timestamp2,
NULL attribute_timestamp3,
NULL attribute_timestamp4,
NULL attribute_timestamp5,
NULL attribute_timestamp6,
NULL attribute_timestamp7,
NULL attribute_timestamp8,
NULL attribute_timestamp9,
NULL attribute_timestamp10,
(SELECT (CASE
WHEN description = 'ARRANGED BY SUPPLIER'
THEN
'BEST WAY'
WHEN description = 'BEST WAY'
THEN
'BEST WAY'
WHEN description = 'BEST WAY PREPAID'
THEN
'BEST WAY PREPAID'
ELSE
description
END)
FROM fnd_lookup_values flv
WHERE flv.language = USERENV ('LANG')
AND flv.lookup_type = 'SHIP_METHOD'
AND flv.lookup_code = plla.ship_via_lookup_code)
carrier,
NULL mode_of_transport,
NULL service_level,
NULL
final_discharge_location_code,
TO_CHAR (NULL, 'YYYY/MM/DD') requested_ship_date,
TO_CHAR (NULL, 'YYYY/MM/DD') promised_ship_date,
TO_CHAR (NULL, 'YYYY/MM/DD') requested_delivery_date,
TO_CHAR (NULL, 'YYYY/MM/DD') promised_delivery_date,
pltv.line_type,
plla.quantity orig_quantity_ordered,
pla.org_id,
plla.quantity_received amount_received,
plla.quantity_received quantity_received,
plla.quantity_billed quantity_billed,
CASE
WHEN plla.receipt_required_flag = 'Y' THEN '3WAY'
else '2WAY'
END
match_flag*/
FROM po_headers_all pha, po_lines_all pla, po_line_locations_all plla,
po_line_types pltv
WHERE pha.po_header_id = pla.po_header_id
AND pla.po_line_id = plla.po_line_id
AND pltv.line_type_id(+) = pla.line_type_id
AND NVL (plla.cancel_flag, 'N') = 'N'
AND pha.approved_flag = 'Y'
AND NVL (pha.closed_code, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED')
AND NVL (pla.closed_code, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED')
AND NVL (plla.closed_code, 'OPEN') NOT IN ('FINALLY CLOSED', 'CLOSED')
AND pha.type_lookup_code = 'BLANKET'
and plla.po_release_id is null
AND nvl(plla.quantity,0) - nvl(plla.quantity_cancelled,0) > 0
AND pha.org_id = 2
-- and pha.segment1
IN( '30002','30011','30576','30026','30052','30059','30586','31007','31046','34475'
)
order by pha.segment1

You might also like