DBA Data[Home] [Help]

APPS.WMS_RULE_PVT SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 82

 select  msei.secondary_inventory_name subinventory_code               --changed
        ,mil.inventory_location_id locator_id
        ,msei.organization_id organization_id                          --changed
        ,mil.project_id project_id
        ,mil.task_id task_id
        ,g_inventory_item_id inventory_item_id
        ,mil.location_current_units location_current_units
        ,mil.inventory_item_id locator_inventory_item_id
        ,mil.empty_flag empty_flag
        ,mil.mixed_items_flag mixed_items_flag
        ,mil.LAST_UPDATE_DATE
        ,mil.LAST_UPDATED_BY
        ,mil.CREATION_DATE
        ,mil.CREATED_BY
        ,mil.LAST_UPDATE_LOGIN
        ,mil.DESCRIPTION
        ,mil.DESCRIPTIVE_TEXT
        ,mil.DISABLE_DATE
        ,mil.INVENTORY_LOCATION_TYPE
        ,mil.PICKING_ORDER
        ,mil.PHYSICAL_LOCATION_CODE
        ,mil.LOCATION_MAXIMUM_UNITS
        ,mil.LOCATION_WEIGHT_UOM_CODE
        ,mil.MAX_WEIGHT
        ,mil.VOLUME_UOM_CODE
        ,mil.MAX_CUBIC_AREA
        ,mil.X_COORDINATE
        ,mil.Y_COORDINATE
        ,mil.Z_COORDINATE
        ,mil.INVENTORY_ACCOUNT_ID
        ,mil.SEGMENT1
        ,mil.SEGMENT2
        ,mil.SEGMENT3
        ,mil.SEGMENT4
        ,mil.SEGMENT5
        ,mil.SEGMENT6
        ,mil.SEGMENT7
        ,mil.SEGMENT8
        ,mil.SEGMENT9
        ,mil.SEGMENT10
        ,mil.SEGMENT11
        ,mil.SEGMENT12
        ,mil.SEGMENT13
        ,mil.SEGMENT14
        ,mil.SEGMENT15
        ,mil.SEGMENT16
        ,mil.SEGMENT17
        ,mil.SEGMENT18
        ,mil.SEGMENT19
        ,mil.SEGMENT20
        ,mil.SUMMARY_FLAG
        ,mil.ENABLED_FLAG
        ,mil.START_DATE_ACTIVE
        ,mil.END_DATE_ACTIVE
        ,mil.ATTRIBUTE_CATEGORY
        ,mil.ATTRIBUTE1
        ,mil.ATTRIBUTE2
        ,mil.ATTRIBUTE3
        ,mil.ATTRIBUTE4
        ,mil.ATTRIBUTE5
        ,mil.ATTRIBUTE6
        ,mil.ATTRIBUTE7
        ,mil.ATTRIBUTE8
        ,mil.ATTRIBUTE9
        ,mil.ATTRIBUTE10
        ,mil.ATTRIBUTE11
        ,mil.ATTRIBUTE12
        ,mil.ATTRIBUTE13
        ,mil.ATTRIBUTE14
        ,mil.ATTRIBUTE15
        ,mil.REQUEST_ID
        ,mil.PROGRAM_APPLICATION_ID
        ,mil.PROGRAM_ID
        ,mil.PROGRAM_UPDATE_DATE
        ,mil.PHYSICAL_LOCATION_ID
        ,mil.PICK_UOM_CODE
        ,mil.DIMENSION_UOM_CODE
        ,mil.LENGTH
        ,mil.WIDTH
        ,mil.HEIGHT
        ,mil.LOCATOR_STATUS
        ,mil.STATUS_ID
        ,mil.CURRENT_CUBIC_AREA
        ,mil.AVAILABLE_CUBIC_AREA
        ,mil.CURRENT_WEIGHT
        ,mil.AVAILABLE_WEIGHT
        ,mil.LOCATION_AVAILABLE_UNITS
        ,mil.SUGGESTED_CUBIC_AREA
        ,mil.SUGGESTED_WEIGHT
        ,mil.LOCATION_SUGGESTED_UNITS
        ,mil.rowid
   from MTL_ITEM_LOCATIONS mil
       ,MTL_SECONDARY_INVENTORIES msei
  where mil.organization_id(+) = msei.organization_id
    and mil.subinventory_code(+) = msei.secondary_inventory_name
    and NVL(msei.disable_date, sysdate+1) > sysdate
    and NVL(mil.disable_date, sysdate+1) > sysdate
    and mil.ORGANIZATION_ID = g_organization_id
'; --8467209.added org_id above
Line: 183

 select  msei.secondary_inventory_name subinventory_code            -- changed
        ,mil.inventory_location_id locator_id
        ,msei.organization_id organization_id                       -- changed
        ,mil.project_id project_id
        ,mil.task_id task_id
        ,g_inventory_item_id inventory_item_id
        ,mil.location_current_units location_current_units
        ,mil.inventory_item_id locator_inventory_item_id
        ,mil.empty_flag empty_flag
        ,mil.mixed_items_flag mixed_items_flag
        ,mil.LAST_UPDATE_DATE
        ,mil.LAST_UPDATED_BY
        ,mil.CREATION_DATE
        ,mil.CREATED_BY
        ,mil.LAST_UPDATE_LOGIN
        ,mil.DESCRIPTION
        ,mil.DESCRIPTIVE_TEXT
        ,mil.DISABLE_DATE
        ,mil.INVENTORY_LOCATION_TYPE
        ,mil.PICKING_ORDER
        ,mil.PHYSICAL_LOCATION_CODE
        ,mil.LOCATION_MAXIMUM_UNITS
        ,mil.LOCATION_WEIGHT_UOM_CODE
        ,mil.MAX_WEIGHT
        ,mil.VOLUME_UOM_CODE
        ,mil.MAX_CUBIC_AREA
        ,mil.X_COORDINATE
        ,mil.Y_COORDINATE
        ,mil.Z_COORDINATE
        ,mil.INVENTORY_ACCOUNT_ID
        ,mil.SEGMENT1
        ,mil.SEGMENT2
        ,mil.SEGMENT3
        ,mil.SEGMENT4
        ,mil.SEGMENT5
        ,mil.SEGMENT6
        ,mil.SEGMENT7
        ,mil.SEGMENT8
        ,mil.SEGMENT9
        ,mil.SEGMENT10
        ,mil.SEGMENT11
        ,mil.SEGMENT12
        ,mil.SEGMENT13
        ,mil.SEGMENT14
        ,mil.SEGMENT15
        ,mil.SEGMENT16
        ,mil.SEGMENT17
        ,mil.SEGMENT18
        ,mil.SEGMENT19
        ,mil.SEGMENT20
        ,mil.SUMMARY_FLAG
        ,mil.ENABLED_FLAG
        ,mil.START_DATE_ACTIVE
        ,mil.END_DATE_ACTIVE
        ,mil.ATTRIBUTE_CATEGORY
        ,mil.ATTRIBUTE1
        ,mil.ATTRIBUTE2
        ,mil.ATTRIBUTE3
        ,mil.ATTRIBUTE4
        ,mil.ATTRIBUTE5
        ,mil.ATTRIBUTE6
        ,mil.ATTRIBUTE7
        ,mil.ATTRIBUTE8
        ,mil.ATTRIBUTE9
        ,mil.ATTRIBUTE10
        ,mil.ATTRIBUTE11
        ,mil.ATTRIBUTE12
        ,mil.ATTRIBUTE13
        ,mil.ATTRIBUTE14
        ,mil.ATTRIBUTE15
        ,mil.REQUEST_ID
        ,mil.PROGRAM_APPLICATION_ID
        ,mil.PROGRAM_ID
        ,mil.PROGRAM_UPDATE_DATE
        ,mil.PHYSICAL_LOCATION_ID
        ,mil.PICK_UOM_CODE
        ,mil.DIMENSION_UOM_CODE
        ,mil.LENGTH
        ,mil.WIDTH
        ,mil.HEIGHT
        ,mil.LOCATOR_STATUS
        ,mil.STATUS_ID
        ,mil.CURRENT_CUBIC_AREA
        ,mil.AVAILABLE_CUBIC_AREA
        ,mil.CURRENT_WEIGHT
        ,mil.AVAILABLE_WEIGHT
        ,mil.LOCATION_AVAILABLE_UNITS
        ,mil.SUGGESTED_CUBIC_AREA
        ,mil.SUGGESTED_WEIGHT
        ,mil.LOCATION_SUGGESTED_UNITS
  ,mil.rowid
from MTL_ITEM_LOCATIONS mil
       ,MTL_SECONDARY_INVENTORIES msei
       ,MTL_ITEM_SUB_INVENTORIES misi
  where mil.organization_id(+) = msei.organization_id
    and mil.organization_id=g_organization_id ---bug8425620 8665549
    and mil.subinventory_code(+) = msei.secondary_inventory_name
    and NVL(msei.disable_date, sysdate+1) > sysdate
    and NVL(mil.disable_date, sysdate+1) > sysdate
    and mil.organization_id = misi.organization_id
    and mil.subinventory_code = misi.secondary_inventory
    and misi.inventory_item_id = g_inventory_item_id
';
Line: 288

 select  mil.subinventory_code subinventory_code
        ,mil.inventory_location_id locator_id
        ,mil.organization_id organization_id
        ,mil.project_id project_id
        ,mil.task_id task_id
        ,g_inventory_item_id inventory_item_id
        ,mil.location_current_units location_current_units
        ,mil.inventory_item_id locator_inventory_item_id
        ,mil.empty_flag empty_flag
        ,mil.mixed_items_flag mixed_items_flag
        ,mil.LAST_UPDATE_DATE
        ,mil.LAST_UPDATED_BY
        ,mil.CREATION_DATE
        ,mil.CREATED_BY
        ,mil.LAST_UPDATE_LOGIN
        ,mil.DESCRIPTION
        ,mil.DESCRIPTIVE_TEXT
        ,mil.DISABLE_DATE
        ,mil.INVENTORY_LOCATION_TYPE
        ,mil.PICKING_ORDER
        ,mil.PHYSICAL_LOCATION_CODE
        ,mil.LOCATION_MAXIMUM_UNITS
        ,mil.LOCATION_WEIGHT_UOM_CODE
        ,mil.MAX_WEIGHT
        ,mil.VOLUME_UOM_CODE
        ,mil.MAX_CUBIC_AREA
        ,mil.X_COORDINATE
        ,mil.Y_COORDINATE
        ,mil.Z_COORDINATE
        ,mil.INVENTORY_ACCOUNT_ID
        ,mil.SEGMENT1
        ,mil.SEGMENT2
        ,mil.SEGMENT3
        ,mil.SEGMENT4
        ,mil.SEGMENT5
        ,mil.SEGMENT6
        ,mil.SEGMENT7
        ,mil.SEGMENT8
        ,mil.SEGMENT9
        ,mil.SEGMENT10
        ,mil.SEGMENT11
        ,mil.SEGMENT12
        ,mil.SEGMENT13
        ,mil.SEGMENT14
        ,mil.SEGMENT15
        ,mil.SEGMENT16
        ,mil.SEGMENT17
        ,mil.SEGMENT18
        ,mil.SEGMENT19
        ,mil.SEGMENT20
        ,mil.SUMMARY_FLAG
        ,mil.ENABLED_FLAG
        ,mil.START_DATE_ACTIVE
        ,mil.END_DATE_ACTIVE
        ,mil.ATTRIBUTE_CATEGORY
        ,mil.ATTRIBUTE1
        ,mil.ATTRIBUTE2
        ,mil.ATTRIBUTE3
        ,mil.ATTRIBUTE4
        ,mil.ATTRIBUTE5
        ,mil.ATTRIBUTE6
        ,mil.ATTRIBUTE7
        ,mil.ATTRIBUTE8
        ,mil.ATTRIBUTE9
        ,mil.ATTRIBUTE10
        ,mil.ATTRIBUTE11
        ,mil.ATTRIBUTE12
        ,mil.ATTRIBUTE13
        ,mil.ATTRIBUTE14
        ,mil.ATTRIBUTE15
        ,mil.REQUEST_ID
        ,mil.PROGRAM_APPLICATION_ID
        ,mil.PROGRAM_ID
        ,mil.PROGRAM_UPDATE_DATE
        ,mil.PHYSICAL_LOCATION_ID
        ,mil.PICK_UOM_CODE
        ,mil.DIMENSION_UOM_CODE
        ,mil.LENGTH
        ,mil.WIDTH
        ,mil.HEIGHT
        ,mil.LOCATOR_STATUS
        ,mil.STATUS_ID
        ,mil.CURRENT_CUBIC_AREA
        ,mil.AVAILABLE_CUBIC_AREA
        ,mil.CURRENT_WEIGHT
        ,mil.AVAILABLE_WEIGHT
        ,mil.LOCATION_AVAILABLE_UNITS
        ,mil.SUGGESTED_CUBIC_AREA
        ,mil.SUGGESTED_WEIGHT
        ,mil.LOCATION_SUGGESTED_UNITS
        ,mil.rowid
   from MTL_ITEM_LOCATIONS mil
       ,MTL_SECONDARY_INVENTORIES msei
       ,MTL_ITEM_SUB_INVENTORIES misi
       ,MTL_SECONDARY_LOCATORS msl
  where mil.organization_id = msei.organization_id
    and mil.organization_id=g_organization_id ---bug8425620 8665549
    and mil.subinventory_code = msei.secondary_inventory_name
    and NVL(msei.disable_date, sysdate+1) > sysdate
    and NVL(mil.disable_date, sysdate+1) > sysdate
    and mil.organization_id = misi.organization_id
    and mil.subinventory_code = misi.secondary_inventory
    and misi.inventory_item_id = g_inventory_item_id
    and mil.organization_id = msl.organization_id
    and mil.inventory_location_id = msl.secondary_locator
    and msl.inventory_item_Id = g_inventory_item_id
';
Line: 397

 select  x.organization_id
        ,x.inventory_item_id
        ,x.subinventory_code
        ,x.locator_id
  from (
  -- subs not restricted and locator controlled
  select msi.ORGANIZATION_ID    ORGANIZATION_ID
        ,msi.INVENTORY_ITEM_ID    INVENTORY_ITEM_ID
        ,msei.SECONDARY_INVENTORY_NAME  SUBINVENTORY_CODE
        ,mil.INVENTORY_LOCATION_ID  LOCATOR_ID
        ,mil.PROJECT_ID     PROJECT_ID
        ,mil.TASK_ID      TASK_ID
    from MTL_ITEM_LOCATIONS                      mil
        ,MTL_SECONDARY_INVENTORIES               msei
        ,MTL_PARAMETERS                          mp
        ,MTL_SYSTEM_ITEMS                        msi
   where nvl(msi.RESTRICT_SUBINVENTORIES_CODE,2) = 2
     and nvl(msi.RESTRICT_LOCATORS_CODE,2)       = 2
     and mp.ORGANIZATION_ID                      = msi.ORGANIZATION_ID
     and msei.ORGANIZATION_ID                    = msi.ORGANIZATION_ID
     and nvl(msei.DISABLE_DATE,sysdate+1)        > sysdate
     and decode(mp.STOCK_LOCATOR_CONTROL_CODE,
                4,decode(msei.LOCATOR_TYPE,
                         5,nvl(msi.LOCATION_CONTROL_CODE,1),
                         nvl(msei.LOCATOR_TYPE,1)),
                mp.STOCK_LOCATOR_CONTROL_CODE)   > 1
     and mil.INVENTORY_LOCATION_ID               > 0  -- force U1 to be used
     and mil.ORGANIZATION_ID                     = msei.ORGANIZATION_ID
     and mil.SUBINVENTORY_CODE                   = msei.SECONDARY_INVENTORY_NAME
     and nvl(mil.DISABLE_DATE,sysdate+1)         > sysdate
  union all
  -- subs restricted and locator controlled
  select msi.ORGANIZATION_ID
        ,msi.INVENTORY_ITEM_ID
        ,misi.SECONDARY_INVENTORY
        ,mil.INVENTORY_LOCATION_ID
        ,mil.PROJECT_ID
        ,mil.TASK_ID
    from MTL_ITEM_LOCATIONS                      mil
        ,MTL_SECONDARY_INVENTORIES               msei
        ,MTL_ITEM_SUB_INVENTORIES                misi
        ,MTL_PARAMETERS                          mp
        ,MTL_SYSTEM_ITEMS                        msi
   where nvl(msi.RESTRICT_SUBINVENTORIES_CODE,2) = 1
     and nvl(msi.RESTRICT_LOCATORS_CODE,2)       = 2
     and mp.ORGANIZATION_ID                      = msi.ORGANIZATION_ID
     and misi.ORGANIZATION_ID                    = msi.ORGANIZATION_ID
     and misi.INVENTORY_ITEM_ID                  = msi.INVENTORY_ITEM_ID
     and msei.ORGANIZATION_ID                    = misi.ORGANIZATION_ID
     and msei.SECONDARY_INVENTORY_NAME           = misi.SECONDARY_INVENTORY
     and nvl(msei.DISABLE_DATE,sysdate+1)        > sysdate
     and decode(mp.STOCK_LOCATOR_CONTROL_CODE,
                4,decode(msei.LOCATOR_TYPE,
                         5,nvl(msi.LOCATION_CONTROL_CODE,1),
                         nvl(msei.LOCATOR_TYPE,1)),
                mp.STOCK_LOCATOR_CONTROL_CODE)   > 1
     and mil.INVENTORY_LOCATION_ID               > 0  -- force U1 to be used
     and mil.ORGANIZATION_ID                     = misi.ORGANIZATION_ID
     and mil.SUBINVENTORY_CODE                   = misi.SECONDARY_INVENTORY
     and nvl(mil.DISABLE_DATE,sysdate+1)         > sysdate
  union all
  -- locators restricted
  select msi.ORGANIZATION_ID
        ,msi.INVENTORY_ITEM_ID
        ,misi.SECONDARY_INVENTORY
        ,msl.SECONDARY_LOCATOR
        ,mil.PROJECT_ID
        ,mil.TASK_ID
    from MTL_ITEM_LOCATIONS                      mil
        ,MTL_SECONDARY_LOCATORS                  msl
        ,MTL_SECONDARY_INVENTORIES               msei
        ,MTL_ITEM_SUB_INVENTORIES                misi
        ,MTL_PARAMETERS                          mp
        ,MTL_SYSTEM_ITEMS                        msi
   where nvl(msi.RESTRICT_SUBINVENTORIES_CODE,2) = 1
     and nvl(msi.RESTRICT_LOCATORS_CODE,2)       = 1
     and mp.ORGANIZATION_ID                      = msi.ORGANIZATION_ID
     and misi.ORGANIZATION_ID                    = msi.ORGANIZATION_ID
     and misi.INVENTORY_ITEM_ID                  = msi.INVENTORY_ITEM_ID
     and msei.ORGANIZATION_ID                    = misi.ORGANIZATION_ID
     and msei.SECONDARY_INVENTORY_NAME           = misi.SECONDARY_INVENTORY
     and nvl(msei.DISABLE_DATE,sysdate+1)        > sysdate
     and msl.ORGANIZATION_ID                     = misi.ORGANIZATION_ID
     and msl.INVENTORY_ITEM_ID                   = misi.INVENTORY_ITEM_ID
     and msl.SUBINVENTORY_CODE                   = misi.SECONDARY_INVENTORY
     and mil.ORGANIZATION_ID                     = msl.ORGANIZATION_ID
     and mil.INVENTORY_LOCATION_ID               = msl.SECONDARY_LOCATOR
     and nvl(mil.DISABLE_DATE,sysdate+1)         > sysdate
  ) x
  group by x.organization_id
         , x.inventory_item_id
         , x.subinventory_code
         , x.locator_id
  ';
