Bursting REP253 Query
Bursting REP253 Query
key_value
key,
'REP253 – Galderma CP GP cbl -Template'
template,
'en-US'
locale,
'TEXT'
output_format,
'EMAIL'
del_channel,
'Galderma_CP_GP_cbl_' || to_char(sysdate, 'MMDDRRRR')
output_name,
email_address
parameter1,
'[email protected]'
parameter3,
'Galderma/CIS Monthly Government Pricing Files – REP253'
parameter4,
'Hello All,
Please find attached Galderma/CIS Monthly Government Pricing Files – REP253
report.' parameter5,
'true'
parameter6,
'[email protected]'
parameter7
FROM
(
SELECT
trx.*,
nvl(:p_override_email, email_address) email_address
FROM
(
SELECT
*
FROM
(
SELECT
key_value,
account,
account_description,
data_source,
sku,
sku_description,
SUM(dollars) dollars
FROM
(
SELECT
'SINGLE' key_value,
gcc.segment2 account,
flex_val.value_description account_description,
NULL data_source,
replace(nvl(esib.item_number,
master_org_items.item_number),
'.',
'') sku,
nvl(nvl(esib.description,
master_org_items.description),
lin.description) sku_description,
lin.extended_amount dollars
FROM
hr_operating_units hou,
ra_customer_trx_all hdr,
ra_customer_trx_lines_all lin,
(
SELECT
customer_trx_line_id,
code_combination_id
FROM
ra_cust_trx_line_gl_dist_all dist
WHERE
1 = 1
AND dist.account_class = 'REV'
) gdl,
gl_code_combinations gcc,
(
SELECT
flex_value,
ffvt.description value_description
FROM
fnd_flex_value_sets ffvs,
fnd_flex_values ffv,
fnd_flex_values_tl ffvt
WHERE
ffvs.flex_value_set_id =
ffv.flex_value_set_id
AND ffv.flex_value_id =
ffvt.flex_value_id
AND ffvt.language = userenv('LANG')
AND flex_value_set_name LIKE
'XX_GALDERMA_ACCOUNT'
) flex_val,
egp_system_items esib,
(
SELECT
esi.inventory_item_id,
esi.item_number,
esi.organization_id,
description
FROM
egp_system_items esi,
(
SELECT
organization_id
FROM
hr_all_organization_units_x
WHERE
name = 'Master Item
Organization'
) inv_org
WHERE
esi.organization_id =
inv_org.organization_id
) master_org_items
WHERE
1 = 1
AND hdr.customer_trx_id = lin.customer_trx_id
AND lin.customer_trx_line_id =
gdl.customer_trx_line_id
AND gdl.code_combination_id =
gcc.code_combination_id
AND gcc.segment2 = flex_val.flex_value
AND hdr.org_id = hou.organization_id
AND hou.name = 'Galderma - GLLP'
AND ( nvl(lin.inventory_item_id, 1) =
esib.inventory_item_id (+)
AND nvl(lin.warehouse_id, 1) =
esib.organization_id (+) )
AND lin.inventory_item_id =
master_org_items.inventory_item_id (+)
AND ( ( ( trx_date BETWEEN :p_from_date
AND :p_to_date )
AND :p_from_date IS NOT NULL
AND :p_to_date IS NOT NULL )
OR ( ( trx_date BETWEEN (
SELECT
start_date
FROM
gl_periods
WHERE
period_name = :p_period
) AND (
SELECT
end_date
FROM
gl_periods
WHERE
period_name = :p_period
) ) ) )
)
WHERE
1 = 1
GROUP BY
key_value,
account,
account_description,
data_source,
sku,
sku_description
)
) trx,
(
SELECT
description email_address
FROM
fnd_lookup_values flv
WHERE
flv.lookup_type = 'GAL_MODELN_INT_EMAILS'
--AND flv.lookup_code ='OD_CONTRACT_EMAIL'
AND tag = 'REP253'
AND flv.language = 'US'
AND flv.enabled_flag = 'Y'
AND trunc(sysdate) BETWEEN trunc(nvl(flv.start_date_active,
sysdate)) AND trunc(nvl(flv.end_date_active, sysdate)
)
) email
)