DBA Data[Home] [Help]

APPS.INV_MO_CANCEL_PVT SQL Statements

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

Line: 23

    * 1. Undetailed reservations are deleted.
    * 2. Detailed reservations are delinked from the allocations.
    * 3. Allocation is deleted for a WMS Organization.
    * 4. Move Order Line is updated.
    * For more info... see the documentation given in the Spec.
    */
  PROCEDURE cancel_move_order_line
  ( x_return_status         OUT NOCOPY   VARCHAR2
  , x_msg_count             OUT NOCOPY   NUMBER
  , x_msg_data              OUT NOCOPY   VARCHAR2
  , p_line_id               IN           NUMBER
  , p_delete_reservations   IN           VARCHAR2
  , p_txn_source_line_id    IN           NUMBER    DEFAULT NULL
  , p_delete_alloc          IN           VARCHAR2  DEFAULT NULL -- ER3969328: CI project
  , p_delivery_detail_id    IN           NUMBER    DEFAULT NULL -- Planned Crossdocking project
  ) IS

    l_line_status               NUMBER;
Line: 46

    l_quantity_to_delete        NUMBER;
Line: 47

    l_deleted_quantity          NUMBER;
Line: 48

    l_max_delete_quantity       NUMBER;
Line: 54

    l_delete_reservations       VARCHAR2(1);
Line: 59

    l_update_rec                inv_reservation_global.mtl_reservation_rec_type;
Line: 68

    l_sec_quantity_to_delete    NUMBER;        --INVCONV
Line: 69

    l_max_delete_sec_quantity   NUMBER;        --INVCONV
Line: 70

    l_sec_deleted_quantity      NUMBER;        --INVCONV
Line: 96

      SELECT quantity
           , NVL(quantity_detailed, 0)
           , secondary_quantity
           , NVL(secondary_quantity_detailed,0)
           , organization_id
           , txn_source_line_id
        FROM mtl_txn_request_lines
       WHERE line_id = p_line_id
         FOR UPDATE NOWAIT;
Line: 107

      SELECT mr.reservation_id
        FROM mtl_reservations  mr
       WHERE mr.demand_source_type_id   IN (2, 8)
         AND nvl(mr.staged_flag,'N')    <> 'Y'
         AND demand_source_line_detail  IS NULL
         AND mr.demand_source_line_id = l_txn_source_line_id
         AND mr.primary_reservation_quantity > NVL(mr.detailed_quantity, 0);
Line: 116

      SELECT mmtt.transaction_temp_id
           , ABS(mmtt.primary_quantity)
           , ABS(mmtt.secondary_transaction_quantity) --INVCONV
           , mmtt.reservation_id
           , mmtt.parent_line_id
        FROM mtl_material_transactions_temp mmtt
       WHERE mmtt.move_order_line_id = p_line_id
         AND NOT EXISTS (SELECT 1 FROM mtl_material_transactions_temp t
                          WHERE t.parent_line_id = mmtt.transaction_temp_id)
       ORDER BY mmtt.transaction_quantity ASC
         FOR UPDATE NOWAIT;
Line: 129

      SELECT status
        FROM wms_dispatched_tasks
       WHERE (l_parent_line_id IS NULL AND transaction_temp_id = l_transaction_temp_id)
          OR (l_parent_line_id IS NOT NULL AND transaction_temp_id = l_parent_line_id);
Line: 136

     SELECT sum(primary_reservation_quantity),
            sum(secondary_reservation_quantity)
     FROM mtl_reservations
     WHERE reservation_id IN (SELECT DISTINCT reservation_id
                            FROM mtl_material_transactions_temp
                            WHERE move_order_line_id = p_line_id);
Line: 144

     SELECT sum(requested_quantity), sum(requested_quantity2)--INVCONV
     FROM wsh_delivery_details
     WHERE move_order_line_id = p_line_id
     AND released_status ='S';
Line: 155

     SELECT mmtt.transaction_temp_id
     FROM mtl_material_transactions_temp mmtt
     WHERE mmtt.move_order_line_id = p_line_id
     AND nvl(mmtt.transaction_status,1) = 2
     FOR UPDATE NOWAIT;
Line: 164

      SELECT mr.reservation_id
        FROM mtl_reservations  mr
       WHERE mr.demand_source_line_detail = p_wdd_id
         AND mr.demand_source_type_id    IN (2,8)
         AND NVL(mr.crossdock_flag,'N')   = 'Y'
         FOR UPDATE NOWAIT;
Line: 181

             || ', p_delete_reservations: ' ||  p_delete_reservations
             || ', p_txn_source_line_id: '  ||  to_char(p_txn_source_line_id)
             || ', p_delete_alloc: '        ||  p_delete_alloc
             || ', p_delivery_detail_id: '  ||  to_char(p_delivery_detail_id)
           ,'CANCEL_MOVE_ORDER_LINE');
Line: 189

    l_deleted_quantity     := 0;
Line: 193

    l_sec_deleted_quantity := 0;
Line: 205

          SELECT NVL(mtrh.move_order_type,0)
            INTO l_move_order_type
            FROM mtl_txn_request_lines    mtrl
               , mtl_txn_request_headers  mtrh
           WHERE mtrl.line_id   = p_line_id
             AND mtrh.header_id = mtrl.header_id;