Line: 494

   select  msn.current_organization_id organization_id
    ,msn.inventory_item_id
    ,msn.revision
    ,msn.lot_number
    ,lot.expiration_date lot_expiration_date
    ,msn.current_subinventory_code subinventory_code
    ,msn.current_locator_id locator_id
    ,msn.cost_group_id
    ,msn.status_id   --added status_id
    ,msn.serial_number
    ,msn.initialization_date date_received
    ,1 primary_quantity
    ,null secondary_quantity                            -- new
    ,lot.grade_code grade_code                          -- new
    ,sub.reservable_type
    ,nvl(loc.reservable_type,1)  locreservable          -- Bug 6719290
    ,nvl(lot.reservable_type,1)  lotreservable          -- Bug 6719290
    ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
    ,WMS_Rule_PVT.GetConversionRate(
         nvl(loc.pick_uom_code, sub.pick_uom_code)
        ,msn.current_organization_id
        ,msn.inventory_item_id) conversion_rate
    ,msn.lpn_id lpn_id
    ,loc.project_id project_id
    ,loc.task_id task_id
          ,NULL locator_inventory_item_id
          ,NULL empty_flag
          ,NULL location_current_units
   from  mtl_serial_numbers msn
    ,mtl_secondary_inventories sub
    ,mtl_item_locations loc
    ,mtl_lot_numbers lot
   where msn.current_status = 3
      and decode(g_unit_number, ''-9999'', ''a'', ''-7777'', nvl(msn.end_item_unit_number, ''-7777''), msn.end_item_unit_number) =
      decode(g_unit_number, ''-9999'', ''a'', g_unit_number)
      and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
      --and (g_detail_serial IN ( 1,2)
        and ( g_detail_any_serial = 2   or   (g_detail_any_serial = 1
            and g_from_serial_number <= msn.serial_number
            and lengthb(g_from_serial_number) = lengthb(msn.serial_number)
            and g_to_serial_number >=  msn.serial_number
            and lengthb(g_to_serial_number) = lengthb(msn.serial_number))
             or ( g_from_serial_number is null or g_to_serial_number is null)
          )
      and sub.organization_id = msn.current_organization_id
      and sub.secondary_inventory_name = msn.current_subinventory_code
      and loc.organization_id (+)= msn.current_organization_id
      and loc.inventory_location_id (+)= msn.current_locator_id
      and lot.organization_id (+)= msn.current_organization_id
      and lot.inventory_Item_id (+)= msn.inventory_item_id
      and lot.lot_number (+)= msn.lot_number
     ';
Line: 550

         select  msn.current_organization_id organization_id
          ,msn.inventory_item_id
          ,msn.revision
          ,msn.lot_number
          ,lot.expiration_date lot_expiration_date
          ,msn.current_subinventory_code subinventory_code
          ,msn.current_locator_id locator_id
          ,msn.cost_group_id
           ,msn.status_id   --added status_id
          ,msn.serial_number
          ,msn.initialization_date date_received
          ,1 primary_quantity
          ,null secondary_quantity                            -- new
          ,lot.grade_code grade_code                          -- new
          ,sub.reservable_type
          ,nvl(loc.reservable_type,1)  locreservable          -- Bug 6719290
          ,nvl(lot.reservable_type,1)  lotreservable          -- Bug 6719290
          ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
          ,WMS_Rule_PVT.GetConversionRate(
               nvl(loc.pick_uom_code, sub.pick_uom_code)
              ,msn.current_organization_id
              ,msn.inventory_item_id) conversion_rate
          ,msn.lpn_id lpn_id
          ,loc.project_id project_id
          ,loc.task_id task_id
                ,NULL locator_inventory_item_id
                ,NULL empty_flag
                ,NULL location_current_units
           from  mtl_serial_numbers msn
          ,mtl_secondary_inventories sub
          ,mtl_item_locations loc
          ,mtl_lot_numbers lot
          where msn.current_status = 3
            and decode(g_unit_number, ''-9999'', ''a'', ''-7777'', nvl(msn.end_item_unit_number, ''-7777''), msn.end_item_unit_number) =
            decode(g_unit_number, ''-9999'', ''a'', g_unit_number)
            and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
            and (g_detail_serial = 4
                OR(g_detail_any_serial = 1
             OR (g_from_serial_number <= msn.serial_number
                AND lengthb(g_from_serial_number) = lengthb(msn.serial_number)
                AND g_to_serial_number >=  msn.serial_number
                      AND lengthb(g_to_serial_number) = lengthb(msn.serial_number)
                )))
            and sub.organization_id = msn.current_organization_id
            and sub.secondary_inventory_name = msn.current_subinventory_code
            and loc.organization_id (+)= msn.current_organization_id
            and loc.inventory_location_id (+)= msn.current_locator_id
            and lot.organization_id (+)= msn.current_organization_id
            and lot.inventory_Item_id (+)= msn.inventory_item_id
            and lot.lot_number (+)= msn.lot_number
             ';
Line: 606

    select  msn.current_organization_id organization_id
     ,msn.inventory_item_id
     ,msn.revision
     ,msn.lot_number
     ,lot.expiration_date lot_expiration_date
     ,msn.current_subinventory_code subinventory_code
     ,msn.current_locator_id locator_id
     ,msn.cost_group_id
     ,msn.status_id        --added status_id
     ,msn.serial_number
     ,msn.initialization_date date_received
     ,1 primary_quantity
     ,null secondary_quantity                            -- new
     ,lot.grade_code grade_code                          -- new
     ,sub.reservable_type
     ,nvl(loc.reservable_type,1)   locreservable                -- Bug 6719290
     ,nvl(lot.reservable_type,1)   lotreservable                -- Bug 6719290
     ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
     ,WMS_Rule_PVT.GetConversionRate(
          nvl(loc.pick_uom_code, sub.pick_uom_code)
         ,msn.current_organization_id
         ,msn.inventory_item_id) conversion_rate
     ,msn.lpn_id lpn_id
     ,loc.project_id project_id
     ,loc.task_id task_id
           ,NULL locator_inventory_item_id
           ,NULL empty_flag
           ,NULL location_current_units
      from  mtl_serial_numbers msn
     ,mtl_secondary_inventories sub
     ,mtl_item_locations loc
     ,mtl_lot_numbers lot
    where msn.current_status = 3
       and decode(g_unit_number, ''-9999'', ''a'', ''-7777'', nvl(msn.end_item_unit_number, ''-7777''), msn.end_item_unit_number) =
       decode(g_unit_number, ''-9999'', ''a'', g_unit_number)
       and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
       and (g_detail_serial = 3
           OR(g_detail_any_serial = 1
        OR (g_from_serial_number <= msn.serial_number
           AND lengthb(g_from_serial_number) = lengthb(msn.serial_number)
           AND g_to_serial_number >=  msn.serial_number
                 AND lengthb(g_to_serial_number) = lengthb(msn.serial_number)
           )))
       and sub.organization_id = msn.current_organization_id
       and sub.secondary_inventory_name = msn.current_subinventory_code
       and loc.organization_id (+)= msn.current_organization_id
       and loc.inventory_location_id (+)= msn.current_locator_id
       and lot.organization_id (+)= msn.current_organization_id
       and lot.inventory_Item_id (+)= msn.inventory_item_id
       and lot.lot_number (+)= msn.lot_number
       and inv_detail_util_pvt.is_serial_trx_allowed(
                                        g_transaction_type_id
                                        ,msn.current_organization_id
                                        ,msn.inventory_item_id
                                        ,msn.status_id) = ''Y'' ';
Line: 665

   select  x.organization_id
          ,x.inventory_item_id
          ,x.revision
          ,x.lot_number
          ,lot.expiration_date lot_expiration_date
          ,x.subinventory_code
          ,sub.reservable_type
          ,nvl(x.reservable_type,1) locreservable             -- Bug 6719290
          ,nvl(lot.reservable_type,1) lotreservable           -- Bug 6719290
          ,x.locator_id
          ,x.cost_group_id
          ,x.status_id                --added status_id
          ,x.date_received date_received
          ,x.primary_quantity primary_quantity
          ,x.secondary_quantity       secondary_quantity            -- new
          ,lot.grade_code             grade_code                    -- new
          ,x.lpn_id lpn_id
          ,x.project_id project_id
          ,x.task_id task_id
     from
          (SELECT
             moq.organization_id
            ,moq.inventory_item_id
            ,moq.revision
            ,moq.lot_number
            ,moq.subinventory_code
            ,moq.locator_id
            ,moq.cost_group_id
            ,moq.status_id                --added status_id
            ,mils.reservable_type                                  -- Bug 6719290
            ,min(NVL(moq.orig_date_received,
                 moq.date_received)) date_received
            ,sum(moq.primary_transaction_quantity) primary_quantity
            ,sum(moq.secondary_transaction_quantity) secondary_quantity   -- new
            ,moq.lpn_id lpn_id
            ,mils.project_id project_id
            ,mils.task_id task_id
          FROM
              mtl_onhand_quantities_detail  moq
            , mtl_item_locations            mils
          WHERE
               moq.organization_id = g_organization_id
           AND moq.inventory_item_id = g_inventory_item_id
           AND moq.organization_id = mils.organization_id
           AND moq.subinventory_code = mils.subinventory_code
           AND moq.locator_id = mils.inventory_location_id
           AND moq.lpn_id IS NOT NULL
           AND NOT EXISTS(
                select lpn_id
                from wms_license_plate_numbers wlpn1
                where wlpn1.parent_lpn_id = moq.lpn_id)
           AND
               1 = (select count(distinct(moq1.inventory_item_id))
               from mtl_onhand_quantities_detail moq1
               where   moq1.organization_id = moq.organization_id
                    and moq1.subinventory_code = moq.subinventory_code
                    and moq1.locator_id = moq.locator_id
                    and moq1.lpn_id = moq.lpn_id)
           GROUP BY
               moq.organization_id, moq.inventory_item_id
	      --,moq.date_received --bug 6648984
              ,NVL(moq.orig_date_received, moq.date_received) --13518247
              ,moq.revision, moq.lot_number
              ,moq.subinventory_code, moq.locator_id   --added status_id
              ,moq.cost_group_id,moq.status_id,mils.reservable_type,moq.lpn_id       -- Bug 6719290
              ,mils.project_id, mils.task_id
           HAVING
               sum(moq.primary_transaction_quantity) > 0 -- high volume project 8546026
          ) x
          ,mtl_secondary_inventories sub
          ,mtl_lot_numbers lot
    where
--      x.primary_quantity > 0 and  -- high volume project 8546026
          x.organization_id = sub.organization_id
      and x.subinventory_code = sub.secondary_inventory_name
      and x.organization_id = lot.organization_id (+)
      and x.inventory_item_id = lot.inventory_item_id (+)
      and x.lot_number = lot.lot_number (+)
';
Line: 751

   select  x.organization_id
          ,x.inventory_item_id
          ,x.revision
          ,x.lot_number
          ,lot.expiration_date lot_expiration_date
          ,x.subinventory_code
          ,sub.reservable_type
          ,nvl(x.reservable_type,1)   locreservable                          -- Bug 6719290
          ,nvl(lot.reservable_type,1) lotreservable                          -- Bug 6719290
          ,x.locator_id
          ,x.cost_group_id
          ,x.status_id                --added status_id
          ,x.date_received date_received
          ,x.primary_quantity primary_quantity
          ,x.secondary_quantity       secondary_quantity            -- new
          ,lot.grade_code             grade_code                    -- new
          ,x.lpn_id lpn_id
          ,x.project_id project_id
          ,x.task_id task_id
     from
          (SELECT
             moq.organization_id
            ,moq.inventory_item_id
            ,moq.revision
            ,moq.lot_number
            ,moq.subinventory_code
            ,moq.locator_id
            ,moq.cost_group_id
            ,moq.status_id                --added status_id
            ,mils.reservable_type                                  -- Bug 6719290
            ,min(NVL(moq.orig_date_received,
                 moq.date_received)) date_received
            ,sum(moq.primary_transaction_quantity) primary_quantity
            ,sum(moq.secondary_transaction_quantity) secondary_quantity   -- new
            ,moq.lpn_id lpn_id
            ,decode(mils.project_id, mils.project_id, moq.project_id) project_id
            ,decode(mils.task_id, mils.task_id, moq.task_id) task_id
          FROM
            mtl_onhand_quantities_detail moq,mtl_item_locations mils
          WHERE
               moq.organization_id = g_organization_id
           AND moq.inventory_item_id = g_inventory_item_id
           AND moq.organization_id = mils.organization_id (+)
           AND moq.subinventory_code = mils.subinventory_code (+)
           AND moq.locator_id = mils.inventory_location_id (+)
          GROUP BY
               moq.organization_id, moq.inventory_item_id
	      --,moq.date_received --bug 6648984
              ,NVL(moq.orig_date_received, moq.date_received) --13518247
              ,moq.revision, moq.lot_number
              ,moq.subinventory_code, moq.locator_id                --added status_id
              ,moq.cost_group_id,moq.status_id, mils.reservable_type, moq.lpn_id         -- Bug 6719290
              ,decode(mils.project_id, mils.project_id, moq.project_id)
              ,decode(mils.task_id, mils.task_id, moq.task_id)
          HAVING
               sum(moq.primary_transaction_quantity) > 0 -- high volume project 8546026
          ) x
          ,mtl_secondary_inventories sub
          ,mtl_lot_numbers lot
    where
--    x.primary_quantity > 0 and   -- high volume project 8546026
          x.organization_id = sub.organization_id
      and x.subinventory_code = sub.secondary_inventory_name
      and x.organization_id = lot.organization_id (+)
      and x.inventory_item_id = lot.inventory_item_id (+)
      and x.lot_number = lot.lot_number (+)
';
Line: 822

  g_base_select                   LONG;
Line: 824

  g_rule_select                   LONG;
Line: 825

  g_rule_select_serial            LONG;
Line: 826

  g_rule_select_serial_new        LONG; -- Added for Bug 13448337
Line: 1033

        SELECT COUNT(*)
       INTO l_lpn_used
       FROM mtl_reservations mr
     WHERE mr.organization_id = p_organization_id
        AND mr.demand_source_type_id = 9 -- Cycle Count Reservation
           AND mr.lpn_id = p_lpn_id;
Line: 1068

     SELECT count( DISTINCT p.object_id)
       INTO l_serial_object_used
       FROM wms_selection_criteria_txn wsc,
            wms_strategies_b wsb,
            wms_strategy_members wsm,
            wms_rules_b wrb,
            wms_restrictions r,
            wms_sort_criteria s,
            wms_rule_consistencies c,
            wms_parameters_b p
      WHERE wsc.rule_type_code = 2
        AND wsc.enabled_flag = 1
        AND wsc.return_type_code = 'S'
        AND wsc.from_organization_id = p_organization_id
        AND wsc.return_type_id = wsb.strategy_id
        AND wsb.strategy_id = wsm.strategy_id
        AND wsm.rule_id = wrb.rule_id
        AND (
             ( wrb.rule_id = r.rule_id AND ((r.parameter_id = p.parameter_id ) OR (r.operand_parameter_id = p.parameter_id)))
                OR (wrb.rule_id = s.rule_id AND s.parameter_id = p.parameter_id)                OR (wrb.rule_id = c.rule_id AND c.parameter_id = p.parameter_id)              )
        AND wrb.organization_id IN (p_organization_id, -1)
        AND p.object_id = 26; --- 26 is Serial object
Line: 1115

    g_base_select         := NULL;
Line: 1116

    g_rule_select         := NULL;
Line: 1117

    g_rule_select_serial  := NULL;
Line: 1118

    g_rule_select_serial_new  := NULL; -- Added for Bug 13448337
Line: 1174

    UPDATE wms_rule_list_package
       SET package_name_count = 3;
Line: 1240

      SELECT   conversion_rate
             , uom_class
          FROM mtl_uom_conversions
         WHERE uom_code = p_uom_code
           AND inventory_item_id IN (p_inventory_item_id, 0)
           AND NVL(disable_date, TRUNC(SYSDATE) + 1) > TRUNC(SYSDATE)
      ORDER BY inventory_item_id DESC;
Line: 1250

      SELECT uom_class
        FROM mtl_units_of_measure muom, mtl_system_items msi
       WHERE msi.organization_id = p_organization_id
         AND msi.inventory_item_id = p_inventory_item_id
         AND muom.uom_code = msi.primary_uom_code;
Line: 1258

      SELECT   conversion_rate
          FROM mtl_uom_class_conversions
         WHERE from_uom_class = l_from_class
           AND to_uom_class = l_to_class
           AND inventory_item_id IN (p_inventory_item_id, 0)
           AND NVL(disable_date, TRUNC(SYSDATE) + 1) > TRUNC(SYSDATE)
      ORDER BY inventory_item_id DESC;
Line: 1349

      SELECT wdo1.table_alias
           , wdo2.table_name
           , wdo2.table_alias
        FROM wms_db_objects wdo1, wms_db_objects wdo2
       WHERE wdo1.db_object_id = 1
         AND wdo2.db_object_id = 2;
Line: 1393

      g_base_select  :=    l_type_dependent_alias
                        || '.REVISION'
                        || g_line_feed
                        || ','
                        || l_type_dependent_alias
                        || '.LOT_NUMBER'
                        || g_line_feed
                        || ','
                        || l_type_dependent_alias
                        || '.LOT_EXPIRATION_DATE'
                        || g_line_feed
                        || ','
                        || g_base_table_alias
                        || '.SUBINVENTORY_CODE'
                        || g_line_feed
                        || ','
                        || g_base_table_alias
                        || '.LOCATOR_ID'
                        || g_line_feed;
Line: 1413

      g_base_select  := g_base_table_alias
                       || '.SUBINVENTORY_CODE'
                       || g_line_feed || ','
                       || g_base_table_alias
                       || '.LOCATOR_ID'
                       || g_line_feed;
Line: 1423

      g_base_select  := g_base_select
                       || ','
                       || g_base_table_alias
                       || '.PROJECT_ID'
                       || g_line_feed;
Line: 1428

      g_base_select  := g_base_select
                       || ','
                       || g_base_table_alias
                       || '.TASK_ID'
                       || g_line_feed;
Line: 1438

      g_base_select  := g_base_select
                       || ','
                       || g_base_table_alias
                       || '.COST_GROUP_ID'
                       || g_line_feed;
Line: 1443

      g_base_select  := g_base_select
                       || ','
                       || g_base_table_alias
                       || '.UOM_CODE'
                       || g_line_feed;
Line: 1450

        g_base_select  := g_base_select
                       || ','
                       || g_base_table_alias
                       || '.LPN_ID'
                       || g_line_feed;
Line: 1456

        g_base_select  := g_base_select
                       || ',decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID'
                       || g_line_feed;
Line: 1465

     *  g_base_select := g_base_select ||',NULL cost_group_id'
     *                                 || g_line_feed;
Line: 1467

     *  g_base_select := g_base_select ||',NULL uom_code'
     *                                 || g_line_feed;
Line: 1541

                 || 'SELECT x.organization_id       organization_id     '
                                       || g_line_feed
                 || '  ,x.inventory_item_id         inventory_item_id   '
                                       || g_line_feed
                 || '  ,x.revision                  revision            '
                                       || g_line_feed
                 || '  ,x.lot_number                lot_number          '
                                       || g_line_feed
                 || '  ,x.lot_expiration_date       lot_expiration_date '
                                       || g_line_feed
                 || '  ,x.subinventory_code         subinventory_code   '
                 || g_line_feed
                 || '  ,x.locator_id                locator_id          '
                                       || g_line_feed
                 || '  ,x.cost_group_id             cost_group_id       '
                                       || g_line_feed
                 || '  ,x.status_id                 status_id       '   --added status_id
                              || g_line_feed
                 || '  ,NULL                        serial_number       '
                                       || g_line_feed
                 || '  ,x.lpn_id                    lpn_id              '
                                       || g_line_feed
                 || '  ,x.project_id                project_id          '
                                       || g_line_feed
                 || '  ,x.task_id                   task_id             '
                                       || g_line_feed
                 || '  ,x.date_received             date_received       '
                                       || g_line_feed
                 || '  ,x.primary_quantity          primary_quantity    '
                                       || g_line_feed
                 || '  ,x.secondary_quantity          secondary_quantity    '         -- new
                                       || g_line_feed                                 -- new
                 || '  ,x.grade_code                  grade_code            '         -- new
                                       || g_line_feed                                 -- new
                 || '  ,x.reservable_type           reservable_type     '
                                       || g_line_feed
                 || '  ,x.locreservable             locreservable '              -- Bug 6719290 Start
                                       || g_line_feed
                 || '  ,x.lotreservable             lotreservable '
                                       || g_line_feed                            -- Bug 6719290 End
                 || '  ,NVL(loc.pick_uom_code,sub.pick_uom_code) uom_code'
                                       || g_line_feed
                 || '  ,WMS_Rule_PVT.GetConversionRate(                 '
                                       || g_line_feed
                 || '       NVL(loc.pick_uom_code, sub.pick_uom_code)   '
                                       || g_line_feed
                 || '       ,x.organization_id            '
                                       || g_line_feed
                 || '       ,x.inventory_item_id) conversion_rate       '
                                       || g_line_feed
                 || '  ,NULL locator_inventory_item_id                  '
                                       || g_line_feed
                 || '  ,NULL empty_flag                                 '
                                       || g_line_feed
                 || '  ,NULL location_current_units                     '
                                       || g_line_feed
                 || 'FROM ('
                 || g_pick_base
                  --extra line feed?                  || g_line_feed
                 || '     ) x                                           '
                                       || g_line_feed
                 || '    ,mtl_secondary_inventories sub                 '
                                       || g_line_feed
                 || '    ,mtl_item_locations loc                        '
                                       || g_line_feed
                 || 'WHERE x.organization_id = loc.organization_id (+)  '
                                       || g_line_feed
                 || '   AND x.locator_id = loc.inventory_location_id (+)'
                                       || g_line_feed
                 || '   AND sub.organization_id = x.organization_id     '
                                       || g_line_feed
                 || '   AND sub.secondary_inventory_name = x.subinventory_code '
                                       || g_line_feed; /*
Line: 1654

                                  select lpn_id
                                  from wms_license_plate_numbers wlpn1
                                  where wlpn1.parent_lpn_id = msn.lpn_id)
                                     and
                                        1 = (select count(distinct(moq1.inventory_item_id))
                                             from mtl_onhand_quantities_detail moq1
                                             where moq1.organization_id = msn.current_organization_id
                             and moq1.subinventory_code = msn.current_subinventory_code
                             and moq1.locator_id = msn.current_locator_id
                             and moq1.lpn_id = msn.lpn_id)
                            ';
Line: 1674

        select lpn_id
        from wms_license_plate_numbers wlpn1
        where wlpn1.parent_lpn_id = msn.lpn_id)
          and
             1 = (select count(distinct(moq1.inventory_item_id))
                   from mtl_onhand_quantities_detail moq1
                   where moq1.organization_id = msn.current_organization_id
         and moq1.subinventory_code = msn.current_subinventory_code
         and moq1.locator_id = msn.current_locator_id
         and moq1.lpn_id = msn.lpn_id)
         ';
Line: 1691

        select lpn_id
        from wms_license_plate_numbers wlpn1
        where wlpn1.parent_lpn_id = msn.lpn_id)
          and
             1 = (select count(distinct(moq1.inventory_item_id))
                   from mtl_onhand_quantities_detail moq1
                   where moq1.organization_id = msn.current_organization_id
         and moq1.subinventory_code = msn.current_subinventory_code
         and moq1.locator_id = msn.current_locator_id
         and moq1.lpn_id = msn.lpn_id)
         ';
Line: 1878

      SELECT   wdo.db_object_id
             , wdo.table_name
             , wdo.table_alias
             , wdo.context_dependent_flag
          FROM wms_db_objects wdo
             , wms_parameters_b wpb
             , (SELECT wsc.parameter_id
                  FROM wms_sort_criteria wsc
                 WHERE wsc.rule_id = p_rule_id
                UNION
                SELECT wr.parameter_id
                  FROM wms_restrictions wr
                 WHERE wr.rule_id = p_rule_id
                UNION
                SELECT wr.operand_parameter_id
                  FROM wms_restrictions wr
                 WHERE wr.rule_id = p_rule_id
                   AND wr.operand_type_code = 4
                UNION
                SELECT wrc.parameter_id
                  FROM wms_rule_consistencies wrc
                 WHERE wrc.rule_id = p_rule_id) x
         WHERE wpb.parameter_id = x.parameter_id
           AND wpb.db_object_ref_type_code = 1
           AND wdo.db_object_id = wpb.db_object_id
           AND wdo.db_object_id NOT IN (1, 2)
      UNION
      -- 2. all parents of single referenced DB objects
      SELECT   wdo.db_object_id
             , wdo.table_name
             , wdo.table_alias
             , wdo.context_dependent_flag
          FROM wms_db_objects wdo
             , (SELECT     wdop.parent_db_object_id
                      FROM wms_db_objects_parents wdop
                     WHERE wdop.type_code = p_type_code
                CONNECT BY wdop.db_object_id = PRIOR wdop.parent_db_object_id
                START WITH wdop.db_object_id IN (SELECT wdod.db_object_id
                                                   FROM wms_db_objects wdod
                                                      , wms_parameters_b wpbd
                                                      , (SELECT wscd.parameter_id
                                                           FROM wms_sort_criteria wscd
                                                          WHERE wscd.rule_id = p_rule_id
                                                         UNION
                                                         SELECT wrd.parameter_id
                                                           FROM wms_restrictions wrd
                                                          WHERE wrd.rule_id = p_rule_id
                                                         UNION
                                                         SELECT wrd.operand_parameter_id
                                                           FROM wms_restrictions wrd
                                                          WHERE wrd.rule_id = p_rule_id
                                                            AND wrd.operand_type_code = 4
                                                         UNION
                                                         SELECT wrcd.parameter_id
                                                           FROM wms_rule_consistencies wrcd
                                                          WHERE wrcd.rule_id = p_rule_id) xd
                                                  WHERE wpbd.parameter_id = xd.parameter_id
                                                    AND wpbd.db_object_ref_type_code = 1
                                                    AND wdod.db_object_id = wpbd.db_object_id)) x
         WHERE wdo.db_object_id = x.parent_db_object_id
           AND wdo.db_object_id NOT IN (1, 2)
      -- 3. all multi referenced DB objects
      UNION
      SELECT   wdo.db_object_id
             , wdo.table_name
             , NVL(wdorm.table_alias, wdo.table_alias)
             , wdo.context_dependent_flag
          FROM wms_db_objects wdo
             , wms_db_obj_ref_members wdorm
             , wms_db_object_references wdor
             , wms_parameters_b wpb
             , (SELECT wsc.parameter_id
                  FROM wms_sort_criteria wsc
                 WHERE wsc.rule_id = p_rule_id
                UNION
                SELECT wr.parameter_id
                  FROM wms_restrictions wr
                 WHERE wr.rule_id = p_rule_id
                UNION
                SELECT wr.operand_parameter_id
                  FROM wms_restrictions wr
                 WHERE wr.rule_id = p_rule_id
                   AND wr.operand_type_code = 4
                UNION
                SELECT wrc.parameter_id
                  FROM wms_rule_consistencies wrc
                 WHERE wrc.rule_id = p_rule_id) x
         WHERE wpb.parameter_id = x.parameter_id
           AND wpb.db_object_ref_type_code = 2
           AND wdor.db_object_reference_id = wpb.db_object_reference_id
           AND wdorm.db_object_reference_id = wdor.db_object_reference_id
           AND wdo.db_object_id = wdorm.db_object_id
           AND wdo.db_object_id NOT IN (1, 2)
      UNION
      -- 4. all parents of multi referenced DB objects
      SELECT   wdo.db_object_id
             , wdo.table_name
             , wdo.table_alias
             , wdo.context_dependent_flag
          FROM wms_db_objects wdo
             , (SELECT     wdop.parent_db_object_id
                      FROM wms_db_objects_parents wdop
                     WHERE wdop.type_code = p_type_code
                CONNECT BY wdop.db_object_id = PRIOR wdop.parent_db_object_id
                START WITH wdop.db_object_id IN (SELECT wdoi.db_object_id
                                                   FROM wms_db_objects wdoi
                                                      , wms_db_obj_ref_members wdormi
                                                      , wms_db_object_references wdori
                                                      , wms_parameters_b wpbi
                                                      , (SELECT wsc.parameter_id
                                                           FROM wms_sort_criteria wsc
                                                          WHERE wsc.rule_id = p_rule_id
                                                         UNION
                                                         SELECT wr.parameter_id
                                                           FROM wms_restrictions wr
                                                          WHERE wr.rule_id = p_rule_id
                                                         UNION
                                                         SELECT wr.operand_parameter_id
                                                           FROM wms_restrictions wr
                                                          WHERE wr.rule_id = p_rule_id
                                                            AND wr.operand_type_code = 4
                                                         UNION
                                                         SELECT wrc.parameter_id
                                                           FROM wms_rule_consistencies wrc
                                                          WHERE wrc.rule_id = p_rule_id) xi
                                                  WHERE wpbi.parameter_id = xi.parameter_id
                                                    AND wpbi.db_object_ref_type_code = 2
                                                    AND wdori.db_object_reference_id = wpbi.db_object_reference_id
                                                    AND wdormi.db_object_reference_id = wdori.db_object_reference_id
                                                    AND wdoi.db_object_id = wdormi.db_object_id)) x
         WHERE wdo.db_object_id = x.parent_db_object_id
           AND wdo.db_object_id NOT IN (1, 2)
      ORDER BY 1;
Line: 2016

      SELECT wpb.parameter_type_code
           , wpb.column_name
           , wpb.expression
           , wpb.data_type_code
           , wpbp.parameter_type_code
           , wpbp.column_name
           , wpbp.expression
           , wpbp.data_type_code
           , wdop.table_alias -- alias n.a. for multi object based parameters
        FROM wms_db_objects wdop, wms_parameters_b wpbp, wms_parameters_b wpb, wms_db_object_joins wdoj
       WHERE wdoj.db_object_id = l_db_object_id
         AND wdoj.type_code = p_type_code
         AND wpb.parameter_id = wdoj.parameter_id
         AND wpbp.parameter_id = wdoj.parent_parameter_id
         AND wdop.db_object_id(+) = wpbp.db_object_id;
Line: 2036

      SELECT wpb.parameter_type_code
           , wpb.column_name
           , wpb.expression
           , wpb.data_type_code
           , wdo.table_alias -- alias n.a. for multi object based parameters
        FROM wms_db_objects wdo, wms_parameters_b wpb, wms_rules_b wrb
       WHERE wrb.rule_id = p_rule_id
         AND wpb.parameter_id = wrb.qty_function_parameter_id
         AND wdo.db_object_id(+) = wpb.db_object_id;
Line: 2050

      SELECT   wpbl.parameter_type_code
             , wpbl.column_name
             , wpbl.expression
             , wpbl.data_type_code
             , wdol.table_alias -- alias n.a. for multi object based parameters
             , DECODE(
                 wr.operator_code
               , 1, '>'
               , 2, '<'
               , 3, '='
               , 4, '<>'
               , 5, '>='
               , 6, '<='
               , 7, 'IN'
               , 8, 'NOT IN'
               , 9, 'LIKE'
               , 10, 'NOT LIKE'
               , 11, 'IS NULL'
               , 12, 'IS NOT NULL'
               , NULL
               )
             , wr.operand_type_code
             , wr.operand_constant_number
             , wr.operand_constant_character
             , wr.operand_constant_date
             , wr.operand_expression
             , wr.operand_flex_value_set_id
             , DECODE(wr.logical_operator_code, 1, 'and', 2, 'or', NULL)
             , wr.bracket_open
             , wr.bracket_close
             , wpbr.parameter_type_code
             , wpbr.column_name
             , wpbr.expression
             , DECODE(
                 wr.operand_type_code
               , 4, wpbr.data_type_code
               , 5, wpbl.data_type_code
               , 6, DECODE(ffvs.format_type, 'N', 1, 'C', 2, 3)
               , 7, NULL
               , wr.operand_type_code
               )
             , wdor.table_alias -- alias n.a. for multi object based parameters
             , ffvs.validation_type -- only 'independent' and 'table' are supported
             , ffvt.id_column_name
             , ffvt.value_column_name
             , ffvt.application_table_name
             , ffvt.additional_where_clause
             , wr.rule_id
             , wr.sequence_number
          FROM fnd_flex_validation_tables ffvt
             , fnd_flex_value_sets ffvs
             , wms_db_objects wdor
             , wms_parameters_b wpbr
             , wms_db_objects wdol
             , wms_parameters_b wpbl
             , wms_restrictions wr
         WHERE wr.rule_id = p_rule_id
           AND wpbl.parameter_id = wr.parameter_id
           AND wdol.db_object_id(+) = wpbl.db_object_id
           AND wpbr.parameter_id(+) = wr.operand_parameter_id
           AND wdor.db_object_id(+) = wpbr.db_object_id
           AND ffvs.flex_value_set_id(+) = wr.operand_flex_value_set_id
           AND ffvt.flex_value_set_id(+) = wr.operand_flex_value_set_id
      ORDER BY wr.rule_id, wr.sequence_number -- order is important
                                             ;
Line: 2120

      SELECT   wpb.parameter_type_code
             , wpb.column_name
             , wpb.expression
             , wpb.data_type_code
             , wdo.table_alias -- alias n.a. for multi object based parameters
             , wms_parameter_pvt.getflexdatatypecode(
                 wpb.data_type_code
               , wpb.db_object_ref_type_code
               , wpb.parameter_type_code
               , wpb.flexfield_usage_code
               , wpb.flexfield_application_id
               , wpb.flexfield_name
               , wpb.column_name
               )
             , DECODE(wsc.order_code, 1, 'asc', 2, 'desc', NULL)
             , wsc.rule_id
             , wsc.sequence_number
	     , wpb.object_id       -- Added for Bug 13448337
             , wsc.parameter_id    -- Added for Bug 13448337
          FROM wms_db_objects wdo, wms_parameters_b wpb, wms_sort_criteria wsc
         WHERE wsc.rule_id = p_rule_id
           AND wpb.parameter_id = wsc.parameter_id
           AND wdo.db_object_id(+) = wpb.db_object_id
      ORDER BY wsc.rule_id, wsc.sequence_number;
Line: 2149

      SELECT wpb.parameter_type_code
           , wpb.column_name
           , wpb.expression
           , wdo.table_alias
        FROM wms_rule_consistencies wrc, wms_parameters_b wpb, wms_db_objects wdo
       WHERE wrc.rule_id = p_rule_id
         AND wpb.parameter_id = wrc.parameter_id
         AND wdo.db_object_id(+) = wpb.db_object_id;
Line: 2174

        g_rule_select  := 'NULL serial_number
                          ,nvl(base.primary_quantity,0)
                          ,nvl(base.secondary_quantity,0)              -- new
                          ,base.grade_code,                            -- new
                          ,NULL consist_string,
                          ,NULL order_by_string';
Line: 2185

        g_rule_select  := 'NULL serial_number
                          ,nvl(WMS_Parameter_PVT.GetAvailableUnitCapacity
                                (  mptdtv.TO_ORGANIZATION_ID
                                   ,base.SUBINVENTORY_CODE
                                   ,base.LOCATOR_ID
                                   ,mil.LOCATION_MAXIMUM_UNITS
                                )
                               ,0)
                          ,NULL consist_string
                          ,NULL order_by_string';
Line: 2394

        g_rule_select  := g_rule_select || ',' || g_base_table_alias || '.SERIAL_NUMBER' || g_line_feed;
Line: 2396

        g_rule_select  := g_rule_select || ',NULL SERIAL_NUMBER' || g_line_feed;
Line: 2401

      g_rule_select_serial  := g_rule_select_serial || ',NULL SERIAL_NUMBER' || g_line_feed;
Line: 2441

        g_rule_select         := g_rule_select || ',nvl(' || l_table_alias || '.' || l_column_name || ',0)' || g_line_feed;
Line: 2442

        g_rule_select_serial  := g_rule_select_serial || ',sum(nvl(' || l_table_alias || '.' || l_column_name || ',0))' || g_line_feed;
Line: 2458

          g_rule_select         := g_rule_select
                                   || ',nvl(' || l_expression || ',0)'
                                   || g_line_feed;
Line: 2461

          g_rule_select_serial  := g_rule_select_serial
                                   || ',sum(nvl(' || l_expression || ',0))'
                                   || g_line_feed;
Line: 2465

          g_rule_select         := g_rule_select
                                || ',base.primary_quantity ' || g_line_feed
                                || ',base.secondary_quantity ' || g_line_feed         -- new
                                || ',base.grade_code ' || g_line_feed;                -- new
Line: 2469

          g_rule_select_serial  := g_rule_select_serial
                                || ',sum(base.primary_quantity) ' || g_line_feed
                                || ',sum(base.secondary_quantity) ' || g_line_feed         -- new
                                || ',base.grade_code ' || g_line_feed;                -- new
Line: 2682

                           || '( select '
                           || l_flex_column_name
                           || ' from '
                           || l_application_table_name
                           || ' '
                           || l_additional_where_clause
                           || ')'
                           || l_bracket_close
                           || g_line_feed;
Line: 2695

                           || '( select FLEX_VALUE from '
                           || 'FND_FLEX_VALUES_VL where FLEX_VALUE_SET_ID = '
                           || l_operand_flex_value_set_id
                           || ' and ENABLED_FLAG = ''Y'' and sysdate between nvl('
                           || 'START_DATE_ACTIVE,sysdate-1) and nvl('
                           || 'END_DATE_ACTIVE,sysdate+1) )'
                           || l_bracket_close
                           || g_line_feed;
Line: 3043

        g_rule_select         := g_rule_select
                                || ','
                                || l_consist_string
                                || ' consist_string'
                                || g_line_feed;
Line: 3048

        g_rule_select_serial  := g_rule_select_serial
                                || ','
                                || l_consist_string
                                || ' consist_string'
                                || g_line_feed;
Line: 3059

        g_rule_select         := g_rule_select || ',NULL consist_string' || g_line_feed;
Line: 3060

        g_rule_select_serial  := g_rule_select_serial || ',NULL consist_string' || g_line_feed;
Line: 3140

      g_rule_select_serial_new := g_rule_select_serial; -- Added for Bug 13448337
Line: 3142

        g_rule_select         := g_rule_select
                                || ','
                                || l_order_by_string
                                || ' order_by_string'
                                || g_line_feed;
Line: 3147

        g_rule_select_serial  := g_rule_select_serial
                                || ','
                                || l_order_by_string
                                || ' order_by_string'
                                || g_line_feed;
Line: 3155

           g_rule_select_serial_new  := g_rule_select_serial_new
                                || ','
                                || l_order_by_string1
                                || ' order_by_string'
                                || g_line_feed;
Line: 3165

                g_rule_select_serial_new  := g_rule_select_serial;
Line: 3169

        g_rule_select         := g_rule_select || ',NULL order_by_string' || g_line_feed;
Line: 3170

        g_rule_select_serial  := g_rule_select_serial || ',NULL order_by_string' || g_line_feed;
Line: 3171

        g_rule_select_serial_new  := g_rule_select_serial_new || ',NULL order_by_string' || g_line_feed;
Line: 3199

      g_rule_select         := g_rule_select || ',NULL consist_string' || g_line_feed;
Line: 3200

      g_rule_select_serial  := g_rule_select_serial || ',NULL consist_string' || g_line_feed;
Line: 3201

      g_rule_select_serial_new  := g_rule_select_serial_new || ',NULL consist_string' || g_line_feed; -- Added for Bug 13448337
Line: 3202

      g_rule_select         := g_rule_select || ',NULL order_by_string' || g_line_feed;
Line: 3203

      g_rule_select_serial  := g_rule_select_serial || ',NULL order_by_string' || g_line_feed;
Line: 3204

      g_rule_select_serial_new  := g_rule_select_serial_new || ',NULL order_by_string' || g_line_feed; -- Added for Bug 13448337
Line: 3327

                        || ' ((exists (select 1 from mtl_parameters where organization_id = g_organization_id and default_status_id is not null ) '
                        || ' AND exists(select 1 from mtl_material_statuses where status_id = '
                        || g_base_table_alias
                        || '.STATUS_ID'
                        || ' AND RESERVABLE_TYPE = 1)) OR '
                        || '((NOT exists(select 1 from mtl_parameters where organization_id = g_organization_id and default_status_id is not NULL) '
                        || ' or '
                        || g_base_table_alias
                        || '.STATUS_ID IS NULL)'
                        || ' and '
                        || 'decode(g_subinventory_code, ''-9999'', '
                        || g_base_table_alias
                        || '.RESERVABLE_TYPE, 1)'
                        || ' = 1))'
                        || g_line_feed;
Line: 3365

                          || ' ((exists (select 1 from mtl_parameters where organization_id = g_organization_id and default_status_id is not null ) '
                          || ' AND exists(select 1 from mtl_material_statuses where status_id = '
                          || g_base_table_alias
                          || '.STATUS_ID'
                          || ' AND RESERVABLE_TYPE = 1)) OR '
                          || '((NOT exists(select 1 from mtl_parameters where organization_id = g_organization_id and default_status_id is not NULL) '
                          || 'or '
                          || g_base_table_alias
                          || '.STATUS_ID IS NULL)'
                          || ' and '
                          || 'decode(g_locator_id, -9999, '
                          || g_base_table_alias
                          || '.locreservable, 1)'
                          || ' = 1))'
                          || g_line_feed;
Line: 3405

                            || ' ((exists (select 1 from mtl_parameters where organization_id = g_organization_id and default_status_id is not null ) '
                            || ' AND exists(select 1 from mtl_material_statuses where status_id = '
                            || g_base_table_alias
                            || '.STATUS_ID'
                            || ' AND RESERVABLE_TYPE = 1)) OR '
                            || '((NOT exists(select 1 from mtl_parameters where organization_id = g_organization_id and default_status_id is not NULL) '
                            || 'or '
                            || g_base_table_alias
                            || '.STATUS_ID IS NULL)'
                            || ' and '
                            || 'decode(g_lot_number, ''-9999'', '
                            || 'decode (INV_Pick_Release_PVT.g_pick_nonrsv_lots,1,1,' --8719074
                            || g_base_table_alias
                            || '.lotreservable), 1)'
                            || ' = 1))'
                            || g_line_feed;
Line: 4440

  PROCEDURE rollback_capacity_update(
    x_return_status     OUT NOCOPY    VARCHAR2
  , x_msg_count         OUT NOCOPY    NUMBER
  , x_msg_data          OUT NOCOPY    VARCHAR2
  , p_organization_id   IN            NUMBER
  , p_inventory_item_id IN            NUMBER
  ) IS
    l_return_status VARCHAR2(1);
Line: 4451

    l_api_name      VARCHAR2(30)  := 'rollback_capacity_update';
Line: 4460

      SELECT   to_locator_id
             , SUM(primary_quantity) quantity
          FROM wms_transactions_temp
         WHERE type_code = 1
           AND line_type_code = 2
      GROUP BY to_locator_id;
Line: 4473

       log_procedure(l_api_name, 'start', 'Start rollback_capacity_update');
Line: 4518

       log_procedure(l_api_name, 'end', 'End rollback_capacity_update');
Line: 4534

   END rollback_capacity_update;
Line: 4578

  PROCEDURE validate_and_insert(
    x_return_status          OUT NOCOPY    VARCHAR2
  , x_msg_count              OUT NOCOPY    NUMBER
  , x_msg_data               OUT NOCOPY    VARCHAR2
  , p_record_id              IN            NUMBER
  , p_needed_quantity        IN            NUMBER
  , p_use_pick_uom           IN            BOOLEAN
  , p_organization_id        IN            NUMBER
  , p_inventory_item_id      IN            NUMBER
  , p_to_subinventory_code   IN            VARCHAR2
  , p_to_locator_id          IN            NUMBER
  , p_to_cost_group_id       IN            NUMBER
  , p_primary_uom            IN            VARCHAR2
  , p_transaction_uom        IN            VARCHAR2
  , p_transaction_temp_id    IN            NUMBER
  , p_type_code              IN            NUMBER
  , p_rule_id                IN            NUMBER
  , p_reservation_id         IN            NUMBER
  , p_tree_id                IN            NUMBER
  , p_debug_on               IN            BOOLEAN
  , p_needed_sec_quantity    IN            NUMBER
  , p_secondary_uom          IN            VARCHAR2
  , p_grade_code             IN            VARCHAR2
  , p_orig_needed_quantity   IN            NUMBER -- Added for 14699845 (Flexible lot allocation)
  , p_orig_needed_sec_qty    IN            NUMBER -- Added for 14699845 (Flexible lot allocation)
  , p_simulation_mode        IN            NUMBER -- Added for 14699845 (Flexible lot allocation)
  , x_inserted_record        OUT NOCOPY    BOOLEAN
  , x_allocated_quantity     OUT NOCOPY    NUMBER
  , x_remaining_quantity     OUT NOCOPY    NUMBER
  , x_sec_allocated_quantity OUT NOCOPY    NUMBER
  , x_sec_remaining_quantity OUT NOCOPY    NUMBER
  ) IS
    l_api_name                  VARCHAR2(30) := 'validate_and_insert';
Line: 4689

      SELECT 1 FROM dual
       WHERE EXISTS
           ( SELECT 1
               FROM mtl_lot_uom_class_conversions
              WHERE lot_number        = g_locs(p_record_id).lot_number
                AND inventory_item_id = p_inventory_item_id
                AND organization_id   = p_organization_id
                AND (disable_date IS NULL or disable_date > sysdate)
           );
Line: 4702

      SELECT reservation_id
      -- Added for bug 8665496
           , lot_number
           , reservation_quantity
           , primary_reservation_quantity
           , detailed_quantity
           , reservation_uom_code
           , secondary_reservation_quantity
           , secondary_detailed_quantity
        FROM mtl_reservations
       WHERE reservation_id = p_reservation_id;
Line: 4717

      SELECT uom_class
        FROM mtl_units_of_measure_vl
       WHERE uom_code = p_uom;
Line: 4730

       log_statement(l_api_name, 'validate and insert', 'Entered with parameters: '             ||
                                 '  p_record_id: '                || p_record_id                ||
                                 ', p_needed_quantity: '          || p_needed_quantity          ||
                                 ', p_organization_id: '          || p_organization_id          ||
                                 ', p_inventory_item_id: '        || p_inventory_item_id        ||
                                 ', p_to_subinventory_code: '     || p_to_subinventory_code     ||
                                 ', p_to_locator_id: '            || p_to_locator_id            ||
                                 ', p_to_cost_group_id: '         || p_to_cost_group_id         ||
                                 ', p_primary_uom: '              || p_primary_uom              ||
                                 ', p_transaction_uom: '          || p_transaction_uom          ||
                                 ', p_transaction_temp_id: '      || p_transaction_temp_id      ||
                                 ', p_type_code: '                || p_type_code                ||
                                 ', p_rule_id: '                  || p_rule_id                  ||
                                 ', p_reservation_id: '           || p_reservation_id           ||
                                 ', p_tree_id: '                  || p_tree_id                  ||
                                 ', p_needed_sec_quantity: '      || p_needed_sec_quantity      ||
                                 ', p_secondary_uom: '            || p_secondary_uom            ||
                                 ', l_orig_needed_quantity: '     || l_orig_needed_quantity     ||
                                 ', l_orig_needed_sec_qty: '      || l_orig_needed_sec_qty      ||
                                 ', p_grade_code: '               || p_grade_code               ||
                                 ', p_simulation_mode: '          || p_simulation_mode

                    );
Line: 4774

       log_statement(l_api_name, 'validate and insert', 'l_allocate_lot_flag: '|| l_allocate_lot_flag);
Line: 4775

       log_statement(l_api_name, 'validate and insert', 'l_indivisible_flag: '|| l_indivisible_flag);
Line: 4851

          log_statement(l_api_name, 'validate and insert', 'g_locs(p_record_id).lpn_id : '|| g_locs(p_record_id).lpn_id);
Line: 4855

             log_statement(l_api_name, 'validate and insert', g_locs(p_record_id).lpn_id || ' exists in g_lpns ');
Line: 4856

             log_statement(l_api_name, 'validate and insert', 'g_lpns(g_locs(p_record_id).lpn_id).quantity: '
                                                              || g_lpns(g_locs(p_record_id).lpn_id).quantity);
Line: 4858

             log_statement(l_api_name, 'validate and insert', 'g_lpns(g_locs(p_record_id).lpn_id).total_quantity: '
                                                              || g_lpns(g_locs(p_record_id).lpn_id).total_quantity);
Line: 4860

             log_statement(l_api_name, 'validate and insert', 'g_lpns(g_locs(p_record_id).lpn_id).secondary_quantity: '
                                                              || g_lpns(g_locs(p_record_id).lpn_id).secondary_quantity);
Line: 4862

             log_statement(l_api_name, 'validate and insert', 'g_lpns(g_locs(p_record_id).lpn_id).secondary_total_quantity: '
                                                              || g_lpns(g_locs(p_record_id).lpn_id).secondary_total_quantity);
Line: 4879

          log_statement(l_api_name, 'validate and insert', 'g_locs(p_record_id).lpn_id IS NULL. ');
Line: 4884

       log_statement(l_api_name, 'validate and insert', 'l_entire_lpn_alloc: '|| l_entire_lpn_alloc);
Line: 4889

          SELECT lot_number
            INTO l_reserved_lot
            FROM mtl_reservations
           WHERE reservation_id = p_reservation_id;
Line: 4898

          log_statement(l_api_name, 'validate and insert', ' l_reserved_lot '||l_reserved_lot);
Line: 4904

          SELECT lot_number
            INTO l_mo_lot
            FROM mtl_txn_request_lines
           WHERE line_id = p_transaction_temp_id;
Line: 4913

          log_statement(l_api_name, 'validate and insert', ' l_mo_lot '||l_mo_lot);
Line: 4920

          log_statement(l_api_name, 'validate and insert', 'Either the RSV or MO has lot, so allocating lot.');
Line: 5163

                      log_statement(l_api_name,'validate and insert'
                          ,'Secondary quantity from UOM conversion: ' || l_lot_sallocation_quantity);
Line: 5171

                         log_error(l_api_name,'validate and insert','UOM conversion error');
Line: 5189

                      log_statement(l_api_name,'validate and insert'
                          ,'Allocating integer secondary, and no secondary remaining');
Line: 5196

                   x_inserted_record        := FALSE;
Line: 5212

                         log_statement(l_api_name,'validate and insert'
                             ,'Primary quantity from UOM conversion: ' || l_allocation_quantity);
Line: 5637

       log_statement(l_api_name, 'validate and insert', 'Fetch the l_top_model_line_id using txn_source_line_id: '
                                  || inv_cache.mol_rec.txn_source_line_id);
Line: 5650

       log_statement(l_api_name, 'validate and insert', 'Fetched l_top_model_line_id: ' || l_top_model_line_id);
Line: 5665

       log_statement(l_api_name, 'validate and insert', 'Final l_indivisible_flag: ' || l_indivisible_flag);
Line: 5691

       log_statement(l_api_name, 'validate and insert', 'New l_att: ' || l_att);
Line: 5692

       log_statement(l_api_name, 'validate and insert', 'New l_satt: ' || l_satt);
Line: 5816

                log_statement(l_api_name,'validate and insert'
                    ,'Secondary quantity from UOM conversion (att < requested): ' || l_sallocation_quantity);
Line: 5825

                      log_statement(l_api_name,'validate and insert'
                          ,'Allocating integer secondary, and no secondary remaining (att < requested)');
Line: 5832

                   x_inserted_record        := FALSE;
Line: 5850

                      log_statement(l_api_name,'validate and insert'
                          ,'Primary quantity from UOM conversion (att < requested): ' || l_allocation_quantity);
Line: 5857

                   log_error(l_api_name,'validate and insert','UOM conversion error');
Line: 5886

       SELECT SUM(primary_quantity), SUM(secondary_quantity)
         INTO l_already_allocated_pri_qty, l_already_allocated_sec_qty
         FROM wms_transactions_temp
        WHERE transaction_temp_id = p_transaction_temp_id
          AND type_code      = 2
          AND line_type_code = 2  ;
Line: 5943

          x_inserted_record        := FALSE;
Line: 5965

       x_inserted_record        := FALSE;
Line: 6018

          x_inserted_record        := FALSE;
Line: 6172

       x_inserted_record         := FALSE;
Line: 6196

          x_inserted_record     := FALSE;
Line: 6211

       log_statement(l_api_name, 'update_tree', 'Updating qty tree');
Line: 6214

    inv_quantity_tree_pvt.update_quantities(
        p_api_version_number         => g_qty_tree_api_version
      , p_init_msg_lst               => fnd_api.g_false
      , x_return_status              => x_return_status
      , x_msg_count                  => x_msg_count
      , x_msg_data                   => x_msg_data
      , p_tree_id                    => p_tree_id
      , p_revision                   => g_locs(p_record_id).revision
      , p_lot_number                 => g_locs(p_record_id).lot_number
      , p_subinventory_code          => g_locs(p_record_id).subinventory_code
      , p_locator_id                 => g_locs(p_record_id).locator_id
      , p_primary_quantity           => l_allocation_quantity
      , p_secondary_quantity         => l_sallocation_quantity                 -- INVCONV
      , p_quantity_type              => inv_quantity_tree_pvt.g_qs_txn
      , x_qoh                        => l_qoh
      , x_rqoh                       => l_rqoh
      , x_qr                         => l_qr
      , x_qs                         => l_qs
      , x_att                        => l_att
      , x_atr                        => l_atr
      , x_sqoh                       => l_sqoh                                 -- INVCONV
      , x_srqoh                      => l_srqoh                                -- INVCONV
      , x_sqr                        => l_sqr                                  -- INVCONV
      , x_sqs                        => l_sqs                                  -- INVCONV
      , x_satt                       => l_satt                                 -- INVCONV
      , x_satr                       => l_satr                                 -- INVCONV
      , p_transfer_subinventory_code => p_to_subinventory_code
      , p_cost_group_id              => g_locs(p_record_id).cost_group_id
      , p_lpn_id                     => g_locs(p_record_id).lpn_id
      );
Line: 6247

          log_statement(l_api_name, 'uerr_update_qty', 'Unexpected error in inv_quantity_tree_pvt.update_quantities');
Line: 6253

          log_statement(l_api_name, 'err_update_qty', 'Error in inv_quantity_tree_pvt.update_quantities');
Line: 6300

       log_statement(l_api_name, 'insert_wtt_rec', 'Inserting wtt recs. Trx Qty: ' || l_possible_trx_qty);
Line: 6301

       log_statement(l_api_name, 'insert_wtt_rec', 'Inserting wtt recs. Sec Trx Qty: ' || l_sec_possible_trx_qty);
Line: 6310

       INSERT INTO wms_transactions_temp
                 ( pp_transaction_temp_id
                 , transaction_temp_id
                 , type_code
                 , line_type_code
                 , transaction_quantity
                 , primary_quantity
                 , secondary_quantity
                 , grade_code
                 , revision
                 , lot_number
                 , lot_expiration_date
                 , from_subinventory_code
                 , from_locator_id
                 , rule_id
                 , reservation_id
                 , serial_number
                 , to_subinventory_code
                 , to_locator_id
                 , from_cost_group_id
                 , to_cost_group_id
                 , lpn_id
                 )
          VALUES ( wms_transactions_temp_s.NEXTVAL
                 , p_transaction_temp_id
                 , p_type_code
                 , 2 -- line type code is output
                 , l_possible_trx_qty
                 , l_allocation_quantity
                 , l_sallocation_quantity
                 , g_locs(p_record_id).grade_code
                 , g_locs(p_record_id).revision
                 , g_locs(p_record_id).lot_number
                 , g_locs(p_record_id).lot_expiration_date
                 , g_locs(p_record_id).subinventory_code
                 , g_locs(p_record_id).locator_id
                 , p_rule_id
                 , p_reservation_id
                 , g_locs(p_record_id).serial_number
                 , p_to_subinventory_code
                 , l_to_locator_id
                 , g_locs(p_record_id).cost_group_id
                 , p_to_cost_group_id
                 , g_locs(p_record_id).lpn_id
                 );
Line: 6358

          SELECT pp_transaction_temp_id
          INTO l_transaction_temp_id
          FROM wms_transactions_temp
          WHERE transaction_temp_id = p_transaction_temp_id
            AND type_code = p_type_code
            AND line_type_code = 2
            AND NVL(grade_code, '-9999') = NVL(g_locs(p_record_id).grade_code, '-9999')
            AND NVL(revision, '-99') = NVL(g_locs(p_record_id).revision, '-99')
            AND lot_number IS NULL
            AND lot_expiration_date IS NULL
            AND NVL(from_subinventory_code, '@@@@') = NVL(g_locs(p_record_id).subinventory_code, '@@@@')
            AND NVL(from_locator_id, '-9999') = NVL(g_locs(p_record_id).locator_id, '-9999')
            AND rule_id =  p_rule_id
            AND NVL(reservation_id, '-9999') = NVL(p_reservation_id, '-9999')
            AND serial_number IS NULL
            AND NVL(to_subinventory_code, '@@@@') = NVL(p_to_subinventory_code, '@@@@')
            AND NVL(to_locator_id, '-9999') = NVL(l_to_locator_id, '-9999')
            AND NVL(from_cost_group_id, '-9999') = NVL(g_locs(p_record_id).cost_group_id, '-9999')
            AND NVL(to_cost_group_id, '-9999') = NVL(p_to_cost_group_id, '-9999')
            AND NVL(lpn_id, '-9999') = NVL(g_locs(p_record_id).lpn_id, '-9999')
            AND ROWNUM < 2;
Line: 6380

          UPDATE wms_transactions_temp
             SET transaction_quantity = NVL(transaction_quantity, 0) + NVL(l_possible_trx_qty, 0),
                 primary_quantity = NVL(primary_quantity, 0) + NVL(l_allocation_quantity, 0),
                 secondary_quantity = NVL(secondary_quantity, 0) + NVL(l_sallocation_quantity, 0)
           WHERE pp_transaction_temp_id = l_transaction_temp_id;
Line: 6387

              INSERT INTO wms_transactions_temp
                        ( pp_transaction_temp_id
                        , transaction_temp_id
                        , type_code
                        , line_type_code
                        , transaction_quantity
                        , primary_quantity
                        , secondary_quantity
                        , grade_code
                        , revision
                        , lot_number
                        , lot_expiration_date
                        , from_subinventory_code
                        , from_locator_id
                        , rule_id
                        , reservation_id
                        , serial_number
                        , to_subinventory_code
                        , to_locator_id
                        , from_cost_group_id
                        , to_cost_group_id
                        , lpn_id
                        )
                 VALUES ( wms_transactions_temp_s.NEXTVAL
                        , p_transaction_temp_id
                        , p_type_code
                        , 2 -- line type code is output
                        , l_possible_trx_qty
                        , l_allocation_quantity
                        , l_sallocation_quantity
                        , g_locs(p_record_id).grade_code
                        , g_locs(p_record_id).revision
                        , NULL
                        , NULL
                        , g_locs(p_record_id).subinventory_code
                        , g_locs(p_record_id).locator_id
                        , p_rule_id
                        , p_reservation_id
                        , NULL --g_locs(p_record_id).serial_number
                        , p_to_subinventory_code
                        , l_to_locator_id
                        , g_locs(p_record_id).cost_group_id
                        , p_to_cost_group_id
                        , g_locs(p_record_id).lpn_id
                        );
Line: 6438

       log_statement(l_api_name, 'finish_insert_wtt', 'Finished inserting wtt recs.');
Line: 6461

    x_inserted_record           := TRUE;
Line: 6468

       log_procedure(l_api_name, 'end', 'End Validate_and_Insert');
Line: 6499

  END validate_and_insert;
Line: 6503

  PROCEDURE validate_and_insert(
    x_return_status          OUT NOCOPY    VARCHAR2
  , x_msg_count              OUT NOCOPY    NUMBER
  , x_msg_data               OUT NOCOPY    VARCHAR2
  , p_record_id              IN            NUMBER
  , p_needed_quantity        IN            NUMBER
  , p_use_pick_uom           IN            BOOLEAN
  , p_organization_id        IN            NUMBER
  , p_inventory_item_id      IN            NUMBER
  , p_to_subinventory_code   IN            VARCHAR2
  , p_to_locator_id          IN            NUMBER
  , p_to_cost_group_id       IN            NUMBER
  , p_primary_uom            IN            VARCHAR2
  , p_transaction_uom        IN            VARCHAR2
  , p_transaction_temp_id    IN            NUMBER
  , p_type_code              IN            NUMBER
  , p_rule_id                IN            NUMBER
  , p_reservation_id         IN            NUMBER
  , p_tree_id                IN            NUMBER
  , p_debug_on               IN            BOOLEAN
  , p_needed_sec_quantity    IN            NUMBER
  , p_secondary_uom          IN            VARCHAR2
  , p_grade_code             IN            VARCHAR2
  , x_inserted_record        OUT NOCOPY    BOOLEAN
  , x_allocated_quantity     OUT NOCOPY    NUMBER
  , x_remaining_quantity     OUT NOCOPY    NUMBER
  , x_sec_allocated_quantity OUT NOCOPY    NUMBER
  , x_sec_remaining_quantity OUT NOCOPY    NUMBER
  ) IS
  BEGIN
     validate_and_insert(
        x_return_status          =>   x_return_status
      , x_msg_count              =>   x_msg_count
      , x_msg_data               =>   x_msg_data
      , p_record_id              =>   p_record_id
      , p_needed_quantity        =>   p_needed_quantity
      , p_use_pick_uom           =>   p_use_pick_uom
      , p_organization_id        =>   p_organization_id
      , p_inventory_item_id      =>   p_inventory_item_id
      , p_to_subinventory_code   =>   p_to_subinventory_code
      , p_to_locator_id          =>   p_to_locator_id
      , p_to_cost_group_id       =>   p_to_cost_group_id
      , p_primary_uom            =>   p_primary_uom
      , p_transaction_uom        =>   p_transaction_uom
      , p_transaction_temp_id    =>   p_transaction_temp_id
      , p_type_code              =>   p_type_code
      , p_rule_id                =>   p_rule_id
      , p_reservation_id         =>   p_reservation_id
      , p_tree_id                =>   p_tree_id
      , p_debug_on               =>   p_debug_on
      , p_needed_sec_quantity    =>   p_needed_sec_quantity
      , p_secondary_uom          =>   p_secondary_uom
      , p_grade_code             =>   p_grade_code
      , p_orig_needed_quantity   =>   p_needed_quantity
      , p_orig_needed_sec_qty    =>   p_needed_sec_quantity
      , p_simulation_mode        =>   wms_engine_pvt.g_no_simulation
      , x_inserted_record        =>   x_inserted_record
      , x_allocated_quantity     =>   x_allocated_quantity
      , x_remaining_quantity     =>   x_remaining_quantity
      , x_sec_allocated_quantity =>   x_sec_allocated_quantity
      , x_sec_remaining_quantity =>   x_sec_remaining_quantity );
Line: 6564

  END validate_and_insert;
Line: 6625

       SELECT SUM(moq.primary_transaction_quantity)
       INTO   l_moq_qty
       FROM   mtl_onhand_quantities_detail moq
       WHERE  moq.organization_id = p_organization_id
       AND    moq.inventory_item_id = p_inventory_item_id
       AND    nvl(moq.revision,'@@') = nvl(p_revision,'@@')
       AND    moq.subinventory_code = p_subinventory_code
       AND    decode(p_lot_number,null,'@@',moq.lot_number) = nvl(p_lot_number,'@@')
       AND    moq.locator_id = p_locator_id
       AND    moq.lpn_id = p_lpn_id;
Line: 6640

       SELECT SUM(Decode(mmtt.transaction_status, 2, 1,
                 Decode(mmtt.transaction_action_id,1,-1,2,-1,28,-1,3,-1,
                       Sign(mmtt.primary_quantity)))
               * round(Abs(mmtt.primary_quantity),5))
       INTO   l_mmtt_qty_src
       FROM   mtl_material_transactions_temp mmtt
       WHERE  mmtt.organization_id = p_organization_id
       AND    mmtt.inventory_item_id = p_inventory_item_id
       AND    nvl(mmtt.revision,'@@') = nvl(p_revision,'@@')
       AND    mmtt.subinventory_code = p_subinventory_code
       AND    mmtt.locator_id = p_locator_id
       AND    NVL(mmtt.content_lpn_id,mmtt.transfer_lpn_id) = p_lpn_id
       AND    mmtt.posting_flag = 'Y'
       AND    mmtt.subinventory_code IS NOT NULL
       AND (Nvl(mmtt.transaction_status,0) <> 2 OR
               Nvl(mmtt.transaction_status,0) = 2 AND
               mmtt.transaction_action_id IN (1,2,28,3,21,29,32,34)
              )
       AND    mmtt.transaction_action_id NOT IN (5,6,24,30);
Line: 6664

       SELECT SUM(Abs(mmtt.primary_quantity))
       INTO   l_mmtt_qty_dest
       FROM   mtl_material_transactions_temp mmtt
       WHERE  decode(mmtt.transaction_action_id,3,
               mmtt.transfer_organization,mmtt.organization_id) = p_organization_id
       AND    mmtt.inventory_item_id = p_inventory_item_id
       AND    nvl(mmtt.revision,'@@') = nvl(p_revision,'@@')
       AND    mmtt.transfer_subinventory = p_subinventory_code
       AND    mmtt.transfer_to_location = p_locator_id
       AND    NVL(mmtt.content_lpn_id,mmtt.transfer_lpn_id) = p_lpn_id
       AND    mmtt.posting_flag = 'Y'
       AND    Nvl(mmtt.transaction_status,0) <> 2
       AND    mmtt.transaction_action_id  in (2,28,3)
       AND    mmtt.wip_supply_type IS NULL;
Line: 6692

       SELECT SUM(Decode(mmtt.transaction_status, 2, 1,
                 Decode(mmtt.transaction_action_id,1,-1,2,-1,28,-1,3,-1,
                       Sign(mmtt.primary_quantity)))
               * round(Abs(mmtt.primary_quantity),5))
       INTO   l_mmtt_qty_src
       FROM   mtl_material_transactions_temp mmtt
       WHERE  mmtt.organization_id = p_organization_id
       AND    mmtt.inventory_item_id = p_inventory_item_id
       AND    nvl(mmtt.revision,'@@') = nvl(p_revision,'@@')
       AND    mmtt.subinventory_code = p_subinventory_code
       AND    mmtt.locator_id = p_locator_id
       AND    mmtt.posting_flag = 'Y'
       AND    mmtt.subinventory_code IS NOT NULL
       AND (Nvl(mmtt.transaction_status,0) <> 2 OR
               Nvl(mmtt.transaction_status,0) = 2 AND
               mmtt.transaction_action_id IN (1,2,28,3,21,29,32,34)
              )
       AND    mmtt.transaction_action_id NOT IN (5,6,24,30);
Line: 6715

       SELECT SUM(moq.primary_transaction_quantity)
       INTO   l_moq_qty
       FROM   mtl_onhand_quantities_detail moq
       WHERE  moq.organization_id = p_organization_id
       AND    moq.inventory_item_id = p_inventory_item_id
       AND    nvl(moq.revision,'@@') = nvl(p_revision,'@@')
       AND    moq.subinventory_code = p_subinventory_code
       AND    decode(p_lot_number,null,'@@',moq.lot_number) = nvl(p_lot_number,'@@')
       AND    moq.locator_id = p_locator_id;
Line: 6729

       SELECT SUM(Decode(mmtt.transaction_status, 2, 1,
                 Decode(mmtt.transaction_action_id,1,-1,2,-1,28,-1,3,-1,
                       Sign(mmtt.primary_quantity)))
               * round(Abs(mmtt.primary_quantity),5))
       INTO   l_mmtt_qty_src
       FROM   mtl_material_transactions_temp mmtt
       WHERE  mmtt.organization_id = p_organization_id
       AND    mmtt.inventory_item_id = p_inventory_item_id
       AND    nvl(mmtt.revision,'@@') = nvl(p_revision,'@@')
       AND    mmtt.subinventory_code = p_subinventory_code
       AND    mmtt.locator_id = p_locator_id
       AND    mmtt.posting_flag = 'Y'
       AND    mmtt.subinventory_code IS NOT NULL
       AND (Nvl(mmtt.transaction_status,0) <> 2 OR
               Nvl(mmtt.transaction_status,0) = 2 AND
               mmtt.transaction_action_id IN (1,2,28,3,21,29,32,34)
              )
       AND    mmtt.transaction_action_id NOT IN (5,6,24,30);
Line: 6772

   PROCEDURE ValidNinsert(
        x_return_status        OUT NOCOPY    VARCHAR2
      , x_msg_count            OUT NOCOPY    NUMBER
      , x_msg_data             OUT NOCOPY    VARCHAR2
      , p_record_id            IN            NUMBER
      , p_needed_quantity      IN            NUMBER
      , p_use_pick_uom         IN            BOOLEAN
      , p_organization_id      IN            NUMBER
      , p_inventory_item_id    IN            NUMBER
      , p_to_subinventory_code IN            VARCHAR2
      , p_to_locator_id        IN            NUMBER
      , p_to_cost_group_id     IN            NUMBER
      , p_primary_uom          IN            VARCHAR2
      , p_transaction_uom      IN            VARCHAR2
      , p_transaction_temp_id  IN            NUMBER
      , p_type_code            IN            NUMBER
      , p_rule_id              IN            NUMBER
      , p_reservation_id       IN            NUMBER
      , p_tree_id              IN            NUMBER
      , p_debug_on             IN            BOOLEAN
      , x_inserted_record      OUT NOCOPY    BOOLEAN
      , x_allocated_quantity   OUT NOCOPY    NUMBER
      , x_remaining_quantity   OUT NOCOPY    NUMBER
      ) IS
        l_api_name                 VARCHAR2(30) := 'validate_N_insert';
Line: 6818

           log_procedure(l_api_name, 'start', 'Start Validate_N_Insert');
Line: 6885

          x_inserted_record     := FALSE;
Line: 6932

            x_inserted_record             := FALSE;
Line: 7005

          x_inserted_record     := FALSE;
Line: 7025

            x_inserted_record     := FALSE;
Line: 7042

           log_statement(l_api_name, 'insert_wtt_rec', 'Inserting wtt recs. Trx Qty: ' || l_possible_trx_qty);
Line: 7045

        INSERT INTO wms_transactions_temp
                    (
                    pp_transaction_temp_id
                  , transaction_temp_id
                  , type_code
                  , line_type_code
                  , transaction_quantity
                  , primary_quantity
                  , revision
                  , lot_number
                  , lot_expiration_date
                  , from_subinventory_code
                  , from_locator_id
                  , rule_id
                  , reservation_id
                  , serial_number
                  , to_subinventory_code
                  , to_locator_id
                  , from_cost_group_id
                  , to_cost_group_id
                  , lpn_id
                    )
             VALUES (
                    wms_transactions_temp_s.NEXTVAL
                  , p_transaction_temp_id
                  , p_type_code
                  , 2 -- line type code is output
                  , l_possible_trx_qty
                  , l_allocation_quantity
                  , g_locs(p_record_id).revision
                  , g_locs(p_record_id).lot_number
                  , g_locs(p_record_id).lot_expiration_date
                  , g_locs(p_record_id).subinventory_code
                  , g_locs(p_record_id).locator_id
                  , p_rule_id
                  , p_reservation_id
                  , g_locs(p_record_id).serial_number
                  , p_to_subinventory_code
                  , p_to_locator_id
                  , g_locs(p_record_id).cost_group_id
                  , p_to_cost_group_id
                  , g_locs(p_record_id).lpn_id
                    );
Line: 7089

           log_statement(l_api_name, 'finish_insert_wtt', 'Finished inserting wtt recs.');
Line: 7097

        x_inserted_record           := TRUE;
Line: 7101

           log_procedure(l_api_name, 'end', 'End ValidNinsert');
Line: 7132

  END ValidNinsert;
Line: 7223

         log_statement(l_api_name, 'first_loc', 'First rec to update: ' || l_current_loc);
Line: 7240

    DELETE FROM wms_transactions_temp
          WHERE line_type_code = 2
            AND type_code = p_type_code;
Line: 7244

       log_statement(l_api_name, 'finish_delete_sugs', 'Finished deleting suggestions and restored quantity tree');
Line: 7317

    l_inserted_record          BOOLEAN;
Line: 7331

    l_insert                   NUMBER    := 0;  --bug# 8270806
Line: 7361

      l_insert := 0;  --bug# 8270806,reseting the value to l_insert
Line: 7390

             log_statement(l_api_name, 'val_insert', 'Calling Validate and Insert');
Line: 7394

          validate_and_insert(
            x_return_status              => x_return_status
          , x_msg_count                  => x_msg_count
          , x_msg_data                   => x_msg_data
          , p_record_id                  => l_uom_loc_id
          , p_needed_quantity            => l_needed_quantity
          , p_use_pick_uom               => FALSE
          , p_organization_id            => p_organization_id
          , p_inventory_item_id          => p_inventory_item_id
          , p_to_subinventory_code       => p_to_subinventory_code
          , p_to_locator_id              => p_to_locator_id
          , p_to_cost_group_id           => p_to_cost_group_id
          , p_primary_uom                => p_primary_uom
          , p_transaction_uom            => p_transaction_uom
          , p_transaction_temp_id        => p_transaction_temp_id
          , p_type_code                  => p_type_code
          , p_rule_id                    => p_rule_id
          , p_reservation_id             => p_reservation_id
          , p_tree_id                    => p_tree_id
          , p_debug_on                   => p_debug_on
          , p_needed_sec_quantity        => l_sec_needed_quantity
          , p_secondary_uom              => p_secondary_uom
          , p_grade_code                 => p_grade_code
          , x_inserted_record            => l_inserted_record
          , x_allocated_quantity         => l_allocated_quantity
          , x_remaining_quantity         => l_remaining_quantity
          , x_sec_allocated_quantity     => l_sec_allocated_quantity
          , x_sec_remaining_quantity     => l_sec_remaining_quantity
          , p_orig_needed_quantity       => l_needed_quantity_wo_tol  -- Added for 14699845 (Flexible lot allocation)
          , p_orig_needed_sec_qty        => l_needed_sec_qty_wo_tol   -- Added for 14699845 (Flexible lot allocation)
          , p_simulation_mode            => p_simulation_mode         -- Added for 14699845 (Flexible lot allocation)
          );
Line: 7429

                log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 7434

                log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 7547

         l_insert := 1;  --bug# 8270806
Line: 7563

         log_statement(l_api_name, 'val_insert', 'Calling Validate and Insert');
Line: 7570

           AND l_insert = 0 AND p_lot_divisible_flag = 'N'
         )
         OR ((NVL(p_lot_divisible_flag, 'Y') = 'Y') OR NVL(l_lot_control_code,1) = 1) -- added for bug7261861
      THEN --{
         validate_and_insert(
           x_return_status              => x_return_status
         , x_msg_count                  => x_msg_count
         , x_msg_data                   => x_msg_data
         , p_record_id                  => l_loc_id
         , p_needed_quantity            => l_needed_quantity
         , p_use_pick_uom               => p_use_pick_uom
         , p_organization_id            => p_organization_id
         , p_inventory_item_id          => p_inventory_item_id
         , p_to_subinventory_code       => p_to_subinventory_code
         , p_to_locator_id              => p_to_locator_id
         , p_to_cost_group_id           => p_to_cost_group_id
         , p_primary_uom                => p_primary_uom
         , p_transaction_uom            => p_transaction_uom
         , p_transaction_temp_id        => p_transaction_temp_id
         , p_type_code                  => p_type_code
         , p_rule_id                    => p_rule_id
         , p_reservation_id             => p_reservation_id
         , p_tree_id                    => p_tree_id
         , p_debug_on                   => p_debug_on
         , p_needed_sec_quantity        => l_sec_needed_quantity
         , p_secondary_uom              => p_secondary_uom
         , p_grade_code                 => p_grade_code
         , x_inserted_record            => l_inserted_record
         , x_allocated_quantity         => l_allocated_quantity
         , x_remaining_quantity         => l_remaining_quantity
         , x_sec_allocated_quantity     => l_sec_allocated_quantity
         , x_sec_remaining_quantity     => l_sec_remaining_quantity
         , p_orig_needed_quantity       => l_needed_quantity_wo_tol -- Added for 14699845 (Flexible lot allocation)
         , p_orig_needed_sec_qty        => l_needed_sec_qty_wo_tol  -- Added for 14699845 (Flexible lot allocation)
         , p_simulation_mode            => p_simulation_mode        -- Added for 14699845 (Flexible lot allocation)
         );
Line: 7609

               log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 7614

               log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 7882

  PROCEDURE insert_consist_record(
    x_return_status        OUT NOCOPY    VARCHAR2
  , x_msg_count            OUT NOCOPY    NUMBER
  , x_msg_data             OUT NOCOPY    VARCHAR2
  , p_record_id            IN            NUMBER
  , p_needed_quantity      IN            NUMBER
  , p_use_pick_uom         IN            BOOLEAN
  , p_organization_id      IN            NUMBER
  , p_inventory_item_id    IN            NUMBER
  , p_to_subinventory_code IN            VARCHAR2
  , p_to_locator_id        IN            NUMBER
  , p_to_cost_group_id     IN            NUMBER
  , p_primary_uom          IN            VARCHAR2
  , p_transaction_uom      IN            VARCHAR2
  , p_transaction_temp_id  IN            NUMBER
  , p_type_code            IN            NUMBER
  , p_rule_id              IN            NUMBER
  , p_reservation_id       IN            NUMBER
  , p_tree_id              IN            NUMBER
  , p_debug_on             IN            BOOLEAN
  , p_order_by_rank        IN            NUMBER
  , p_needed_sec_quantity  IN            NUMBER
  , p_secondary_uom        IN            VARCHAR2
  , p_grade_code           IN            VARCHAR2
  , p_orig_needed_quantity IN            NUMBER  -- Added for 14699845 (Flexible lot allocation)
  , p_orig_needed_sec_qty  IN            NUMBER  -- Added for 14699845 (Flexible lot allocation)
  , p_simulation_mode      IN            NUMBER  -- Added for 14699845 (Flexible lot allocation)
  , x_finished             OUT NOCOPY    BOOLEAN
  , x_remaining_quantity   OUT NOCOPY    NUMBER
  , x_remaining_sec_qty    OUT NOCOPY    NUMBER
  ) IS
    l_api_name               VARCHAR2(30) := 'insert_consist_record';
Line: 7932

       log_procedure(l_api_name, 'start', 'Start Insert Consist Record');
Line: 8245

       log_procedure(l_api_name, 'end', 'End Insert_Consist_Record');
Line: 8274

  END insert_consist_record;
Line: 8354

    /*SELECT *
      INTO l_locator
      FROM mtl_item_locations
     WHERE inventory_location_id = p_locator_id; Commented bug3237702*/
Line: 8360

       SELECT *
       INTO g_locator
       FROM MTL_ITEM_LOCATIONS
       WHERE inventory_location_id = p_locator_id;
Line: 8388

  select *
  into l_org
  from mtl_parameters
  where organization_id = l_locator.organization_id;
Line: 8394

/*  select *
  into l_sub
  from mtl_secondary_inventories
  where secondary_inventory_name = l_locator.subinventory_code
  and organization_id = l_locator.organization_id;
Line: 8580

    l_capacity_updated       BOOLEAN;
Line: 8601

    l_inserted_record        BOOLEAN;
Line: 8665

    l_custom_select_serials    INV_DETAIL_UTIL_PVT.g_serial_row_table_rec;
Line: 8690

      SELECT allocation_mode_id
           , qty_function_parameter_id
        FROM wms_rules_b
       WHERE rule_id = l_rule_id;
Line: 8697

      SELECT consistency_id
        FROM wms_rule_consistencies
       WHERE rule_id = l_rule_id;
Line: 8703

      SELECT SUM(primary_transaction_quantity)
           , NVL(SUM(secondary_transaction_quantity),0)
        FROM mtl_onhand_quantities_detail
       WHERE lpn_id = v_current_row.lpn_id;
Line: 8710

       SELECT serial_number FROM wms_transactions_temp
       WHERE rule_id = l_rule_id;
Line: 8971

    g_trace_recs.DELETE;
Line: 9346

               log_statement(l_api_name,'detailed', 'Reservation is fully detailed, validate and insert');
Line: 9360

               SELECT status_id
                 INTO l_serial_status_id
                 FROM mtl_serial_numbers
                WHERE inventory_item_id        = p_inventory_item_id
                  AND current_organization_id  = p_organization_id
                  AND serial_number            = l_serial_number;
Line: 9480

            validate_and_insert(
              x_return_status              => x_return_status
            , x_msg_count                  => x_msg_count
            , x_msg_data                   => x_msg_data
            , p_record_id                  => 1
            , p_needed_quantity            => l_needed_quantity
            , p_use_pick_uom               => FALSE
            , p_organization_id            => p_organization_id
            , p_inventory_item_id          => p_inventory_item_id
            , p_to_subinventory_code       => l_to_subinventory_code
            , p_to_locator_id              => l_to_locator_id
            , p_to_cost_group_id           => l_to_cost_group_id
            , p_primary_uom                => p_primary_uom
            , p_transaction_uom            => p_transaction_uom
            , p_transaction_temp_id        => p_transaction_temp_id
            , p_type_code                  => p_type_code
            , p_rule_id                    => l_rule_id
            , p_reservation_id             => l_reservation_id
            , p_tree_id                    => p_tree_id
            , p_debug_on                   => l_debug_on
            , p_needed_sec_quantity        => l_sec_needed_quantity
            , p_secondary_uom              => p_secondary_uom
            , p_grade_code                 => p_grade_code
            , x_inserted_record            => l_inserted_record
            , x_allocated_quantity         => l_allocated_quantity
            , x_remaining_quantity         => l_remaining_quantity
            , x_sec_allocated_quantity     => l_sec_allocated_quantity
            , x_sec_remaining_quantity     => l_sec_remaining_quantity
            , p_orig_needed_quantity       => l_needed_quantity      -- Added for 14699845 (Flexible lot allocation)
            , p_orig_needed_sec_qty        => l_sec_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
            , p_simulation_mode            => p_simulation_mode      -- Added for 14699845 (Flexible lot allocation)
            );
Line: 9514

                  log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 9519

                  log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 9625

         g_locs.DELETE;
Line: 9626

         g_consists.DELETE;
Line: 9627

         g_lpns.DELETE;
Line: 9662

                  AND (NVL(l_custom_serial_index,-1) < NVL(l_custom_select_serials.serial_number.LAST,-1))
               THEN
                  -- next record should be next serial from custom API
                  l_custom_serial_index := l_custom_serial_index + 1;
Line: 9666

                  v_current_row.serial_number := l_custom_select_serials.serial_number(l_custom_serial_index);
Line: 9733

                           SELECT source_header_type_id, source_header_id, source_line_id
                           INTO l_source_type_id, l_source_header_id, l_source_line_id
                           FROM wsh_delivery_details
                           WHERE move_order_line_id = p_transaction_temp_id
                           AND rownum = 1;
Line: 9771

                       , x_serial_numbers          => l_custom_select_serials );
Line: 9785

                     l_custom_serial_index := l_custom_select_serials.serial_number.FIRST;
Line: 9786

                     v_current_row.serial_number := l_custom_select_serials.serial_number(l_custom_serial_index);
Line: 9797

                     SELECT status_id
                       INTO l_serial_status_id
                       FROM mtl_serial_numbers
                      WHERE inventory_item_id       = p_inventory_item_id
                        AND current_organization_id = p_organization_id
                        AND serial_number           = v_current_row.serial_number;
Line: 9945

                              validate_and_insert(
                                x_return_status              => x_return_status
                              , x_msg_count                  => x_msg_count
                              , x_msg_data                   => x_msg_data
                              , p_record_id                  => l_cur_lpn_rec
                              , p_needed_quantity            => l_needed_quantity
                              , p_use_pick_uom               => FALSE
                              , p_organization_id            => p_organization_id
                              , p_inventory_item_id          => p_inventory_item_id
                              , p_to_subinventory_code       => l_to_subinventory_code
                              , p_to_locator_id              => l_to_locator_id
                              , p_to_cost_group_id           => l_to_cost_group_id
                              , p_primary_uom                => p_primary_uom
                              , p_transaction_uom            => p_transaction_uom
                              , p_transaction_temp_id        => p_transaction_temp_id
                              , p_type_code                  => p_type_code
                              , p_rule_id                    => l_rule_id
                              , p_reservation_id             => l_reservation_id
                              , p_tree_id                    => p_tree_id
                              , p_debug_on                   => l_debug_on
                              , p_needed_sec_quantity        => l_sec_needed_quantity
                              , p_secondary_uom              => p_secondary_uom
                              , p_grade_code                 => p_grade_code
                              , x_inserted_record            => l_inserted_record
                              , x_allocated_quantity         => l_allocated_quantity
                              , x_remaining_quantity         => l_remaining_quantity
                              , x_sec_allocated_quantity     => l_sec_allocated_quantity
                              , x_sec_remaining_quantity     => l_sec_remaining_quantity
                              , p_orig_needed_quantity       => l_needed_quantity     -- Added for 14699845 (Flexible lot allocation)
                              , p_orig_needed_sec_qty        => l_sec_needed_quantity -- Added for 14699845 (Flexible lot allocation)
                              , p_simulation_mode            => p_simulation_mode     -- Added for 14699845 (Flexible lot allocation)
                              );
Line: 9980

                                    log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 9985

                                    log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 9991

                              IF l_inserted_record = FALSE
                                 OR (NVL(wms_engine_pvt.g_fulfillment_base,'P') = 'P' AND l_allocated_quantity < l_expected_quantity)
                                 OR (NVL(wms_engine_pvt.g_fulfillment_base,'P') = 'S' AND l_sec_allocated_quantity < l_sec_expected_quantity)
                              THEN
                                 IF l_debug = 1 THEN
                                    log_statement(l_api_name, 'insert_failed', 'Record failed to allocation.  Rolling back and '
                                                               || 'invalidating LPN');
Line: 10015

                                 DELETE FROM wms_transactions_temp
                                  WHERE line_type_code = 2
                                    AND type_code = p_type_code;
Line: 10033

                                    log_statement(l_api_name, 'finish_delete_sugs',
                                                              'Finished deleting suggestions and restored quantity tree');
Line: 10226

                           validate_and_insert(
                             x_return_status              => x_return_status
                           , x_msg_count                  => x_msg_count
                           , x_msg_data                   => x_msg_data
                           , p_record_id                  => l_cur_lpn_rec
                           , p_needed_quantity            => l_needed_quantity
                           , p_use_pick_uom               => FALSE
                           , p_organization_id            => p_organization_id
                           , p_inventory_item_id          => p_inventory_item_id
                           , p_to_subinventory_code       => l_to_subinventory_code
                           , p_to_locator_id              => l_to_locator_id
                           , p_to_cost_group_id           => l_to_cost_group_id
                           , p_primary_uom                => p_primary_uom
                           , p_transaction_uom            => p_transaction_uom
                           , p_transaction_temp_id        => p_transaction_temp_id
                           , p_type_code                  => p_type_code
                           , p_rule_id                    => l_rule_id
                           , p_reservation_id             => l_reservation_id
                           , p_tree_id                    => p_tree_id
                           , p_debug_on                   => l_debug_on
                           , p_needed_sec_quantity        => l_sec_needed_quantity
                           , p_secondary_uom              => p_secondary_uom
                           , p_grade_code                 => p_grade_code
                           , x_inserted_record            => l_inserted_record
                           , x_allocated_quantity         => l_allocated_quantity
                           , x_remaining_quantity         => l_remaining_quantity
                           , x_sec_allocated_quantity     => l_sec_allocated_quantity
                           , x_sec_remaining_quantity     => l_sec_remaining_quantity
                           , p_orig_needed_quantity       => l_needed_quantity      -- Added for 14699845 (Flexible lot allocation)
                           , p_orig_needed_sec_qty        => l_sec_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
                           , p_simulation_mode            => p_simulation_mode      -- Added for 14699845 (Flexible lot allocation)
                           );
Line: 10261

                                 log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 10266

                                 log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 10272

                           IF l_inserted_record = FALSE
                              OR (NVL(wms_engine_pvt.g_fulfillment_base,'P') = 'P' AND l_allocated_quantity < l_expected_quantity)
                              OR (NVL(wms_engine_pvt.g_fulfillment_base,'P') = 'S' AND l_sec_allocated_quantity < l_sec_expected_quantity)
                           THEN --{
                              IF l_debug = 1 THEN
                                 log_statement(l_api_name, 'insert_failed', 'Record failed to allocation.  Rolling back and '
                                                            || 'invalidating LPN');
Line: 10302

                              DELETE FROM wms_transactions_temp
                               WHERE line_type_code = 2
                                 AND type_code = p_type_code;
Line: 10320

                                 log_statement(l_api_name, 'finish_delete_sugs', 'Finished deleting suggestions and restored quantity tree');
Line: 10908

                     log_statement(l_api_name, 'val_insert', 'Calling validate_and_insert');
Line: 10911

                  validate_and_insert(
                    x_return_status              => x_return_status
                  , x_msg_count                  => x_msg_count
                  , x_msg_data                   => x_msg_data
                  , p_record_id                  => l_cur_lpn_rec
                  , p_needed_quantity            => l_needed_quantity
                  , p_use_pick_uom               => FALSE
                  , p_organization_id            => p_organization_id
                  , p_inventory_item_id          => p_inventory_item_id
                  , p_to_subinventory_code       => l_to_subinventory_code
                  , p_to_locator_id              => l_to_locator_id
                  , p_to_cost_group_id           => l_to_cost_group_id
                  , p_primary_uom                => p_primary_uom
                  , p_transaction_uom            => p_transaction_uom
                  , p_transaction_temp_id        => p_transaction_temp_id
                  , p_type_code                  => p_type_code
                  , p_rule_id                    => l_rule_id
                  , p_reservation_id             => l_reservation_id
                  , p_tree_id                    => p_tree_id
                  , p_debug_on                   => l_debug_on
                  , p_needed_sec_quantity        => l_sec_needed_quantity
                  , p_secondary_uom              => p_secondary_uom
                  , p_grade_code                 => p_grade_code
                  , x_inserted_record            => l_inserted_record
                  , x_allocated_quantity         => l_allocated_quantity
                  , x_remaining_quantity         => l_remaining_quantity
                  , x_sec_allocated_quantity     => l_sec_allocated_quantity
                  , x_sec_remaining_quantity     => l_sec_remaining_quantity
                  , p_orig_needed_quantity       => l_needed_quantity     -- Added for 14699845 (Flexible lot allocation)
                  , p_orig_needed_sec_qty        => l_sec_needed_quantity -- Added for 14699845 (Flexible lot allocation)
                  , p_simulation_mode            => p_simulation_mode     -- Added for 14699845 (Flexible lot allocation)
                  );
Line: 10946

                        log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 10952

                        log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 10959

                  IF l_inserted_record = FALSE
                     OR (NVL(wms_engine_pvt.g_fulfillment_base,'P') = 'P'
                         AND l_allocated_quantity < g_locs(l_cur_lpn_rec).quantity)
                     OR (NVL(wms_engine_pvt.g_fulfillment_base,'P') = 'S'
                         AND l_sec_allocated_quantity < g_locs(l_cur_lpn_rec).secondary_quantity)
                  THEN --{
                     IF l_debug = 1 THEN
                        log_statement(l_api_name, 'insert_fail', 'Record failed to insert.' || 'Invalidating LPN');
Line: 11015

                     DELETE FROM wms_transactions_temp
                      WHERE line_type_code = 2
                        AND type_code = p_type_code;
Line: 11033

                        log_statement(l_api_name, 'finish_delete_sugs', 'Finished deleting suggestions and restored quantity tree');
Line: 11163

                    AND (NVL(l_custom_serial_index,-1) < NVL(l_custom_select_serials.serial_number.LAST,-1))
               THEN
                  -- next record should be next serial from custom API
                  l_custom_serial_index := l_custom_serial_index + 1;
Line: 11167

                  v_current_row.serial_number := l_custom_select_serials.serial_number(l_custom_serial_index);
Line: 11229

                           SELECT source_header_type_id, source_header_id, source_line_id
                             INTO l_source_type_id, l_source_header_id, l_source_line_id
                             FROM wsh_delivery_details
                            WHERE move_order_line_id = p_transaction_temp_id
                              AND rownum = 1;
Line: 11267

                       , x_serial_numbers          => l_custom_select_serials );
Line: 11284

                     l_custom_serial_index := l_custom_select_serials.serial_number.FIRST;
Line: 11285

                     v_current_row.serial_number := l_custom_select_serials.serial_number(l_custom_serial_index);
Line: 11306

                     SELECT status_id
                       INTO l_serial_status_id
                       FROM mtl_serial_numbers
                      WHERE inventory_item_id       = p_inventory_item_id
                        AND current_organization_id = p_organization_id
                        AND serial_number           = v_current_row.serial_number;
Line: 11419

                           log_statement(l_api_name, 'insert_consist', 'Calling Insert_Consist_Record');
Line: 11423

                        insert_consist_record(
                          x_return_status              => x_return_status
                        , x_msg_count                  => x_msg_count
                        , x_msg_data                   => x_msg_data
                        , p_record_id                  => l_cur_uom_rec
                        , p_needed_quantity            => l_needed_quantity
                        , p_use_pick_uom               => FALSE
                        , p_organization_id            => p_organization_id
                        , p_inventory_item_id          => p_inventory_item_id
                        , p_to_subinventory_code       => l_to_subinventory_code
                        , p_to_locator_id              => l_to_locator_id
                        , p_to_cost_group_id           => l_to_cost_group_id
                        , p_primary_uom                => p_primary_uom
                        , p_transaction_uom            => p_transaction_uom
                        , p_transaction_temp_id        => p_transaction_temp_id
                        , p_type_code                  => p_type_code
                        , p_rule_id                    => l_rule_id
                        , p_reservation_id             => l_reservation_id
                        , p_tree_id                    => p_tree_id
                        , p_debug_on                   => l_debug_on
                        , p_order_by_rank              => l_order_by_rank
                        , p_needed_sec_quantity        => l_sec_needed_quantity
                        , p_secondary_uom              => p_secondary_uom
                        , p_grade_code                 => p_grade_code
                        , x_finished                   => l_finished
                        , x_remaining_quantity         => l_remaining_quantity
                        , x_remaining_sec_qty          => l_sec_remaining_quantity
                        , p_orig_needed_quantity       => l_orig_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
                        , p_orig_needed_sec_qty        => l_orig_needed_sec_qty   -- Added for 14699845 (Flexible lot allocation)
                        , p_simulation_mode            => p_simulation_mode       -- Added for 14699845 (Flexible lot allocation)
                        );
Line: 11457

                              log_statement(l_api_name, 'uerr_insert_consist', 'Unexpected error in insert_consist_record');
Line: 11462

                              log_statement(l_api_name, 'err_insert_consist', 'Error in insert_consist_record');
Line: 11484

                           log_statement(l_api_name, 'validate_insert', 'Calling Validate_and_Insert');
Line: 11487

                        validate_and_insert(
                          x_return_status              => x_return_status
                        , x_msg_count                  => x_msg_count
                        , x_msg_data                   => x_msg_data
                        , p_record_id                  => l_cur_uom_rec
                        , p_needed_quantity            => l_needed_quantity
                        , p_use_pick_uom               => FALSE
                        , p_organization_id            => p_organization_id
                        , p_inventory_item_id          => p_inventory_item_id
                        , p_to_subinventory_code       => l_to_subinventory_code
                        , p_to_locator_id              => l_to_locator_id
                        , p_to_cost_group_id           => l_to_cost_group_id
                        , p_primary_uom                => p_primary_uom
                        , p_transaction_uom            => p_transaction_uom
                        , p_transaction_temp_id        => p_transaction_temp_id
                        , p_type_code                  => p_type_code
                        , p_rule_id                    => l_rule_id
                        , p_reservation_id             => l_reservation_id
                        , p_tree_id                    => p_tree_id
                        , p_debug_on                   => l_debug_on
                        , p_needed_sec_quantity        => l_sec_needed_quantity
                        , p_secondary_uom              => p_secondary_uom
                        , p_grade_code                 => p_grade_code
                        , x_inserted_record            => l_inserted_record
                        , x_allocated_quantity         => l_allocated_quantity
                        , x_remaining_quantity         => l_remaining_quantity
                        , x_sec_allocated_quantity     => l_sec_allocated_quantity
                        , x_sec_remaining_quantity     => l_sec_remaining_quantity
                        , p_orig_needed_quantity       => l_orig_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
                        , p_orig_needed_sec_qty        => l_orig_needed_sec_qty   -- Added for 14699845 (Flexible lot allocation)
                        , p_simulation_mode            => p_simulation_mode       -- Added for 14699845 (Flexible lot allocation)
                        );
Line: 11522

                              log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 11527

                              log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 11533

                        IF l_inserted_record THEN
                           l_needed_quantity := l_needed_quantity - l_allocated_quantity;
Line: 11737

                        log_statement(l_api_name, 'insert_consist', 'Calling insert consist record from pick UOM list');
Line: 11741

                     insert_consist_record(
                       x_return_status              => x_return_status
                     , x_msg_count                  => x_msg_count
                     , x_msg_data                   => x_msg_data
                     , p_record_id                  => l_cur_uom_rec
                     , p_needed_quantity            => l_needed_quantity
                     , p_use_pick_uom               => FALSE
                     , p_organization_id            => p_organization_id
                     , p_inventory_item_id          => p_inventory_item_id
                     , p_to_subinventory_code       => l_to_subinventory_code
                     , p_to_locator_id              => l_to_locator_id
                     , p_to_cost_group_id           => l_to_cost_group_id
                     , p_primary_uom                => p_primary_uom
                     , p_transaction_uom            => p_transaction_uom
                     , p_transaction_temp_id        => p_transaction_temp_id
                     , p_type_code                  => p_type_code
                     , p_rule_id                    => l_rule_id
                     , p_reservation_id             => l_reservation_id
                     , p_tree_id                    => p_tree_id
                     , p_debug_on                   => l_debug_on
                     , p_order_by_rank              => l_order_by_rank
                     , p_needed_sec_quantity        => l_sec_needed_quantity
                     , p_secondary_uom              => p_secondary_uom
                     , p_grade_code                 => p_grade_code
                     , x_finished                   => l_finished
                     , x_remaining_quantity         => l_remaining_quantity
                     , x_remaining_sec_qty          => l_sec_remaining_quantity
                     , p_orig_needed_quantity       => l_orig_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
                     , p_orig_needed_sec_qty        => l_orig_needed_sec_qty   -- Added for 14699845 (Flexible lot allocation)
                     , p_simulation_mode            => p_simulation_mode       -- Added for 14699845 (Flexible lot allocation)
                     );
Line: 11775

                           log_statement(l_api_name, 'uerr_insert_consist', 'Unexpected error in insert_consist_record');
Line: 11780

                           log_statement(l_api_name, 'err_insert_consist', 'Error in insert_consist_record');
Line: 11803

                        log_statement(l_api_name, 'validate_insert', 'Calling Validate_and_insert for pick uom list');
Line: 11807

                     validate_and_insert(
                       x_return_status              => x_return_status
                     , x_msg_count                  => x_msg_count
                     , x_msg_data                   => x_msg_data
                     , p_record_id                  => l_cur_uom_rec
                     , p_needed_quantity            => l_needed_quantity
                     , p_use_pick_uom               => FALSE
                     , p_organization_id            => p_organization_id
                     , p_inventory_item_id          => p_inventory_item_id
                     , p_to_subinventory_code       => l_to_subinventory_code
                     , p_to_locator_id              => l_to_locator_id
                     , p_to_cost_group_id           => l_to_cost_group_id
                     , p_primary_uom                => p_primary_uom
                     , p_transaction_uom            => p_transaction_uom
                     , p_transaction_temp_id        => p_transaction_temp_id
                     , p_type_code                  => p_type_code
                     , p_rule_id                    => l_rule_id
                     , p_reservation_id             => l_reservation_id
                     , p_tree_id                    => p_tree_id
                     , p_debug_on                   => l_debug_on
                     , p_needed_sec_quantity        => l_sec_needed_quantity
                     , p_secondary_uom              => p_secondary_uom
                     , p_grade_code                 => p_grade_code
                     , x_inserted_record            => l_inserted_record
                     , x_allocated_quantity         => l_allocated_quantity
                     , x_remaining_quantity         => l_remaining_quantity
                     , x_sec_allocated_quantity     => l_sec_allocated_quantity
                     , x_sec_remaining_quantity     => l_sec_remaining_quantity
                     , p_orig_needed_quantity       => l_orig_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
                     , p_orig_needed_sec_qty        => l_orig_needed_sec_qty   -- Added for 14699845 (Flexible lot allocation)
                     , p_simulation_mode            => p_simulation_mode       -- Added for 14699845 (Flexible lot allocation)
                     );
Line: 11842

                           log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 11847

                           log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 11853

                     IF l_inserted_record THEN
                        l_needed_quantity  := l_needed_quantity - l_allocated_quantity;
Line: 11862

                           log_statement(l_api_name, 'success_validate', 'Successfully inserted record.  New needed quantity: '
                                                                          || l_needed_quantity);
Line: 11864

                           log_statement(l_api_name, 'success_validate', 'Successfully inserted record.  New needed sec quantity: '
                                                                          || l_sec_needed_quantity);
Line: 11867

                           log_statement(l_api_name, 'success_validate', 'Successfully inserted record.  New orig needed quantity: '
                                                                          || l_orig_needed_quantity);
Line: 11869

                           log_statement(l_api_name, 'success_validate', 'Successfully inserted record.  New orig needed sec qty: '
                                                                          || l_orig_needed_sec_qty);
Line: 12150

                  log_statement(l_api_name, 'insert_consist', 'Calling Insert_Consist_Record');
Line: 12158

               insert_consist_record(
                 x_return_status              => x_return_status
               , x_msg_count                  => x_msg_count
               , x_msg_data                   => x_msg_data
               , p_record_id                  => g_locs_index
               , p_needed_quantity            => l_needed_quantity
               , p_use_pick_uom               => l_use_pick_uom
               , p_organization_id            => p_organization_id
               , p_inventory_item_id          => p_inventory_item_id
               , p_to_subinventory_code       => l_to_subinventory_code
               , p_to_locator_id              => l_to_locator_id
               , p_to_cost_group_id           => l_to_cost_group_id
               , p_primary_uom                => p_primary_uom
               , p_transaction_uom            => p_transaction_uom
               , p_transaction_temp_id        => p_transaction_temp_id
               , p_type_code                  => p_type_code
               , p_rule_id                    => l_rule_id
               , p_reservation_id             => l_reservation_id
               , p_tree_id                    => p_tree_id
               , p_debug_on                   => l_debug_on
               , p_order_by_rank              => l_order_by_rank
               , p_needed_sec_quantity        => l_sec_needed_quantity
               , p_secondary_uom              => p_secondary_uom
               , p_grade_code                 => p_grade_code
               , x_finished                   => l_finished
               , x_remaining_quantity         => l_remaining_quantity
               , x_remaining_sec_qty          => l_sec_remaining_quantity
               , p_orig_needed_quantity       => l_orig_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
               , p_orig_needed_sec_qty        => l_orig_needed_sec_qty   -- Added for 14699845 (Flexible lot allocation)
               , p_simulation_mode            => p_simulation_mode       -- Added for 14699845 (Flexible lot allocation)
               );
Line: 12192

                     log_statement(l_api_name, 'uerr_insert_consist', 'Unexpected error in insert_consist_record');
Line: 12197

                     log_statement(l_api_name, 'err_insert_consist', 'Error in insert_consist_record');
Line: 12219

                  log_statement(l_api_name, 'validate_insert', 'Calling Validate_and_insert');
Line: 12222

               validate_and_insert(
                 x_return_status              => x_return_status
               , x_msg_count                  => x_msg_count
               , x_msg_data                   => x_msg_data
               , p_record_id                  => g_locs_index
               , p_needed_quantity            => l_needed_quantity
               , p_use_pick_uom               => l_use_pick_uom
               , p_organization_id            => p_organization_id
               , p_inventory_item_id          => p_inventory_item_id
               , p_to_subinventory_code       => l_to_subinventory_code
               , p_to_locator_id              => l_to_locator_id
               , p_to_cost_group_id           => l_to_cost_group_id
               , p_primary_uom                => p_primary_uom
               , p_transaction_uom            => p_transaction_uom
               , p_transaction_temp_id        => p_transaction_temp_id
               , p_type_code                  => p_type_code
               , p_rule_id                    => l_rule_id
               , p_reservation_id             => l_reservation_id
               , p_tree_id                    => p_tree_id
               , p_debug_on                   => l_debug_on
               , p_needed_sec_quantity        => l_sec_needed_quantity
               , p_secondary_uom              => p_secondary_uom
               , p_grade_code                 => p_grade_code
               , x_inserted_record            => l_inserted_record
               , x_allocated_quantity         => l_allocated_quantity
               , x_remaining_quantity         => l_remaining_quantity
               , x_sec_allocated_quantity     => l_sec_allocated_quantity
               , x_sec_remaining_quantity     => l_sec_remaining_quantity
               , p_orig_needed_quantity       => l_orig_needed_quantity  -- Added for 14699845 (Flexible lot allocation)
               , p_orig_needed_sec_qty        => l_orig_needed_sec_qty   -- Added for 14699845 (Flexible lot allocation)
               , p_simulation_mode            => p_simulation_mode       -- Added for 14699845 (Flexible lot allocation)
               );
Line: 12257

                     log_statement(l_api_name, 'uerr_validate_insert', 'Unexpected error in validate_and_insert');
Line: 12262

                     log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 12268

               IF l_inserted_record THEN
                  l_needed_quantity := l_needed_quantity - l_allocated_quantity;
Line: 12277

                     log_statement(l_api_name, 'inserted_rec', 'Inserted record.  New needed quantity: '
                                                || l_needed_quantity);
Line: 12279

                     log_statement(l_api_name, 'inserted_rec', 'Inserted record.  New needed sec quantity: '
                                                || l_sec_needed_quantity);
Line: 12282

                     log_statement(l_api_name, 'inserted_rec', 'Inserted record.  New orig needed quantity: ' || l_orig_needed_quantity);
Line: 12283

                     log_statement(l_api_name, 'inserted_rec', 'Inserted record.  New orig needed sec qty:  ' || l_orig_needed_sec_qty);
Line: 12401

        l_capacity_updated  := FALSE;
Line: 12967

               log_statement(l_api_name, 'update_capacity', 'Updating suggested capacity');
Line: 12969

            inv_loc_wms_utils.update_loc_suggested_capacity(
              x_return_status              => x_return_status
            , x_msg_count                  => x_msg_count
            , x_msg_data                   => x_msg_data
            , p_organization_id            => p_organization_id
            , p_inventory_location_id      => l_olocator_id
            , p_inventory_item_id          => p_inventory_item_id
            , p_primary_uom_flag           => 'Y'
            , p_transaction_uom_code       => NULL
            , p_quantity                   => l_possible_quantity
            );
Line: 12983

                 log_statement(l_api_name, 'uerr_update_capacity', 'Unexpected error in update_loc_suggested_capacity');
Line: 12988

                 log_statement(l_api_name, 'err_update_capacity', 'Error in update_loc_suggested_capacity');
Line: 12992

              l_capacity_updated  := TRUE;
Line: 13011

            log_statement(l_api_name, 'insert_put_wtt_recs', 'Before insert values of l_possible_trx_qty'|| l_possible_trx_qty);
Line: 13012

            log_statement(l_api_name, 'insert_put_wtt_recs', 'Before insert values of l_possible_quantity'|| l_possible_quantity);
Line: 13016

             log_statement(l_api_name, 'insert_put_wtt_recs', 'Inserting putaway records in wtt');
Line: 13019

          INSERT INTO wms_transactions_temp
                      (
                      pp_transaction_temp_id
                    , transaction_temp_id
                    , type_code
                    , line_type_code
                    , transaction_quantity
                    , primary_quantity
                    , secondary_quantity
                    , grade_code
                    , revision
                    , lot_number
                    , lot_expiration_date
                    , from_subinventory_code
                    , from_locator_id
                    , rule_id
                    , reservation_id
                    , to_subinventory_code
                    , to_locator_id
                    , from_cost_group_id
                    , to_cost_group_id
                    , lpn_id
                      )
               VALUES (
                      wms_transactions_temp_s.NEXTVAL
                    , p_transaction_temp_id
                    , p_type_code
                    , 2 -- line type code is output
                    , l_possible_trx_qty
                    , l_possible_quantity
                    , l_sec_possible_quantity
                    , l_grade_code
                    , l_revision
                    , l_lot_number
                    , l_lot_expiration_date
                    , l_from_subinventory_code
                    , l_from_locator_id
                    , l_rule_id
                    , l_reservation_id
                    , l_osubinventory_code
                    , l_olocator_id
                    , l_from_cost_group_id
                    , l_to_cost_group_id
                    , l_input_lpn_id
                      );
Line: 13066

          l_capacity_updated  := FALSE;
Line: 13177

                        inv_log_util.trace('Serial not found', 'delete_serial_numbers', 9);
Line: 13183

                           inv_log_util.trace('Org: ' || p_organization_id, 'delete_serial_numbers', 9);
Line: 13184

                           inv_log_util.trace('Item: ' || p_inventory_item_id, 'delete_serial_numbers', 9);
Line: 13185

                           inv_log_util.trace('Serial: ' || l_serial_number, 'delete_serial_numbers', 9);
Line: 13187

                                               || inv_detail_util_pvt.g_serial_tbl_ptr, 'delete_serial_numbers', 9);
Line: 13203

                                  inv_detail_util_pvt.g_output_serial_rows.DELETE(inv_detail_util_pvt.g_serial_tbl_ptr);
Line: 13208

                                                         || inv_detail_util_pvt.g_serial_tbl_ptr, 'delete_serial_numbers', 9);
Line: 13212

                                  inv_detail_util_pvt.g_output_serial_rows.DELETE;
Line: 13216

                                     inv_log_util.trace('Array cleared', 'delete_serial_numbers', 9);
Line: 13221

                               EXIT; -- if a serial has been deleted, needn't check other serials present in g_output_serial_rows
Line: 13248

               rollback_capacity_update(
                 x_return_status              => x_return_status
               , x_msg_count                  => x_msg_count
               , x_msg_data                   => x_msg_data
               , p_organization_id            => p_organization_id
               , p_inventory_item_id          => p_inventory_item_id
               );
Line: 13258

                     log_statement(l_api_name, 'uerr_rollback_cap', 'Unexpected error in rollback_capacity_update');
Line: 13263

                     log_statement(l_api_name, 'err_rollback_cap', 'Error in rollback_capacity_update');
Line: 13270

               IF l_capacity_updated THEN
                  IF l_debug = 1 THEN
                     log_statement(l_api_name, 'revert_capacity', 'Calling revert_loc_suggested_capacity');
Line: 13298

                  l_capacity_updated  := FALSE;
Line: 13317

               wms_search_order_globals_pvt.insert_trace_lines(
                 p_api_version                => 1.0
               , p_init_msg_list              => fnd_api.g_false
               , p_validation_level           => fnd_api.g_valid_level_full
               , x_return_status              => l_return_status
               , x_msg_count                  => x_msg_count
               , x_msg_data                   => x_msg_data
               , p_header_id                  => wms_engine_pvt.g_trace_header_id
               , p_rule_id                    => l_rule_id
               , p_pre_suggestions            => g_trace_recs
               );
Line: 13344

               UPDATE wms_transactions_temp
                  SET primary_quantity = l_needed_quantity
                    , secondary_quantity = l_sec_needed_quantity
                WHERE pp_transaction_temp_id = l_pp_transaction_temp_id;
Line: 13349

               wms_re_common_pvt.updateinputline(l_needed_quantity,l_sec_needed_quantity);
Line: 13362

         DELETE FROM wms_transactions_temp
          WHERE pp_transaction_temp_id = l_pp_transaction_temp_id;
Line: 13367

         wms_re_common_pvt.deleteinputline;
Line: 13413

         wms_search_order_globals_pvt.insert_trace_lines(
           p_api_version                => 1.0
         , p_init_msg_list              => fnd_api.g_false
         , p_validation_level           => fnd_api.g_valid_level_full
         , x_return_status              => l_return_status
         , x_msg_count                  => x_msg_count
         , x_msg_data                   => x_msg_data
         , p_header_id                  => wms_engine_pvt.g_trace_header_id
         , p_rule_id                    => l_rule_id
         , p_pre_suggestions            => g_trace_recs
         );
Line: 13453

      rollback_capacity_update(
        x_return_status              => l_return_status
      , x_msg_count                  => l_msg_count
      , x_msg_data                   => l_msg_data
      , p_organization_id            => p_organization_id
      , p_inventory_item_id          => p_inventory_item_id
      );
Line: 13463

      IF l_capacity_updated THEN
        inv_loc_wms_utils.revert_loc_suggested_capacity(
          x_return_status              => l_return_status
        , x_msg_count                  => l_msg_count
        , x_msg_data                   => l_msg_data
        , p_organization_id            => p_organization_id
        , p_inventory_location_id      => l_olocator_id
        , p_inventory_item_id          => p_inventory_item_id
        , p_primary_uom_flag           => 'Y'
        , p_transaction_uom_code       => NULL
        , p_quantity                   => l_possible_quantity
        );
Line: 13475

        l_capacity_updated  := FALSE;
Line: 13496

      rollback_capacity_update(
        x_return_status              => l_return_status
      , x_msg_count                  => l_msg_count
      , x_msg_data                   => l_msg_data
      , p_organization_id            => p_organization_id
      , p_inventory_item_id          => p_inventory_item_id
      );
Line: 13506

      IF l_capacity_updated THEN
        inv_loc_wms_utils.revert_loc_suggested_capacity(
          x_return_status              => l_return_status
        , x_msg_count                  => l_msg_count
        , x_msg_data                   => l_msg_data
        , p_organization_id            => p_organization_id
        , p_inventory_location_id      => l_olocator_id
        , p_inventory_item_id          => p_inventory_item_id
        , p_primary_uom_flag           => 'Y'
        , p_transaction_uom_code       => NULL
        , p_quantity                   => l_possible_quantity
        );
Line: 13518

        l_capacity_updated  := FALSE;
Line: 13539

      rollback_capacity_update(
        x_return_status              => l_return_status
      , x_msg_count                  => l_msg_count
      , x_msg_data                   => l_msg_data
      , p_organization_id            => p_organization_id
      , p_inventory_item_id          => p_inventory_item_id
      );
Line: 13549

      IF l_capacity_updated THEN
        inv_loc_wms_utils.revert_loc_suggested_capacity(
          x_return_status              => l_return_status
        , x_msg_count                  => l_msg_count
        , x_msg_data                   => l_msg_data
        , p_organization_id            => p_organization_id
        , p_inventory_location_id      => l_olocator_id
        , p_inventory_item_id          => p_inventory_item_id
        , p_primary_uom_flag           => 'Y'
        , p_transaction_uom_code       => NULL
        , p_quantity                   => l_possible_quantity
        );
Line: 13561

        l_capacity_updated  := FALSE;
Line: 13719

          SELECT  subinventory_code
            FROM  mtl_item_sub_defaults
            WHERE inventory_item_id = l_inventory_item_id
              AND organization_id   = l_organization_id
              AND default_type      = 3;  -- default transfer order sub
Line: 13726

          SELECT  status_id
            FROM  mtl_item_locations
            WHERE inventory_location_id = l_putaway_loc
              AND organization_id  = l_organization_id ;
Line: 13732

          SELECT  locator_id
            FROM  mtl_item_loc_defaults mtld,
                  mtl_item_locations mil
            WHERE mtld.locator_id        = mil.inventory_location_id
              AND mtld.organization_id   = mil.organization_id
              AND mtld.inventory_item_id = l_inventory_item_id
              AND mtld.organization_id   = l_organization_id
              AND mtld.subinventory_code = l_putaway_sub
              AND mtld.default_type      = 3
              AND nvl(mil.disable_date,sysdate + 1) > sysdate;
Line: 14039

        SELECT lpn_controlled_flag
          FROM mtl_secondary_inventories
         WHERE organization_id = p_organization_id
           AND secondary_inventory_name = l_osubinventory_code;
Line: 14125

  g_trace_recs.DELETE;
Line: 14260

      select locator_type into l_locator_type
        from mtl_secondary_inventories
       where organization_id = p_organization_id
         and SECONDARY_INVENTORY_NAME  = l_to_subinventory_code;
Line: 14597

        log_statement(l_api_name, 'insert_put_wtt_recs',
         'Inserting putaway records in wtt');
Line: 14601

     INSERT
       INTO WMS_TRANSACTIONS_TEMP
       ( PP_TRANSACTION_TEMP_ID
        ,TRANSACTION_TEMP_ID
        ,TYPE_CODE
        ,LINE_TYPE_CODE
        ,TRANSACTION_QUANTITY
        ,PRIMARY_QUANTITY
        ,SECONDARY_QUANTITY
        ,GRADE_CODE
        ,REVISION
        ,LOT_NUMBER
        ,LOT_EXPIRATION_DATE
        ,FROM_SUBINVENTORY_CODE
        ,FROM_LOCATOR_ID
        ,RULE_ID
        ,RESERVATION_ID
        ,TO_SUBINVENTORY_CODE
        ,TO_LOCATOR_ID
        ,FROM_COST_GROUP_ID
        ,TO_COST_GROUP_ID
        ,LPN_ID
        ) VALUES
       ( wms_transactions_temp_s.NEXTVAL
        ,p_transaction_temp_id
        ,1      -- p_type_code
        ,2             -- line type code is output
        ,l_possible_trx_qty
        ,l_possible_quantity
        ,l_sec_possible_quantity
        ,l_grade_code
        ,l_revision
        ,l_lot_number
        ,l_lot_expiration_date
        ,l_from_subinventory_code
        ,l_from_locator_id
        ,NULL   -- l_rule_id
        ,l_reservation_id
        ,l_osubinventory_code
        ,l_olocator_id
        ,l_from_cost_group_id
        ,l_to_cost_group_id
        ,l_input_lpn_id
         );
Line: 14674

         DELETE
           FROM WMS_TRANSACTIONS_TEMP
           WHERE pp_transaction_temp_id = l_pp_transaction_temp_id;
Line: 14679

         wms_re_common_pvt.DeleteInputLine;
Line: 14682

        wms_search_order_globals_pvt.insert_trace_lines(
           p_api_version => 1.0
          ,p_init_msg_list => fnd_api.g_false
          ,p_validation_level => fnd_api.g_valid_level_full
          ,x_return_status => l_return_status
          ,x_msg_count => x_msg_count
          ,x_msg_data => x_msg_data
          ,p_header_id => wms_engine_pvt.g_trace_header_id
          ,p_rule_id => null
          ,p_pre_suggestions => g_trace_recs
         );
Line: 14871

      SELECT rule_id
           , organization_id
           , type_code
           , NAME
           , description
           , qty_function_parameter_id
           , enabled_flag
           , user_defined_flag
           , attribute_category
           , attribute1
           , attribute2
           , attribute3
           , attribute4
           , attribute5
           , attribute6
           , attribute7
           , attribute8
           , attribute9
           , attribute10
           , attribute11
           , attribute12
           , attribute13
           , attribute14
           , attribute15
        FROM wms_rules_vl
       WHERE rule_id = p_rule_id;
Line: 14950

    g_build_package_tbl.DELETE;
Line: 15013

      SELECT status
      FROM   user_objects
      WHERE  object_name = UPPER(p_package_name)
      AND    object_type='PACKAGE'
      AND    status <> 'VALID'
      AND    rownum = 1;
Line: 15021

      SELECT status
      FROM   user_objects
      WHERE  object_name = UPPER(p_package_name)
      AND    object_type = 'PACKAGE BODY'
      AND    status <> 'VALID'
      AND    rownum = 1;
Line: 15065

           ,insert_newlines => 'FALSE'
           ,comp_error => l_comp_error
           );
Line: 15174

      SELECT type_code
           , allocation_mode_id
        FROM wms_rules_b mpr
       WHERE mpr.rule_id = p_rule_id;
Line: 15317

      g_stmt_serial         :=    'select '
                               || g_base_select
                               || g_rule_select_serial_new -- Added for Bug 13448337
                               || ' from '
                               || g_rule_from
                               || g_base_from_serial
                               || ' where '
                               || g_input_where
                               || g_rule_where
                               || ' group by '
                               || g_base_group_by
                               || g_rule_group_by_new; -- Added for Bug 13448337
Line: 15330

      g_stmt_serial_validate :=    'select '
                               || g_base_select
                               || g_rule_select_serial_new -- Added for Bug 13448337
                               || ' from '
                               || g_rule_from
                               || g_base_from_serial_v
                               || ' where '
                               || g_input_where
                               || g_rule_where
                               || ' group by '
                               || g_base_group_by
                               || g_rule_group_by_new; -- Added for Bug 13448337
Line: 15343

      g_stmt_serial_detail  :=    'select '
                               || g_base_select
                               || g_rule_select
                               || ' from '
                               || g_rule_from
                               || g_base_from_serial
                               || ' where '
                               || g_input_where
                               || g_rule_where;
Line: 15353

     g_stmt_serial_detail_new  :=    'select '
                               || g_base_select
                               || g_rule_select
                               || ' from '
                               || g_rule_from
                               || g_base_from_serial_detail
                               || ' where '
                               || g_input_where
                               || g_rule_where;
Line: 15375

      g_stmt_serial          := 'select 1,1,sysdate,1,1,1,1,1,1,1,1,1 from dual';
Line: 15376

      g_stmt_serial_validate := 'select 1,1,sysdate,1,1,1,1,1,1,1,1,1 from dual';
Line: 15377

      g_stmt_serial_detail   := 'select 1,1,sysdate,1,1,1,1,1,1,1,1,1 from dual';
Line: 15378

      g_stmt_serial_detail_new   := 'select 1,1,sysdate,1,1,1,1,1,1,1,1,1 from dual';
Line: 15388

      g_stmt           :=    'select count(*) '
                          || '  from '
                          || NVL(g_rule_from, 'WMS_LABEL_REQUESTS wlr')
                          || ' where wlr.label_request_id = p_label_request_id '
                          || g_rule_where;
Line: 15455

      g_stmt           :=    'select count(*) '
                          || '  from '
                          || NVL(g_rule_from, 'MTL_MATERIAL_TRANSACTIONS_TEMP mmtt')
                          || ' where mmtt.transaction_temp_id = p_pp_transaction_temp_id '
                          || g_rule_where;
Line: 15519

      g_stmt           :=    'select count(*) '
                          || '  from '
                          || NVL(g_rule_from, 'MTL_MATERIAL_TRANSACTIONS_TEMP mmtt')
                          || ' where (MMTT.PARENT_LINE_ID = p_pp_transaction_temp_id or MMTT.TRANSACTION_TEMP_ID = p_pp_transaction_temp_id) '   -- Bug Fix 5560849, 8546026(High vol project)
                          || g_rule_where;
Line: 15585

      g_stmt           :=    'select count(*) '
                          || '  from '
                          || NVL(g_rule_from, 'WMS_COST_GROUPS_INPUT_V wcgiv')
                          || ' where wcgiv.line_id = g_line_id '
                          || g_rule_where;
Line: 15671

                              'select ' || g_base_select || ' from ' || g_rule_from || g_base_from || ' where ' || g_input_where || g_rule_where;
Line: 15983

             'select ' || g_base_select || g_rule_select || ' from ' || g_rule_from || g_base_from || ' where ' || g_input_where || g_rule_where;
Line: 15988

        g_stmt  :=    'select '
                   || g_base_select
                   || g_rule_select_serial
                   || ' from '
                   || g_rule_from
                   || g_base_from
                   || ' where '
                   || g_input_where
                   || g_rule_where
                   || 'group by '
                   || g_base_group_by
                   || g_rule_group_by;
Line: 16444

      SELECT mmtt.transaction_temp_id
        FROM mtl_material_transactions_temp mmtt, mtl_txn_request_lines mol
       WHERE mmtt.operation_plan_id IS NULL
         AND mmtt.move_order_line_id = mol.line_id
         AND mol.header_id = p_move_order_header_id;
Line: 16464

       SELECT 1 INTO l_count
         FROM dual
         WHERE EXISTS (SELECT 1 FROM wms_rules_b rules
                       WHERE  rules.type_code = 7
                       AND    rules.enabled_flag = 'Y'
                       AND    (organization_id = -1
                               OR organization_id IN (SELECT mmtt.organization_id
                                                      FROM mtl_material_transactions_temp mmtt,
                                                      mtl_txn_request_lines mol
                                                      WHERE mmtt.operation_plan_id IS NULL /*bug9128227*/
                                                      AND mmtt.move_order_line_id = mol.line_id
                                                      AND mol.header_id = p_move_order_header_id)));
