Showing posts with label GRN. Show all posts
Showing posts with label GRN. Show all posts

Monday, December 30, 2024

Query to get GRN Details in Oracle APPS R12

SELECT    
       DISTINCT rsl.to_subinventory
           ,rts.invoice_status_code
   ,phs.org_id
   ,phs.segment1 po_number
   ,rts.transaction_date
           FROM po_vendor_sites_all pvss
               ,po_vendor_sites_all pvss2
               ,po_vendors pvds
               ,po_headers_all phs
               ,po_lines_all pls
               ,po_line_locations_all plls
               ,rcv_shipment_headers rsh
               ,rcv_shipment_lines rsl
               ,inl_ship_lines_all isl
               ,rcv_transactions rts
               ,mtl_system_items_b msi
          WHERE rts.shipment_header_id = rsh.shipment_header_id
            AND rts.po_header_id = phs.po_header_id
            AND rts.po_line_location_id = plls.line_location_id
            AND rts.po_line_id = pls.po_line_id
            AND rts.shipment_header_id = rsl.shipment_header_id
            AND rts.shipment_line_id = rsl.shipment_line_id
            AND rts.lcm_shipment_line_id = isl.ship_line_id(+)
            AND rts.lcm_adjustment_num = isl.adjustment_num(+)
            AND phs.vendor_id = pvds.vendor_id
            AND phs.vendor_site_id = pvss.vendor_site_id
            AND rsh.receipt_source_code = 'VENDOR'
            AND rts.source_document_code = 'PO' 
            AND phs.segment1 = '1234567890'           --- Purchase Order Number/LPO Number
            --AND NVL (rts.invoice_status_code, 'NA') IN ('PENDING', 'REJECTED')
            AND (   (rts.transaction_type = 'RECEIVE')
                 OR (    'N' = 'Y'
                     AND rts.transaction_type = 'CORRECT'
                     AND rts.timecard_id IS NOT NULL
                     AND EXISTS (
                            SELECT 1
                              FROM apps.rcv_transactions prt
                             WHERE prt.transaction_type = 'RECEIVE'
                               AND prt.source_document_code = 'PO'
                               AND prt.transaction_id =
                                                     rts.parent_transaction_id
                               AND prt.invoice_status_code = 'INVOICED'
                               AND prt.last_update_date <= rts.creation_date)
                    )
                )
            AND pvss.pay_on_code IN ('RECEIPT', 'RECEIPT_AND_USE')
            AND phs.pay_on_code IN ('RECEIPT', 'RECEIPT_AND_USE')
            AND NVL (plls.consigned_flag, 'N') <> 'Y'
            AND pvss2.vendor_site_id = NVL (pvss.default_pay_site_id, pvss.vendor_site_id)
            AND NVL (rsh.asn_type, ' ') <> 'ASBN'
            AND rts.po_release_id IS NULL
            AND rsl.item_id = msi.inventory_item_id
            AND rts.organization_id = msi.organization_id
            AND rts.transaction_date >= '01-JAN-2024'

APEX$TASK_PK

  APEX$TASK_PK is a substitution string holding the primary key value of the system of records