Margin Analysis Report Queries - SQL
Margin Analysis Report Queries - SQL
or reference_header_id=&header_id)));
--rctlgd
SELECT *
FROM ra_cust_trx_line_gl_dist_all rctlgd
WHERE rctlgd.customer_trx_line_id IN
(SELECT rctl.customer_trx_line_id
FROM ra_customer_trx_lines_all rctl
WHERE rctl.interface_line_context = 'ORDER ENTRY'
AND TO_NUMBER(rctl.interface_line_attribute1) IN
(select order_number from oe_order_headers_all
where header_id in
(select header_id from oe_order_lines_all
where header_id=&header_id
or reference_header_id=&header_id)));
--cms
SELECT * FROM cst_margin_summary
WHERE header_id IN (select header_id from oe_order_lines_all
where header_id=&header_id
or reference_header_id=&header_id);
--cmb
SELECT * FROM cst_margin_build
WHERE build_id IN
( SELECT DISTINCT build_id
FROM cst_margin_summary
WHERE header_id IN (select header_id from oe_order_lines_all
where header_id=&header_id
or reference_header_id=&header_id));
--msi
SELECT costing_enabled_flag, INVENTORY_ASSET_FLAG,
inventory_item_id, organization_id
FROM mtl_system_items
WHERE organization_id = &organization_id
AND inventory_item_id IN
(SELECT inventory_item_id
FROM mtl_material_transactions mmt
WHERE mmt.transaction_source_type_id in (2,8)
and mmt.transaction_action_id <> 28
AND mmt.trx_source_line_id IN
(SELECT line_id
FROM oe_order_lines_all
WHERE header_id = &header_id
OR reference_header_id=&header_id));
--pkg
SELECT text
FROM all_source
WHERE NAME='CSTPMRGL'
AND TYPE='PACKAGE BODY'
ORDER BY line;
--pkgobj
SELECT object_name,object_type,status
FROM all_objects
WHERE object_name='CSTPMRGL';