Line: 269

          IF p_delete_reservations IS NULL OR p_delete_reservations <> 'Y'
          THEN
             l_delete_reservations  := 'N';
Line: 273

             l_delete_reservations  := 'Y';
Line: 277

             DEBUG('Delete Reservations (Y/N) = '
                    || l_delete_reservations, 'CANCEL_MOVE_ORDER_LINE');
Line: 281

          IF l_delete_reservations = 'Y' AND l_quantity > l_quantity_detailed
          THEN
          -- {
             l_quantity_to_delete      := l_quantity - l_quantity_detailed;
Line: 285

             l_sec_quantity_to_delete  := l_sec_quantity - l_sec_quantity_detailed;  --INVCONV
Line: 288

                      || l_quantity_to_delete, 'Cancel_Move_Order_Line');
Line: 290

                      || l_sec_quantity_to_delete, 'Cancel_Move_Order_Line');
Line: 309

                EXIT WHEN l_quantity_to_delete <= 0;
Line: 359

                l_update_rec := l_rsv_tbl(1);
Line: 360

                l_update_rec.reservation_quantity := NULL;
Line: 364

                l_max_delete_quantity
                  := l_update_rec.primary_reservation_quantity
                     - l_update_rec.detailed_quantity;
Line: 367

                l_max_delete_sec_quantity
                  := l_update_rec.secondary_reservation_quantity
                     - l_update_rec.secondary_detailed_quantity; --INVCONV
Line: 371

                IF l_max_delete_quantity > l_quantity_to_delete
                THEN
                   l_update_rec.primary_reservation_quantity
                     := l_update_rec.primary_reservation_quantity - l_quantity_to_delete;
Line: 375

                   l_quantity_to_delete := 0;
Line: 376

                   l_update_rec.secondary_reservation_quantity
                     := l_update_rec.secondary_reservation_quantity
                        - l_sec_quantity_to_delete; --INVCONV
Line: 379

                   l_sec_quantity_to_delete := 0; --INVCONV
Line: 381

                   l_quantity_to_delete
                     := l_quantity_to_delete - l_max_delete_quantity;
Line: 383

                   l_update_rec.primary_reservation_quantity
                     := l_update_rec.primary_reservation_quantity - l_max_delete_quantity;
Line: 385

                   l_sec_quantity_to_delete
                     := l_quantity_to_delete - l_max_delete_quantity; --INVCONV
Line: 387

                   l_update_rec.secondary_reservation_quantity
                     := l_update_rec.secondary_reservation_quantity
                        - l_max_delete_sec_quantity; --INVCONV
Line: 394

                          || l_update_rec.primary_reservation_quantity
                        ,'CANCEL_MOVE_ORDER_LINE');
Line: 397

                          || l_update_rec.secondary_reservation_quantity
                        ,'CANCEL_MOVE_ORDER_LINE');
Line: 403

                IF (l_update_rec.secondary_uom_code IS NULL)
                THEN
                   l_update_rec.secondary_reservation_quantity := NULL;
Line: 406

                   l_update_rec.secondary_detailed_quantity    := NULL;
Line: 410

                inv_reservation_pub.update_reservation
                ( p_api_version_number     => 1.0
                , p_init_msg_lst           => fnd_api.g_false
                , x_return_status          => l_api_return_status
                , x_msg_count              => x_msg_count
                , x_msg_data               => x_msg_data
                , p_original_rsv_rec       => l_rsv_tbl(1)
                , p_to_rsv_rec             => l_update_rec
                , p_original_serial_number => l_dummy_sn
                , p_to_serial_number       => l_dummy_sn
                , p_validation_flag        => fnd_api.g_true
                );
Line: 425

                      DEBUG('update_reservation returned success'
                           ,'CANCEL_MOVE_ORDER_LINE');
Line: 430

                      DEBUG('Error: Update Reservations return status: '
                             || l_api_return_status, 'CANCEL_MOVE_ORDER_LINE');
Line: 434

                   fnd_message.set_name('INV','INV_UPDATE_RSV_FAILED');
Line: 466

                      ||' requested quantity then need to delete'
                    ,'CANCEL_MOVE_ORDER_LINE');
Line: 511

                    DEBUG('The extra reserved quantity that needs to be deleted'
                           || l_extra_rsv_quantity,'CANCEL_MOVE_ORDER_LINE');
Line: 514

                    DEBUG('The extra reserved quantity2 that needs to be deleted'
                           || l_extra_rsv_quantity2,'CANCEL_MOVE_ORDER_LINE');
Line: 598

                l_update_rec              := l_rsv_tbl(1);
Line: 601

                IF l_update_rec.detailed_quantity > l_primary_quantity
                THEN
                   l_update_rec.detailed_quantity
                     := l_update_rec.detailed_quantity - l_primary_quantity;
Line: 606

                   l_update_rec.secondary_detailed_quantity
                     := l_update_rec.secondary_detailed_quantity - l_secondary_quantity;
Line: 609

                   l_update_rec.detailed_quantity  := 0;
Line: 611

                   l_update_rec.secondary_detailed_quantity  := 0;
Line: 615

                    DEBUG('New Detailed Qty = ' || l_update_rec.detailed_quantity
                         ,'CANCEL_MOVE_ORDER_LINE');
Line: 618

                    DEBUG('New Detailed Qty1 = ' || l_update_rec.secondary_detailed_quantity
                         ,'CANCEL_MOVE_ORDER_LINE');
Line: 623

                IF l_delete_reservations = 'Y' OR l_extra_rsv_quantity > 0
                THEN
                -- {
                  l_update_rec.reservation_quantity  := NULL;
Line: 628

                  l_update_rec.secondary_reservation_quantity  := NULL;
Line: 630

                  IF l_update_rec.primary_reservation_quantity > l_primary_quantity
                  THEN
                    l_update_rec.primary_reservation_quantity
                      := l_update_rec.primary_reservation_quantity - l_primary_quantity;
Line: 635

                    l_update_rec.secondary_reservation_quantity
                      := l_update_rec.secondary_reservation_quantity - l_secondary_quantity;
Line: 652

                  ELSIF (l_delete_reservations ='N'
                         AND
                         (l_update_rec.primary_reservation_quantity >= l_extra_rsv_quantity))
                  THEN
                    IF (l_debug=1) THEN
                       DEBUG('need to reduce reservation quantity only for the extra qty'
                              || l_extra_rsv_quantity,'CANCEL_MOVE_ORDER_LINE');
Line: 660

                       l_update_rec.primary_reservation_quantity
                         := l_update_rec.primary_reservation_quantity - l_extra_rsv_quantity;
Line: 664

                       l_update_rec.secondary_reservation_quantity
                         := l_update_rec.secondary_reservation_quantity - l_extra_rsv_quantity2;
Line: 670

                                 || l_update_rec.primary_reservation_quantity
                               ,'CANCEL_MOVE_ORDER_LINE');
Line: 676

                         l_extra_rsv_quantity >= l_update_rec.primary_reservation_quantity)
                     THEN
                        l_extra_rsv_quantity
                          := l_extra_rsv_quantity - l_update_rec.primary_reservation_quantity;
Line: 682

                          := l_extra_rsv_quantity2 - l_update_rec.secondary_reservation_quantity;
Line: 693

                               || l_update_rec.primary_reservation_quantity
                             ,'CANCEL_MOVE_ORDER_LINE');
Line: 699

                               || l_update_rec.secondary_reservation_quantity
                              ,'CANCEL_MOVE_ORDER_LINE');
Line: 703

                     l_update_rec.primary_reservation_quantity := 0;
Line: 705

                     l_update_rec.secondary_reservation_quantity  := 0;
Line: 710

                            || l_update_rec.primary_reservation_quantity
                          ,'Cancel_Move_Order_Line');
Line: 713

                            || l_update_rec.secondary_reservation_quantity
                          ,'Cancel_Move_Order_Line');
Line: 717

                END IF; -- delete reservations
Line: 720

                IF ( l_update_rec.secondary_uom_code IS NULL )
                THEN
                   l_update_rec.secondary_reservation_quantity := NULL;
Line: 723

                   l_update_rec.secondary_detailed_quantity    := NULL;
Line: 728

                inv_reservation_pub.update_reservation
                ( p_api_version_number         => 1.0
                , p_init_msg_lst               => fnd_api.g_false
                , x_return_status              => l_api_return_status
                , x_msg_count                  => x_msg_count
                , x_msg_data                   => x_msg_data
                , p_original_rsv_rec           => l_rsv_tbl(1)
                , p_to_rsv_rec                 => l_update_rec
                , p_original_serial_number     => l_dummy_sn
                , p_to_serial_number           => l_dummy_sn
                , p_validation_flag            => fnd_api.g_true
                , p_over_reservation_flag      => 2  -- Bug 5158514
                );
Line: 744

                      DEBUG('update_reservation returned success'
                           ,'CANCEL_MOVE_ORDER_LINE');
Line: 749

                      DEBUG('Error: Update Reservations returned '
                             || l_api_return_status, 'CANCEL_MOVE_ORDER_LINE');
Line: 753

                   fnd_message.set_name('INV','INV_UPDATE_RSV_FAILED');
Line: 773

                   l_deleted_quantity := l_deleted_quantity + l_primary_quantity;
Line: 775

                   l_sec_deleted_quantity := l_sec_deleted_quantity + l_secondary_quantity;
Line: 778

                   inv_trx_util_pub.delete_transaction
                   ( x_return_status       => l_api_return_status
                   , x_msg_data            => x_msg_data
                   , x_msg_count           => x_msg_count
                   , p_transaction_temp_id => l_transaction_temp_id
                   );
Line: 787

                         DEBUG('delete_transaction returned success'
                              ,'CANCEL_MOVE_ORDER_LINE');
Line: 792

                         DEBUG('Error: delete_transaction return status: '
                               || l_api_return_status
                              ,'CANCEL_MOVE_ORDER_LINE');
Line: 796

                      fnd_message.set_name('INV','INV_DELETE_TXN_FAILED');
Line: 818

          UPDATE mtl_material_transactions_temp
             SET reservation_id = NULL
           WHERE move_order_line_id = p_line_id;
