DBA Data[Home] [Help]

APPS.INV_MO_PURGE SQL Statements

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

Line: 17

    can_delete       NUMBER                                   := 0;
Line: 32

     SELECT   mtrh.header_id
            , mtrl.line_id
            , mtrh.move_order_type
            , mtrl.line_status
            , mtrl.quantity quantity
            , NVL(mtrl.quantity_detailed, 0) quantity_detailed
            , NVL(mtrl.quantity_delivered, 0) quantity_delivered
            , NVL(required_quantity, 0) required_quantity
            , txn_source_line_id
     FROM     mtl_txn_request_headers mtrh
            , mtl_txn_request_lines mtrl
     WHERE mtrh.header_id = mtrl.header_id
       AND mtrl.line_status IN (5, 6, 9)
       AND ( p_organization_id IS NULL
          OR mtrh.organization_id = p_organization_id )
       AND ( p_organization_id IS NULL
          OR mtrl.organization_id = p_organization_id )
       AND ( p_mo_type_id IS NULL
          OR mtrh.move_order_type = p_mo_type_id )
       AND ( l_date_from IS NULL
          OR TO_DATE ( TO_CHAR ( mtrl.creation_date , 'DD-MM-YYYY' ) , 'DD-MM-YYYY' )
             >= TO_DATE ( TO_CHAR ( l_date_from , 'DD-MM-YYYY' ) , 'DD-MM-YYYY' ) )
       AND TO_DATE ( TO_CHAR ( mtrl.creation_date , 'DD-MM-YYYY' ) , 'DD-MM-YYYY' )
             <= TO_DATE ( TO_CHAR ( l_date_to , 'DD-MM-YYYY' ) , 'DD-MM-YYYY' )
     ORDER BY mtrh.header_id;
Line: 73

      can_delete        := 0;
Line: 78

        can_delete  := 1;
Line: 84

          /* Delete MTRL if inventory interface has completed successfully and
             order_line is not open (OE_ORDER_LINES_ALL.OPEN_FLAG <> 'Y')
             or is cancelled (CANCELLED_FLAG = 'Y')*/
     	     wdd_exists := 'Y';	  -- Added for bug # 6469970
Line: 90

            SELECT 1
              INTO can_delete
              FROM wsh_delivery_details wsd
             WHERE wsd.move_order_line_id = mo_line.line_id
               AND wsd.inv_interfaced_flag = 'Y'
               AND ROWNUM < 2;
Line: 97

            IF (can_delete = 1) THEN
              SELECT 1
                INTO can_delete
                FROM oe_order_lines_all oola
               WHERE oola.line_id = mo_line.txn_source_line_id
                 AND (oola.open_flag <> 'Y'
                      OR oola.cancelled_flag = 'Y'
                     )
                 AND ROWNUM < 2;
Line: 109

              can_delete  := 0;
Line: 114

          IF (can_delete = 0) THEN
            BEGIN
              SELECT 1
              INTO can_delete
              FROM oe_order_lines_all oola
              WHERE oola.line_id = mo_line.txn_source_line_id
              AND   ( (NVL(open_flag, 'Y') = 'N') OR cancelled_flag = 'Y')
              AND NOT EXISTS (
                  SELECT 1
                  FROM   wsh_delivery_details wdd
                  WHERE  wdd.source_line_id = oola.line_id
                  AND    wdd.inv_interfaced_flag IN ('N', 'P')
                  AND    wdd.released_status <> 'D')
              AND ROWNUM =1;
Line: 130

                can_delete := 0;
Line: 132

          END IF;   --END IF delete canceled SO lines
Line: 138

          IF (can_delete = 0 AND mo_line.line_status = 5 AND
                ((mo_line.quantity = mo_line.quantity_delivered
                              AND
                 mo_line.quantity_detailed = mo_line.quantity_delivered)
                       OR
                 (mo_line.quantity > 0 AND mo_line.quantity_delivered = 0))) THEN
            BEGIN
              SELECT 1
              INTO can_delete
              FROM oe_order_lines_all oola
              WHERE oola.line_id = mo_line.txn_source_line_id
              AND   (NVL(open_flag,'Y') ='Y' and cancelled_flag='N')
              AND   NOT EXISTS (
                    SELECT 1
                    FROM   mtl_material_transactions_temp mmtt
                    WHERE  mmtt.move_order_line_id = mo_line.line_id)
              AND NOT EXISTS (
                  SELECT 1
                  FROM   wsh_delivery_details wdd
                  WHERE  wdd.source_line_id = oola.line_id
                  AND    wdd.source_code = 'OE'
                  AND    wdd.move_order_line_id = mo_line.line_id)
              AND ROWNUM = 1;
