Tuesday, 14 May 2013

Inventory to po and pa link

SELECT   msi.concatenated_segments item,
            REPLACE (msil.description, '~', '-') item_description,
            ph.segment1 po_number,
            rsh.receipt_num receipt_number,
            mmt.subinventory_code subinventory,
            TRUNC (mmt.transaction_date) transaction_date,
            pv.vendor_name vendor_name,
            pv.segment1 vendor_number,
            mmt.creation_date creation_date,
            oap.period_name gl_period,
            oap.period_start_date gl_period_start_date,
            mmt.actual_cost unit_cost,
            mmt.revision item_revision,
            mil.concatenated_segments stock_locators,
            pl.line_num po_line_number,
            pp.name project_name,
            pp.segment1 project_number,
            mmt.primary_quantity quantity,
            (mmt.actual_cost * mmt.primary_quantity) VALUE,
            mtr.reason_id,
            mtr.reason_name reason,
            pt.task_name task_name,
            pt.task_number task_number,
            mmt.transaction_reference transaction_reference,
            mts.transaction_source_type_name,
            mtt.transaction_type_name transaction_type,
            msi.primary_unit_of_measure unit_of_measure,
            DECODE (mmt.costed_flag, 'N', 'No', NVL (MMT.COSTED_FLAG, 'Yes'))
               Valued_Flag,
            mtt.transaction_type_id,
            mil.inventory_location_id,
            pt.task_id,
            pp.project_id,
            oap.acct_period_id,
            msi.inventory_item_id,
            rsh.shipment_header_id,
            rt.transaction_id rcv_transaction_id,
            pv.vendor_id,
            pl.po_header_id,
            pl.line_num,
            rsh.shipment_num,
            rsh.receipt_num,
            haou.name inv_org_name,
            mmt.organization_id,
            mmt.transaction_source_type_id,
            mmt.transaction_action_id,
            mmt.transaction_source_id,
            mmt.department_id,
            mmt.error_explanation,
            mmt.vendor_lot_number supplier_lot,
            mmt.source_line_id,
            mmt.parent_transaction_id,
            mmt.shipment_number shipment_number,
            mmt.waybill_airbill waybill_airbill,
            mmt.freight_code freight_code,
            mmt.number_of_containers,
            mmt.move_transaction_id,
            mmt.completion_transaction_id,
            mmt.operation_seq_num opertion_sequence,
            mmt.expenditure_type,
            mmt.transaction_set_id,
            mmt.transaction_source_name,
            mmt.transaction_uom,
            mmt.transfer_subinventory,
            mmt.transfer_transaction_id,
            mmt.transaction_id mmt_transaction_id,
            mil.organization_id mil_organization_id,
            oap.organization_id oap_organization_id,
            msil.inventory_item_id msil_inventory_item_id,
            msil.organization_id msil_organization_id,
            msil.language,
            msi.organization_id msi_organization_id,
            pl.po_line_id,
            ph.po_header_id ph_po_header_id,
            mp.organization_id mp_organization_id,
            haou.organization_id haou_organization_id,
            mts.transaction_source_type_id mts_transaction_source_type_id
     FROM   mtl_transaction_types mtt,
            mtl_item_locations_kfv mil,
            pa_tasks pt,
            pa_projects pp,
            org_acct_periods oap,
            mtl_system_items_tl msil,
            mtl_system_items_kfv msi,
            mtl_material_transactions mmt,
            rcv_shipment_headers rsh,
            rcv_transactions rt,
            po_vendors pv,
            po_lines pl,
            po_headers ph,
            mtl_parameters mp,
            mtl_transaction_reasons mtr,
            hr_all_organization_units haou,
            mtl_txn_source_types mts
    WHERE       msi.organization_id = mp.organization_id
            AND mmt.organization_id = mp.organization_id
            AND mmt.inventory_item_id = msi.inventory_item_id
            AND mmt.transaction_source_type_id = 1
            AND ph.po_header_id = mmt.transaction_source_id
            AND rt.transaction_id = mmt.rcv_transaction_id
            AND pl.po_line_id = rt.po_line_id
            AND rsh.shipment_header_id = rt.shipment_header_id
            AND pv.vendor_id = ph.vendor_id
            AND oap.organization_id(+) = mmt.organization_id
            AND oap.acct_period_id(+) = mmt.acct_period_id
            AND msil.inventory_item_id(+) = msi.inventory_item_id
            AND msil.organization_id(+) = msi.organization_id
            AND MSIL.LANGUAGE(+) = USERENV ('LANG')
            AND mmt.project_id = pp.project_id(+)
            AND mmt.task_id = pt.task_id(+)
            AND mmt.locator_id = mil.inventory_location_id(+)
            AND mil.organization_id(+) = mmt.organization_id
            AND mmt.transaction_type_id = mtt.transaction_type_id(+)
            AND mtr.reason_id(+) = mmt.reason_id
            AND haou.organization_id = mmt.organization_id
            AND mts.transaction_source_type_id =
                  mmt.transaction_source_type_id

No comments:

Post a Comment