Line: 16526

       UPDATE mtl_material_transactions_temp mmtt
         SET mmtt.operation_plan_id = (SELECT NVL(default_pick_op_plan_id, 1)
                                       FROM mtl_parameters mp
                                       WHERE mp.organization_id = mmtt.organization_id)
         WHERE mmtt.operation_plan_id IS NULL
           AND mmtt.move_order_line_id IN (SELECT line_id
                                           FROM mtl_txn_request_lines mol
                                           WHERE mol.header_id = p_move_order_header_id)
           AND mmtt.transaction_source_type_id in (2, 8);
Line: 16589

      SELECT   rules.rule_id
             , mmtt.organization_id
             , mmtt.wms_task_type
             , rules.type_hdr_id
          FROM wms_rules_b rules, wms_op_plans_b wop, mtl_material_transactions_temp mmtt
        WHERE rules.type_code = 7
        AND rules.enabled_flag = 'Y'
        AND rules.type_hdr_id = wop.operation_plan_id
        AND wop.system_task_type = NVL(mmtt.wms_task_type, wop.system_task_type)
        --AND    mmtt.transaction_source_type_id <> 5 -- exclude wip issue tasks
        AND    mmtt.transaction_source_type_id IN (2, 8) --restrict to sales order and internal order mmtts only
        AND mmtt.transaction_temp_id = p_task_id
        AND rules.organization_id IN (mmtt.organization_id, -1)
        AND NVL(wop.organization_id, mmtt.organization_id) = mmtt.organization_id
           AND wop.enabled_flag = 'Y'
      ORDER BY rules.rule_weight DESC, rules.creation_date;
