0% found this document useful (0 votes)
363 views3 pages

Margin Analysis Report Queries - SQL

The document contains a series of SQL queries that retrieve data from various Oracle E-Business Suite tables related to orders, transactions, costs, and revenues. The queries reference a header_id or order_number parameter to filter the results to a specific problematic sales order. Additional queries are provided for Oracle E-Business Suite release 12.

Uploaded by

Parth Desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
363 views3 pages

Margin Analysis Report Queries - SQL

The document contains a series of SQL queries that retrieve data from various Oracle E-Business Suite tables related to orders, transactions, costs, and revenues. The queries reference a header_id or order_number parameter to filter the results to a specific problematic sales order. Additional queries are provided for Oracle E-Business Suite release 12.

Uploaded by

Parth Desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

-- The following query could be used to get the Order Header Id

FOR the problematic Sales ORDER NUMBER.


SELECT header_id Header_id
FROM oe_order_headers_all
WHERE order_number = &order_number;
----------------------------------------------------mmt
select *
from mtl_material_transactions b
where trx_source_line_id in (select line_id from oe_order_lines_all
where header_id=&header_id or reference_header_id=&header_id);
--mta2
select *
from mtl_transaction_accounts
where transaction_id in
(select transaction_id
from mtl_material_transactions
where trx_source_line_id in (select line_id from oe_order_lines_all
where header_id=&header_id or reference_header_id=&header_id));
--oola
select * from oe_order_lines_all
where header_id=&header_id
or reference_header_id=&header_id;
--ooha
select * 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);
--rctla
SELECT *
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));
--rcta
SELECT *
FROM ra_customer_trx_all rct
WHERE customer_trx_id IN
(SELECT customer_trx_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)));
--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';

Additional queries if R12 Release ===================================


--crcml
select * from cst_revenue_cogs_match_lines
where cogs_om_line_id in (select line_id from oe_order_lines_all
where header_id=&header_id);
--cce
select * from cst_cogs_events
where cogs_om_line_id in (select line_id from oe_order_lines_all
where header_id=&header_id);
--crrl
select * from cst_revenue_recognition_lines
where revenue_om_line_id in (select revenue_om_line_id from cst_revenue_cogs_ma
tch_lines
where cogs_om_line_id in (select line_id from oe_order_lines_all
where header_id=&header_id));
--mta_cce
select *
from mtl_transaction_accounts
where transaction_id in
(select mmt_transaction_id
from cst_cogs_events
where cogs_om_line_id in (select line_id from oe_order_lines_all
where header_id=&header_id));

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy