Tuesday, 14 May 2013

Inventory onhand quentity Query

SELECT   haou.name inv_org_name,
            moq.organization_id organization_id,
            mp.organization_code organization_code,
            ood.organization_code master_org_code,
            moq.subinventory_code subinventory_code,
            moq.locator_id locator_id,
            mil.concatenated_segments LOCATOR,
            moq.inventory_item_id inventory_item_id,
            msiv.concatenated_segments item,
            moq.revision revision,
            muom.unit_of_measure,
            moq.primary_transaction_quantity on_hand,
            DECODE (moq.containerized_flag,
                    1, 0,
                    moq.primary_transaction_quantity)
               unpacked,
            DECODE (moq.containerized_flag,
                    1, moq.primary_transaction_quantity,
                    0)
               packed,
            moq.cost_group_id cost_group_id,
            moq.lot_number lot_number,
            mil.project_id project_id,
            mil.task_id task_id,
            msi.status_id subinventory_status_id,
            mil.status_id locator_status_id,
            mln.status_id lot_status_id,
            moq.planning_tp_type planning_tp_type,
            moq.planning_organization_id planning_organization_id,
            oodp.organization_name planning_organization,
            moq.owning_tp_type owning_tp_type,
            moq.owning_organization_id owning_organization_id,
            oodw.organization_name owning_organization,
            mpv.project_name,
            mln.expiration_date lot_expiry_date,
            ccg.cost_group,
            mlv.lpn,
            moq.lpn_id,
            mms.status_code,
            pun.unit_number,
            msi.subinventory_type,
            msi.secondary_inventory_name,
            moq.date_received,
            moq.onhand_quantities_id,
            mil.inventory_location_id,
            muom.language,
            msiv.MIN_MINMAX_QUANTITY,
            msiv.MAX_MINMAX_QUANTITY,
            MSIV.LIST_PRICE_PER_UNIT,
            mp.organization_id mp_organization_id,
            mil.organization_id mil_organization_id,
            msi.organization_id msi_organization_id,
            msiv.inventory_item_id msiv_inventory_item_id,
            msiv.organization_id msiv_organization_id,
            mtv.task_id mtv_task_id,
            ccg.cost_group_id ccg_cost_group_id,
            ccga.cost_group_id ccga_cost_group_id,
            ccga.organization_id ccga_organization_id,
            mms.status_id mms_status_id,
            ood.organization_id ood_organization_id,
            oodw.organization_id oodw_organization_id,
            OODP.ORGANIZATION_ID OODP_ORGANIZATION_ID,
            HAOU.ORGANIZATION_ID HAOU_ORGANIZATION_ID,
            MLN.INVENTORY_ITEM_ID MLN_INVENTORY_ITEM_ID,
            MLN.ORGANIZATION_ID MLN_ORGANIZATION_ID,
            mln.lot_number mln_lot_number
     FROM   mtl_parameters mp,
            mtl_item_locations_kfv mil,
            mtl_secondary_inventories msi,
            mtl_lot_numbers mln,
            mtl_system_items_kfv msiv,
            mtl_onhand_quantities_detail moq,
            mtl_project_v mpv,
            mtl_task_v mtv,
            mtl_units_of_measure_tl muom,
            mtl_onhand_lpn_v mlv,
            cst_cost_groups ccg,
            cst_cost_group_accounts ccga,
            mtl_material_statuses_vl mms,
            pjm_unit_numbers pun,
            org_organization_definitions ood,
            org_organization_definitions oodw,
            org_organization_definitions oodp,
            hr_all_organization_units haou
    WHERE       moq.organization_id = mp.organization_id
            AND moq.organization_id = mil.organization_id(+)
            AND moq.locator_id = mil.inventory_location_id(+)
            AND moq.organization_id = msi.organization_id
            AND moq.subinventory_code = msi.secondary_inventory_name
            AND moq.organization_id = mln.organization_id(+)
            AND moq.inventory_item_id = mln.inventory_item_id(+)
            AND moq.lot_number = mln.lot_number(+)
            AND moq.organization_id = msiv.organization_id
            AND moq.inventory_item_id = msiv.inventory_item_id
            AND mil.project_id = mpv.project_id(+)
            AND mtv.task_id(+) = mil.task_id
            AND muom.uom_code = msiv.primary_uom_code
            AND muom.language = USERENV ('LANG')
            AND ccg.cost_group_id = ccga.cost_group_id
            AND moq.cost_group_id = ccg.cost_group_id
            AND mlv.lpn_id(+) = moq.lpn_id
            AND mms.status_id(+) = mil.status_id
            AND pun.master_organization_id(+) = moq.organization_id
            AND mp.master_organization_id = ood.organization_id
            AND moq.planning_organization_id = oodp.organization_id
            AND moq.owning_organization_id = oodw.organization_id
            AND haou.organization_id = msi.organization_id
            --and ood.operating_unit= fnd_profile.VALUE ('ORG_ID')

No comments:

Post a Comment