Monday, January 18, 2016

Query to show AR Order details

Below queries are for 12.x.x

-- This query will show Receivable Sales Order transaction details posted between date range:
-- Enter values 1. GL Posted Date range
-----------------------------------------------------------------------------------------------------------------
SELECT qttl.NAME "Transaction Name",
       oha.order_number "Order Number",
       ola.line_number "SO Line Number",
       ola.ordered_item "Item",
       ola.ordered_quantity * ola.unit_selling_price "Line Amount",
       rcta.trx_number invoice_number, rcta.trx_date "Invoice Date",
       rctla.line_number "Inv Line Number",
       rctlg.gl_posted_date "AR-GL Posted Date"
  FROM oe_order_headers_all oha,
       oe_order_lines_all ola,
       ra_customer_trx_all rcta,
       ra_customer_trx_lines_all rctla,
       apps.oe_transaction_types_tl qttl,
       apps.ra_cust_trx_line_gl_dist_all rctlg
 WHERE oha.header_id = ola.header_id
   AND rcta.customer_trx_id = rctla.customer_trx_id
   AND rctla.interface_line_attribute6 = TO_CHAR (ola.line_id)
   AND rctla.interface_line_attribute1 = TO_CHAR (oha.order_number)
   AND oha.order_type_id = qttl.transaction_type_id
   AND rctlg.customer_trx_line_id = rctla.customer_trx_line_id
   AND rctlg.gl_posted_date BETWEEN 'DD-MON-YYYY' AND 'DD-MON-YYYY';
-----------------------------------------------------------------------------------------------------------------

-- This query will show the same column details as above for a Sales Order
-- Enter value - 1. Sales Order number
-----------------------------------------------------------------------------------------------------------------
SELECT qttl.NAME "Transaction Name", oha.order_number "Order Number",
       ola.line_number "SO Line Number", ola.ordered_item "Item",
       ola.ordered_quantity * ola.unit_selling_price "Line Amount",
       rcta.trx_number invoice_number, rcta.trx_date "Invoice Date",
       rctla.line_number "Inv Line Number",
       rctlg.gl_posted_date "AR GL Posted Date"
  FROM oe_order_headers_all oha,
       oe_order_lines_all ola,
       ra_customer_trx_all rcta,
       ra_customer_trx_lines_all rctla,
       apps.oe_transaction_types_tl qttl,
       apps.ra_cust_trx_line_gl_dist_all rctlg
 WHERE oha.header_id = ola.header_id
   AND rcta.customer_trx_id = rctla.customer_trx_id
   AND rctla.interface_line_attribute6 = TO_CHAR (ola.line_id)
   AND rctla.interface_line_attribute1 = TO_CHAR (oha.order_number)
   AND order_number = :p_order_number
   AND oha.order_type_id = qttl.transaction_type_id
   AND rctlg.customer_trx_line_id = rctla.customer_trx_line_id;
-----------------------------------------------------------------------------------------------------------------

-- This query will show the same column details as above for the specific account segment (Segment2)-- Change the segment number depending on combination setup
-- Enter value - Segment
-----------------------------------------------------------------------------------------------------------------
SELECT qttl.NAME "Transaction Name", oha.order_number "Order Number",
       ola.line_number "SO Line Number", ola.ordered_item "Item",
       ola.ordered_quantity * ola.unit_selling_price "Line Amount",
       rcta.trx_number invoice_number, rcta.trx_date "Invoice Date",
       rctla.line_number "Inv Line Number",
       rctlg.gl_posted_date "AR GL Posted Date"
  FROM oe_order_headers_all oha,
       oe_order_lines_all ola,
       ra_customer_trx_all rcta,
       ra_customer_trx_lines_all rctla,
       apps.oe_transaction_types_tl qttl,
       apps.ra_cust_trx_line_gl_dist_all rctlg
 WHERE oha.header_id = ola.header_id
   AND rcta.customer_trx_id = rctla.customer_trx_id
   AND rctla.interface_line_attribute6 = TO_CHAR (ola.line_id)
   AND rctla.interface_line_attribute1 = TO_CHAR (oha.order_number)
   AND oha.order_type_id = qttl.transaction_type_id
   AND rctlg.customer_trx_line_id = rctla.customer_trx_line_id
   AND rctlg.code_combination_id IN (SELECT code_combination_id
                                       FROM gl_code_combinations
                                      WHERE segment2 = :SEGMENT);
-----------------------------------------------------------------------------------------------------------------

-- This query will show the same column details as above for the specific transaction type
-- Enter value - Transaction type
-----------------------------------------------------------------------------------------------------------------
SELECT qttl.NAME "Transaction Name", oha.order_number "Order Number",
       ola.line_number "SO Line Number", ola.ordered_item "Item",
       ola.ordered_quantity * ola.unit_selling_price "Line Amount",
       rcta.trx_number invoice_number, rcta.trx_date "Invoice Date",
       rctla.line_number "Inv Line Number",
       rctlg.gl_posted_date "AR GL Posted Date"
  FROM oe_order_headers_all oha,
       oe_order_lines_all ola,
       ra_customer_trx_all rcta,
       ra_customer_trx_lines_all rctla,
       apps.oe_transaction_types_tl qttl,
       apps.ra_cust_trx_line_gl_dist_all rctlg
 WHERE oha.header_id = ola.header_id
   AND rcta.customer_trx_id = rctla.customer_trx_id
   AND rctla.interface_line_attribute6 = TO_CHAR (ola.line_id)
   AND rctla.interface_line_attribute1 = TO_CHAR (oha.order_number)
   AND oha.order_type_id = qttl.transaction_type_id
   AND rctlg.customer_trx_line_id = rctla.customer_trx_line_id
   AND qttl.NAME LIKE '%' || :trx_type || '%' -----------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment