DBA Data[Home] [Help]

APPS.INV_CYC_LOVS SQL Statements

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

Line: 20

   g_update_flag NUMBER;
Line: 21

   g_insert_flag NUMBER;
Line: 36

   g_updated_prior BOOLEAN := FALSE;  -- Bug 6371673
Line: 60

         SELECT   cycle_count_header_name,
                  cycle_count_header_id,
                  description,
                  inventory_adjustment_account,
                  orientation_code,
                  onhand_visible_flag,
                  zero_count_flag,
                  disable_date,
                  approval_option_code,
                  automatic_recount_flag,
                  unscheduled_count_entry,
                  approval_tolerance_positive,
                  approval_tolerance_negative,
                  cost_tolerance_positive,
                  cost_tolerance_negative,
                  hit_miss_tolerance_positive,
                  hit_miss_tolerance_negative,
                  serial_count_option,
                  serial_detail_option,
                  serial_adjustment_option,
                  serial_discrepancy_option,
                  container_adjustment_option,
                  container_discrepancy_option,
                  container_enabled_flag,
                  cycle_count_type,
                  schedule_empty_locations
         FROM     mtl_cycle_count_headers
         WHERE    organization_id = p_organization_id
         AND      trunc(nvl(disable_date, sysdate+1)) > trunc(sysdate)  --Changed for bug 5519506
         AND      cycle_count_header_name LIKE ( p_cycle_count )
         AND      (     ( cycle_count_header_id IN (
                             SELECT UNIQUE cycle_count_header_id
                             FROM          mtl_cycle_count_entries
                             WHERE         organization_id = p_organization_id
                             AND           entry_status_code IN ( 1, 3 ) )
                        )
                    OR NVL ( unscheduled_count_entry, 2 ) = 1
                  )
         ORDER BY 1;
Line: 120

   PROCEDURE update_count_list_sequence (
      p_organization_id NUMBER,
      p_cycle_count_header_id NUMBER,
      x_count_list_sequence OUT NOCOPY NUMBER
   )
   IS
      PRAGMA AUTONOMOUS_TRANSACTION;
Line: 131

      SELECT NVL ( MAX ( count_list_sequence ), 0 ) + 1
      INTO   l_count_list_sequence
      FROM   mtl_cycle_count_entries
      WHERE  cycle_count_header_id = p_cycle_count_header_id
      AND    organization_id = p_organization_id;
Line: 138

      UPDATE mtl_cycle_count_headers
      SET next_user_count_sequence = l_count_list_sequence + 1
      WHERE  cycle_count_header_id = p_cycle_count_header_id
      AND    organization_id = p_organization_id;
Line: 146

   END update_count_list_sequence;