Line: 824

          IF l_deleted_quantity >= l_quantity
          THEN
             l_quantity     := 0;
Line: 831

             l_quantity     := l_quantity - l_deleted_quantity;
Line: 834

             l_sec_quantity := l_sec_quantity - l_sec_deleted_quantity;
Line: 848

          UPDATE mtl_txn_request_lines
             SET quantity           = l_quantity
               , required_quantity  = 0
               , line_status        = l_line_status
               , secondary_quantity = l_sec_quantity
               , secondary_required_quantity
                                    = decode(l_sec_quantity, NULL, NULL, 0)
           WHERE line_id = p_line_id;
Line: 866

          IF p_delete_alloc IS NULL
          THEN
             IF g_auto_del_alloc is null
             THEN
                select NVL(auto_del_alloc_flag,'N')
                  into g_auto_del_alloc
                  from mtl_parameters
                 where organization_id = l_org_id;
Line: 877

             l_alloc_flag := p_delete_alloc;
Line: 884

          select count(*)
            into l_count_alloc
            from mtl_material_transactions_temp
           where move_order_line_id = p_line_id;
Line: 900

                 inv_mo_line_detail_util.delete_allocations
                 ( x_return_status       => l_api_return_status
                 , x_msg_data            => x_msg_count
                 , x_msg_count           => x_msg_data
                 , p_mo_line_id          => p_line_id
                 , p_transaction_temp_id => c_mmtt_rec.transaction_temp_id
                 );
Line: 909

                       DEBUG('delete_allocations returned success'
                            ,'Cancel_Move_Order_Line');
Line: 915

                       DEBUG('Error: delete_allocations return status: '
                              || l_api_return_status
                            ,'Cancel_Move_Order_Line');
Line: 930

                update mtl_txn_request_lines
                   set line_status = 5
                 where line_id = p_line_id;
Line: 947

             SELECT 'x'
               INTO l_dummy
               FROM mtl_txn_request_lines  mtrl
              WHERE mtrl.line_id = p_line_id
                FOR UPDATE NOWAIT;
Line: 1020

       l_xdock_rsv_tbl.DELETE;
Line: 1054

             DEBUG('About to delete reservation ID: '
                    || to_char(l_rsv_rec.reservation_id)
                  ,'CANCEL_MOVE_ORDER_LINE');
Line: 1060

          inv_reservation_pub.delete_reservation
          ( p_api_version_number => 1.0
          , p_init_msg_lst       => fnd_api.g_false
          , x_return_status      => l_api_return_status
          , x_msg_count          => x_msg_count
          , x_msg_data           => x_msg_data
          , p_rsv_rec            => l_rsv_rec
          , p_serial_number      => l_serial_tbl
          );
Line: 1073

                DEBUG('inv_reservation_pub.delete_reservation returned success'
                     ,'CANCEL_MOVE_ORDER_LINE');
Line: 1079

                DEBUG('inv_reservation_pub.delete_reservation returned an error status: '
                       || l_api_return_status, 'CANCEL_MOVE_ORDER_LINE');
Line: 1098

       l_xdock_rsv_tbl.DELETE;
Line: 1195

    l_deleted_quantity          NUMBER;
Line: 1201

    l_update_rec                inv_reservation_global.mtl_reservation_rec_type;
Line: 1206

    l_quantity_to_delete        NUMBER;
Line: 1207

    l_sec_quantity_to_delete    NUMBER; --INVCONV
Line: 1208

    l_sec_deleted_quantity      NUMBER; --INVCONV
Line: 1213

    l_max_delete_sec_quantity   NUMBER; --INVCONV
Line: 1214

    l_sec_qty_to_delete         NUMBER; --INVCONV
Line: 1215

    l_max_delete_quantity       NUMBER;
Line: 1222

    l_prim_quantity_to_delete   NUMBER;
Line: 1240

     'secnodary_required_quantity' are also selected.*/
    CURSOR c_line_info IS
      SELECT quantity
            ,NVL(required_quantity, quantity)
            , NVL(quantity_detailed, 0)
	    , secondary_quantity
            , NVL(secondary_required_quantity, secondary_quantity) --INVCONV
            , secondary_quantity_detailed        --INVCONV
            , organization_id
            , inventory_item_id
            , uom_code
            , txn_source_line_id
        FROM mtl_txn_request_lines
       WHERE line_id = p_line_id
         FOR UPDATE;
Line: 1257

      SELECT primary_uom_code
        FROM mtl_system_items
       WHERE organization_id = l_organization_id
         AND inventory_item_id = l_inventory_item_id;
Line: 1265

      SELECT source_line_id
      FROM wsh_delivery_details
      WHERE move_order_line_id IS NOT NULL
        AND move_order_line_id = p_line_id
	AND released_status = 'S';
Line: 1272

      SELECT mr.reservation_id
        FROM mtl_reservations  mr
       WHERE mr.demand_source_type_id  IN (2,8)
         AND NVL(mr.staged_flag,'N')   <> 'Y'
         AND mr.demand_source_line_id   = l_txn_source_line_id
         AND mr.demand_source_line_detail IS NULL
         AND mr.primary_reservation_quantity > NVL(mr.detailed_quantity, 0);