Line: 16609

      SELECT NVL(default_pick_op_plan_id, 1)
        FROM mtl_parameters
       WHERE organization_id = l_organization_id;
Line: 16669

          UPDATE mtl_material_transactions_temp mmtt
             SET mmtt.operation_plan_id = l_operation_plan_id
           WHERE mmtt.transaction_temp_id = p_task_id;
Line: 16689

            select organization_id
             into  l_organization_id
             from  mtl_material_transactions_temp
              where  transaction_temp_id = p_task_id
              AND transaction_source_type_id IN (2, 8);   -- bug fix 3361560
Line: 16713

      UPDATE mtl_material_transactions_temp mmtt
         SET mmtt.operation_plan_id = l_operation_plan_id
       WHERE mmtt.transaction_temp_id = p_task_id;
Line: 16781

      SELECT mmtt.transaction_temp_id
            ,mmtt.organization_id -- Added new
            ,mmtt.wms_task_type   -- Added new
        FROM mtl_material_transactions_temp mmtt, mtl_txn_request_lines mol
       WHERE mmtt.standard_operation_id IS NULL
         AND mmtt.move_order_line_id = mol.line_id
         AND mol.header_id = p_move_order_header_id;
Line: 16806

       SELECT 1 INTO l_count
         FROM dual
         WHERE EXISTS (SELECT 1 FROM wms_rules_b rules
                       WHERE  rules.type_code = 3
                       AND    rules.enabled_flag = 'Y'
                       AND    (organization_id = -1
                               OR organization_id IN (SELECT mmtt.organization_id
                                                      FROM mtl_material_transactions_temp mmtt,
                                                      mtl_txn_request_lines mol
                                                      WHERE mmtt.standard_operation_id IS NULL
                                                      AND mmtt.move_order_line_id = mol.line_id
                                                      AND mol.header_id = p_move_order_header_id)));