Line: 163

                can_delete := 0;
Line: 165

          END IF;   --END IF delete completely backordered lines
Line: 168

          IF (can_delete = 0) THEN
             BEGIN
                  SELECT distinct wdd.inv_interfaced_flag into inv_int_flag
                  FROM wsh_delivery_details wdd
                  WHERE wdd.move_order_line_id = mo_line.line_id;
Line: 175

	              can_delete := 1;
Line: 177

	              can_delete := 0;
Line: 181

	              can_delete := 1; -- No corresponding wdd record
Line: 184

                      can_delete := 0; -- At least one inv_int_flag is set to 'N' or 'P' in wdd
Line: 187

             IF (can_delete = 1 and wdd_exists = 'N')  THEN
                 BEGIN
                     SELECT 0
                     INTO can_delete
                     FROM oe_order_lines_all oola
                     WHERE oola.line_id = mo_line.txn_source_line_id
                     AND (oola.open_flag = 'Y' AND  NVL(oola.CANCELLED_FLAG,'N')='N');
Line: 195

                     can_delete := 0;
Line: 197

                     can_delete  := 1;
Line: 204

	  IF (can_delete = 0) THEN
              BEGIN
                  SELECT 'Y'
                  INTO oel_exists
                  FROM oe_order_lines_all oola
                  WHERE oola.line_id = mo_line.txn_source_line_id
                  and rownum < 2;
Line: 213

		        can_delete := 0;
Line: 215

		        can_delete := 1;
Line: 219

	           can_delete := 1; -- there is no oel record
Line: 225

          /*   Delete MTRL if allocations doesn't exist
          (MMTT should not exist for this line id, MMTT.move_order_line_id = MTRL.line_id)
          and order_line is not open (OE_ORDER_LINES_ALL.OPEN_FLAG <> 'Y')  */
          BEGIN
            SELECT 1
              INTO can_delete
              FROM mtl_material_transactions_temp mmtt
             WHERE mmtt.move_order_line_id = mo_line.line_id
               AND ROWNUM < 2;
Line: 235

            can_delete  := 0;
Line: 239

                SELECT 1
                  INTO can_delete
                  FROM oe_order_lines_all oola
                 WHERE oola.line_id = mo_line.txn_source_line_id
                   AND (oola.open_flag <> 'Y'
                        OR oola.cancelled_flag = 'Y'
                       )
                   AND ROWNUM < 2;
Line: 249

                  can_delete  := 0;
Line: 261

          can_delete  := 1;
Line: 265

            SELECT 1
              INTO can_delete
              FROM mtl_material_transactions_temp mmtt
             WHERE mmtt.move_order_line_id = mo_line.line_id
               AND ROWNUM < 2;
Line: 271

            can_delete  := 0;
Line: 274

              can_delete  := 1;
Line: 279

      IF (can_delete = 1) THEN
        -- inv_trx_util_pub.TRACE('DELETED lines---mo_line.line_id= '  ||mo_line.line_id ,'INVMOPG',9);
Line: 281

        DELETE FROM mtl_txn_request_lines
              WHERE line_id = mo_line.line_id;
Line: 284

        can_delete  := 0;
Line: 290

        DELETE FROM mtl_txn_request_headers
              WHERE header_id = l_prev_header_id
                AND NOT EXISTS( SELECT 1
                                  FROM mtl_txn_request_lines
                                 WHERE header_id = l_prev_header_id);
Line: 298

          can_delete  := 0;
Line: 312

    DELETE FROM mtl_txn_request_headers
          WHERE header_id = mo_line.header_id
            AND NOT EXISTS( SELECT 1
                              FROM mtl_txn_request_lines
                             WHERE header_id = mo_line.header_id);
Line: 320

      can_delete  := 0;
Line: 328

    INSERT INTO mtl_purge_header
                (
                purge_id
              , last_update_date
              , last_updated_by
              , last_update_login
              , creation_date
              , created_by
              , purge_date
              , move_order_type
              , archive_flag
              , purge_name
              , organization_id
              , creation_date_from
              , creation_date_to
              , lines_purged
                )
         VALUES (
                mtl_material_transactions_s.NEXTVAL
              , SYSDATE
              , fnd_global.user_id
              , fnd_global.user_id
              , SYSDATE
              , fnd_global.user_id
              , SYSDATE
              , p_mo_type_id
              , NULL
              , p_purge_name
              , p_organization_id
              , l_date_from
              , l_date_to
              , l_count
                );