Line: 173

         SELECT *
         FROM   mtl_cycle_count_entries
         WHERE  cycle_count_header_id = p_cycle_count_header_id
         AND    organization_id = p_organization_id
         AND    subinventory = p_subinventory
         AND    NVL ( locator_id, -99999 ) = NVL ( p_locator_id, -99999 )
         AND    NVL ( parent_lpn_id, -99999 ) = NVL ( p_parent_lpn_id, -99999 )
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    NVL ( lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
         AND    NVL ( serial_number, '@@@@@' ) =
                                             NVL ( l_current_serial, '@@@@@' )
         AND    entry_status_code IN ( 1, 3 );
Line: 189

         SELECT *
         FROM   mtl_cycle_count_entries
         WHERE  cycle_count_header_id = p_cycle_count_header_id
         AND    organization_id = p_organization_id
         AND    subinventory = p_subinventory
         AND    NVL ( locator_id, -99999 ) = NVL ( p_locator_id, -99999 )
         AND    NVL ( parent_lpn_id, -99999 ) = NVL ( p_parent_lpn_id, -99999 )
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    NVL ( lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
         AND    entry_status_code IN ( 1, 3 );
Line: 203

         SELECT *
         FROM   mtl_cycle_count_entries
         WHERE  cycle_count_header_id = p_cycle_count_header_id
         AND    organization_id = p_organization_id
         AND    NVL ( parent_lpn_id, -99999 ) = NVL ( p_parent_lpn_id, -99999 )
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    NVL ( lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
         AND    NVL ( serial_number, '@@@@@' ) =
                                             NVL ( l_current_serial, '@@@@@' )
         AND    entry_status_code IN ( 1, 3 );
Line: 217

         SELECT *
         FROM   mtl_cycle_count_entries
         WHERE  cycle_count_header_id = p_cycle_count_header_id
         AND    organization_id = p_organization_id
         AND    NVL ( parent_lpn_id, -99999 ) = NVL ( p_parent_lpn_id, -99999 )
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    NVL ( lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
         AND    entry_status_code IN ( 1, 3 );
Line: 233

         SELECT *
         FROM   mtl_cycle_count_entries
         WHERE  cycle_count_header_id = p_cycle_count_header_id
         AND    organization_id = p_organization_id
         AND    inventory_item_id = p_inventory_item_id
         AND    serial_number = NVL ( l_current_serial, '@@@@@' )
         AND    entry_status_code IN ( 1, 3 );
Line: 318

         SELECT MIN ( cycle_count_entry_id )
         INTO   l_dispatched_task
         FROM   mtl_cycle_count_entries
         WHERE  cycle_count_header_id = p_cycle_count_header_id
         AND    organization_id = p_organization_id
         AND    subinventory = p_subinventory
         AND    NVL ( locator_id, -99999 ) = NVL ( p_locator_id, -99999 )
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    entry_status_code IN ( 1, 3 );
Line: 337

      SELECT COUNT ( * )
      INTO   l_dispatched_count
      FROM   wms_dispatched_tasks
      WHERE  task_type = 3
      AND    organization_id = p_organization_id
      AND    transaction_temp_id = l_dispatched_task
      AND    person_id <> NVL ( g_employee_id, -999 );
Line: 409

               pre_update ( );
Line: 410

               update_row ( );
Line: 413

               SELECT NVL ( serial_discrepancy_option, 2 ),
                      NVL ( container_discrepancy_option, 2 )
               INTO   l_serial_discrepancy,
                      l_container_discrepancy
               FROM   mtl_cycle_count_headers
               WHERE  cycle_count_header_id = p_cycle_count_header_id
               AND    organization_id = p_organization_id;
Line: 448

                  pre_update ( );
Line: 449

                  update_row ( );
Line: 455

                        print_debug ( 'Unscheduled single serial entry to be inserted'
                                    );
Line: 467

                     /*update_count_list_sequence
                       (p_organization_id        => p_organization_id,
                        p_cycle_count_header_id  => p_cycle_count_header_id,
                        x_count_list_sequence    => l_count_list_sequence);*/
Line: 521

                     g_cc_entry.last_update_date := SYSDATE;
Line: 522

                     g_cc_entry.last_updated_by := p_user_id;
Line: 525

                     g_cc_entry.last_update_login := g_login_id;
Line: 530

                     pre_insert ( );
Line: 531

                     insert_row ( );
Line: 572

            pre_update ( );
Line: 573

            update_row ( );
Line: 576

            SELECT NVL ( serial_discrepancy_option, 2 ),
                   NVL ( container_discrepancy_option, 2 )
            INTO   l_serial_discrepancy,
                   l_container_discrepancy
            FROM   mtl_cycle_count_headers
            WHERE  cycle_count_header_id = p_cycle_count_header_id
            AND    organization_id = p_organization_id;
Line: 610

               pre_update ( );
Line: 611

               update_row ( );
Line: 633

            pre_update ( );
Line: 634

            update_row ( );
Line: 637

            SELECT NVL ( container_discrepancy_option, 2 )
            INTO   l_container_discrepancy
            FROM   mtl_cycle_count_headers
            WHERE  cycle_count_header_id = p_cycle_count_header_id
            AND    organization_id = p_organization_id;
Line: 663

               pre_update ( );
Line: 664

               update_row ( );
Line: 670

                     print_debug ( 'Unscheduled non-serial entry to be inserted'
                                 );
Line: 682

                  /*update_count_list_sequence
                    (p_organization_id        => p_organization_id,
                p_cycle_count_header_id  => p_cycle_count_header_id,
                x_count_list_sequence    => l_count_list_sequence);*/
Line: 735

                  g_cc_entry.last_update_date := SYSDATE;
Line: 736

                  g_cc_entry.last_updated_by := p_user_id;
Line: 739

                  g_cc_entry.last_update_login := g_login_id;
Line: 744

                  pre_insert ( );
Line: 745

                  insert_row ( );
Line: 819

   PROCEDURE delete_wdt(
      p_cycle_count_header_id    IN    NUMBER            ,
      p_organization_id          IN    NUMBER            ,
      p_subinventory             IN    VARCHAR2          ,
      p_locator_id               IN    NUMBER            ,
      p_parent_lpn_id            IN    NUMBER            ,
      p_inventory_item_id        IN    NUMBER            ,
      p_revision                 IN    VARCHAR2          ,
      p_lot_number               IN    VARCHAR2          ,
      p_from_serial_number       IN    VARCHAR2          ,
      p_to_serial_number         IN    VARCHAR2          ,
      p_count_quantity           IN    NUMBER            ,
      p_count_uom                IN    VARCHAR2          ,
      p_unscheduled_count_entry  IN    NUMBER            ,
      p_user_id                  IN    NUMBER            ,
      p_cost_group_id            IN    NUMBER            )

      IS
         l_cycle_count_entry_id NUMBER;
Line: 842

            SELECT  cycle_count_entry_id
            FROM   mtl_cycle_count_entries mcce, wms_dispatched_tasks wdt
            WHERE  mcce.cycle_count_header_id = p_cycle_count_header_id
            AND    mcce.cycle_count_entry_id = wdt.transaction_temp_id
            AND    mcce.organization_id = p_organization_id
            AND    mcce.subinventory = p_subinventory
            AND    mcce.locator_id = p_locator_id
            AND    NVL (mcce.parent_lpn_id, -99999) = NVL ( p_parent_lpn_id, -99999)
            AND    mcce.inventory_item_id = NVL (p_inventory_item_id, mcce.inventory_item_id)
            AND    NVL (mcce.revision, '@@@@@' ) = NVL (p_revision , '@@@@@' )
            AND    NVL (mcce.lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
            AND    NVL (mcce.serial_number, '@@@@@' ) = NVL ( p_from_serial_number, '@@@@@' )
            AND    NVL (mcce.serial_number, '@@@@@' ) = NVL ( p_to_serial_number, '@@@@@' )
            AND    mcce.entry_status_code IN (2, 4, 5 );
Line: 859

            print_debug ( '***In delete_wdt ***');
Line: 897

                   DELETE FROM wms_dispatched_tasks wdt
                   WHERE wdt.transaction_temp_id = l_cycle_count_entry_id;
Line: 900

                      print_debug('** Deleted wms_dispatched_tasks record with transaction_temp_id : ' || l_cycle_count_entry_id);
Line: 917

              print_debug ( 'Exiting delete_wdt');
Line: 920

   END delete_wdt;
Line: 929

   PROCEDURE insert_row
   IS
      l_return_status VARCHAR2 ( 300 );
Line: 938

         print_debug ( '***insert_row***' );
Line: 955

           SELECT outermost_lpn_id
           INTO   g_cc_entry.outermost_lpn_id
           FROM   WMS_LICENSE_PLATE_NUMBERS
           WHERE  lpn_id = g_cc_entry.parent_lpn_id;
Line: 971

      INSERT INTO mtl_cycle_count_entries
                  ( cycle_count_entry_id,
                    last_update_date,
                    last_updated_by,
                    creation_date,
                    created_by,
                    last_update_login,
                    count_list_sequence,
                    count_date_first,
                    count_date_current,
                    count_date_prior,
                    count_date_dummy,
                    counted_by_employee_id_first,
                    counted_by_employee_id_current,
                    counted_by_employee_id_prior,
                    counted_by_employee_id_dummy,
                    count_uom_first,
                    count_uom_current,
                    count_uom_prior,
                    count_quantity_first,
                    count_quantity_current,
                    count_quantity_prior,
                    inventory_item_id,
                    subinventory,
                    entry_status_code,
                    count_due_date,
                    organization_id,
                    cycle_count_header_id,
                    number_of_counts,
                    locator_id,
                    adjustment_quantity,
                    adjustment_date,
                    adjustment_amount,
                    item_unit_cost,
                    inventory_adjustment_account,
                    approval_date,
                    approver_employee_id,
                    revision,
                    lot_number,
                    lot_control,
                    system_quantity_first,
                    system_quantity_current,
                    system_quantity_prior,
                    reference_first,
                    reference_current,
                    reference_prior,
                    primary_uom_quantity_first,
                    primary_uom_quantity_current,
                    primary_uom_quantity_prior,
                    count_type_code,
                    transaction_reason_id,
                    request_id,
                    program_application_id,
                    program_id,
                    program_update_date,
                    approval_type,
                    attribute_category,
                    attribute1,
                    attribute2,
                    attribute3,
                    attribute4,
                    attribute5,
                    attribute6,
                    attribute7,
                    attribute8,
                    attribute9,
                    attribute10,
                    attribute11,
                    attribute12,
                    attribute13,
                    attribute14,
                    attribute15,
                    serial_number,
                    serial_detail,
                    approval_condition,
                    neg_adjustment_quantity,
                    neg_adjustment_amount,
                    export_flag,
                    task_priority,
                    standard_operation_id,
                    parent_lpn_id,
                    outermost_lpn_id,
                    cost_group_id
                    -- INVCONV, NSRIVAST
                    ,secondary_uom_quantity_first
                    ,secondary_uom_quantity_current
                    ,secondary_uom_quantity_prior
                    ,count_secondary_uom_first
                    ,count_secondary_uom_current
                    ,count_secondary_uom_prior
                   -- INVCONV, NSRIVAST
                  )
           VALUES ( g_cc_entry.cycle_count_entry_id,
                    g_cc_entry.last_update_date,
                    g_cc_entry.last_updated_by,
                    g_cc_entry.creation_date,
                    g_cc_entry.created_by,
                    g_cc_entry.last_update_login,
                    g_cc_entry.count_list_sequence,
                    g_cc_entry.count_date_first,
                    g_cc_entry.count_date_current,
                    g_cc_entry.count_date_prior,
                    g_cc_entry.count_date_dummy,
                    g_cc_entry.counted_by_employee_id_first,
                    g_cc_entry.counted_by_employee_id_current,
                    g_cc_entry.counted_by_employee_id_prior,
                    g_cc_entry.counted_by_employee_id_dummy,
                    g_cc_entry.count_uom_first,
                    g_cc_entry.count_uom_current,
                    g_cc_entry.count_uom_prior,
                    g_cc_entry.count_quantity_first,
                    g_cc_entry.count_quantity_current,
                    g_cc_entry.count_quantity_prior,
                    g_cc_entry.inventory_item_id,
                    g_cc_entry.subinventory,
                    g_cc_entry.entry_status_code,
                    g_cc_entry.count_due_date,
                    g_cc_entry.organization_id,
                    g_cc_entry.cycle_count_header_id,
                    g_cc_entry.number_of_counts,
                    g_cc_entry.locator_id,
                    g_cc_entry.adjustment_quantity,
                    g_cc_entry.adjustment_date,
                    g_cc_entry.adjustment_amount,
                    g_cc_entry.item_unit_cost,
                    g_cc_entry.inventory_adjustment_account,
                    g_cc_entry.approval_date,
                    g_cc_entry.approver_employee_id,
                    g_cc_entry.revision,
                    g_cc_entry.lot_number,
                    g_cc_entry.lot_control,
                    g_cc_entry.system_quantity_first,
                    g_cc_entry.system_quantity_current,
                    g_cc_entry.system_quantity_prior,
                    g_cc_entry.reference_first,
                    g_cc_entry.reference_current,
                    g_cc_entry.reference_prior,
                    g_cc_entry.primary_uom_quantity_first,
                    g_cc_entry.primary_uom_quantity_current,
                    g_cc_entry.primary_uom_quantity_prior,
                    g_cc_entry.count_type_code,
                    g_cc_entry.transaction_reason_id,
                    g_cc_entry.request_id,
                    g_cc_entry.program_application_id,
                    g_cc_entry.program_id,
                    g_cc_entry.program_update_date,
                    g_cc_entry.approval_type,
                    g_cc_entry.attribute_category,
                    g_cc_entry.attribute1,
                    g_cc_entry.attribute2,
                    g_cc_entry.attribute3,
                    g_cc_entry.attribute4,
                    g_cc_entry.attribute5,
                    g_cc_entry.attribute6,
                    g_cc_entry.attribute7,
                    g_cc_entry.attribute8,
                    g_cc_entry.attribute9,
                    g_cc_entry.attribute10,
                    g_cc_entry.attribute11,
                    g_cc_entry.attribute12,
                    g_cc_entry.attribute13,
                    g_cc_entry.attribute14,
                    g_cc_entry.attribute15,
                    LTRIM ( RTRIM ( g_cc_entry.serial_number ) ),
                                                                /* BUG2842145*/
                    g_cc_entry.serial_detail,
                    g_cc_entry.approval_condition,
                    g_cc_entry.neg_adjustment_quantity,
                    g_cc_entry.neg_adjustment_amount,
                    g_cc_entry.export_flag,
                    g_cc_entry.task_priority,
                    g_cc_entry.standard_operation_id,
                    g_cc_entry.parent_lpn_id,
                    g_cc_entry.outermost_lpn_id,
                    g_cc_entry.cost_group_id
                    -- INVCONV, NSRIVAST
                    ,g_cc_entry.secondary_uom_quantity_first
                    ,g_cc_entry.secondary_uom_quantity_current
                    ,g_cc_entry.secondary_uom_quantity_prior
                    ,g_cc_entry.count_secondary_uom_first
                    ,g_cc_entry.count_secondary_uom_current
                    ,g_cc_entry.count_secondary_uom_prior
                    -- INVCONV, NSRIVAST
                  );
Line: 1159

   END insert_row;
Line: 1161

   PROCEDURE update_row
   IS
      l_return_status VARCHAR2 ( 300 );
Line: 1170

         print_debug ( '***update_row***' );
Line: 1174

      g_cc_entry.last_update_date := SYSDATE;
Line: 1175

      g_cc_entry.last_updated_by := g_user_id;
Line: 1176

      g_cc_entry.last_update_login := g_login_id;
Line: 1191

           SELECT outermost_lpn_id
           INTO   g_cc_entry.outermost_lpn_id
           FROM   WMS_LICENSE_PLATE_NUMBERS
           WHERE  lpn_id = g_cc_entry.parent_lpn_id;
Line: 1207

      UPDATE mtl_cycle_count_entries
      SET last_update_date = g_cc_entry.last_update_date,
          last_updated_by = g_cc_entry.last_updated_by,
          last_update_login = g_cc_entry.last_update_login,
          count_list_sequence = g_cc_entry.count_list_sequence,
          count_date_first = g_cc_entry.count_date_first,
          count_date_current = g_cc_entry.count_date_current,
          count_date_prior = g_cc_entry.count_date_prior,
          count_date_dummy = g_cc_entry.count_date_dummy,
          counted_by_employee_id_first =
                                       g_cc_entry.counted_by_employee_id_first,
          counted_by_employee_id_current =
                                     g_cc_entry.counted_by_employee_id_current,
          counted_by_employee_id_prior =
                                       g_cc_entry.counted_by_employee_id_prior,
          counted_by_employee_id_dummy =
                                       g_cc_entry.counted_by_employee_id_dummy,
          count_uom_first = g_cc_entry.count_uom_first,
          count_uom_current = g_cc_entry.count_uom_current,
          count_uom_prior = g_cc_entry.count_uom_prior,
          count_quantity_first = g_cc_entry.count_quantity_first,
          count_quantity_current = g_cc_entry.count_quantity_current,
          count_quantity_prior = g_cc_entry.count_quantity_prior,
          inventory_item_id = g_cc_entry.inventory_item_id,
          subinventory = g_cc_entry.subinventory,
          entry_status_code = g_cc_entry.entry_status_code,
          count_due_date = g_cc_entry.count_due_date,
          organization_id = g_cc_entry.organization_id,
          cycle_count_header_id = g_cc_entry.cycle_count_header_id,
          number_of_counts = g_cc_entry.number_of_counts,
          locator_id = g_cc_entry.locator_id,
          adjustment_quantity = g_cc_entry.adjustment_quantity,
          adjustment_date = g_cc_entry.adjustment_date,
          adjustment_amount = g_cc_entry.adjustment_amount,
          item_unit_cost = g_cc_entry.item_unit_cost,
          inventory_adjustment_account =
                                       g_cc_entry.inventory_adjustment_account,
          approval_date = g_cc_entry.approval_date,
          approver_employee_id = g_cc_entry.approver_employee_id,
          revision = g_cc_entry.revision,
          lot_number = g_cc_entry.lot_number,
          lot_control = g_cc_entry.lot_control,
          system_quantity_first = g_cc_entry.system_quantity_first,
          system_quantity_current = g_cc_entry.system_quantity_current,
          system_quantity_prior = g_cc_entry.system_quantity_prior,
          reference_first = g_cc_entry.reference_first,
          reference_current = g_cc_entry.reference_current,
          reference_prior = g_cc_entry.reference_prior,
          primary_uom_quantity_first = g_cc_entry.primary_uom_quantity_first,
          primary_uom_quantity_current =
                                       g_cc_entry.primary_uom_quantity_current,
          primary_uom_quantity_prior = g_cc_entry.primary_uom_quantity_prior,
          count_type_code = g_cc_entry.count_type_code,
          transaction_reason_id = g_cc_entry.transaction_reason_id,
          approval_type = g_cc_entry.approval_type,
          attribute_category = g_cc_entry.attribute_category,
          attribute1 = g_cc_entry.attribute1,
          attribute2 = g_cc_entry.attribute2,
          attribute3 = g_cc_entry.attribute3,
          attribute4 = g_cc_entry.attribute4,
          attribute5 = g_cc_entry.attribute5,
          attribute6 = g_cc_entry.attribute6,
          attribute7 = g_cc_entry.attribute7,
          attribute8 = g_cc_entry.attribute8,
          attribute9 = g_cc_entry.attribute9,
          attribute10 = g_cc_entry.attribute10,
          attribute11 = g_cc_entry.attribute11,
          attribute12 = g_cc_entry.attribute12,
          attribute13 = g_cc_entry.attribute13,
          attribute14 = g_cc_entry.attribute14,
          attribute15 = g_cc_entry.attribute15,
          serial_number = g_cc_entry.serial_number,
          serial_detail = g_cc_entry.serial_detail,
          approval_condition = g_cc_entry.approval_condition,
          neg_adjustment_quantity = g_cc_entry.neg_adjustment_quantity,
          neg_adjustment_amount = g_cc_entry.neg_adjustment_amount,
          parent_lpn_id = g_cc_entry.parent_lpn_id,
          outermost_lpn_id = g_cc_entry.outermost_lpn_id,
          cost_group_id = g_cc_entry.cost_group_id
           -- INVCONV, NSRIVAST
          ,secondary_uom_quantity_first    =   g_cc_entry.secondary_uom_quantity_first ,
          secondary_uom_quantity_current  =   g_cc_entry.secondary_uom_quantity_current,
          secondary_uom_quantity_prior    =   g_cc_entry.secondary_uom_quantity_prior ,
          count_secondary_uom_first       =   g_cc_entry.count_secondary_uom_first,
          count_secondary_uom_current     =   g_cc_entry.count_secondary_uom_current,
          count_secondary_uom_prior       =   g_cc_entry.count_secondary_uom_prior,
          -- INVCONV, NSRIVAST
	  -- nsinghi Bug#6052831 START
	  secondary_adjustment_quantity   =   g_cc_entry.secondary_adjustment_quantity,
	  secondary_system_qty_current    =   g_cc_entry.secondary_system_qty_current,
	  secondary_system_qty_first      =   g_cc_entry.secondary_system_qty_first,
	  secondary_system_qty_prior      =   g_cc_entry.secondary_system_qty_prior
	  -- nsinghi Bug#6052831 END
      WHERE  cycle_count_entry_id = g_cc_entry.cycle_count_entry_id;
Line: 1305

   END update_row;
Line: 1407

      SELECT primary_uom_code
      INTO   l_primary_uom
      FROM   MTL_SYSTEM_ITEMS
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1475

         SELECT abc_class_id
         INTO   l_abc_class_id
         FROM   mtl_cycle_count_items
         WHERE  cycle_count_header_id = l_cycle_count_header_id
         AND    inventory_item_id = l_inventory_item_id;
Line: 1487

         SELECT approval_tolerance_positive,
                approval_tolerance_negative
         INTO   l_item_app_tol_pos,
                l_item_app_tol_neg
         FROM   mtl_cycle_count_items
         WHERE  cycle_count_header_id = l_cycle_count_header_id
         AND    inventory_item_id = l_inventory_item_id;
Line: 1500

         SELECT approval_tolerance_positive,
                approval_tolerance_negative,
                cost_tolerance_positive,
                cost_tolerance_negative
         INTO   l_class_app_tol_pos,
                l_class_app_tol_neg,
                l_class_cost_tol_pos,
                l_class_cost_tol_neg
         FROM   mtl_cycle_count_classes
         WHERE  abc_class_id = l_abc_class_id
         AND    cycle_count_header_id = l_cycle_count_header_id;
Line: 1518

      SELECT NVL ( approval_tolerance_positive, -1 ),
             NVL ( approval_tolerance_negative, -1 ),
             NVL ( cost_tolerance_positive, -1 ),
             NVL ( cost_tolerance_negative, -1 )
      INTO   l_head_app_tol_pos,
             l_head_app_tol_neg,
             l_head_cost_tol_pos,
             l_head_cost_tol_neg
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = l_cycle_count_header_id
      AND    organization_id = l_organization_id;
Line: 1617

      IF ( g_cc_entry.entry_status_code = 3 ) AND g_updated_prior = FALSE THEN		-- Modified for Bug 6371673
         current_to_prior ( );
Line: 1663

      SELECT primary_uom_code
      INTO   l_primary_uom
      FROM   MTL_SYSTEM_ITEMS
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1716

         SELECT positive_measurement_error,
                negative_measurement_error,
                parent_lpn_id
         INTO   l_pos_meas_err,
                l_neg_meas_err,
                l_parent_lpn_id
         FROM   mtl_cycle_count_entries_v
         WHERE  cycle_count_entry_id = g_cc_entry.cycle_count_entry_id
         AND    organization_id = g_cc_entry.organization_id;
Line: 1733

      SELECT NVL ( container_enabled_flag, 2 ),
             NVL ( container_adjustment_option, 2 ),
             NVL ( container_discrepancy_option, 2 )
      INTO   l_container_enabled_flag,
             l_container_adjustment_option,
             l_container_discrepancy_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1744

      SELECT NVL ( approval_option_code, 1 )
      INTO   l_approval_option_code
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1888

      final_preupdate_logic ( );
Line: 1905

      SELECT NVL ( approval_option_code, 1 )
      INTO   l_approval_option_code
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1914

      SELECT NVL ( container_enabled_flag, 2 ),
             NVL ( container_adjustment_option, 2 ),
             NVL ( container_discrepancy_option, 2 )
      INTO   l_container_enabled_flag,
             l_container_adjustment_option,
             l_container_discrepancy_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1964

      SELECT NVL ( approval_option_code, 1 ),
             NVL ( automatic_recount_flag, 2 ),
             NVL ( maximum_auto_recounts, 0 ),
             NVL ( days_until_late, 0 ),
             NVL ( serial_count_option, 1 )
      INTO   l_approval_option_code,
             l_auto_recount_flag,
             l_max_recounts,
             l_days_until_late,
             l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1979

      SELECT NVL ( container_enabled_flag, 2 ),
             NVL ( container_adjustment_option, 2 ),
             NVL ( container_discrepancy_option, 2 )
      INTO   l_container_enabled_flag,
             l_container_adjustment_option,
             l_container_discrepancy_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 1990

         SELECT serial_number_control_code
         INTO   l_serial_number_ctrl_code
         FROM   mtl_system_items
         WHERE  inventory_item_id = g_cc_entry.inventory_item_id
         AND    organization_id = g_cc_entry.organization_id;
Line: 2056

   PROCEDURE pre_insert
   IS
      l_number_of_counts NUMBER := NVL ( g_cc_entry.number_of_counts, 0 );
Line: 2087

         print_debug ( '***pre_insert***' );
Line: 2092

      SELECT serial_number_control_code
      INTO   l_serial_number_ctrl_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2098

      SELECT NVL ( serial_detail_option, 1 ),
             NVL ( serial_count_option, 1 )
      INTO   l_serial_detail_option,
             l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2111

         SELECT mtl_cycle_count_entries_s.NEXTVAL
         INTO   l_cc_entry_id
         FROM   DUAL;
Line: 2135

            SELECT primary_uom_code
            INTO   l_primary_uom
            FROM   MTL_SYSTEM_ITEMS
            WHERE  inventory_item_id = g_cc_entry.inventory_item_id
            AND    organization_id = g_cc_entry.organization_id;
Line: 2186

               print_debug('Called from pre_insert ');
Line: 2187

               final_preupdate_logic ( );
Line: 2227

                  SELECT primary_uom_code
                  INTO   l_primary_uom
                  FROM   MTL_SYSTEM_ITEMS
                  WHERE  inventory_item_id = g_cc_entry.inventory_item_id
                  AND    organization_id = g_cc_entry.organization_id;
Line: 2274

                  UPDATE MTL_MATERIAL_TRANSACTIONS_TEMP
                  SET LOCATOR_ID = l_locator_id
                  WHERE  CYCLE_COUNT_ID = l_cc_entry_id
                  AND    TRANSACTION_SOURCE_ID = l_cc_header_id
                  AND    LOCATOR_ID = -1;
Line: 2283

                         UPDATE MTL_CC_SERIAL_NUMBERS
                         SET
                                UNIT_STATUS_CURRENT = DECODE((NVL(POS_ADJUSTMENT_QTY,0) -
                                      NVL(NEG_ADJUSTMENT_QTY,0)), 1, 2, -1, 1, UNIT_STATUS_CURRENT),
                                POS_ADJUSTMENT_QTY = 0,
                                NEG_ADJUSTMENT_QTY = 0,
                                APPROVAL_CONDITION = NULL
                         WHERE CYCLE_COUNT_ENTRY_ID = l_cc_entry_id;
Line: 2324

               SELECT primary_uom_code
               INTO   l_primary_uom
               FROM   MTL_SYSTEM_ITEMS
               WHERE  inventory_item_id = g_cc_entry.inventory_item_id
               AND    organization_id = g_cc_entry.organization_id;
Line: 2377

   END pre_insert;
Line: 2379

   PROCEDURE pre_update
   IS
      l_number_of_counts NUMBER := NVL ( g_cc_entry.number_of_counts, 0 );
Line: 2421

         print_debug ( '***pre_update***' );
Line: 2441

            SELECT NVL ( subinventory_code, '###' ),
                   NVL ( locator_id, -99 ),
                   lpn_context
            INTO   l_lpn_subinv,
                   l_lpn_locator_id,
                   l_lpn_context
            FROM   WMS_LICENSE_PLATE_NUMBERS
            WHERE  lpn_id = g_cc_entry.parent_lpn_id ;
Line: 2482

      SELECT serial_number_control_code
      INTO   l_serial_number_ctrl_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2488

      SELECT NVL ( serial_detail_option, 1 ),
             NVL ( serial_count_option, 1 )
      INTO   l_serial_detail_option,
             l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2498

      SELECT NVL ( number_of_counts, 0 )
      INTO   l_old_num_counts
      FROM   mtl_cycle_count_entries
      WHERE  cycle_count_entry_id = l_cc_entry_id;
Line: 2504

         FND_MESSAGE.SET_NAME ( 'INV', 'INV_DUPLICATE_COUNT_UPDATE' );
Line: 2525

            SELECT primary_uom_code
            INTO   l_primary_uom
            FROM   MTL_SYSTEM_ITEMS
            WHERE  inventory_item_id = g_cc_entry.inventory_item_id
            AND    organization_id = g_cc_entry.organization_id;
Line: 2563

	       g_updated_prior := TRUE;				-- Bug 6371673
Line: 2577

               print_debug('from pre_update : 1');
Line: 2578

               final_preupdate_logic ( );
Line: 2587

	    g_updated_prior := FALSE;	-- Bug 6371673
Line: 2613

                  SELECT SUM ( DECODE ( UNIT_STATUS_CURRENT, 1, 1, 0 ) )
                  INTO   l_total_serial_num_cnt
                  FROM   MTL_CC_SERIAL_NUMBERS
                  WHERE  CYCLE_COUNT_ENTRY_ID = l_cc_entry_id;
Line: 2631

                        print_debug ( 'Multiple entry has been completed so call final_preupdate_logic'
                                    );
Line: 2640

                     print_debug('from pre_update : 2');
Line: 2641

                     final_preupdate_logic ( );
Line: 2656

               SELECT primary_uom_code
               INTO   l_primary_uom
               FROM   MTL_SYSTEM_ITEMS
               WHERE  inventory_item_id = g_cc_entry.inventory_item_id
               AND    organization_id = g_cc_entry.organization_id;
Line: 2705

                     UPDATE MTL_CC_SERIAL_NUMBERS
                         SET
                                UNIT_STATUS_CURRENT = DECODE((NVL(POS_ADJUSTMENT_QTY,0) -
                                      NVL(NEG_ADJUSTMENT_QTY,0)), 1, 2, -1, 1, UNIT_STATUS_CURRENT),
                                POS_ADJUSTMENT_QTY = 0,
                                NEG_ADJUSTMENT_QTY = 0,
                                APPROVAL_CONDITION = NULL
                         WHERE CYCLE_COUNT_ENTRY_ID = l_cc_entry_id;
Line: 2742

               SELECT primary_uom_code
               INTO   l_primary_uom
               FROM   MTL_SYSTEM_ITEMS
               WHERE  inventory_item_id = g_cc_entry.inventory_item_id
               AND    organization_id = g_cc_entry.organization_id;
Line: 2807

   END pre_update;
Line: 2809

   PROCEDURE final_preupdate_logic
   IS
      l_entry_status_code NUMBER := g_cc_entry.entry_status_code;
Line: 2897

         print_debug ( '***final_preupdate_logic***' );
Line: 2906

      SELECT primary_uom_code
      INTO   l_to_uom
      FROM   MTL_SYSTEM_ITEMS
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2912

      SELECT serial_number_control_code
      INTO   l_serial_number_ctrl_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2918

      SELECT NVL ( serial_count_option, 1 ),
             NVL ( inventory_adjustment_account, -1 )
      INTO   l_serial_count_option,
             l_txn_acct_id
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 2926

      SELECT concatenated_segments
      INTO   l_item_name
      FROM   mtl_system_items_kfv
      WHERE  inventory_item_id = l_item_id AND organization_id = l_org_id;
Line: 2933

          delete_reservation ( );
Line: 2938

      SELECT negative_inv_receipt_code
      INTO   l_neg_inv_rcpt_code --Negative Balance  1:Allowed   2:Disallowed
      FROM   mtl_parameters
      WHERE  organization_id = l_org_id;
Line: 2959

         SELECT serial_number_control_code,
                lot_control_code,
                revision_qty_control_code
         INTO   v_ser_code,
                v_lot_code,
                v_rev_code
         FROM   mtl_system_items
         WHERE  inventory_item_id = l_item_id AND organization_id = l_org_id;
Line: 2984

             SELECT NVL ( subinventory_code, '###' ),
                    NVL ( locator_id, -99 )
             INTO   l_lpn_subinv,
                    l_lpn_locator_id
             FROM   WMS_LICENSE_PLATE_NUMBERS
             WHERE  lpn_id = l_lpn_id;
Line: 3159

        /* Bug 5725198-Added the check for LPN being counted to update quantity tree */
           IF (( l_lpn_id IS NOT NULL ) AND (l_lpn_subinv <> '###' AND l_lpn_locator_id <> -99)) THEN
              inv_quantity_tree_pub.update_quantities ( p_api_version_number => 1.0,
                                                        p_init_msg_lst      => 'F',
                                                        x_return_status     => x_return_status,
                                                        x_msg_count         => l_msg_count,
                                                        x_msg_data          => l_msg_data,
                                                        p_organization_id   => l_org_id,
                                                        p_inventory_item_id => l_item_id,
                                                        p_tree_mode         => 1,
                                                        p_is_revision_control => v_is_rev_controlled,
                                                        p_is_lot_control    => v_is_lot_controlled,
                                                        p_is_serial_control => v_is_ser_controlled,
                                                        p_demand_source_type_id => NULL,
                                                        p_revision          => l_rev,
                                                        p_lot_number        => l_lot_num,
                                                        p_subinventory_code => l_lpn_subinv,
                                                        p_locator_id        => l_lpn_locator_id,
                                                        p_onhand_source     => 3,
                                                        p_containerized     => 0,
                                                        p_primary_quantity  => ABS ( l_adjustment_quantity
                                                                                   ),
                                                        p_secondary_quantity => ABS ( l_sec_adjustment_quantity ), -- nsinghi bug#6052831
                                                        p_quantity_type     => 5,
                                                        x_qoh               => x_qoh,
                                                        x_rqoh              => l_rqoh,
                                                        x_qr                => l_qr,
                                                        x_qs                => l_qs,
                                                        x_att               => x_att,
                                                        x_atr               => l_atr,
                                                        p_lpn_id            => l_lpn_id,
                                                        -- nsinghi bug#6052831 START
                                                        x_sqoh              => l_sqoh,
                                                        x_srqoh             => l_srqoh,
                                                        x_sqr               => l_sqr,
                                                        x_sqs               => l_sqs,
                                                        x_satt              => l_satt,
                                                        x_satr              => l_satr
                                                        -- nsinghi bug#6052831 END
                                                      );
Line: 3212

         inv_quantity_tree_pub.update_quantities ( p_api_version_number => 1.0,
                                                   p_init_msg_lst      => 'F',
                                                   x_return_status     => x_return_status,
                                                   x_msg_count         => l_msg_count,
                                                   x_msg_data          => l_msg_data,
                                                   p_organization_id   => l_org_id,
                                                   p_inventory_item_id => l_item_id,
                                                   p_tree_mode         => 1,
                                                   p_is_revision_control => v_is_rev_controlled,
                                                   p_is_lot_control    => v_is_lot_controlled,
                                                   p_is_serial_control => v_is_ser_controlled,
                                                   p_demand_source_type_id => NULL,
                                                   p_revision          => l_rev,
                                                   p_lot_number        => l_lot_num,
                                                   p_subinventory_code => l_sub,
                                                   p_locator_id        => l_locator_id,
                                                   p_onhand_source     => 3,
                                                   p_containerized     => 0,
                                                   p_primary_quantity  => ABS ( l_adjustment_quantity
                                                                              ),
                                                   p_secondary_quantity => ABS ( l_sec_adjustment_quantity ), -- nsinghi bug#6052831
                                                   p_quantity_type     => 5,
                                                   x_qoh               => x_qoh,
                                                   x_rqoh              => l_rqoh,
                                                   x_qr                => l_qr,
                                                   x_qs                => l_qs,
                                                   x_att               => x_att,
                                                   x_atr               => l_atr,
                                                   p_lpn_id            => NULL, --added for lpn reservation
                                                   -- nsinghi bug#6052831 START
                                                   x_sqoh              => l_sqoh,
                                                   x_srqoh             => l_srqoh,
                                                   x_sqr               => l_sqr,
                                                   x_sqs               => l_sqs,
                                                   x_satt              => l_satt,
                                                   x_satr              => l_satr
                                                   -- nsinghi bug#6052831 END
                                                 );
Line: 3290

/*         SELECT NVL ( subinventory_code, '###' ),
                NVL ( locator_id, -99 )
         INTO   l_lpn_subinv,
                l_lpn_locator_id
         FROM   WMS_LICENSE_PLATE_NUMBERS
         WHERE  lpn_id = l_lpn_id;
Line: 3332

            SELECT mtl_material_transactions_s.NEXTVAL
            INTO   l_txn_header_id
            FROM   DUAL;
Line: 3342

            SELECT mtl_material_transactions_s.NEXTVAL
            INTO   l_txn_temp_id
            FROM   DUAL;
Line: 3346

            SELECT auto_serial_alpha_prefix
            INTO   l_serial_prefix
            FROM   mtl_system_items
            WHERE  inventory_item_id = l_item_id
                   AND organization_id = l_org_id;
Line: 3378

            SELECT NVL ( REVISION, 'XXX' ),
                   NVL ( LOT_NUMBER, 'X' ),
                   CURRENT_STATUS,
                   CURRENT_SUBINVENTORY_CODE,
                   NVL ( CURRENT_LOCATOR_ID, 0 ),
                   NVL ( LPN_ID, -99 )
            INTO   l_msn_revision,
                   l_msn_lot_number,
                   l_current_status,
                   l_msn_subinv,
                   l_msn_locator_id,
                   l_msn_lpn_id
            FROM   MTL_SERIAL_NUMBERS
            WHERE  SERIAL_NUMBER = l_serial_number
            AND    INVENTORY_ITEM_ID = g_cc_entry.inventory_item_id
            AND    CURRENT_ORGANIZATION_ID = g_cc_entry.organization_id;
Line: 3520

               SELECT mtl_material_transactions_s.NEXTVAL
               INTO   l_txn_temp_id
               FROM   DUAL;
Line: 3532

            SELECT NVL ( subinventory_code, '###' ),
                   NVL ( locator_id, -99 )
            INTO   l_lpn_subinv,
                   l_lpn_locator_id
            FROM   WMS_LICENSE_PLATE_NUMBERS
            WHERE  lpn_id = l_lpn_id;
Line: 3558

               SELECT COUNT ( * )
               INTO   l_temp_lpn_count
               FROM   mtl_material_transactions_temp
               WHERE  transaction_header_id = l_txn_header_id
               AND    inventory_item_id = -1
               AND    content_lpn_id = l_lpn_id
               AND    transaction_source_id = l_cc_header_id
               AND    cycle_count_id IS NULL;
Line: 3569

                     print_debug ( 'The LPN sub xfer record has already been inserted into MMTT'
                                 );
Line: 3653

                  SELECT mtl_material_transactions_s.NEXTVAL
                  INTO   l_txn_temp_id
                  FROM   DUAL;
Line: 3778

   END final_preupdate_logic;
Line: 3780

   PROCEDURE delete_reservation
   IS
      l_mtl_reservation_rec INV_RESERVATION_GLOBAL.MTL_RESERVATION_REC_TYPE
                            := INV_CC_RESERVATIONS_PVT.Define_Reserv_Rec_Type;
Line: 3796

         print_debug ( '***delete_reservation***' );
Line: 3800

      /* Delete only cycle count reservation */
      l_mtl_reservation_rec.demand_source_type_id := 9;
Line: 3816

		 SELECT NVL (subinventory_code, '###' ),
                 NVL (locator_id, -99 )
		 INTO   l_lpn_subinv,
                 l_lpn_locator_id
                 FROM   WMS_LICENSE_PLATE_NUMBERS
                 WHERE  lpn_id = g_cc_entry.parent_lpn_id;
Line: 3839

         print_debug ( 'Calling Delete_All_Reservation with the following values for the reservation record:'
                     );
Line: 3855

      INV_CC_RESERVATIONS_PVT.Delete_All_Reservation ( p_api_version_number => 1.0,
                                                       p_init_msg_lst      => l_init_msg_lst,
                                                       p_mtl_reservation_rec => l_mtl_reservation_rec,
                                                       x_error_code        => l_error_code,
                                                       x_return_status     => l_return_status,
                                                       x_msg_count         => l_msg_count,
                                                       x_msg_data          => l_msg_data
                                                     );
Line: 3870

   END delete_reservation;
Line: 3892

      SELECT COUNT ( * )
      INTO   l_count
      FROM   mtl_cycle_count_entries
      WHERE  cycle_count_header_id = l_cc_header_id
      AND    organization_id = l_org_id
      AND    inventory_item_id = l_item_id
      AND    subinventory = l_sub
      AND    entry_status_code IN ( 1, 2, 3 )
      --            AND nvl(export_flag,2) = 2
      AND    (    l_locator_id IS NULL
               OR locator_id = l_locator_id )
      AND    (    l_revision IS NULL
               OR revision = l_revision )
      AND    (    l_lot IS NULL
               OR lot_NUMBER = l_lot )
      AND    (    l_cc_serial_number IS NULL
               OR serial_number = l_cc_serial_number
             )
      AND    (    l_cost_group_id IS NULL
               OR cost_group_id = l_cost_group_id)

       AND    NVL(parent_lpn_id,-1 ) = NVL(l_lpn_id, -1);
Line: 3943

         SELECT cycle_count_entry_id,
                entry_status_code,
                inventory_item_id
         FROM   MTL_CYCLE_COUNT_ENTRIES_V
         WHERE  cycle_count_header_id = l_cc_header_id
         --       AND nvl(export_flag,2) = 2
         AND    serial_number_control_code IN ( 2, 5 );
Line: 3972

         SELECT COUNT ( * )
         INTO   l_temp_count
         FROM   mtl_material_transactions_temp
         WHERE  transaction_header_id = l_txn_header_id;
Line: 3994

      /*SELECT NVL(serial_count_option, 1)
        INTO l_serial_count_option
        FROM mtl_cycle_count_headers
        WHERE cycle_count_header_id = l_cc_header_id
        AND organization_id = l_org_id;
Line: 4018

          UPDATE mtl_serial_numbers
            SET group_mark_id = NULL
            WHERE inventory_item_id = l_inventory_item_id
            AND current_organization_id = l_org_id
            AND serial_number IN
            (SELECT serial_number
             FROM mtl_cc_serial_numbers
             WHERE cycle_count_entry_id = l_cc_entry_id);
Line: 4182

      g_update_flag := 2;
Line: 4183

      g_insert_flag := 2;
Line: 4209

      l_last_updated_by NUMBER := g_cc_entry.last_updated_by;
Line: 4210

      l_last_update_login NUMBER := g_cc_entry.last_update_login;
Line: 4251

               SELECT NVL ( subinventory_code, '###' ),
                      NVL ( locator_id, -99 ),
                      lpn_context
               INTO   l_lpn_subinv,
                      l_lpn_locator_id,
                      l_lpn_context
               FROM   WMS_LICENSE_PLATE_NUMBERS
               WHERE  lpn_id = l_lpn_id ;
Line: 4282

      SELECT primary_uom_code,
             serial_number_control_code
      INTO   l_from_uom,
             l_serial_number_control_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 4290

      SELECT NVL ( serial_count_option, 1 )
      INTO   l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 4317

               SELECT NVL ( SUM ( primary_transaction_quantity ), 0 )
               INTO   l_primary_sys_qty
               FROM   MTL_ONHAND_QUANTITIES_DETAIL
               WHERE  inventory_item_id = l_item_id
               AND    organization_id = l_org_id
               AND    NVL ( containerized_flag, 2 ) = 2
               AND    subinventory_code = l_sub
               AND    NVL ( lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( locator_id, -2 ) = NVL ( l_loc, -2 )
               AND    NVL ( cost_group_id, -9 ) = NVL ( l_cost_group_id, -9 );
Line: 4329

               SELECT NVL ( SUM ( quantity ), 0 )
               INTO   l_loaded_sys_qty
               FROM   WMS_LOADED_QUANTITIES_V
               WHERE  inventory_item_id = l_item_id
               AND    organization_id = l_org_id
               AND    NVL ( containerized_flag, 2 ) = 2
               AND    subinventory_code = l_sub
               AND    NVL ( lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( locator_id, -2 ) = NVL ( l_loc, -2 )
               --Bug# 3071372
               --AND    NVL ( cost_group_id, -9 ) = NVL ( l_cost_group_id, -9 )
               AND    qty_type = 'LOADED'
               AND    lpn_id IS NULL
               AND    content_lpn_id IS NULL;                                                       -- bug 2640378
Line: 4360

               SELECT NVL ( SUM ( primary_transaction_quantity ), 0 )
               INTO   l_primary_sys_qty
               FROM   MTL_ONHAND_QUANTITIES_DETAIL
               WHERE  inventory_item_id = l_item_id
               AND    organization_id = l_org_id
               AND    NVL ( containerized_flag, 2 ) = 2
               AND    subinventory_code = l_sub
               AND    NVL ( lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( locator_id, -2 ) = NVL ( l_loc, -2 );
Line: 4406

            SELECT NVL ( SUM ( DECODE ( msn.current_status, 3, 1, 0 ) ), 0 )
            INTO   l_primary_sys_qty
            FROM   mtl_serial_numbers msn
            WHERE  msn.serial_number = NVL ( l_serial_number, serial_number )
            AND    msn.inventory_item_id = l_item_id
            AND    msn.current_organization_id = l_org_id
            AND    msn.current_subinventory_code = l_sub
            AND    NVL ( msn.lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
            AND    NVL ( msn.revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
            AND    NVL ( msn.current_locator_id, -2 ) = NVL ( l_loc, -2 )
            AND    msn.lpn_id IS NULL
            AND    is_serial_loaded ( l_org_id,
                                      l_item_id,
                                      NVL ( l_serial_number, serial_number ),
                                      NULL
                                    ) = 2;
Line: 4447

               SELECT mtl_cycle_count_entries_s.NEXTVAL
               INTO   l_cycle_count_entry_id
               FROM   DUAL;
Line: 4459

            INSERT INTO MTL_CC_SERIAL_NUMBERS
                        ( CYCLE_COUNT_ENTRY_ID,
                          SERIAL_NUMBER,
                          LAST_UPDATE_DATE,
                          LAST_UPDATED_BY,
                          CREATION_DATE,
                          CREATED_BY,
                          LAST_UPDATE_LOGIN
                        )
               SELECT l_cycle_count_entry_id,
                      SERIAL_NUMBER,
                      SYSDATE,
                      l_last_updated_by,
                      SYSDATE,
                      l_last_updated_by,
                      l_last_update_login
               FROM   mtl_serial_numbers msn
               WHERE  msn.inventory_item_id = l_item_id
               AND    msn.current_organization_id = l_org_id
               AND    msn.current_subinventory_code = l_sub
               AND    NVL ( msn.lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( msn.revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( msn.current_locator_id, -2 ) = NVL ( l_loc, -2 )
               AND    msn.current_status = 3
               AND    NVL ( msn.lpn_id, -99999 ) = NVL ( l_lpn_id, -99999 )
               AND    NOT EXISTS (
                         SELECT 'x'
                         FROM   MTL_CC_SERIAL_NUMBERS
                         WHERE  CYCLE_COUNT_ENTRY_ID = l_cycle_count_entry_id
                         AND    SERIAL_NUMBER = msn.SERIAL_NUMBER );
Line: 4544

      l_last_updated_by NUMBER := g_cc_entry.last_updated_by;
Line: 4545

      l_last_update_login NUMBER := g_cc_entry.last_update_login;
Line: 4580

               SELECT NVL ( subinventory_code, '###' ),
                      NVL ( locator_id, -99 ),
                      lpn_context
               INTO   l_lpn_subinv,
                      l_lpn_locator_id,
                      l_lpn_context
               FROM   WMS_LICENSE_PLATE_NUMBERS
               WHERE  lpn_id = l_lpn_id ;
Line: 4611

      SELECT primary_uom_code,
             serial_number_control_code
      INTO   l_from_uom,
             l_serial_number_control_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 4619

      SELECT NVL ( serial_count_option, 1 )
      INTO   l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 4646

               SELECT NVL ( SUM ( primary_transaction_quantity ), 0 )
                      , NVL ( SUM ( secondary_transaction_quantity ), 0 ) -- nsinghi bug#6052831
               INTO   l_primary_sys_qty
                      , l_secondary_sys_qty  -- nsinghi bug#6052831
               FROM   MTL_ONHAND_QUANTITIES_DETAIL
               WHERE  inventory_item_id = l_item_id
               AND    organization_id = l_org_id
               AND    NVL ( containerized_flag, 2 ) = 2
               AND    subinventory_code = l_sub
               AND    NVL ( lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( locator_id, -2 ) = NVL ( l_loc, -2 )
               AND    NVL ( cost_group_id, -9 ) = NVL ( l_cost_group_id, -9 );
Line: 4660

               SELECT NVL ( SUM ( quantity ), 0 )
                      , NVL ( SUM ( secondary_quantity ), 0 ) -- nsinghi bug#6052831
               INTO   l_loaded_sys_qty
                      , l_loaded_sec_sys_qty -- nsinghi bug#6052831
               FROM   WMS_LOADED_QUANTITIES_V
               WHERE  inventory_item_id = l_item_id
               AND    organization_id = l_org_id
               AND    NVL ( containerized_flag, 2 ) = 2
               AND    subinventory_code = l_sub
               AND    NVL ( lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( locator_id, -2 ) = NVL ( l_loc, -2 )
               --Bug# 3071372
               --AND    NVL ( cost_group_id, -9 ) = NVL ( l_cost_group_id, -9 )
               AND    qty_type = 'LOADED'
               AND    lpn_id IS NULL
               AND    content_lpn_id IS NULL;                                                       -- bug 2640378
Line: 4693

               SELECT NVL ( SUM ( primary_transaction_quantity ), 0 )
                      , NVL ( SUM ( secondary_transaction_quantity ), 0 ) -- nsinghi bug#6052831
               INTO   l_primary_sys_qty
                      , l_secondary_sys_qty  -- nsinghi bug#6052831
               FROM   MTL_ONHAND_QUANTITIES_DETAIL
               WHERE  inventory_item_id = l_item_id
               AND    organization_id = l_org_id
               AND    NVL ( containerized_flag, 2 ) = 2
               AND    subinventory_code = l_sub
               AND    NVL ( lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( locator_id, -2 ) = NVL ( l_loc, -2 );
Line: 4742

            SELECT NVL ( SUM ( DECODE ( msn.current_status, 3, 1, 0 ) ), 0 )
            INTO   l_primary_sys_qty
            FROM   mtl_serial_numbers msn
            WHERE  msn.serial_number = NVL ( l_serial_number, serial_number )
            AND    msn.inventory_item_id = l_item_id
            AND    msn.current_organization_id = l_org_id
            AND    msn.current_subinventory_code = l_sub
            AND    NVL ( msn.lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
            AND    NVL ( msn.revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
            AND    NVL ( msn.current_locator_id, -2 ) = NVL ( l_loc, -2 )
            AND    msn.lpn_id IS NULL
            AND    is_serial_loaded ( l_org_id,
                                      l_item_id,
                                      NVL ( l_serial_number, serial_number ),
                                      NULL
                                    ) = 2;
Line: 4783

               SELECT mtl_cycle_count_entries_s.NEXTVAL
               INTO   l_cycle_count_entry_id
               FROM   DUAL;
Line: 4795

            INSERT INTO MTL_CC_SERIAL_NUMBERS
                        ( CYCLE_COUNT_ENTRY_ID,
                          SERIAL_NUMBER,
                          LAST_UPDATE_DATE,
                          LAST_UPDATED_BY,
                          CREATION_DATE,
                          CREATED_BY,
                          LAST_UPDATE_LOGIN
                        )
               SELECT l_cycle_count_entry_id,
                      SERIAL_NUMBER,
                      SYSDATE,
                      l_last_updated_by,
                      SYSDATE,
                      l_last_updated_by,
                      l_last_update_login
               FROM   mtl_serial_numbers msn
               WHERE  msn.inventory_item_id = l_item_id
               AND    msn.current_organization_id = l_org_id
               AND    msn.current_subinventory_code = l_sub
               AND    NVL ( msn.lot_number, 'XX' ) = NVL ( l_lot, 'XX' )
               AND    NVL ( msn.revision, 'XXX' ) = NVL ( l_rev, 'XXX' )
               AND    NVL ( msn.current_locator_id, -2 ) = NVL ( l_loc, -2 )
               AND    msn.current_status = 3
               AND    NVL ( msn.lpn_id, -99999 ) = NVL ( l_lpn_id, -99999 )
               AND    NOT EXISTS (
                         SELECT 'x'
                         FROM   MTL_CC_SERIAL_NUMBERS
                         WHERE  CYCLE_COUNT_ENTRY_ID = l_cycle_count_entry_id
                         AND    SERIAL_NUMBER = msn.SERIAL_NUMBER );
Line: 4896

      SELECT primary_uom_code
      INTO   l_to_uom
      FROM   MTL_SYSTEM_ITEMS
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 4982

         SELECT NVL ( ccicv.item_cost, 0 )
         INTO   l_item_cost
         FROM   cst_cg_item_costs_view ccicv,
                mtl_parameters mp
         WHERE  l_locator_id IS NULL
         AND    ccicv.organization_id = in_org_id
         AND    ccicv.inventory_item_id = in_item_id
         AND    ccicv.organization_id = mp.organization_id
         /* Bug 5555367 - Modified the condition
         AND    ccicv.cost_group_id =
                   DECODE ( mp.primary_cost_method,
                            1, 1,
                            NVL ( l_cost_group_id, 1 )
                          )
         */
         AND     ccicv.cost_group_id =
                      DECODE ( mp.primary_cost_method,
                               1, 1,
                               NVL ( l_cost_group_id, mp.default_cost_group_id)
                             )
         UNION ALL
         SELECT NVL ( ccicv.item_cost, 0 )
         FROM   mtl_item_locations mil,
                cst_cg_item_costs_view ccicv,
                mtl_parameters mp
         WHERE  l_locator_id IS NOT NULL
         AND    mil.organization_id = in_org_id
         AND    mil.inventory_location_id = l_locator_id
         AND    mil.project_id IS NULL
         AND    ccicv.organization_id = mil.organization_id
         AND    ccicv.inventory_item_id = in_item_id
         AND    ccicv.organization_id = mp.organization_id
         /* Bug 5555367 - Modified the condition
         AND    ccicv.cost_group_id =
                   DECODE ( mp.primary_cost_method,
                            1, 1,
                            NVL ( l_cost_group_id, 1 )
                          )
         */
         AND     ccicv.cost_group_id =
                      DECODE ( mp.primary_cost_method,
                               1, 1,
                               NVL ( l_cost_group_id, mp.default_cost_group_id)
                             )
         UNION ALL
         SELECT NVL ( ccicv.item_cost, 0 )
         FROM   mtl_item_locations mil,
                mrp_project_parameters mrp,
                cst_cg_item_costs_view ccicv,
                mtl_parameters mp
         WHERE  l_locator_id IS NOT NULL
         AND    mil.organization_id = in_org_id
         AND    mil.inventory_location_id = l_locator_id
         AND    mil.project_id IS NOT NULL
         AND    mrp.organization_id = mil.organization_id
         AND    mrp.project_id = mil.project_id
         AND    ccicv.organization_id = mil.organization_id
         AND    ccicv.inventory_item_id = in_item_id
         AND    ccicv.organization_id = mp.organization_id
         AND    ccicv.cost_group_id =
                   DECODE ( mp.primary_cost_method,
                            1, 1,
                            NVL (  mrp.costing_group_id, 1 )
                          );
Line: 5084

            SELECT lot_control_code
            INTO   l_lot_control_code
            FROM   mtl_system_items
            WHERE  organization_id = p_organization_id
            AND    inventory_item_id = p_inventory_item_id;
Line: 5092

               SELECT COUNT ( * )
               INTO   l_serial_count
               FROM   mtl_serial_numbers_temp s,
                      wms_loaded_quantities_v wl
               WHERE  s.transaction_temp_id = wl.transaction_temp_id
               AND    p_serial_number BETWEEN s.fm_serial_number
                                          AND s.to_serial_number;
Line: 5108

               SELECT COUNT ( * )
               INTO   l_serial_count
               FROM   mtl_serial_numbers_temp s,
                      wms_loaded_quantities_v wl,
                      mtl_transaction_lots_temp l
               WHERE  wl.transaction_temp_id = l.transaction_temp_id
               AND    s.transaction_temp_id = l.serial_transaction_temp_id
               AND    p_serial_number BETWEEN fm_serial_number
                                          AND to_serial_number;
Line: 5127

            SELECT COUNT ( * )
            INTO   l_serial_count
            FROM   mtl_serial_numbers s,
                   wms_loaded_quantities_v wl
            WHERE  s.lpn_id = p_lpn_id
            AND    NVL ( wl.content_lpn_id, NVL ( wl.lpn_id, -1 ) ) = s.lpn_id
            AND    s.serial_number = p_serial_number
            AND    s.current_organization_id = p_organization_id
            AND    s.inventory_item_id = p_inventory_item_id;
Line: 5162

      l_last_updated_by NUMBER := g_cc_entry.last_updated_by;
Line: 5163

      l_last_update_login NUMBER := g_cc_entry.last_update_login;
Line: 5180

      SELECT NVL ( serial_count_option, 1 ),
             NVL ( serial_detail_option, 1 )
      INTO   l_serial_count_option,
             l_serial_detail_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 5189

      SELECT serial_number_control_code
      INTO   l_serial_number_control_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 5215

               SELECT   MIN ( NVL ( number_of_counts, 0 ) )
               INTO     l_number_of_counts
               FROM     mtl_cc_serial_numbers
               WHERE    cycle_count_entry_id = l_cycle_count_entry_id
               GROUP BY cycle_count_entry_id;
Line: 5252

               SELECT   MIN ( number_of_counts )
               INTO     l_number_of_counts
               FROM     mtl_cc_serial_numbers
               WHERE    cycle_count_entry_id = l_cycle_count_entry_id
               GROUP BY cycle_count_entry_id;
Line: 5307

      SELECT    NVL ( serial_count_option, 1 ),
                NVL ( serial_adjustment_option, 2 ),
                NVL ( automatic_recount_flag, 2 ),
                NVL ( maximum_auto_recounts, 0 ),
                NVL ( days_until_late , 0 ),
                --Bug 6978840
                NVL ( approval_option_code , 3)
      INTO   l_serial_count_option,
             l_serial_adjustment_option,
             l_automatic_recount_flag,
             l_maximum_auto_recounts,
             l_days_until_late,
             l_approval_option_code
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 5328

         SELECT COUNT ( * )
         INTO   l_count
         FROM   MTL_CC_SERIAL_NUMBERS
         WHERE  serial_number = l_serial_number
         AND    cycle_count_entry_id = l_cycle_count_entry_id;
Line: 5451

               final_preupdate_logic ( );
Line: 5472

               final_preupdate_logic ( );
Line: 5488

            final_preupdate_logic ( );
Line: 5498

   /* Deletes the serial info from mtl_cc_Serial_numbers in case of an Issue transaction */
   PROCEDURE delete_Serial_entry(p_serial_number IN VARCHAR2, p_cc_header_id IN NUMBER, p_cycle_count_entry_id IN NUMBER) IS
   BEGIN

      DELETE FROM mtl_cc_Serial_numbers
       WHERE serial_number = p_serial_number
         AND cycle_count_entry_id IN
            (SELECT cycle_count_entry_id
               FROM mtl_cycle_count_entries
              WHERE cycle_Count_header_id =   p_cc_header_id
                AND entry_status_code IN (1,3))
                   AND cycle_count_entry_id <> p_cycle_Count_entry_id;
Line: 5513

         print_debug('Exception while trying to delete serial number ' || g_cc_Serial_entry.serial_number);
Line: 5514

   END delete_serial_entry;
Line: 5555

      SELECT NVL ( serial_count_option, 1 ),
             NVL ( serial_adjustment_option, 2 ),
             NVL ( automatic_recount_flag, 2 ),
             NVL ( maximum_auto_recounts, 0 ),
             NVL ( days_until_late , 0 ),
             --Bug 6978840
             NVL ( approval_option_code , 3)
      INTO   l_serial_count_option,
             l_serial_adjustment_option,
             l_automatic_recount_flag,
             l_maximum_auto_recounts,
             l_days_until_late,
             l_approval_option_code
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 5627

            SELECT NVL ( SUM ( DECODE ( msn.current_status, 3, 1, 0 ) ), 0 )
            INTO   l_multiple_count
            FROM   mtl_serial_numbers msn
            WHERE  msn.serial_number = g_cc_serial_entry.serial_number
            AND    msn.inventory_item_id = g_cc_entry.inventory_item_id
            AND    msn.current_organization_id = g_cc_entry.organization_id
            AND    msn.current_subinventory_code = g_cc_entry.subinventory
            AND    NVL ( msn.lot_number, 'XX' ) =
                                           NVL ( g_cc_entry.lot_number, 'XX' )
            AND    NVL ( msn.revision, 'XXX' ) =
                                            NVL ( g_cc_entry.revision, 'XXX' )
            AND    NVL ( msn.current_locator_id, -2 ) =
                                              NVL ( g_cc_entry.locator_id, -2 )
            AND    msn.lpn_id IS NULL --Bug# 3646068
            AND    is_serial_loaded ( g_cc_entry.organization_id,
                                      g_cc_entry.inventory_item_id,
                                      g_cc_serial_entry.serial_number,
                                      NULL
                                    ) = 2;
Line: 5652

            SELECT NVL ( SUM ( DECODE ( msn.current_status, 3, 1, 0 ) ), 0 )
            INTO   l_multiple_count
            FROM   mtl_serial_numbers msn
            WHERE  msn.serial_number = g_cc_serial_entry.serial_number
            AND    msn.inventory_item_id = g_cc_entry.inventory_item_id
            AND    msn.current_organization_id = g_cc_entry.organization_id
            AND    NVL ( msn.lot_number, 'XX' ) =
                                           NVL ( g_cc_entry.lot_number, 'XX' )
            AND    NVL ( msn.revision, 'XXX' ) =
                                            NVL ( g_cc_entry.revision, 'XXX' )
            AND    msn.lpn_id = g_cc_entry.parent_lpn_id
            AND    is_serial_loaded ( g_cc_entry.organization_id,
                                      g_cc_entry.inventory_item_id,
                                      g_cc_serial_entry.serial_number,
                                      g_cc_entry.parent_lpn_id
                                    ) = 2;
Line: 5705

      SELECT primary_uom_code
      INTO   l_primary_uom
      FROM   MTL_SYSTEM_ITEMS
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 5935

               final_preupdate_logic ( );
Line: 5961

               final_preupdate_logic ( );
Line: 5993

               final_preupdate_logic ( );
Line: 6019

               final_preupdate_logic ( );
Line: 6032

            final_preupdate_logic ( );
Line: 6092

      SELECT NVL ( serial_count_option, 1 ),
             NVL ( serial_detail_option, 1 ),
             NVL ( serial_discrepancy_option, 2 )
      INTO   l_serial_count_option,
             l_serial_detail,
             l_serial_discrepancy
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 6103

      SELECT serial_number_control_code
      INTO   l_serial_number_control_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 6119

            SELECT SERIAL_NUMBER_TYPE
            INTO   l_serial_number_type
            FROM   MTL_PARAMETERS
            WHERE  ORGANIZATION_ID = l_org_id;
Line: 6162

            SELECT CURRENT_SUBINVENTORY_CODE,
                   NVL ( CURRENT_LOCATOR_ID, 0 )
            INTO   l_msn_subinv,
                   l_msn_locator_id
            FROM   MTL_SERIAL_NUMBERS
            WHERE  SERIAL_NUMBER = u1
            AND    INVENTORY_ITEM_ID = g_cc_entry.inventory_item_id
            AND    CURRENT_ORGANIZATION_ID = g_cc_entry.organization_id;
Line: 6230

               SELECT 1,
                      current_status
               INTO   serial_count,
                      l_current_status
               FROM   MTL_SERIAL_NUMBERS
               WHERE  SERIAL_NUMBER = l_serial_number
               AND    INVENTORY_ITEM_ID = l_item_id
               AND    CURRENT_ORGANIZATION_ID = l_org_id
               AND    CURRENT_STATUS IN ( 1, 3 );
Line: 6405

      SELECT primary_uom_code
      INTO   l_to_uom
      FROM   MTL_SYSTEM_ITEMS
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 6412

      SELECT NVL ( inventory_adjustment_account, -1 )
      INTO   l_txn_acct_id
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 6418

      SELECT concatenated_segments
      INTO   l_item_name
      FROM   mtl_system_items_kfv
      WHERE  inventory_item_id = l_item_id AND organization_id = l_org_id;
Line: 6460

            SELECT mtl_material_transactions_s.NEXTVAL
            INTO   l_txn_header_id
            FROM   DUAL;
Line: 6467

         SELECT mtl_material_transactions_s.NEXTVAL
         INTO   l_txn_temp_id
         FROM   DUAL;
Line: 6471

         SELECT auto_serial_alpha_prefix
         INTO   l_serial_prefix
         FROM   mtl_system_items
         WHERE  inventory_item_id = l_item_id AND organization_id = l_org_id;
Line: 6487

         delete_reservation ( );
Line: 6491

         SELECT negative_inv_receipt_code
         INTO   l_neg_inv_rcpt_code --Negative Balance  1:Allowed   2:Disallowed
         FROM   mtl_parameters
         WHERE  organization_id = l_org_id;
Line: 6508

            SELECT serial_number_control_code,
                   lot_control_code,
                   revision_qty_control_code
            INTO   v_ser_code,
                   v_lot_code,
                   v_rev_code
            FROM   mtl_system_items
            WHERE  inventory_item_id = l_item_id
                   AND organization_id = l_org_id;
Line: 6607

            inv_quantity_tree_pub.update_quantities ( p_api_version_number => 1.0,
                                                      p_init_msg_lst      => 'F',
                                                      x_return_status     => x_return_status,
                                                      x_msg_count         => l_msg_count,
                                                      x_msg_data          => l_msg_data,
                                                      p_organization_id   => l_org_id,
                                                      p_inventory_item_id => l_item_id,
                                                      p_tree_mode         => 1,
                                                      p_is_revision_control => v_is_rev_controlled,
                                                      p_is_lot_control    => v_is_lot_controlled,
                                                      p_is_serial_control => v_is_ser_controlled,
                                                      p_demand_source_type_id => NULL,
                                                      p_revision          => l_rev,
                                                      p_lot_number        => l_lot_num,
                                                      p_subinventory_code => l_sub,
                                                      p_locator_id        => l_locator_id,
                                                      p_onhand_source     => 3,
                                                      p_containerized     => 0,
                                                      p_primary_quantity  => ABS ( l_adjustment_quantity
                                                                                 ),
                                                      p_quantity_type     => 5,
                                                      x_qoh               => x_qoh,
                                                      x_rqoh              => l_rqoh,
                                                      x_qr                => l_qr,
                                                      x_qs                => l_qs,
                                                      x_att               => x_att,
                                                      x_atr               => l_atr,
                                                      p_lpn_id            => NULL --added for lpn reservation
                                                    );
Line: 6640

         SELECT NVL ( REVISION, 'XXX' ),
                NVL ( LOT_NUMBER, 'X' ),
                CURRENT_STATUS,
                CURRENT_SUBINVENTORY_CODE,
                NVL ( CURRENT_LOCATOR_ID, 0 ),
                NVL ( LPN_ID, -99 )
         INTO   l_msn_revision,
                l_msn_lot_number,
                l_current_status,
                l_msn_subinv,
                l_msn_locator_id,
                l_msn_lpn_id
         FROM   MTL_SERIAL_NUMBERS
         WHERE  SERIAL_NUMBER = l_serial_number
         AND    INVENTORY_ITEM_ID = g_cc_entry.inventory_item_id
         AND    CURRENT_ORGANIZATION_ID = g_cc_entry.organization_id;
Line: 6757

               print_debug('Calling delete_Serial_entry 1');
Line: 6760

            delete_serial_entry(l_serial_number,l_cc_header_id,l_cycle_count_entry_id); --3595723 Delete the serial info from mtl_cc_Serial_numbers
Line: 6785

            SELECT mtl_material_transactions_s.NEXTVAL
            INTO   l_txn_temp_id
            FROM   DUAL;
Line: 6800

               print_debug('Calling delete_Serial_entry 2');
Line: 6802

            delete_serial_entry(l_serial_number,l_cc_header_id,l_cycle_count_entry_id); --3595723 Delete the serial info from mtl_cc_Serial_numbers
Line: 6923

   PROCEDURE update_serial_row
   IS
      l_debug   NUMBER := NVL ( FND_PROFILE.VALUE ( 'INV_DEBUG_TRACE' ), 0 );
Line: 6928

         print_debug ( '***update_serial_row***' );
Line: 6932

      g_cc_serial_entry.last_update_date := SYSDATE;
Line: 6933

      g_cc_serial_entry.last_updated_by := g_user_id;
Line: 6934

      g_cc_serial_entry.last_update_login := g_login_id;
Line: 6936

      UPDATE MTL_CC_SERIAL_NUMBERS
      SET last_update_date = g_cc_serial_entry.last_update_date,
          last_updated_by = g_cc_serial_entry.last_updated_by,
          last_update_login = g_cc_serial_entry.last_update_login,
          number_of_counts = g_cc_serial_entry.number_of_counts,
          unit_status_current = g_cc_serial_entry.unit_status_current,
          unit_status_prior = g_cc_serial_entry.unit_status_prior,
          unit_status_first = g_cc_serial_entry.unit_status_first,
          approval_condition = g_cc_serial_entry.approval_condition,
          pos_adjustment_qty = g_cc_serial_entry.pos_adjustment_qty,
          neg_adjustment_qty = g_cc_serial_entry.neg_adjustment_qty
      WHERE  cycle_count_entry_id = g_cc_entry.cycle_count_entry_id
      AND    (     ( serial_number = g_cc_serial_entry.serial_number )
               OR (     serial_number IS NULL
                    AND g_cc_serial_entry.serial_number IS NULL
                  )
             );
Line: 6957

   END update_serial_row;
Line: 6978

      SELECT serial_number_control_code
      INTO   l_serial_number_ctrl_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 6984

      SELECT NVL ( serial_count_option, 1 )
      INTO   l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 7083

      SELECT serial_number_control_code
      INTO   l_serial_number_ctrl_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 7089

      SELECT NVL ( serial_count_option, 1 )
      INTO   l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 7095

      SELECT NVL ( serial_number, '@@@@@' ),
             inventory_item_id
      INTO   l_current_serial,
             l_current_item
      FROM   mtl_cycle_count_entries
      WHERE  cycle_count_entry_id = cycle_cnt_entry_id;
Line: 7207

         SELECT mec.full_name,
                fus.employee_id
         INTO   l_employee_full_name,
                l_employee_id
         FROM   mtl_employees_current_view mec,
                fnd_user fus
         WHERE  fus.user_id = l_user_id
         AND    mec.employee_id = fus.employee_id
         AND    mec.organization_id = l_org_id;
Line: 7220

            SELECT fus.employee_id
            INTO   l_employee_id
            FROM   fnd_user fus
            WHERE  fus.user_id = l_user_id;
Line: 7251

         SELECT     *
         FROM       WMS_LICENSE_PLATE_NUMBERS
         START WITH lpn_id = p_parent_lpn_id
         CONNECT BY parent_lpn_id = PRIOR lpn_id;
Line: 7258

         SELECT *
         FROM   WMS_LPN_CONTENTS
         WHERE  parent_lpn_id = l_current_lpn
         AND    NVL ( serial_summary_entry, 2 ) = 2;
Line: 7265

         SELECT *
         FROM   MTL_SERIAL_NUMBERS
         WHERE  lpn_id = l_current_lpn;
Line: 7271

         SELECT *
         FROM   WMS_LPN_CONTENTS
         WHERE  parent_lpn_id = l_current_lpn AND serial_summary_entry = 1;
Line: 7278

            SELECT NVL ( SUM ( quantity ), 0 )
            FROM   WMS_LOADED_QUANTITIES_V WLQV
            WHERE  WLQV.inventory_item_id = p_inventory_item_id
            AND    WLQV.organization_id = p_organization_id
            AND    (lpn_id = p_lpn_id OR content_lpn_id = p_lpn_id )
            AND    qty_type = 'LOADED';
Line: 7299

      SELECT NVL ( serial_count_option, 1 )
      INTO   l_serial_count_option
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = p_cycle_count_header_id
      AND    organization_id = p_organization_id;
Line: 7319

            SELECT COUNT ( * )
            INTO   l_temp_count
            FROM   mtl_cycle_count_items
            WHERE  inventory_item_id = v_lpn_id.inventory_item_id
            AND    cycle_count_header_id = p_cycle_count_header_id;
Line: 7327

               SELECT primary_uom_code
               INTO   l_temp_uom_code
               FROM   mtl_system_items
               WHERE  inventory_item_id = v_lpn_id.inventory_item_id
               AND    organization_id = v_lpn_id.organization_id;
Line: 7361

            SELECT COUNT ( * )
            INTO   l_temp_count
            FROM   mtl_cycle_count_items
            WHERE  inventory_item_id = v_lpn_content.inventory_item_id
            AND    cycle_count_header_id = p_cycle_count_header_id;
Line: 7413

               SELECT COUNT ( * )
               INTO   l_temp_count
               FROM   mtl_cycle_count_items
               WHERE  inventory_item_id =
                                        v_lpn_serial_content.inventory_item_id
               AND    cycle_count_header_id = p_cycle_count_header_id;
Line: 7422

                  SELECT primary_uom_code
                  INTO   l_temp_uom_code
                  FROM   mtl_system_items
                  WHERE  inventory_item_id =
                                        v_lpn_serial_content.inventory_item_id
                  AND    organization_id =
                                  v_lpn_serial_content.current_organization_id;
Line: 7443

                       SELECT
                              lpn_context
                       INTO   l_lpn_context
                       FROM   WMS_LICENSE_PLATE_NUMBERS
                       WHERE  lpn_id = p_parent_lpn_id ;
Line: 7486

               SELECT COUNT ( * )
               INTO   l_temp_count
               FROM   mtl_cycle_count_items
               WHERE  inventory_item_id =
                                       v_lpn_multiple_serial.inventory_item_id
               AND    cycle_count_header_id = p_cycle_count_header_id;
Line: 7706

         SELECT default_cost_group_id
         INTO   l_default_cost_group_id
         FROM   mtl_secondary_inventories
         WHERE  organization_id = p_organization_id
         AND    secondary_inventory_name = p_subinventory;
Line: 7718

         SELECT NVL ( default_cost_group_id, -999 )
         INTO   l_default_cost_group_id
         FROM   mtl_parameters
         WHERE  organization_id = p_organization_id;
Line: 7748

         SELECT NVL ( cost_group_id, -999 )
         INTO   l_cost_group_id
         FROM   mtl_serial_numbers
         WHERE  serial_number = p_serial_number
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    NVL ( lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
         AND    current_organization_id = p_organization_id
         --AND current_subinventory_code = p_subinventory
         --AND NVL(current_locator_id, -99999) = NVL(p_locator_id, -99999)
         AND    NVL ( lpn_id, -99999 ) = NVL ( p_parent_lpn_id, -99999 );
Line: 7761

         SELECT DISTINCT NVL ( cost_group_id, -999 ) --bug3687177
         INTO   l_cost_group_id
         FROM   wms_lpn_contents
         WHERE  parent_lpn_id = p_parent_lpn_id
         AND    organization_id = p_organization_id
         AND    inventory_item_id = p_inventory_item_id
         AND    NVL ( revision, '@@@@@' ) = NVL ( p_revision, '@@@@@' )
         AND    NVL ( lot_number, '@@@@@' ) = NVL ( p_lot_number, '@@@@@' )
         AND    NVL ( serial_summary_entry, 2 ) = 2;
Line: 7777

         SELECT DISTINCT NVL ( cost_group_id, -999 )
         INTO            l_cost_group_id
         FROM            MTL_ONHAND_QUANTITIES_DETAIL
         WHERE           inventory_item_id = p_inventory_item_id
         AND             NVL ( revision, '@@@@@' ) =
                                                   NVL ( p_revision, '@@@@@' )
         AND             NVL ( lot_number, '@@@@@' ) =
                                                 NVL ( p_lot_number, '@@@@@' )
         AND             organization_id = p_organization_id
         AND             subinventory_code = p_subinventory
         AND             NVL ( locator_id, -99999 ) =
                                                   NVL ( p_locator_id, -99999 )
         AND             NVL ( containerized_flag, 2 ) = 2;
Line: 7819

         SELECT *
         FROM   mtl_cc_serial_numbers
         WHERE  cycle_count_entry_id = g_cc_entry.cycle_count_entry_id;
Line: 7870

         SELECT group_mark_id
         INTO   l_group_mark_id
         FROM   mtl_serial_numbers
         WHERE  serial_number = g_cc_serial_entry.serial_number
         AND    current_organization_id = g_cc_entry.organization_id
         AND    inventory_item_id = g_cc_entry.inventory_item_id;
Line: 7941

      SELECT primary_uom_code
      INTO   g_count_uom
      FROM   mtl_system_items
      WHERE  inventory_item_id = g_cc_entry.inventory_item_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 7949

      SELECT NVL ( serial_adjustment_option, 2 ), NVL ( automatic_recount_flag, 2 ),
             NVL ( maximum_auto_recounts, 0 ), NVL ( days_until_late , 0 ),
             --Bug 6978840
             NVL( approval_option_code , 3)
      INTO   l_serial_adjustment_option, l_automatic_recount_flag, l_maximum_auto_recounts, l_days_until_late, l_approval_option_code
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id;
Line: 8021

         SELECT group_mark_id
         INTO   l_group_mark_id
         FROM   mtl_serial_numbers
         WHERE  serial_number = g_cc_serial_entry.serial_number
         AND    current_organization_id = g_cc_entry.organization_id
         AND    inventory_item_id = g_cc_entry.inventory_item_id;
Line: 8085

            update_serial_row ( );
Line: 8102

            update_serial_row ( );
Line: 8118

            UPDATE mtl_serial_numbers
            SET group_mark_id = NULL
            WHERE  serial_number = g_cc_serial_entry.serial_number
            AND    current_organization_id = g_cc_entry.organization_id
            AND    inventory_item_id = g_cc_entry.inventory_item_id;
Line: 8174

      SELECT NVL ( approval_option_code, 1 )
      INTO   l_approval_option_code
      FROM   mtl_cycle_count_headers
      WHERE  cycle_count_header_id = g_cc_entry.cycle_count_header_id
      AND    organization_id = g_cc_entry.organization_id;
Line: 8299

      SELECT COUNT ( * )
      INTO   x_count
      FROM   mtl_cycle_count_entries
      WHERE  cycle_count_header_id = p_cycle_count_header_id
      AND    entry_status_code IN ( 1, 3 )
      AND    NVL ( export_flag, 2 ) = 2;
Line: 8310

   PROCEDURE insert_dynamic_lot (
      p_api_version IN NUMBER,
      p_init_msg_list IN VARCHAR2,
      p_commit    IN VARCHAR2,
      p_validation_level IN NUMBER,
      p_inventory_item_id IN NUMBER,
      p_organization_id IN NUMBER,
      p_lot_number IN VARCHAR2,
      p_expiration_date IN OUT NOCOPY DATE,
      p_transaction_temp_id IN NUMBER,
      p_transaction_action_id IN NUMBER,
      p_transfer_organization_id IN NUMBER,
      p_status_id IN NUMBER,
      p_update_status IN VARCHAR2,
      x_object_id OUT NOCOPY NUMBER,
      x_return_status OUT NOCOPY VARCHAR2,
      x_msg_count OUT NOCOPY NUMBER,
      x_msg_data  OUT NOCOPY VARCHAR2
   )
   IS
      l_debug   NUMBER := NVL ( FND_PROFILE.VALUE ( 'INV_DEBUG_TRACE' ), 0 );
Line: 8336

         print_debug ( '***Calling insert_dynamic_lot***' );
Line: 8340

         print_debug ( 'Calling insertlot' );
Line: 8343

      inv_lot_api_pub.insertlot ( p_api_version       => p_api_version,
                                  p_init_msg_list     => p_init_msg_list,
                                  p_commit            => p_commit,
                                  p_validation_level  => p_validation_level,
                                  p_inventory_item_id => p_inventory_item_id,
                                  p_organization_id   => p_organization_id,
                                  p_lot_number        => p_lot_number,
                                  p_expiration_date   => p_expiration_date,
                                  p_transaction_temp_id => p_transaction_temp_id,
                                  p_transaction_action_id => p_transaction_action_id,
                                  p_transfer_organization_id => p_transfer_organization_id,
                                  x_object_id         => x_object_id,
                                  x_return_status     => x_return_status,
                                  x_msg_count         => x_msg_count,
                                  x_msg_data          => x_msg_data
                                );
Line: 8362

            print_debug ( 'insertLot was not called successfully' );
Line: 8369

         print_debug ( 'insertLot was called successfully' );
Line: 8373

           AND ( p_update_status = 'TRUE' )
         ) THEN
         IF ( l_debug = 1 ) THEN
            print_debug ( 'Update the status of the new lot' );
Line: 8379

         inv_material_status_grp.update_status ( p_api_version_number => p_api_version,
                                                 p_init_msg_lst      => NULL,
                                                 x_return_status     => x_return_status,
                                                 x_msg_count         => x_msg_count,
                                                 x_msg_data          => x_msg_data,
                                                 p_update_method     => inv_material_status_pub.g_update_method_receive,
                                                 p_status_id         => p_status_id,
                                                 p_organization_id   => p_organization_id,
                                                 p_inventory_item_id => p_inventory_item_id,
                                                 p_sub_code          => NULL,
                                                 p_locator_id        => NULL,
                                                 p_lot_number        => p_lot_number,
                                                 p_serial_number     => NULL,
                                                 p_to_serial_number  => NULL,
                                                 p_object_type       => 'O'
                                               );
Line: 8398

               print_debug ( 'update_status was not called successfully' );
Line: 8404

   END insert_dynamic_lot;
Line: 8406

   PROCEDURE update_serial_status (
      p_api_version IN NUMBER,
      p_init_msg_list IN VARCHAR2,
      p_commit    IN VARCHAR2,
      p_validation_level IN NUMBER,
      p_inventory_item_id IN NUMBER,
      p_organization_id IN NUMBER,
      p_from_serial_number IN VARCHAR2,
      p_to_serial_number IN VARCHAR2,
      p_current_status IN NUMBER,
      p_serial_status_id IN NUMBER,
      p_update_serial_status IN VARCHAR2,
      p_lot_number IN VARCHAR2,
      x_return_status OUT NOCOPY VARCHAR2,
      x_msg_count OUT NOCOPY NUMBER,
      x_msg_data  OUT NOCOPY VARCHAR2
   )
   IS
      l_from_ser_number NUMBER;
Line: 8437

         print_debug (    'Enter update_serial_status: 10:'
                       || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                     );
Line: 8444

      SAVEPOINT count_update_serial_sp;
Line: 8475

         UPDATE mtl_serial_numbers
         SET previous_status = current_status,
             current_status = p_current_status,
             lot_number = p_lot_number,
             current_organization_id = p_organization_id
         WHERE  serial_number = l_cur_serial_number
         AND    inventory_item_id = p_inventory_item_id;
Line: 8485

         IF p_update_serial_status = 'TRUE' THEN
            l_progress  := '70';
Line: 8487

            inv_material_status_grp.update_status ( p_api_version_number => p_api_version,
                                                    p_init_msg_lst      => NULL,
                                                    x_return_status     => x_return_status,
                                                    x_msg_count         => x_msg_count,
                                                    x_msg_data          => x_msg_data,
                                                    p_update_method     => inv_material_status_pub.g_update_method_receive,
                                                    p_status_id         => p_serial_status_id,
                                                    p_organization_id   => p_organization_id,
                                                    p_inventory_item_id => p_inventory_item_id,
                                                    p_sub_code          => NULL,
                                                    p_locator_id        => NULL,
                                                    p_lot_number        => p_lot_number,
                                                    p_serial_number     => l_cur_serial_number,
                                                    p_to_serial_number  => NULL,
                                                    p_object_type       => 'S'
                                                  );
Line: 8525

         print_debug (    'Exit update_serial_status 110:'
                       || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                     );
Line: 8531

         ROLLBACK TO count_update_serial_sp;
Line: 8535

            print_debug (    'Exitting update_serial_status - execution error:'
                          || l_progress
                          || ' '
                          || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                        );
Line: 8548

         ROLLBACK TO count_update_serial_sp;
Line: 8552

            print_debug (    'Exitting update_serial_status - unexpected error:'
                          || l_progress
                          || ' '
                          || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                        );
Line: 8565

         ROLLBACK TO count_update_serial_sp;
Line: 8569

            print_debug (    'Exitting update_serial_status - other exceptions:'
                          || l_progress
                          || ' '
                          || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                        );
Line: 8577

            inv_mobile_helper_functions.sql_error ( 'INV_RCV_COMMON_APIS.update_serial_status',
                                                    l_progress,
                                                    SQLCODE
                                                  );
Line: 8584

            fnd_msg_pub.add_exc_msg ( g_pkg_name, 'update_serial_status' );
Line: 8592

   END update_serial_status;
Line: 8595

   PROCEDURE insert_range_serial (
      p_api_version IN NUMBER,
      p_init_msg_list IN VARCHAR2,
      p_commit    IN VARCHAR2,
      p_validation_level IN NUMBER,
      p_inventory_item_id IN NUMBER,
      p_organization_id IN NUMBER,
      p_from_serial_number IN VARCHAR2,
      p_to_serial_number IN VARCHAR2,
      p_revision  IN VARCHAR2,
      p_lot_number IN VARCHAR2,
      p_current_status IN NUMBER,
      p_serial_status_id IN NUMBER,
      p_update_serial_status IN VARCHAR2,
      x_return_status OUT NOCOPY VARCHAR2,
      x_msg_count OUT NOCOPY NUMBER,
      x_msg_data  OUT NOCOPY VARCHAR2
   )
   IS
      l_object_id NUMBER;
Line: 8620

         print_debug (    'Enter insert_range_serial: 10:'
                       || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                     );
Line: 8627

      SAVEPOINT count_insert_range_serial_sp;
Line: 8629

      inv_serial_number_pub.insert_range_serial ( p_api_version       => p_api_version,
                                                  p_init_msg_list     => p_init_msg_list,
                                                  p_commit            => p_commit,
                                                  p_validation_level  => p_validation_level,
                                                  p_inventory_item_id => p_inventory_item_id,
                                                  p_organization_id   => p_organization_id,
                                                  p_from_serial_number => p_from_serial_number,
                                                  p_to_serial_number  => p_to_serial_number,
                                                  p_initialization_date => SYSDATE,
                                                  p_completion_date   => NULL,
                                                  p_ship_date         => NULL,
                                                  p_revision          => p_revision,
                                                  p_lot_number        => p_lot_number,
                                                  p_current_locator_id => NULL,
                                                  p_subinventory_code => NULL,
                                                  p_trx_src_id        => NULL,
                                                  p_unit_vendor_id    => NULL,
                                                  p_vendor_lot_number => NULL,
                                                  p_vendor_serial_number => NULL,
                                                  p_receipt_issue_type => NULL,
                                                  p_txn_src_id        => NULL,
                                                  p_txn_src_name      => NULL,
                                                  p_txn_src_type_id   => NULL,
                                                  p_transaction_id    => NULL,
                                                  p_current_status    => p_current_status,
                                                  p_parent_item_id    => NULL,
                                                  p_parent_serial_number => NULL,
                                                  p_cost_group_id     => NULL,
                                                  p_transaction_action_id => NULL,
                                                  p_transaction_temp_id => NULL,
                                                  p_status_id         => NULL,
                                                  p_inspection_status => NULL,
                                                  x_object_id         => l_object_id,
                                                  x_return_status     => x_return_status,
                                                  x_msg_count         => x_msg_count,
                                                  x_msg_data          => x_msg_data
                                                );
Line: 8675

      IF p_update_serial_status = 'TRUE' THEN
         l_progress  := '40';
Line: 8677

         inv_material_status_grp.update_status ( p_api_version_number => p_api_version,
                                                 p_init_msg_lst      => NULL,
                                                 x_return_status     => x_return_status,
                                                 x_msg_count         => x_msg_count,
                                                 x_msg_data          => x_msg_data,
                                                 p_update_method     => inv_material_status_pub.g_update_method_receive,
                                                 p_status_id         => p_serial_status_id,
                                                 p_organization_id   => p_organization_id,
                                                 p_inventory_item_id => p_inventory_item_id,
                                                 p_sub_code          => NULL,
                                                 p_locator_id        => NULL,
                                                 p_lot_number        => p_lot_number,
                                                 p_serial_number     => p_from_serial_number,
                                                 p_to_serial_number  => p_to_serial_number,
                                                 p_object_type       => 'S'
                                               );
Line: 8712

         print_debug (    'Exit insert_range_serial 90:'
                       || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                     );
Line: 8718

         ROLLBACK TO count_insert_range_serial_sp;
Line: 8722

            print_debug (    'Exitting insert_range_serial - execution error:'
                          || l_progress
                          || ' '
                          || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                        );
Line: 8735

         ROLLBACK TO count_insert_range_serial_sp;
Line: 8738

            print_debug (    'Exitting insert_range_serial - unexpected error:'
                          || l_progress
                          || ' '
                          || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                        );
Line: 8752

         ROLLBACK TO count_insert_range_serial_sp;
Line: 8755

            print_debug (    'Exitting insert_range_serial - other exceptions:'
                          || l_progress
                          || ' '
                          || TO_CHAR ( SYSDATE, 'YYYY-MM-DD HH:DD:SS' )
                        );
Line: 8765

            inv_mobile_helper_functions.sql_error ( 'INV_RCV_COMMON_APIS.insert_range_serial',
                                                    l_progress,
                                                    SQLCODE
                                                  );
Line: 8772

            fnd_msg_pub.add_exc_msg ( g_pkg_name, 'insert_range_serial' );
Line: 8780

   END insert_range_serial;
Line: 8823

               SELECT NVL ( subinventory_code, '###' ),
                      NVL ( locator_id, -99 ),
                      lpn_context
               INTO   l_lpn_subinv,
                      l_lpn_locator_id,
                      l_lpn_context
               FROM   WMS_LICENSE_PLATE_NUMBERS
               WHERE  lpn_id = p_parent_lpn_id ;
Line: 8850

      SELECT primary_uom_code,
             serial_number_control_code
      INTO   l_primary_uom,
             l_serial_number_control_code
      FROM   mtl_system_items
      WHERE  inventory_item_id = p_inventory_item_id
      AND    organization_id = p_organization_id;
Line: 8870

            SELECT NVL ( SUM ( primary_transaction_quantity ), 0 )
            INTO   x_system_quantity
            FROM   MTL_ONHAND_QUANTITIES_DETAIL
            WHERE  inventory_item_id = p_inventory_item_id
            AND    organization_id = p_organization_id
            AND    NVL ( containerized_flag, 2 ) = 2
            AND    subinventory_code = p_subinventory
            AND    NVL ( locator_id, -99 ) = NVL ( p_locator_id, -99 )
            AND    (    NVL ( lot_number, 'XX' ) = NVL ( p_lot_number, 'XX' )
                     OR p_lot_number IS NULL
                   ) -- Lot number might not have been entered yet
            AND    NVL ( revision, 'XXX' ) = NVL ( p_revision, 'XXX' );
Line: 8883

            SELECT NVL ( SUM ( quantity ), 0 )
            INTO   l_loaded_sys_qty
            FROM   WMS_LOADED_QUANTITIES_V
            WHERE  inventory_item_id = p_inventory_item_id
            AND    organization_id = p_organization_id
            AND    NVL ( containerized_flag, 2 ) = 2
            AND    subinventory_code = p_subinventory
            AND    NVL ( locator_id, -99 ) = NVL ( p_locator_id, -99 )
            AND    (    NVL ( lot_number, 'XX' ) = NVL ( p_lot_number, 'XX' )
                     OR p_lot_number IS NULL
                   )
            -- Lot number might not have been entered yet
            AND    NVL ( revision, 'XXX' ) = NVL ( p_revision, 'XXX' )
            AND    qty_type = 'LOADED'
            AND    lpn_id IS NULL
            AND    content_lpn_id IS NULL; -- bug 2640378
Line: 8914

               SELECT nvl(sum(primary_quantity),0)   --BUG3026540
               INTO   x_system_quantity
               FROM   WMS_LPN_CONTENTS
               WHERE  parent_lpn_id = p_parent_lpn_id
               AND    organization_id = p_organization_id
               AND    inventory_item_id = p_inventory_item_id
               AND    (    NVL ( lot_number, 'XX' ) =
                                                    NVL ( p_lot_number, 'XX' )
                        OR p_lot_number IS NULL
                      )
               -- Lot number might not have been entered yet
               AND    NVL ( revision, 'XXX' ) = NVL ( p_revision, 'XXX' )
               AND    NVL ( serial_summary_entry, 2 ) = 2;
Line: 8928

               SELECT NVL ( SUM ( quantity ), 0 )
               INTO   l_loaded_sys_qty
               FROM   wms_loaded_quantities_v
               WHERE  NVL ( lpn_id, NVL ( content_lpn_id, -1 ) ) = p_parent_lpn_id
               and    inventory_item_id = p_inventory_item_id
               and    organization_id = p_organization_id;
Line: 8955

            SELECT NVL ( SUM ( DECODE ( current_status, 3, 1, 0 ) ), 0 )
            INTO   x_system_quantity
            FROM   mtl_serial_numbers
            WHERE  lpn_id IS NULL
            AND    inventory_item_id = p_inventory_item_id
            AND    current_organization_id = p_organization_id
            AND    current_subinventory_code = p_subinventory
            AND    NVL ( current_locator_id, -99 ) = NVL ( p_locator_id, -99 )
            AND    (    NVL ( lot_number, 'XX' ) = NVL ( p_lot_number, 'XX' )
                     OR p_lot_number IS NULL
                   )
            -- Lot number might not have been entered yet
            AND    NVL ( revision, 'XXX' ) = NVL ( p_revision, 'XXX' );
Line: 8969

            select count(*)
            into   l_loaded_sys_qty
                           from   mtl_serial_numbers_temp msnt, wms_loaded_quantities_v wl
                           where  ((msnt.transaction_temp_id = wl.transaction_temp_id
                     and wl.lot_number is null) or
                                   (msnt.transaction_temp_id = wl.serial_transaction_temp_id
                     and wl.lot_number is not null)
                                       )
            and    wl.containerized_flag = 2
                           and    wl.inventory_item_id = p_inventory_item_id
                           and    wl.subinventory_code = p_subinventory
                           and    nvl(wl.locator_id,-99) = nvl(p_locator_id,-99)
            and    (nvl(wl.lot_number,'@@@') = nvl(p_lot_number,'@@@')
                    or p_lot_number is null)
            and    nvl(wl.revision,'##') = nvl(p_revision,'##');
Line: 8993

            SELECT COUNT ( * )
            INTO   x_system_quantity
            FROM   mtl_serial_numbers
            WHERE  lpn_id = p_parent_lpn_id
            AND    inventory_item_id = p_inventory_item_id
            AND    current_organization_id = p_organization_id
            AND    (    NVL ( lot_number, 'XX' ) = NVL ( p_lot_number, 'XX' )
                     OR p_lot_number IS NULL
                   )
            -- Lot number might not have been entered yet
            AND    NVL ( revision, 'XXX' ) = NVL ( p_revision, 'XXX' );
Line: 9005

            select distinct wl.quantity
            into   l_loaded_sys_qty
                      from   mtl_serial_numbers msn, wms_loaded_quantities_v wl
                           where  msn.lpn_id = nvl(wl.content_lpn_id,nvl(wl.lpn_id,-1))
                           and   wl.containerized_flag = 1
                      and    msn.inventory_item_id = wl.inventory_item_id
                      and    msn.current_organization_id = wl.ORGANIZATION_ID
                      and    wl.inventory_item_id = p_inventory_item_id
                           and    wl.organization_id = p_organization_id
                           and    msn.lpn_id = p_parent_lpn_id
            and    (nvl(msn.lot_number,'@@@') = nvl(wl.lot_number,'@@@') or
                   p_lot_number is null)
            AND    NVL ( wl.revision, 'XXX' ) = NVL ( p_revision, 'XXX' );
Line: 9058

         SELECT wdt.transaction_temp_id
         FROM   wms_dispatched_tasks wdt
         WHERE  wdt.person_id = l_employee_id
         AND    wdt.task_type = 3
         AND    NOT EXISTS (
                   SELECT 'ACTIVE_TASK'
                   FROM   wms_dispatchable_tasks_v
                   WHERE  wms_task_type_id = 3
                   AND    task_id = wdt.transaction_temp_id );
Line: 9079

      SELECT DISTINCT NVL ( person_id, -999 )
      INTO            l_employee_id
      FROM            wms_dispatched_tasks_history
      WHERE           transaction_id = p_transaction_temp_id AND task_type = 3;
Line: 9110

            print_debug ( 'Inserting record into tasks history table' );
Line: 9113

         INSERT INTO WMS_DISPATCHED_TASKS_HISTORY
                     ( task_id,
                       transaction_id,
                       organization_id,
                       user_task_type,
                       person_id,
                       effective_start_date,
                       effective_end_date,
                       equipment_id,
                       equipment_instance,
                       person_resource_id,
                       machine_resource_id,
                       status,
                       dispatched_time,
                       loaded_time,
                       drop_off_time,
                       last_update_date,
                       last_updated_by,
                       creation_date,
                       created_by,
                       last_update_login,
                       attribute_category,
                       attribute1,
                       attribute2,
                       attribute3,
                       attribute4,
                       attribute5,
                       attribute6,
                       attribute7,
                       attribute8,
                       attribute9,
                       attribute10,
                       attribute11,
                       attribute12,
                       attribute13,
                       attribute14,
                       attribute15,
                       task_type,
                       priority,
                       task_group_id
                     )
            SELECT task_id,
                   transaction_temp_id,
                   organization_id,
                   user_task_type,
                   person_id,
                   effective_start_date,
                   effective_end_date,
                   equipment_id,
                   equipment_instance,
                   person_resource_id,
                   machine_resource_id,
                   6,
                   dispatched_time,
                   loaded_time,
                   drop_off_time,
                   last_update_date,
                   last_updated_by,
                   creation_date,
                   created_by,
                   last_update_login,
                   attribute_category,
                   attribute1,
                   attribute2,
                   attribute3,
                   attribute4,
                   attribute5,
                   attribute6,
                   attribute7,
                   attribute8,
                   attribute9,
                   attribute10,
                   attribute11,
                   attribute12,
                   attribute13,
                   attribute14,
                   attribute15,
                   task_type,
                   priority,
                   task_group_id
            FROM   WMS_DISPATCHED_TASKS
            WHERE  TRANSACTION_TEMP_ID = l_task_temp_id AND TASK_TYPE = 3;
Line: 9204

         DELETE FROM WMS_DISPATCHED_TASKS
         WHERE       TRANSACTION_TEMP_ID = l_task_temp_id AND TASK_TYPE = 3;