Line: 1281

      SELECT mmtt.transaction_temp_id
           , ABS(mmtt.transaction_quantity)
           , ABS(mmtt.secondary_transaction_quantity)
           , ABS(mmtt.primary_quantity)
           , mmtt.reservation_id
        FROM mtl_material_transactions_temp mmtt
       WHERE mmtt.move_order_line_id = p_line_id
         AND NOT EXISTS( SELECT 'Y'
                           FROM wms_dispatched_tasks wdt
                          WHERE wdt.transaction_temp_id
                                = nvl( mmtt.parent_line_id
                                     , mmtt.transaction_temp_id
                                     )
                       )
       ORDER BY mmtt.transaction_quantity ASC;
Line: 1300

      SELECT mr.reservation_id
        FROM mtl_reservations  mr
       WHERE mr.demand_source_line_detail = p_wdd_id
         AND mr.demand_source_type_id    IN (2,8)
         AND NVL(mr.crossdock_flag,'N')   = 'Y'
         FOR UPDATE NOWAIT;
Line: 1310

      SELECT wdd.delivery_detail_id
           , wdd.requested_quantity
           , wdd.requested_quantity_uom
           , wdd.requested_quantity2
           , wdd.requested_quantity_uom2
        FROM wsh_delivery_details  wdd
       WHERE wdd.delivery_detail_id = p_wdd_id
         FOR UPDATE NOWAIT;
Line: 1344

    l_deleted_quantity       := 0;
Line: 1345

    l_sec_deleted_quantity   := 0; --INVCONV
Line: 1357

          SELECT NVL(mtrh.move_order_type,0)
            INTO l_move_order_type
            FROM mtl_txn_request_lines    mtrl
               , mtl_txn_request_headers  mtrh
           WHERE mtrl.line_id   = p_line_id
             AND mtrh.header_id = mtrl.header_id;
Line: 1447

          , p_delete_reservations => 'Y'
          , p_txn_source_line_id  => p_txn_source_line_id
          );
Line: 1467

          l_quantity_to_delete := l_quantity - l_quantity_detailed;
Line: 1468

          l_sec_quantity_to_delete := l_sec_quantity
                                        - l_sec_quantity_detailed; --INVCONV
Line: 1470

          IF l_reduction_quantity < l_quantity_to_delete
          THEN
             l_quantity_to_delete     := l_reduction_quantity;
Line: 1473

             l_sec_quantity_to_delete := l_sec_reduction_quantity; --INVCONV
Line: 1477

             l_reduction_quantity     := l_reduction_quantity - l_quantity_to_delete;
Line: 1479

                                           - l_sec_quantity_to_delete; --INVCONV
Line: 1484

            DEBUG('l_quantity_to_delete :  ' || l_quantity_to_delete, 'Reduce_Move_Order_Quantity');
Line: 1486

          l_quantity := l_quantity - l_quantity_to_delete; /*Bug#5095840*/
Line: 1504

             l_prim_quantity_to_delete := inv_convert.inv_um_convert
                                          ( l_inventory_item_id
                                          , NULL
                                          , l_quantity_to_delete
                                          , l_mo_uom_code
                                          , l_primary_uom_code
                                          , NULL
                                          , NULL
                                          );
Line: 1513

             IF (l_prim_quantity_to_delete = -99999)
             THEN
                IF (l_debug = 1) THEN
                   DEBUG('Cannot convert uom to primary uom', 'Reduce_Move_Order_Quantity');
Line: 1526

             l_prim_quantity_to_delete := l_quantity_to_delete;
Line: 1529

          l_sec_qty_to_delete := l_sec_quantity_to_delete; --INVCONV
Line: 1532

            DEBUG('l_prim_quantity_to_delete: ' || l_prim_quantity_to_delete, 'Reduce_Move_Order_Quantity');
Line: 1556

             EXIT WHEN l_prim_quantity_to_delete <= 0;
Line: 1591

             l_update_rec := l_rsv_tbl(1);
Line: 1592

             l_update_rec.reservation_quantity := NULL;
Line: 1595

             l_update_rec.secondary_reservation_quantity := NULL;
Line: 1596

             l_max_delete_quantity := l_update_rec.primary_reservation_quantity
                                      - l_update_rec.detailed_quantity;
Line: 1598

             l_max_delete_sec_quantity := l_update_rec.secondary_reservation_quantity
                                           - l_update_rec.secondary_detailed_quantity; --INVCONV
Line: 1602

                DEBUG('l_max_delete_quantity::' || l_max_delete_quantity, 'Reduce_Move_Order_Quantity');
Line: 1606

             IF l_max_delete_quantity > l_prim_quantity_to_delete
             THEN
                l_update_rec.primary_reservation_quantity
                  := l_update_rec.primary_reservation_quantity
                       - l_prim_quantity_to_delete;
Line: 1611

                l_prim_quantity_to_delete := 0;
Line: 1612

                l_sec_qty_to_delete       := 0; --INVCONV
Line: 1613

                l_update_rec.secondary_reservation_quantity
                  := l_update_rec.secondary_reservation_quantity
                     - l_sec_quantity_to_delete; --INVCONV