Line: 16851

       UPDATE mtl_material_transactions_temp mmtt
         SET standard_operation_id =
         (SELECT DECODE(mmtt.wms_task_type, 1, default_pick_task_type_id,
                        2, default_putaway_task_type_id,
                        3, default_cc_task_type_id,
                        4, default_repl_task_type_id,
                        5, default_moxfer_task_type_id,
                        6, default_moissue_task_type_id,
                        NULL)
          FROM mtl_parameters mp WHERE mp.organization_id = mmtt.organization_id)
         WHERE mmtt.standard_operation_id IS NULL
           AND mmtt.move_order_line_id IN (SELECT line_id
                                           FROM mtl_txn_request_lines mol
                                           WHERE mol.header_id = p_move_order_header_id);
Line: 16936

      SELECT   rules.rule_id
             , rules.type_hdr_id /* Added this Column */
             , mmtt.organization_id
             , mmtt.wms_task_type
          FROM wms_rules_b rules, bom_standard_operations bso , mtl_material_transactions_temp mmtt
         WHERE rules.type_code = 3
           AND rules.enabled_flag = 'Y'
           AND rules.type_hdr_id = bso.standard_operation_id
           AND bso.wms_task_type = NVL(mmtt.wms_task_type, bso.wms_task_type)
           AND mmtt.transaction_temp_id = p_task_id
           AND rules.organization_id IN (mmtt.organization_id, -1)
           AND bso.organization_id = mmtt.organization_id
      ORDER BY rules.rule_weight DESC, rules.creation_date;
