Accounting Details for a PO, Associated Receipts and Invoices

Source: Internet
Author: User

Script

REM ============================================== ======================================

Rem name: PO_Details. SQL
Rem purpose: To get accounting details for a PO, associated receipts and invoices
REM vulnerability: 6492480
Rem product: Cost
Rem product versions: 11.5
Rem platform: Generic
Rem parameters: po_number
REM ============================================== ======================================
REM
REM ============================================== ======================================
Rem change history:
REM 11--200-2007 sbhati 1.0 Created
REM 12--200-2007 dnorman Templated
REM 15--200-2007 dnorman 2.0 Added prompts to make script automatically runable
REM
REM ============================================== ======================================

PROMPT Get po_header_id from po_number

Select po_header_id
From po_headers_all
Where segment1 = '& po_number ';

/*-----------------------------------------------------------------
Section:.
Data from PO tables
-------------------------------------------------------------------*/

Prompt 1. po_headers_all
Select * from po_headers_all
Where po_header_id = & po_header_id;

Prompt 2. po_lines_all
Select * from po_lines_all
Where po_header_id = & po_header_id;

Prompt 3. po_line_locations_all
Select * from po_line_locations_all
Where po_header_id = & po_header_id;

Prompt 4. po_distributions_all
Select * from po_distributions_all
Where po_header_id = & po_header_id;

Prompt 5. po_releases_all
SELECT * FROM po_releases_all
WHERE po_header_id = & po_header_id;

/*-----------------------------------------------------------------
Section: B.
Data from Receving tables and inventory tables
-------------------------------------------------------------------*/

Prompt 6. rcv_shipment_headers
Select * from rcv_shipment_headers
Where shipment_header_id in
(Select shipment_header_id from rcv_shipment_lines
Where po_header_id = & po_header_id );

Prompt 7. rcv_shipment_lines
Select * from rcv_shipment_lines
Where po_header_id = & po_header_id;

Prompt 8. rcv_transactions
Select * from rcv_transactions
Where po_header_id = & po_header_id;

Prompt 9. rcv_Accounting_Events from 11i10 Onwards
SELECT * FROM rcv_Accounting_Events
WHERE rcv_transaction_id IN
(Select transaction_id from rcv_transactions
Where po_header_id = & po_header_id );

Prompt 10. rcv_receiving_sub_ledger
Select * from rcv_receiving_sub_ledger
Where rcv_transaction_id in
(Select transaction_id from rcv_transactions
Where po_header_id = & po_header_id );

Prompt 11. rcv_sub_ledger_details
Select * from rcv_sub_ledger_details
Where rcv_transaction_id in
(Select transaction_id from rcv_transactions
Where po_header_id = & po_header_id );

Prompt 12. mtl_material_transactions
Select * from mtl_material_transactions
Where transaction_source_id = & po_header_id;

Prompt 13. mtl_transaction_accounts
Select * from mtl_transaction_accounts
Where transaction_id in
(Select transaction_id from mtl_material_transactions
Where transaction_source_id = & po_header_id );

/*-----------------------------------------------------------------
Section: C.
Invoicing details.
Note: Pls provide the details of following queries if invoicing
Data only if the issue is related to the calculation
Accrual amount or issue with the data in POXXRVDR, POXPORRA
(Any Accrual reports)
-------------------------------------------------------------------*/

Prompt 14. ap_invoice_distributions_all
Select * from ap_invoice_distributions_all
Where po_distribution_id in
(Select po_distribution_id from po_distributions_all
Where po_header_id = & po_header_id );

Prompt 15. ap_invoices_all
Select * from ap_invoices_all
Where invoice_id in
(Select invoice_id from ap_invoice_distributions_all
Where po_distribution_id in
(Select po_distribution_id from po_distributions_all
Where po_header_id = & po_header_id ));

/*-----------------------------------------------------------------
Section: D.
Projects data
Note: Pls provide details if issue is related to the cost
Transferred to projects for Inventory and processing ing.
-------------------------------------------------------------------*/
Prompt 16. pa_expenditure_items_all
Select *
From pa_expenditure_items_all peia
Where peia. orig_transaction_reference in
(Select to_char (transaction_id) from mtl_material_transactions
Where transaction_source_id = & po_header_id );

-- One more query required from RRSL to PA

/*-----------------------------------------------------------------
Section: E.
Encumbrances Data
Note: Pls provide details if issue is related to the Encumbrance
Amount mismatch for the PO.
-------------------------------------------------------------------*/
Prompt 17. gl_bc_packets
SELECT *
FROM gl_bc_packets
WHERE reference2 IN ('& po_header_id ');

/*-----------------------------------------------------------------
Section: F.
GL data
Note: Pls furnish following details only if issue is related
To the GL Transfer of processing ing transactions.
-----------------------------------------------------------------*/
Prompt 18. GL_INTERFACE
SELECT *
FROM GL_INTERFACE GLI
WHERE user_je_source_name = 'purchasing'
AND gl_sl_link_table = 'rsl'
AND reference21 = 'po'
AND EXISTS
(SELECT 1
FROM rcv_receiving_sub_ledger RRSL
Where gli. reference22 = RRSL. reference2
And gli. reference23 = RRSL. referenpushed
And gli. reference24 = RRSL. reference4
And rrsl. rcv_transaction_id in
(Select transaction_id from rcv_transactions
Where po_header_id = & po_header_id ));

Prompt 19. gl_import_references
SELECT *
FROM gl_import_references GLIR
WHERE reference_1 = 'po'
AND gl_sl_link_table = 'rsl'
AND EXISTS
(SELECT 1
FROM rcv_receiving_sub_ledger RRSL
Where glir. reference_2 = RRSL. reference2
And glir. reference_3 = RRSL. referenpushed
And glir. reference_4 = RRSL. reference4
And rrsl. rcv_transaction_id in
(Select transaction_id from rcv_transactions
Where po_header_id = & po_header_id ));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.