Line: 1617

                l_prim_quantity_to_delete := l_prim_quantity_to_delete
                                             - l_max_delete_quantity;
Line: 1619

                l_update_rec.primary_reservation_quantity
                  := l_update_rec.primary_reservation_quantity
                     - l_max_delete_quantity;
Line: 1622

                l_sec_qty_to_delete := l_sec_qty_to_delete
                                       - l_max_delete_sec_quantity; --INVCONV
Line: 1624

                l_update_rec.secondary_reservation_quantity
                  := l_update_rec.secondary_reservation_quantity
                     - l_max_delete_sec_quantity;  --INVCONV
Line: 1630

             IF ( l_update_rec.secondary_uom_code IS NULL ) THEN
                l_update_rec.secondary_reservation_quantity := NULL;
Line: 1632

                l_update_rec.secondary_detailed_quantity    := NULL;
Line: 1636

               DEBUG('l_update_rec.primary_reservation_quantity::' || l_update_rec.primary_reservation_quantity, 'Reduce_Move_Order_Quantity');
Line: 1637

               DEBUG('l_update_rec.detailed_quantity::' || l_update_rec.detailed_quantity, 'Reduce_Move_Order_Quantity');
Line: 1641

             inv_reservation_pub.update_reservation
             ( p_api_version_number     => 1.0
             , p_init_msg_lst           => fnd_api.g_false
             , x_return_status          => l_return_status
             , x_msg_count              => x_msg_count
             , x_msg_data               => x_msg_data
             , p_original_rsv_rec       => l_rsv_tbl(1)
             , p_to_rsv_rec             => l_update_rec
             , p_original_serial_number => l_dummy_sn
             , p_to_serial_number       => l_dummy_sn
             , p_validation_flag        => fnd_api.g_true
             );
Line: 1656

                   DEBUG('Update reservation returned error'
                        ,'Reduce_Move_Order_Quantity');
Line: 1664

                   DEBUG('Update reservation returned unexpected error'
                        ,'Reduce_Move_Order_Quantity');
Line: 1703

                   l_quantity_to_delete := l_reduction_quantity;
Line: 1704

                   l_sec_quantity_to_delete := l_sec_reduction_quantity; --INVCONV
Line: 1706

                   l_quantity_to_delete := l_task_qty;
Line: 1707

                   l_sec_quantity_to_delete := l_sec_qty; --INVCONV
Line: 1711

                                        - l_quantity_to_delete;
Line: 1713

                                            - l_sec_quantity_to_delete; --INVCONV
Line: 1717

                  DEBUG('l_quantity_to_delete: ' || l_quantity_to_delete, 'Reduce_Move_Order_Quantity');
Line: 1726

                , p_quantity_to_delete     => l_quantity_to_delete
                , p_sec_quantity_to_delete => l_sec_quantity_to_delete
                );
Line: 1730

                l_deleted_quantity := l_deleted_quantity
                                      + l_quantity_to_delete;
Line: 1732

                l_sec_deleted_quantity := l_sec_deleted_quantity
                                          + l_sec_quantity_to_delete; --INCONV
Line: 1736

                  DEBUG('l_deleted_quantity: ' || l_deleted_quantity, 'Reduce_Move_Order_Quantity');
Line: 1756

       l_quantity := l_quantity - l_deleted_quantity;/*Bug#5095840*/
Line: 1757

       l_sec_quantity := l_sec_quantity - l_sec_deleted_quantity; --INVCONV/*Bug#5095840*/
Line: 1778

         DEBUG(' update MTRL with quantity:  ' || l_quantity ||
               ', quantity_detailed: ' || l_quantity_detailed, 'Reduce_Move_Order_Quantity');
Line: 1783

       /*Bug#5095840. Modified the below UPDATE statement to update
         the 'required_quantity' and 'secondary_required_quantity' with
         'l_required_quantity' and 'l_sec_required_quantity' respectively
	 rather than with NULL. Also updation of 'quantity_detailed' is
	 commented.*/

       UPDATE mtl_txn_request_lines
          SET quantity           = l_quantity
            , required_quantity  = l_required_quantity
            , secondary_quantity = l_sec_quantity --INVCONV
            , secondary_required_quantity = l_sec_required_quantity  --INVCONV
--            , quantity_detailed = l_quantity_detailed
            , secondary_quantity_detailed = l_sec_quantity_detailed
        WHERE line_id = p_line_id;
Line: 1846

       l_xdock_rsv_tbl.DELETE;
Line: 2023

             l_update_rec := l_rsv_tbl(1);
Line: 2024

             l_update_rec.reservation_quantity
               := l_update_rec.reservation_quantity - l_reduc_qty_conv;
Line: 2026

             l_update_rec.primary_reservation_quantity
               := l_update_rec.primary_reservation_quantity - l_prim_qty_conv;
Line: 2029

             IF l_update_rec.secondary_uom_code IS NOT NULL
             THEN
                l_update_rec.secondary_reservation_quantity
                  := l_update_rec.secondary_reservation_quantity
                       - l_sec_reduc_qty_conv;
