Você está na página 1de 3

SELECT division_code,

warehouse_code,
item_code,
description,
long_description,
uom,
uom_rate,
outer_rate,
unit_selling_price,
ROUND((unit_selling_price / uom_rate),3) unit_selling_price_perunit,
ROUND((unit_selling_price / uom_rate),3) return_selling_price_perunit,
unit_selling_price return_price,
item_status,
Future_use1,
NULL Future_use2,
Brand_code,
Category_code,
Sub_Category_code,
barcode,
inventory_item_id,
list_header_id,
warehouse_id,
ou_name,
ou_id,
creation_Date,
last_update_Date,
Month_Yr,
-- hht_creation_date,
Status
FROM
(SELECT DISTINCT hou.short_code division_code,
(SELECT organization_code
FROM org_organization_definitions
WHERE organization_id=item.organization_id) warehouse_code,
item.segment1 item_code,
TRIM(item.long_description) description,
TRIM(item.description) long_description,
--TRIM(SUBSTR (item.description,1,40)) description,
--TRIM(SUBSTR (item.long_description,1,20)) long_description,
--item.primary_unit_of_measure uom,
CASE WHEN
hou.short_code='CA MDC OU' THEN
DECODE(qpa.product_uom_code,'CS','Case',qpa.product_uom_code)
ELSE item.primary_unit_of_measure
END UOM,
(SELECT muc.conversion_rate
FROM mtl_uom_conversions muc
WHERE muc.inventory_item_id = item.inventory_item_id
AND UPPER (item.primary_unit_of_measure) = UPPER (muc.unit_of_measure)
AND disable_date IS NULL) uom_rate,
(SELECT muc.conversion_rate
FROM mtl_uom_conversions muc
WHERE muc.inventory_item_id = item.inventory_item_id
AND UPPER (muc.unit_of_measure) = 'OUTER'
AND disable_date IS NULL) outer_rate,
qll.operand unit_selling_price,

DECODE(item.inventory_item_status_code,'Active','A','I',item.inventory_item_status_
code) item_status,
(SELECT cross_reference
FROM mtl_cross_references_b
WHERE UPPER(cross_reference_type) = 'LINE 500 SKU CODE'
AND inventory_item_id = item.inventory_item_id
) Future_use1,
qlhb.orig_org_id,
(SELECT TRIM(SUBSTR(ffvv.description,1,40))
FROM fnd_flex_value_sets ffvs,
fnd_flex_values_vl ffvv
WHERE ffvs.flex_value_set_id=ffvv.flex_value_set_id
AND flex_value=item_category.segment3
AND ffvs.flex_value_set_name='EGC_Brand'
AND rownum < 2) Brand_code,
(SELECT TRIM(SUBSTR(ffvv.description,1,40))
FROM fnd_flex_value_sets ffvs,
fnd_flex_values_vl ffvv
WHERE ffvs.flex_value_set_id=ffvv.flex_value_set_id
AND flex_value=item_category.segment4
AND ffvs.flex_value_set_name='EGC_Category'
AND rownum < 2) Category_code,
(SELECT TRIM(SUBSTR(ffvv.description,1,40))
FROM fnd_flex_value_sets ffvs,
fnd_flex_values_vl ffvv
WHERE ffvs.flex_value_set_id=ffvv.flex_value_set_id
AND flex_value=item_category.segment5
AND ffvs.flex_value_set_name='EGC_Sub Category'
AND rownum < 2) Sub_Category_code,
(SELECT cross_reference
FROM mtl_cross_references_b
WHERE cross_reference_type = 'GTIN'
AND inventory_item_id = item.inventory_item_id
) barcode,
item.inventory_item_id,
qlhb.list_header_id,
item.organization_id warehouse_id,
hou.name ou_name,
hou.organization_id ou_id,
GREATEST (item.creation_date, item_category.creation_date) creation_Date,
GREATEST (item.last_update_date, item_category.last_update_date)
last_update_Date,
TO_CHAR (GREATEST (item.creation_date, item_category.creation_date), 'MON-
YY' ) Month_Yr,
-- NVL(xhit.last_update_date,sysdate-500) hht_creation_date ,
DECODE((xhit.last_update_date),NULL,'New','Update') Status
FROM qp_list_headers_tl qlht,
qp_list_headers_all_b qlhb,
qp_list_lines qll,
qp_pricing_attributes qpa,
hr_operating_units hou,
mtl_uom_conversions muc,
mtl_system_items_fvl item,
mtl_item_categories_v item_category,
XXFT_HHT_ITEM_MASTER xhit
WHERE 1 = 1
AND qlht.list_header_id = qll.list_header_id
AND qll.list_line_type_code = 'PLL'
AND qlht.list_header_id = qlhb.list_header_id
AND qpa.list_header_id = qlhb.list_header_id
AND qpa.list_line_id = qll.list_line_id
AND qpa.product_attribute = 'PRICING_ATTRIBUTE1'
AND qlhb.orig_org_id = hou.organization_id
AND item.inventory_item_id = TO_NUMBER (qpa.product_attr_value)
AND item.inventory_item_id = item_category.inventory_item_id
AND item.organization_id = item_category.organization_id
AND item_category.category_set_id=1
AND item.inventory_item_id = muc.inventory_item_id
AND item.organization_id = (SELECT DISTINCT master_organization_id
FROM mtl_parameters)
AND qlht.language = qlht.source_lang
AND qlhb.list_type_code = 'PRL'
AND qll.end_date_active IS NULL
--AND qlhb.list_header_id = 7120
--AND qlht.name IN ('CONS','RB','MDC MASTER PRICE LIST')
AND qlhb.attribute2 = 'YES'
and item.inventory_item_id = xhit.inventory_item_id(+)
-- AND hou.organization_id in (select ORGANIZATION_ID from hr_operating_units
-- where set_of_books_id=2089)
AND item.inventory_item_id = xhit.inventory_item_id(+)
AND item.organization_id = xhit.warehouse_id(+)
and ( GREATEST
(qlht.last_update_date,qlhb.last_update_date,qll.last_update_date,qpa.last_update_d
ate, muc.last_update_date, item.last_update_date, item_category.last_update_date) >
nvl(xhit.last_update_date,to_date('12/31/1951', 'mm/dd/yyyy'))
or
GREATEST(qlht.creation_date,qlhb.creation_date,qll.creation_date,qpa.creation_date,
muc.creation_date, item.creation_date, item_category.creation_date) >
nvl(xhit.creation_date,to_date('12/31/1951', 'mm/dd/yyyy')))
)DUAL
WHERE UPPER(uom)='CASE'