Line: 16951

    SELECT   rules.rule_id ,  rules.type_hdr_id
        FROM wms_rules_b rules, bom_standard_operations bso
       WHERE rules.type_code = 3
         AND rules.enabled_flag = 'Y'
         AND rules.type_hdr_id = bso.standard_operation_id
         AND bso.wms_task_type = NVL(p_wms_task_type, bso.wms_task_type)
         AND rules.organization_id IN (p_organization_id, -1)
         AND bso.organization_id = p_organization_id
    ORDER BY rules.rule_weight DESC, rules.creation_date; */
Line: 16963

      SELECT default_pick_task_type_id
            ,default_cc_task_type_id
            ,default_putaway_task_type_id
            ,default_repl_task_type_id
        FROM mtl_parameters
       WHERE organization_id = l_organization_id;
Line: 16972

      SELECT default_pick_task_type_id
           , default_cc_task_type_id
           , default_putaway_task_type_id
           , default_repl_task_type_id
           , default_moxfer_task_type_id
           , default_moissue_task_type_id
           , default_pick_op_plan_id
        FROM mtl_parameters
       WHERE organization_id =  l_organization_id;
Line: 17056

          UPDATE mtl_material_transactions_temp mmtt
             SET mmtt.standard_operation_id = l_type_hdr_id
           WHERE mmtt.transaction_temp_id = p_task_id;