Line: 2036

             inv_reservation_pub.update_reservation
             ( p_api_version_number     => 1.0
             , p_init_msg_lst           => fnd_api.g_false
             , x_return_status          => x_return_status
             , x_msg_count              => x_msg_count
             , x_msg_data               => x_msg_data
             , p_original_rsv_rec       => l_rsv_tbl(1)
             , p_to_rsv_rec             => l_update_rec
             , p_original_serial_number => l_dummy_sn
             , p_to_serial_number       => l_dummy_sn
             , p_validation_flag        => fnd_api.g_true
             );
Line: 2051

                   DEBUG('Error: Update Reservations returned '
                          || x_return_status
                        ,'Reduce_Move_Order_Quantity');
Line: 2057

                   fnd_message.set_name('INV','INV_UPDATE_RSV_FAILED');
Line: 2071

          ELSE -- RSV qty <= qty to reduce, so delete RSV
          -- {
             IF l_rsv_rec2.reservation_quantity = l_reduc_qty_conv
             THEN
                l_reduction_quantity := 0;
Line: 2148

                DEBUG('About to delete reservation ID: '
                       || to_char(l_rsv_rec2.reservation_id)
                     ,'Reduce_Move_Order_Quantity');
Line: 2153

             inv_reservation_pub.delete_reservation
             ( p_api_version_number => 1.0
             , p_init_msg_lst       => fnd_api.g_false
             , x_return_status      => x_return_status
             , x_msg_count          => x_msg_count
             , x_msg_data           => x_msg_data
             , p_rsv_rec            => l_rsv_rec2
             , p_serial_number      => l_serial_tbl
             );
Line: 2167

                   DEBUG('inv_reservation_pub.delete_reservation returned an error status: '
                          || x_return_status, 'Reduce_Move_Order_Quantity');
Line: 2190

                   DEBUG('inv_reservation_pub.delete_reservation returned success'
                        ,'Reduce_Move_Order_Quantity');
Line: 2204

       l_xdock_rsv_tbl.DELETE;
Line: 2252

  , p_quantity_to_delete      IN            NUMBER
  , p_sec_quantity_to_delete  IN            NUMBER  DEFAULT NULL --INVCONV
  , p_ato_serial_pick         IN            VARCHAR2 DEFAULT NULL --7190635 Added to check whether the call is for ATO serial picking
  ) IS
    l_reservation_id          NUMBER;
Line: 2262

    l_update_rec              inv_reservation_global.mtl_reservation_rec_type;
Line: 2265

    l_quantity_to_delete      NUMBER;
Line: 2266

    l_sec_quantity_to_delete  NUMBER;  --INVCONV
Line: 2268

    l_sec_deleted_quantity    NUMBER;  --INVCONV
Line: 2269

    l_sec_qty_to_delete       NUMBER;  --INVCONV
Line: 2273

    l_prim_quantity_to_delete NUMBER;
Line: 2275

    l_deleted_quantity        NUMBER;
Line: 2282

      SELECT primary_uom_code
        FROM mtl_system_items
       WHERE organization_id = l_organization_id
         AND inventory_item_id = l_inventory_item_id;
Line: 2295

    l_deleted_quantity         := 0;
Line: 2296

    l_quantity_to_delete       := p_quantity_to_delete;
Line: 2297

    l_sec_deleted_quantity     := 0; --INVCONV
Line: 2298

    l_sec_quantity_to_delete   := p_sec_quantity_to_delete; --INVCONV
Line: 2303

      DEBUG('quantity_to_delete:' || l_quantity_to_delete, 'reduce_rsv_allocation');
Line: 2304

      DEBUG('sec_quantity_to_delete:' || l_sec_quantity_to_delete, 'reduce_rsv_allocation');
Line: 2307

    SELECT ABS(mmtt.transaction_quantity)
         , ABS(mmtt.primary_quantity)
         , ABS(mmtt.secondary_transaction_quantity) --INVCONV
         , mmtt.reservation_id
         , mmtt.organization_id
         , mmtt.inventory_item_id
         , mtrl.uom_code
-- INVCONV correcting the orders
      INTO l_task_qty
         , l_primary_quantity
         , l_sec_qty    --INVCONV
         , l_reservation_id
         , l_organization_id
         , l_inventory_item_id
         , l_mo_uom_code
      FROM mtl_material_transactions_temp mmtt, mtl_txn_request_lines mtrl
     WHERE mmtt.transaction_temp_id = l_transaction_temp_id
       AND mmtt.move_order_line_id = mtrl.line_id;
Line: 2346

      l_prim_quantity_to_delete  :=
                 inv_convert.inv_um_convert(l_inventory_item_id, NULL, l_quantity_to_delete, l_mo_uom_code, l_primary_uom_code, NULL, NULL);
Line: 2349

      IF (l_prim_quantity_to_delete = -99999) THEN
        IF (l_debug = 1) THEN
          DEBUG('Cannot convert uom to primary uom', 'reduce_rsv_allocation');
Line: 2361

      l_prim_quantity_to_delete  := l_quantity_to_delete;
Line: 2363

      l_sec_qty_to_delete := l_sec_quantity_to_delete; --INVCONV
Line: 2401

      l_update_rec                       := l_rsv_tbl(1);
