Monday, 16 July 2012

PO, Receiving and XLA Queries

=>Provide PO Number to the following query.

 SELECT PO_HEADER_ID
   FROM PO_HEADERS_ALL
  WHERE SEGMENT1 ='&PO_NUMBER';

Take the PO_HEADER_ID from the above output and provide it the following queries
 
Data from PO Tables:
 1.
 SELECT *
 FROM   PO_HEADERS_ALL
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;
2.
 SELECT *
 FROM   PO_LINES_ALL
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;
3.
 SELECT *
 FROM   PO_LINE_LOCATIONS_ALL
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;
4.
 SELECT *
 FROM   PO_DISTRIBUTIONS_ALL
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;
5.
 SELECT *
 FROM   PO_RELEASES_ALL
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;

Data from Receiving Tables & Inventory Tables:

6.
 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);
7.
 SELECT *
 FROM   RCV_SHIPMENT_LINES
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;
8.
 SELECT *
 FROM   RCV_TRANSACTIONS
 WHERE  PO_HEADER_ID = &PO_HEADER_ID; 
9.
 SELECT *
 FROM   RCV_ACCOUNTING_EVENTS
 WHERE  PO_HEADER_ID = &PO_HEADER_ID;
10.
 SELECT *
 FROM   RCV_RECEIVING_SUB_LEDGER
 WHERE  REFERENCE3 IN
        (SELECT TO_CHAR(PO_DISTRIBUTION_ID)
        FROM    PO_DISTRIBUTIONS_ALL
        WHERE   PO_HEADER_ID = &PO_HEADER_ID);
11.
 SELECT *
 FROM   RCV_SUB_LEDGER_DETAILS
 WHERE  RCV_TRANSACTION_ID IN
        (SELECT TRANSACTION_ID
        FROM    RCV_TRANSACTIONS
        WHERE   PO_HEADER_ID = &PO_HEADER_ID);
12.
 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);
13.
 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));

XLA Queries
14.
SELECT *
FROM   XLA_DISTRIBUTION_LINKS XDL
WHERE  XDL.SOURCE_DISTRIBUTION_ID_NUM_1 IN
       (SELECT TO_CHAR(RRSL.RCV_SUB_LEDGER_ID)
       FROM    RCV_RECEIVING_SUB_LEDGER RRSL
       WHERE   RRSL.REFERENCE3 IN
               (SELECT TO_CHAR(PO_DISTRIBUTION_ID)
               FROM    PO_DISTRIBUTIONS_ALL
               WHERE   PO_HEADER_ID = &PO_HEADER_ID)
       )
AND    SOURCE_DISTRIBUTION_TYPE = 'RCV_RECEIVING_SUB_LEDGER'
AND    APPLICATION_ID           = 707;

15.
SELECT *
FROM   XLA_DISTRIBUTION_LINKS XDL
WHERE  XDL.SOURCE_DISTRIBUTION_ID_NUM_1 IN
       ( SELECT aida.invoice_distribution_id
       FROM    AP_INVOICE_DISTRIBUTIONS_ALL aida
       WHERE   aida.PO_DISTRIBUTION_ID IN
               (SELECT pod.PO_DISTRIBUTION_ID
               FROM    PO_DISTRIBUTIONS_ALL pod
               WHERE   pod.PO_HEADER_ID = &PO_HEADER_ID)
       )
AND    APPLICATION_ID = 200;

=> Get AE_HEADER_ID from above query and prvide as input to following queries

16.
SELECT XAH.GL_TRANSFER_STATUS_CODE, XAH.*
FROM   XLA_AE_HEADERS XAH
WHERE  XAH.APPLICATION_ID =200
AND    AE_HEADER_ID       = &AE_HEADER_ID ;
17.
SELECT *
FROM   XLA_AE_LINES XAL
WHERE  XAL.APPLICATION_ID = 200
AND    AE_HEADER_ID       = &AE_HEADER_ID;

No comments:

Post a Comment