Line: 17060

           UPDATE mtl_material_transactions_temp mmtt
                        SET mmtt.standard_operation_id = (SELECT type_hdr_id
                                                            FROM wms_rules_b
                                                           WHERE rule_id = l_rule_id)
           WHERE mmtt.transaction_temp_id = p_task_id
           */

          EXIT; -- task assigned, jump out of the rule loop
Line: 17083

      select organization_id, wms_task_type
       into  l_organization_id, l_wms_task_type
       from  mtl_material_transactions_temp
      where  transaction_temp_id = p_task_id;
Line: 17149

      UPDATE mtl_material_transactions_temp mmtt
         SET mmtt.standard_operation_id = l_task_type_id
       WHERE mmtt.transaction_temp_id = p_task_id;
Line: 17208

    UPDATE wms_rules_b
       SET rule_weight = (SELECT 100 * COUNT(parameter_id)
                            FROM (SELECT DISTINCT rules.rule_id
                                                , par.parameter_id
                                             FROM wms_rules_b rules, wms_restrictions rest, wms_parameters_b par
                                            WHERE rules.rule_id = p_rule_id
                                              AND rules.rule_id = rest.rule_id(+)
                                              AND rest.parameter_id = par.parameter_id(+)
                                              AND (NVL(par.use_for_tt_assn_flag, 'Y') = 'Y'
                                                   OR NVL(par.use_for_label_rest_flag, 'Y') = 'Y'
                                                  )))
     WHERE rule_id = p_rule_id
       AND rule_weight IS NULL;