Line: 2404

      IF l_update_rec.detailed_quantity > l_prim_quantity_to_delete THEN
        l_update_rec.detailed_quantity  := l_update_rec.detailed_quantity - l_prim_quantity_to_delete;
Line: 2406

        l_update_rec.secondary_detailed_quantity  := l_update_rec.secondary_detailed_quantity - l_sec_qty_to_delete; --INCONV
Line: 2408

        l_update_rec.detailed_quantity  := 0;
Line: 2409

        l_update_rec.secondary_detailed_quantity  := 0; --INCONV
Line: 2413

      l_update_rec.reservation_quantity  := NULL;
Line: 2416

      IF l_update_rec.primary_reservation_quantity > l_prim_quantity_to_delete THEN
        l_update_rec.primary_reservation_quantity  := l_update_rec.primary_reservation_quantity - l_prim_quantity_to_delete;
Line: 2418

        l_update_rec.secondary_reservation_quantity  := l_update_rec.secondary_reservation_quantity - l_sec_qty_to_delete; --INVCONV
Line: 2419

      ELSE -- delete entire reservation
        l_update_rec.primary_reservation_quantity  := 0;
Line: 2421

        l_update_rec.secondary_reservation_quantity  := 0; --INVCONV
Line: 2425

        DEBUG('update reservation', 'reduce_rsv_allocation');
Line: 2429

        IF (  l_update_rec.secondary_uom_code IS NULL ) THEN
              l_update_rec.secondary_reservation_quantity := NULL;
Line: 2431

              l_update_rec.secondary_detailed_quantity    := NULL;
Line: 2435

      inv_reservation_pub.update_reservation(
        p_api_version_number         => 1.0
      , p_init_msg_lst               => fnd_api.g_false
      , x_return_status              => l_return_status
      , x_msg_count                  => x_msg_count
      , x_msg_data                   => x_msg_data
      , p_original_rsv_rec           => l_rsv_tbl(1)
      , p_to_rsv_rec                 => l_update_rec
      , p_original_serial_number     => l_dummy_sn
      , p_to_serial_number           => l_dummy_sn
      , p_validation_flag            => fnd_api.g_true
      );
Line: 2450

          DEBUG('Update reservation returned error', 'reduce_rsv_allocation');
Line: 2456

          DEBUG('Update reservation returned unexpected error', 'reduce_rsv_allocation');
Line: 2466

         DEBUG('Quantity to delete:'||l_quantity_to_delete, 'reduce_rsv_allocation');
Line: 2472

    IF l_quantity_to_delete = l_task_qty
        OR (l_retain_ato_profile = 'Y'  AND l_ato_serial_pick='Y') THEN
      l_deleted_quantity  := l_deleted_quantity + l_task_qty;
Line: 2475

      l_sec_deleted_quantity  := l_sec_deleted_quantity + l_sec_qty; --INVCONV
Line: 2477

      inv_trx_util_pub.delete_transaction(
        x_return_status       => l_return_status
      , x_msg_data            => x_msg_data
      , x_msg_count           => x_msg_count
      , p_transaction_temp_id => l_transaction_temp_id
      );
Line: 2496

      l_deleted_quantity  := l_deleted_quantity + l_quantity_to_delete;
Line: 2497

      l_sec_deleted_quantity  := l_sec_deleted_quantity + l_sec_quantity_to_delete; --INVCONV
Line: 2501

      , p_quantity            => l_quantity_to_delete
      , p_secondary_quantity  => l_sec_quantity_to_delete --INVCONV
      );
Line: 2536

  /* The following procedure is called by shipping to update carton group id whenever
     shipping unassign a wdd line from a delivery */
  PROCEDURE update_mol_carton_group
  ( x_return_status       OUT NOCOPY   VARCHAR2
  , x_msg_cnt             OUT NOCOPY   NUMBER
  , x_msg_data            OUT NOCOPY   VARCHAR2
  , p_line_id             IN           NUMBER
  , p_carton_grouping_id  IN           NUMBER
  ) IS

    l_debug    NUMBER;
Line: 2552

      SELECT mtrh.move_order_type
        FROM mtl_txn_request_lines    mtrl
           , mtl_txn_request_headers  mtrh
       WHERE mtrl.line_id   = p_mo_line_id
         AND mtrh.header_id = mtrl.header_id;
Line: 2560

       DEBUG('move order line id: ' || p_line_id, 'update_mol_carton_group');
Line: 2561

       DEBUG('carton group id: ' || p_carton_grouping_id, 'update_mol_carton_group');
Line: 2562

       DEBUG('before update statement...', 'update_mol_carton_group');
Line: 2581

       UPDATE mtl_txn_request_lines
          SET carton_grouping_id = p_carton_grouping_id
        WHERE line_id = p_line_id;
Line: 2594

            DEBUG('can not find move order line', 'update_mol_carton_group');
Line: 2602

          DEBUG('after update statement', 'update_mol_carton_group');
Line: 2615

         DEBUG('Exception: ' || sqlerrm, 'update_mol_carton_group');
Line: 2618

      fnd_message.set_name('INV', 'FAIL_TO_UPDATE_CARTON_GROUP'); --  need new msg
Line: 2620

  END update_mol_carton_group;