SELECT gl_date, SOURCE, CATEGORY, doc_sequence_value gl_document, user_name,
location_name, location_code,
(CASE
WHEN order_number_rec IS NULL
THEN order_number
ELSE order_number_rec
END
) order_number, (case when PO_REQ_RECE is null then PR_REQ else PO_REQ_RECE end) pr_requisition_number,
receipt_num, gl_code_acct,
(CASE
WHEN accounting_class_code = 'INTRANSIT_VALUATION'
THEN 'GOODS IN TRANSIT'
END
) descp,
gl_code_id, joual_name, line_desc, accounted_dr, accounted_cr, period_nme
FROM(SELECT SUBSTR (jc.user_je_category_name, 1, 26) CATEGORY,
t1.period_name period_nme,
DECODE (t7.doc_sequence_value,
NULL, t1.doc_sequence_value,
t7.doc_sequence_value
) doc_sequence_value,
( t3.segment1
|| '.'
|| t3.segment2
|| '.'
|| t3.segment3
|| '.'
|| t3.segment4
|| '.'
|| t3.segment5
|| '.'
|| t3.segment6
|| '.'
|| t3.segment7
|| '.'
|| t3.segment8
|| '.'
|| t3.segment9
|| '.'
|| t3.segment10
) gl_code_acct,
(SELECT DISTINCT haotl.NAME
FROM hr_all_organization_units hao,
hr_all_organization_units_tl haotl
WHERE DECODE
(hr_security.view_all,
'Y', 'TRUE',
hr_security.show_record
('HR_ALL_ORGANIZATION_UNITS',
haotl.organization_id
)
) = 'TRUE'
AND DECODE (hr_general.get_xbg_profile,
'Y', hao.business_group_id,
hr_general.get_business_group_id
) = hao.business_group_id
AND hao.organization_id = haotl.organization_id
AND haotl.LANGUAGE = USERENV ('LANG')
AND SUBSTR (hao.attribute1, 1, 4) =
TO_CHAR (t3.segment3))
location_name,
(SELECT DISTINCT hu.attribute1
FROM hr_all_organization_units hu
WHERE SUBSTR (hu.attribute1, 1, 4) =
TO_CHAR (t3.segment3))
location_code,
NVL (t2.accounted_dr, 0) accounted_dr,
NVL (t2.accounted_cr, 0) accounted_cr, xteu.transaction_number,
t1.description, t2.description line_desc,
SUBSTR (t1.je_source, 1, 15) SOURCE,
TO_CHAR (t2.effective_date, 'DD-MON-YY') gl_date,
t1.NAME joual_name, t1.doc_sequence_value hnumber,
SUBSTR (t1.NAME, 1, 8) journal_name, mmt.transaction_id,
t1.external_reference REFERENCE, t2.period_name period_name,
mmt.organization_id, mmt.inventory_item_id,
mmt.rcv_transaction_id, t2.effective_date,
(SELECT b.receipt_num
FROM rcv_transactions a,
rcv_shipment_headers b
WHERE a.shipment_header_id =
b.shipment_header_id
AND a.transaction_id = mmt.rcv_transaction_id
AND ROWNUM < 2) receipt_num,
(SELECT e.segment1
FROM rcv_transactions a,
rcv_shipment_headers b,
rcv_shipment_lines c,
po_requisition_lines_all d,
po_requisition_headers_all e
WHERE a.shipment_header_id = b.shipment_header_id
AND c.shipment_header_id = b.shipment_header_id
AND c.requisition_line_id = d.requisition_line_id
AND e.requisition_header_id = d.requisition_header_id
AND a.transaction_id = mmt.rcv_transaction_id
AND ROWNUM < 2) po_req_rece,
(SELECT TO_CHAR (f.order_number)
FROM rcv_transactions a,
rcv_shipment_headers b,
rcv_shipment_lines c,
po_requisition_lines_all d,
po_requisition_headers_all e,
oe_order_headers_all f
WHERE a.shipment_header_id = b.shipment_header_id
AND c.shipment_header_id = b.shipment_header_id
AND c.requisition_line_id = d.requisition_line_id
AND e.requisition_header_id = d.requisition_header_id
AND e.segment1 = f.orig_sys_document_ref
AND a.transaction_id = mmt.rcv_transaction_id
AND ROWNUM < 2) order_number_rec,
t5.accounting_class_code, wdd.transaction_id delive,
wdd.source_line_id, mmt.trx_source_line_id,
wdd.source_header_number order_number,
(SELECT orig_sys_document_ref
FROM oe_order_headers_all ooha
WHERE order_number = wdd.source_header_number) pr_req,
t5.currency_code currency, t5.currency_conversion_rate rate,
xteu.entity_code,
DECODE (fu.description,
NULL, fu.user_name,
fu.description
) user_name,
t3.code_combination_id gl_code_id
FROM gl_je_headers t1,
gl_je_lines t2,
gl_code_combinations t3,
gl_import_references t4,
xla_ae_lines t5,
xla_ae_headers t7,
xla_distribution_links t6,
xla_transaction_entities_upg xteu,
mtl_material_transactions mmt,
wsh_delivery_details wdd,
gl_je_categories jc,
fnd_user fu
WHERE t1.je_header_id = t2.je_header_id
AND jc.je_category_name = t1.je_category
AND t1.created_by = fu.user_id
AND t2.je_header_id = t4.je_header_id
AND t2.je_line_num = t4.je_line_num
AND t4.gl_sl_link_id = t5.gl_sl_link_id
AND t4.gl_sl_link_table = t5.gl_sl_link_table
AND t5.ae_header_id = t6.ae_header_id
AND t5.ae_header_id = t7.ae_header_id
AND t5.ae_line_num = t6.ae_line_num
AND t2.ledger_id = 2021
AND t2.code_combination_id = t3.code_combination_id
AND t2.effective_date BETWEEN :p_date_from AND :p_date_to
AND t3.segment3 = NVL (:p_segment3, t3.segment3)
AND t3.segment7 = NVL (:p_account_from, t3.segment7)
AND mmt.trx_source_line_id = wdd.source_line_id(+)
AND t7.entity_id = xteu.entity_id
AND t5.accounting_class_code IN ('INTRANSIT_VALUATION')
AND TO_CHAR (mmt.transaction_id) = xteu.transaction_number)
location_name, location_code,
(CASE
WHEN order_number_rec IS NULL
THEN order_number
ELSE order_number_rec
END
) order_number, (case when PO_REQ_RECE is null then PR_REQ else PO_REQ_RECE end) pr_requisition_number,
receipt_num, gl_code_acct,
(CASE
WHEN accounting_class_code = 'INTRANSIT_VALUATION'
THEN 'GOODS IN TRANSIT'
END
) descp,
gl_code_id, joual_name, line_desc, accounted_dr, accounted_cr, period_nme
FROM(SELECT SUBSTR (jc.user_je_category_name, 1, 26) CATEGORY,
t1.period_name period_nme,
DECODE (t7.doc_sequence_value,
NULL, t1.doc_sequence_value,
t7.doc_sequence_value
) doc_sequence_value,
( t3.segment1
|| '.'
|| t3.segment2
|| '.'
|| t3.segment3
|| '.'
|| t3.segment4
|| '.'
|| t3.segment5
|| '.'
|| t3.segment6
|| '.'
|| t3.segment7
|| '.'
|| t3.segment8
|| '.'
|| t3.segment9
|| '.'
|| t3.segment10
) gl_code_acct,
(SELECT DISTINCT haotl.NAME
FROM hr_all_organization_units hao,
hr_all_organization_units_tl haotl
WHERE DECODE
(hr_security.view_all,
'Y', 'TRUE',
hr_security.show_record
('HR_ALL_ORGANIZATION_UNITS',
haotl.organization_id
)
) = 'TRUE'
AND DECODE (hr_general.get_xbg_profile,
'Y', hao.business_group_id,
hr_general.get_business_group_id
) = hao.business_group_id
AND hao.organization_id = haotl.organization_id
AND haotl.LANGUAGE = USERENV ('LANG')
AND SUBSTR (hao.attribute1, 1, 4) =
TO_CHAR (t3.segment3))
location_name,
(SELECT DISTINCT hu.attribute1
FROM hr_all_organization_units hu
WHERE SUBSTR (hu.attribute1, 1, 4) =
TO_CHAR (t3.segment3))
location_code,
NVL (t2.accounted_dr, 0) accounted_dr,
NVL (t2.accounted_cr, 0) accounted_cr, xteu.transaction_number,
t1.description, t2.description line_desc,
SUBSTR (t1.je_source, 1, 15) SOURCE,
TO_CHAR (t2.effective_date, 'DD-MON-YY') gl_date,
t1.NAME joual_name, t1.doc_sequence_value hnumber,
SUBSTR (t1.NAME, 1, 8) journal_name, mmt.transaction_id,
t1.external_reference REFERENCE, t2.period_name period_name,
mmt.organization_id, mmt.inventory_item_id,
mmt.rcv_transaction_id, t2.effective_date,
(SELECT b.receipt_num
FROM rcv_transactions a,
rcv_shipment_headers b
WHERE a.shipment_header_id =
b.shipment_header_id
AND a.transaction_id = mmt.rcv_transaction_id
AND ROWNUM < 2) receipt_num,
(SELECT e.segment1
FROM rcv_transactions a,
rcv_shipment_headers b,
rcv_shipment_lines c,
po_requisition_lines_all d,
po_requisition_headers_all e
WHERE a.shipment_header_id = b.shipment_header_id
AND c.shipment_header_id = b.shipment_header_id
AND c.requisition_line_id = d.requisition_line_id
AND e.requisition_header_id = d.requisition_header_id
AND a.transaction_id = mmt.rcv_transaction_id
AND ROWNUM < 2) po_req_rece,
(SELECT TO_CHAR (f.order_number)
FROM rcv_transactions a,
rcv_shipment_headers b,
rcv_shipment_lines c,
po_requisition_lines_all d,
po_requisition_headers_all e,
oe_order_headers_all f
WHERE a.shipment_header_id = b.shipment_header_id
AND c.shipment_header_id = b.shipment_header_id
AND c.requisition_line_id = d.requisition_line_id
AND e.requisition_header_id = d.requisition_header_id
AND e.segment1 = f.orig_sys_document_ref
AND a.transaction_id = mmt.rcv_transaction_id
AND ROWNUM < 2) order_number_rec,
t5.accounting_class_code, wdd.transaction_id delive,
wdd.source_line_id, mmt.trx_source_line_id,
wdd.source_header_number order_number,
(SELECT orig_sys_document_ref
FROM oe_order_headers_all ooha
WHERE order_number = wdd.source_header_number) pr_req,
t5.currency_code currency, t5.currency_conversion_rate rate,
xteu.entity_code,
DECODE (fu.description,
NULL, fu.user_name,
fu.description
) user_name,
t3.code_combination_id gl_code_id
FROM gl_je_headers t1,
gl_je_lines t2,
gl_code_combinations t3,
gl_import_references t4,
xla_ae_lines t5,
xla_ae_headers t7,
xla_distribution_links t6,
xla_transaction_entities_upg xteu,
mtl_material_transactions mmt,
wsh_delivery_details wdd,
gl_je_categories jc,
fnd_user fu
WHERE t1.je_header_id = t2.je_header_id
AND jc.je_category_name = t1.je_category
AND t1.created_by = fu.user_id
AND t2.je_header_id = t4.je_header_id
AND t2.je_line_num = t4.je_line_num
AND t4.gl_sl_link_id = t5.gl_sl_link_id
AND t4.gl_sl_link_table = t5.gl_sl_link_table
AND t5.ae_header_id = t6.ae_header_id
AND t5.ae_header_id = t7.ae_header_id
AND t5.ae_line_num = t6.ae_line_num
AND t2.ledger_id = 2021
AND t2.code_combination_id = t3.code_combination_id
AND t2.effective_date BETWEEN :p_date_from AND :p_date_to
AND t3.segment3 = NVL (:p_segment3, t3.segment3)
AND t3.segment7 = NVL (:p_account_from, t3.segment7)
AND mmt.trx_source_line_id = wdd.source_line_id(+)
AND t7.entity_id = xteu.entity_id
AND t5.accounting_class_code IN ('INTRANSIT_VALUATION')
AND TO_CHAR (mmt.transaction_id) = xteu.transaction_number)
No comments:
Post a Comment