Line: 17285

      SELECT   rules.rule_id
             , rules.rule_weight
             , rules.type_hdr_id
             , wl.label_format_name
             , wl.document_id
          FROM wms_rules_b rules, wms_label_formats wl, wms_label_requests wlr
         WHERE rules.type_code = 4
           AND rules.type_hdr_id = wl.label_format_id
           AND wl.label_format_id = NVL(wlr.label_format_id, wl.label_format_id)
           AND NVL(format_disable_date, SYSDATE + 1) > SYSDATE   --Bug #3452076
           AND wlr.document_id = wl.document_id
           AND wlr.label_request_id = p_label_request_id
           AND rules.enabled_flag = 'Y'
           AND (rules.organization_id = wlr.organization_id
                OR rules.organization_id = -1
               ) -- Common to All Org.
      ORDER BY rules.rule_weight DESC, rules.creation_date;
Line: 17304

      SELECT label_format_id
           , label_format_name
        FROM wms_label_formats
       WHERE document_id = l_document_id
         AND default_format_flag IN ('Y', 'y');
Line: 17311

      SELECT *
        FROM wms_label_requests
       WHERE label_request_id = p_label_request_id;
Line: 17322

       SELECT   count(rules.rule_id ) into  ll_ctr
       FROM wms_rules_b rules, wms_label_formats wl, wms_label_requests wlr
       WHERE rules.type_code = 4
                  AND rules.type_hdr_id = wl.label_format_id
                  AND wl.label_format_id = NVL(wlr.label_format_id, wl.label_format_id)
                  AND NVL(format_disable_date, SYSDATE + 1) > SYSDATE   --Bug #        3452076
                  AND wlr.document_id = wl.document_id
                  AND wlr.label_request_id = p_label_request_id
                  AND rules.enabled_flag = 'Y'
                  AND (rules.organization_id = wlr.organization_id
                       OR rules.organization_id = -1
                  ) ;
Line: 17425

        UPDATE wms_label_requests wlr
           SET wlr.label_format_id = l_label_format_id
             , wlr.rule_id = l_rule_id
             , wlr.strategy_id = l_strategy_id
             , wlr.rule_weight = l_rule_weight
         WHERE wlr.label_request_id = p_label_request_id;
Line: 17432

           TRACE('Rule Match.Update Label Request with format ID :'|| l_label_format_id || ' ' || l_label_format_name);
Line: 17471

    UPDATE wms_label_requests wlr
       SET wlr.label_format_id = l_label_format_id
     WHERE wlr.label_request_id = p_label_request_id;
Line: 17476

       TRACE('Update Label Request with label ID :'|| l_label_format_id || '.(' || SQL%ROWCOUNT || ')');
Line: 17550

      SELECT   rule_id
          FROM wms_rules_b
         WHERE enabled_flag = 'Y'
      ORDER BY rule_id;
Line: 17721

            l_inserted_record        BOOLEAN;
Line: 17757

          SELECT STATUS_ID FROM MTL_SERIAL_NUMBERS
          WHERE INVENTORY_ITEM_ID = P_INVENTORY_ITEM_ID
          AND LPN_ID = l_lpn_id;
Line: 17915

           g_locs.DELETE;
Line: 18098

                     log_statement(l_api_name, 'QuickPick', 'Calling  validate_and_insert');
Line: 18113

                     log_statement(l_api_name, 'QuickPick', 'Insert an Output record into WTT if status allowed');
Line: 18131

                       log_statement(l_api_name, 'Calling validate_and_insert', '');
Line: 18133

                      validate_and_insert(
                       x_return_status              => x_return_status
                     , x_msg_count                  => x_msg_count
                     , x_msg_data                   => x_msg_data
                     , p_record_id                  => l_cur_rec
                     , p_needed_quantity            => l_needed_quantity
                     , p_use_pick_uom               => FALSE
                     , p_organization_id            => p_organization_id
                     , p_inventory_item_id          => p_inventory_item_id
                     , p_to_subinventory_code       => l_to_subinventory_code
                     , p_to_locator_id              => l_to_locator_id
                     , p_to_cost_group_id           => l_to_cost_group_id
                     , p_primary_uom                => p_primary_uom
                     , p_transaction_uom            => p_transaction_uom
                     , p_transaction_temp_id        => p_transaction_temp_id
                     , p_type_code                  => p_type_code
                     , p_rule_id                    => 0
                     , p_reservation_id             => l_reservation_id
                     , p_tree_id                    => l_tree_id
                     , p_debug_on                   => l_debug_on
                     , p_needed_sec_quantity        => l_sec_needed_quantity
                     , p_secondary_uom              => p_secondary_uom
                     , p_grade_code                 => p_grade_code
                     , x_inserted_record            => l_inserted_record
                     , x_allocated_quantity         => l_allocated_quantity
                     , x_remaining_quantity         => l_remaining_quantity
                     , x_sec_allocated_quantity     => l_sec_allocated_quantity
                     , x_sec_remaining_quantity     => l_sec_remaining_quantity
                     );
Line: 18162

                 ELSIF p_tree_id is NULL THEN  -- Call the new local procedure validate_and_insert_noqtytree() for bug #4006426

                       IF l_debug = 1 THEN
                          log_statement(l_api_name, 'Calling validateNinsert', '');
Line: 18168

                         ValidNinsert(
                             x_return_status              => x_return_status
                           , x_msg_count                  => x_msg_count
                           , x_msg_data                   => x_msg_data
                           , p_record_id                  => l_cur_rec
                           , p_needed_quantity            => l_needed_quantity
                           , p_use_pick_uom               => FALSE
                           , p_organization_id            => p_organization_id
                           , p_inventory_item_id          => p_inventory_item_id
                           , p_to_subinventory_code       => l_to_subinventory_code
                           , p_to_locator_id              => l_to_locator_id
                           , p_to_cost_group_id           => l_to_cost_group_id
                           , p_primary_uom                => p_primary_uom
                           , p_transaction_uom            => p_transaction_uom
                           , p_transaction_temp_id        => p_transaction_temp_id
                           , p_type_code                  => p_type_code
                           , p_rule_id                    => 0
                           , p_reservation_id             => l_reservation_id
                           , p_tree_id                    => l_tree_id
                           , p_debug_on                   => l_debug_on
                           , x_inserted_record            => l_inserted_record
                           , x_allocated_quantity         => l_allocated_quantity
                           , x_remaining_quantity         => l_remaining_quantity
                           );
Line: 18196

                                log_statement(l_api_name, 'uerr_validate_insert',
                                        'Unexpected error in validate_and_insert');
Line: 18202

                            log_statement(l_api_name, 'err_validate_insert', 'Error in validate_and_insert');
Line: 18208

                      IF l_inserted_record = FALSE  OR ABS(l_allocated_quantity - l_needed_quantity) > 0.00005
                      THEN     -- made by when testing 13591755
                         fnd_message.set_name('WMS', 'WMS_LPN_UNAVAILABLE');  --- to be Added to Mesg Dict
Line: 18221

                                log_statement(l_api_name, 'insert_failed', 'Record failed to allocation.  Rolling back and ' || 'invalidating LPN');
Line: 18228

                                log_statement(l_api_name, 'insert_failed', 'Rolling back');
Line: 18459

    l_capacity_updated       BOOLEAN;
Line: 18481

    l_inserted_record        BOOLEAN;
Line: 18485

    l_sec_inserted_record    BOOLEAN;                   -- new
Line: 18531

      SELECT allocation_mode_id
           , qty_function_parameter_id
        FROM wms_rules_b
       WHERE rule_id = l_rule_id;
Line: 18538

      SELECT consistency_id
        FROM wms_rule_consistencies
       WHERE rule_id = l_rule_id;
Line: 18544

      SELECT SUM(primary_transaction_quantity)
        FROM mtl_onhand_quantities_detail
       WHERE lpn_id = v_current_row.lpn_id;
Line: 18668

      /* Lgao, Bug 5141737 select available will not check this flag, not used */
      /*IF p_partial_success_allowed_flag IS NULL
         OR p_partial_success_allowed_flag = fnd_api.g_miss_char THEN
        IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
          fnd_message.set_name('WMS', 'WMS_PARTIAL_SUCC_FLAG_MISS');
Line: 18813

    g_trace_recs.DELETE;
Line: 19253

l_update BOOLEAN := FALSE;
Line: 19277

  l_update := TRUE;
Line: 19313

  IF(l_update) THEN
   fnd_profile.put('MFG_ORGANIZATION_ID',l_organization_id);