DBA Data[Home] [Help]

APPS.PO_SUPPLY SQL Statements

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

Line: 25

FUNCTION update_req_line_qty(
  p_lineid IN NUMBER
, p_qty    IN NUMBER
) RETURN BOOLEAN;
Line: 31

FUNCTION update_req_line_date(
  p_lineid       IN NUMBER
, p_receipt_date IN DATE
) RETURN BOOLEAN;
Line: 37

FUNCTION update_planned_po(
  p_docid       IN     NUMBER
, p_shipid      IN     NUMBER DEFAULT 0
, p_entity_type IN     VARCHAR2
, p_supply_flag IN OUT NOCOPY BOOLEAN
) RETURN BOOLEAN;
Line: 150

    ELSIF (p_action = 'Update_Req_Line_Qty') THEN

      d_progress := 90;
Line: 153

      l_return_value := update_req_line_qty(
                          p_lineid => p_lineid
                        , p_qty    => p_qty
                        );
Line: 158

    ELSIF (p_action = 'Update_Req_Line_Date') THEN

      d_progress := 100;
Line: 161

      l_return_value := update_req_line_date(
                          p_lineid       => p_lineid
                        , p_receipt_date => p_receipt_date
                        );
Line: 224

      l_return_value := delete_supply(
                          p_entity_id => p_docid
                        , p_entity_type => 'PO'
                        );
Line: 232

      l_return_value := delete_supply(
                          p_entity_id => p_docid
                        , p_entity_type => 'RELEASE'
                        );
Line: 240

      l_return_value := update_supply(
                          p_entity_id => p_lineid
                        , p_entity_type => 'PO LINE'
                        );
Line: 248

      l_return_value := update_supply(
                          p_entity_id => p_shipid
                        , p_entity_type => 'PO SHIPMENT'
                        );
Line: 256

      l_return_value := update_supply(
                          p_entity_id => p_docid
                        , p_entity_type => 'RELEASE SHIPMENT'
                        , p_shipid => p_shipid
                        );
Line: 357

    IF (UPPER(p_reservation_action) = 'UPDATE_SO_QUANTITY') THEN

      d_progress := 710;
Line: 384

         select requisition_header_id
         into l_doc_id
         from po_requisition_lines_all
         where requisition_line_id = p_lineid;
Line: 435

    END IF;  -- IF (UPPER(p_reservation_action) = 'UPDATE_SO_QUANTITY')...
Line: 481

/*   Update mtl_supply for an Approve PO Action                            */
/*                                                                         */
/* ----------------------------------------------------------------------- */


FUNCTION approve_po_supply(p_docid IN NUMBER) RETURN BOOLEAN IS

l_auth_status  po_headers.authorization_status%TYPE;
Line: 497

  SELECT poh.authorization_status
  FROM po_headers_all poh
  WHERE poh.po_header_id = header_id;
Line: 549

      UPDATE mtl_supply ms
      SET ms.quantity = 0
        , ms.change_flag = 'Y'
      WHERE ms.supply_type_code = 'REQ'
        AND ms.supply_source_id IN
            (
              SELECT prl.requisition_line_id
              FROM po_requisition_lines_all prl
                 , po_distributions_all pd
              WHERE prl.line_location_id = pd.line_location_id
                AND pd.po_header_id = p_docid
            );
Line: 565

        PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows.');
Line: 603

/*   Update mtl_supply for an Approve Blanket Release Action               */
/*                                                                         */
/* ----------------------------------------------------------------------- */



FUNCTION approve_blanket_supply(p_docid IN NUMBER)
RETURN BOOLEAN
IS

l_auth_status  po_headers.authorization_status%TYPE;
Line: 617

  SELECT por.authorization_status
  FROM po_releases_all por
  WHERE por.po_release_id = release_id;
Line: 669

      UPDATE mtl_supply ms
      SET ms.quantity = 0
        , ms.change_flag = 'Y'
      WHERE ms.supply_type_code = 'REQ'
        AND ms.supply_source_id IN
            (
              SELECT prl.requisition_line_id
              FROM po_requisition_lines_all prl
                  , po_line_locations_all pll
              WHERE prl.line_location_id = pll.line_location_id
                AND pll.po_release_id = p_docid
            );
Line: 685

        PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows.');
Line: 722

/*   Update mtl_supply for an Approve Planned Release Action               */
/*                                                                         */
/* ----------------------------------------------------------------------- */

FUNCTION approve_planned_supply(p_docid IN NUMBER)
RETURN BOOLEAN
IS

l_auth_status  po_releases.authorization_status%TYPE;
Line: 737

  SELECT por.authorization_status, por.po_header_id
  FROM po_releases_all por
  WHERE por.po_release_id = release_id;
Line: 850

/*   Insert new PO Supply into mtl_supply for Standard or Planned PO       */
/*   Approval, Blanket or Planned Release Approval, Standard or Planned    */
/*   PO Line Approval, Standard or Planned PO Shipment Approval, Blanket   */
/*   or Planned Release Shipment                                           */
/*                                                                         */
/*   New PO Supply is inserted based on Entity Type                        */
/*                                                                         */
/*   	Entity Type	Action                                             */
/*  	-----------	---------------------------------------------      */
/*  	PO		New PO Supply for Standard or Planned PO           */
/*  			Approval                                           */
/*                                                                         */
/*  	RELEASE		New PO Supply for Blanket or Planned Release       */
/*  			Approval                                           */
/*                                                                         */
/*      PO LINE		New PO Supply for Standard or Planned PO Line      */
/*  			Approval                                           */
/*                                                                         */
/*  	PO SHIPMENT	New PO Supply for Standard or Planned PO           */
/*  			Shipment Approval                                  */
/*                                                                         */
/*  	RELEASE         New PO Supply for Blanket or Planned Release       */
/*	SHIPMENT	Shipment                                           */
/*                                                                         */
/* ----------------------------------------------------------------------- */

-- : create_po_supply had conflicting logic in PO_SUPPLY
-- vs. the Pro*C code.  The latter is more accurate, so the method has been changed
-- to reflect the logic in Pro*C wherever there is a conflict.

FUNCTION create_po_supply(
  p_entity_id   IN NUMBER
, p_entity_type IN VARCHAR2
) RETURN BOOLEAN
IS

l_distid               po_distributions.po_distribution_id%TYPE;
Line: 906

  SELECT SUM(to_org_primary_quantity),
         to_org_primary_uom,
         NVL(item_id, -1)
  FROM mtl_supply
  WHERE supply_type_code IN ('RECEIVING', 'SHIPMENT')
    AND po_line_location_id = p_line_loc_id
  GROUP BY to_org_primary_uom, nvl(item_id, -1);
Line: 935

    l_return_value := delete_supply(
                        p_entity_id   => p_entity_id
                      , p_entity_type => p_entity_type
                      );
Line: 943

        PO_LOG.stmt(d_module, d_progress, 'delete_supply not successful');
Line: 957

    sql_dist :=    'SELECT pd.po_distribution_id, '
                || 'pd.quantity_ordered - nvl(pd.quantity_delivered, 0) - nvl(pd.quantity_cancelled, 0), '
                || 'pl.unit_meas_lookup_code, '
                || 'pd.line_location_id '
                || 'FROM po_distributions_all pd, po_lines_all pl ';
Line: 1052

          SELECT NVL(SUM(pod.quantity_ordered - NVL(pod.quantity_delivered, 0)
                           - NVL(pod.quantity_cancelled, 0)), 0)
          INTO l_released_qty
          FROM po_distributions_all pod
             , po_releases_all por
          WHERE pod.source_distribution_id = l_distid
            AND pod.po_release_id = por.po_release_id
            AND NVL(por.authorization_status, 'IN PROCESS') = 'APPROVED';
Line: 1158

        INSERT INTO mtl_supply(supply_type_code,
                               supply_source_id,
                               last_updated_by,
                               last_update_date,
                               last_update_login,
                               created_by,
                               creation_date,
                               po_header_id,
                               po_line_id,
                               po_line_location_id,
                               po_distribution_id,
                               po_release_id,                -- 
                               item_id,
                               item_revision,
                               quantity,
                               unit_of_measure,
                               receipt_date,
                               need_by_date,
                               destination_type_code,
                               location_id,
                               to_organization_id,
                               to_subinventory,
                               change_flag)
                        SELECT 'PO',
                               pd.po_distribution_id,
                               pd.last_updated_by,
                               pd.last_update_date,
                               pd.last_update_login,
                               pd.created_by,
                               pd.creation_date,
                               pd.po_header_id,
                               pd.po_line_id,
                               pd.line_location_id,
                               pd.po_distribution_id,
                               pd.po_release_id,
                               pl.item_id,
                               pl.item_revision,
                               l_out_poqty,
                               pl.unit_meas_lookup_code,
                               nvl(pll.promised_date, pll.need_by_date),
                               nvl(pll.promised_date, pll.need_by_date), -- bug 4300150
                               pd.destination_type_code,
                               pd.deliver_to_location_id,
                               pd.destination_organization_id,
                               pd.destination_subinventory,
                               'Y'
                          FROM po_distributions_all pd,
                               po_line_locations_all pll,
                               po_lines_all pl
                         WHERE pd.po_distribution_id = l_distid
                           AND pll.line_location_id = pd.line_location_id
                           AND pl.item_id IS NOT NULL   -- 
                           AND pl.po_line_id = pd.po_line_id
                           AND nvl(pll.closed_code, 'OPEN') not in ('FINALLY CLOSED', 'CLOSED', 'CLOSED FOR RECEIVING')
                           AND nvl(pll.cancel_flag, 'N') = 'N'
                           AND nvl(pll.approved_flag, 'Y') = 'Y'
                           AND pll.quantity IS NOT NULL        -- 
                           AND not exists
                               (
                                 SELECT 'Supply Exists'
                                 FROM mtl_supply ms1
                                 WHERE ms1.supply_type_code = 'PO'
                                   AND ms1.supply_source_id = pd.po_distribution_id
                               );
Line: 1281

/*   Delete Supply for PO Header or PO Release                             */
/*                                                                         */
/*   New PO Supply is inserted based on Entity Type                        */
/*                                                                         */
/*   	Entity Type		Action                                     */
/*  	-----------		-----------------------------------------  */
/*  	PO			Remove PO Supply for PO Header             */
/*                                                                         */
/*  	RELEASE			Remove PO Supply for PO Release            */
/*                                                                         */
/*  	PO LINE			Remove PO Supply for PO Line               */
/*                                                                         */
/*  	PO SHIPMENT		Remove PO Supply for PO Shipment           */
/*                                                                         */
/*  	RELEASE SHIPMENT	Remove PO Supply for Release Shipment      */
/*                                                                         */
/* ----------------------------------------------------------------------- */


FUNCTION delete_supply(
  p_entity_id   IN NUMBER
, p_entity_type IN VARCHAR2
) RETURN BOOLEAN
IS

d_module        VARCHAR2(70) := 'po.plsql.PO_SUPPLY.delete_supply';
Line: 1321

    DELETE FROM mtl_supply
    WHERE supply_type_code = 'PO'
      AND po_header_id = p_entity_id
      AND po_release_id IS NULL;       -- : From Pro*C
Line: 1328

    DELETE FROM mtl_supply
    WHERE supply_type_code = 'PO'
      AND po_release_id = p_entity_id;
Line: 1334

    DELETE FROM mtl_supply
    WHERE supply_type_code = 'PO'
      AND po_line_id = p_entity_id
      AND po_release_id IS NULL;     -- : From Pro*C
Line: 1341

    DELETE FROM mtl_supply
    WHERE supply_type_code = 'PO'
      AND po_line_location_id = p_entity_id;
Line: 1350

    PO_LOG.stmt(d_module, d_progress, 'Deleted ' || SQL%ROWCOUNT || ' records');
Line: 1369

END delete_supply;
Line: 1376

/*   Update Supply Quantity to 0 for PO Line, PO Shipment or Release       */
/*   Shipment                                                              */
/*                                                                         */
/*   PO Supply is Updated based on the Entity Type                         */
/*                                                                         */
/*   	Entity Type	Action                                             */
/*  	-----------	---------------------------------------------      */
/*  	PO LINE		Update Supply Quantity for PO Line                 */
/*                                                                         */
/*  	PO SHIPMENT	Update Supply Quantity for PO Shipment             */
/*                                                                         */
/*  	RELEASE 	Update Supply Quantity for Release Shipment        */
/*      SHIPMENT                                                           */
/*                                                                         */
/* ----------------------------------------------------------------------- */


FUNCTION update_supply(
  p_entity_id   IN NUMBER
, p_entity_type IN VARCHAR2
, p_shipid      IN NUMBER DEFAULT 0
) RETURN BOOLEAN
IS

d_module        VARCHAR2(70) := 'po.plsql.PO_SUPPLY.update_supply';
Line: 1416

    UPDATE mtl_supply
    SET quantity = 0
      , change_flag = 'Y'
    WHERE supply_type_code = 'PO'
      AND po_line_id = p_entity_id
      AND po_release_id IS NULL;     -- 
Line: 1425

    UPDATE mtl_supply
    SET quantity = 0
      , change_flag = 'Y'
    WHERE supply_type_code = 'PO'
      AND po_line_location_id = p_entity_id;
Line: 1433

    UPDATE mtl_supply
    SET quantity = 0
      , change_flag = 'Y'
    WHERE supply_type_code = 'PO'
      AND po_release_id = p_entity_id
      AND po_line_location_id = p_shipid;
Line: 1445

    PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' records');
Line: 1464

END update_supply;
Line: 1516

    l_return_value := delete_supply(
                        p_entity_id       => p_entity_id
                      , p_entity_type     => 'PO'
                      );
Line: 1523

    l_return_value := update_supply(
                        p_entity_id       => p_entity_id
                      , p_entity_type     => 'PO LINE'
                      );
Line: 1530

    l_return_value := update_supply(
                        p_entity_id       => p_entity_id
                      , p_entity_type     => 'PO SHIPMENT'
                      );
Line: 1537

    l_return_value := delete_supply(
                        p_entity_id       => p_entity_id
                      , p_entity_type     => 'RELEASE'
                      );
Line: 1544

    l_return_value := update_supply(
                        p_entity_id       => p_entity_id
                      , p_entity_type     => 'RELEASE SHIPMENT'
                      , p_shipid          => p_shipid
                      );
Line: 1576

/*   Update mtl_supply for Cancel Planned Release or Cancel Planned        */
/*   Release Shipment Action                                               */
/*                                                                         */
/*   Cancellation of Planned Release and Planned Shipment is based on      */
/*   Entity Type                                                           */
/*                                                                         */
/*   	Entity Type		Action                                     */
/*  	-----------		------------------------------------------ */
/*  	RELEASE			Cancel Planned Release                     */
/*                                                                         */
/*  	RELEASE	SHIPMENT	Cancel Planned Release Shipment            */
/*                                                                         */
/* ----------------------------------------------------------------------- */


FUNCTION cancel_planned(
  p_entity_id     IN NUMBER
, p_entity_type   IN VARCHAR2
, p_shipid        IN NUMBER DEFAULT 0
, p_recreate_flag IN BOOLEAN
) RETURN BOOLEAN
IS

l_supply_flag  BOOLEAN := TRUE;
Line: 1607

  SELECT por.po_header_id
  FROM po_releases_all por
  WHERE por.po_release_id = release_id;
Line: 1636

      l_return_value := delete_supply(
                          p_entity_id    => p_entity_id
                        , p_entity_type  => 'RELEASE'
                        );
Line: 1643

          PO_LOG.stmt(d_module, d_progress, 'delete_supply not successful');
Line: 1656

        l_return_value := update_planned_po(
                            p_docid        => p_entity_id
                          , p_entity_type  => 'ADD PLANNED'
                          , p_supply_flag  => l_supply_flag
                          );
Line: 1664

            PO_LOG.stmt(d_module, d_progress, 'update_planned_po not successful');
Line: 1708

      l_return_value := update_supply(
                          p_entity_id    => p_entity_id
                        , p_entity_type  => 'RELEASE SHIPMENT'
                        , p_shipid       => p_shipid
                        );
Line: 1716

          PO_LOG.stmt(d_module, d_progress, 'update_supply not successful');
Line: 1729

        l_return_value := update_planned_po(
                            p_docid        => p_entity_id
                          , p_shipid       => p_shipid
                          , p_entity_type  => 'UPDATE PLANNED'
                          , p_supply_flag  => l_supply_flag
                          );
Line: 1738

            PO_LOG.stmt(d_module, d_progress, 'update_planned_po not successful');
Line: 1812

 * Added an extra FOR UPDATE clause in the below cursor to avoid the
 * deadlock scenario.
 */

CURSOR sup2
IS
  SELECT /*+ index(mtl_supply MTL_SUPPLY_N10) */
         quantity
       , unit_of_measure
       , nvl(item_id, -1) item_id
       , from_organization_id
       , to_organization_id
       , receipt_date
       , rowid
  FROM mtl_supply
  WHERE change_flag = 'Y'
  ORDER BY DECODE (supply_type_code,
                     'REQ', 1,
                     'PO',  2,
                     'SHIPMENT', 3,
                     'RECEIVING', 4,
                     5), QUANTITY
  FOR UPDATE;
Line: 1838

  SELECT muom.unit_of_measure
       , NULL
  FROM mtl_units_of_measure muom
     , mtl_units_of_measure tuom
  WHERE tuom.unit_of_measure = from_uom
    AND tuom.uom_class = muom.uom_class
    AND muom.base_uom_flag = 'Y';
Line: 1848

  SELECT primary_unit_of_measure
       , postprocessing_lead_time
  FROM mtl_system_items
  WHERE inventory_item_id = item_id
    AND organization_id = to_org;
Line: 1872

      DELETE FROM mtl_supply
      WHERE rowid = c_sup2.rowid;
Line: 1877

        PO_LOG.stmt(d_module, d_progress, 'Deleted ' || SQL%ROWCOUNT || ' rows');
Line: 1929

      UPDATE mtl_supply
      SET to_org_primary_quantity = l_pri_qty
        , to_org_primary_uom = l_uom
        , change_flag = null
        , change_type = null
        , expected_delivery_date =
             DECODE(c_sup2.item_id, -1, to_date(NULL),
                                        c_sup2.receipt_date + NVL(l_lead_time, 0))
      WHERE rowid = c_sup2.rowid;
Line: 1941

        PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows');
Line: 1991

  SELECT authorization_status
  FROM po_requisition_headers_all
  WHERE requisition_header_id = header_id;
Line: 2081

    UPDATE mtl_supply
    SET quantity = 0
      , change_flag = 'Y'
    WHERE supply_type_code = 'REQ'
      AND req_header_id = p_entity_id;
Line: 2091

    UPDATE mtl_supply
    SET quantity = 0
      , change_flag = 'Y'
    WHERE supply_type_code = 'REQ'
      AND req_line_id = p_entity_id;
Line: 2100

    PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows');
Line: 2145

  UPDATE mtl_supply ms
  SET ms.quantity = 0
    , ms.change_flag = 'Y'
  WHERE ms.supply_type_code = 'REQ'
    AND ms.req_header_id = p_docid
    AND EXISTS
         (
           SELECT 1
           FROM po_requisition_lines_all porl
           WHERE porl.source_type_code = 'VENDOR'
             AND porl.requisition_line_id = ms.req_line_id
         );
Line: 2159

    PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows');
Line: 2219

    DELETE FROM mtl_supply ms1
    WHERE ms1.supply_source_id IN
           (
             SELECT pl.requisition_line_id
             FROM po_requisition_lines_all pl
             WHERE pl.requisition_header_id = p_entity_id
               AND NVL(pl.modified_by_agent_flag, 'N') <> 'Y'
               AND NVL(pl.closed_code, 'OPEN') = 'OPEN'
               AND NVL(pl.cancel_flag, 'N') = 'N'
               AND pl.line_location_id IS NULL
           )
      AND ms1.supply_type_code = 'REQ';
Line: 2233

      PO_LOG.stmt(d_module, d_progress, 'Deleted ' || SQL%ROWCOUNT || ' rows');
Line: 2242

    INSERT INTO mtl_supply
               (supply_type_code,
                supply_source_id,
                last_updated_by,
                last_update_date,
                last_update_login,
                created_by,
                creation_date,
                req_header_id,
                req_line_id,
                item_id,
                item_revision,
                quantity,
                unit_of_measure,
                receipt_date,
                need_by_date,
                destination_type_code,
                location_id,
                from_organization_id,
                from_subinventory,
                to_organization_id,
                to_subinventory,
                change_flag)
               SELECT 'REQ',
                       prl.requisition_line_id,
                       last_updated_by,
                       last_update_date,
                       last_update_login,
                       created_by,
                       creation_date,
                       prl.requisition_header_id,
                       prl.requisition_line_id,
                       prl.item_id,
                       decode(prl.source_type_code,'INVENTORY', null,
                              prl.item_revision),
                       prl.quantity - ( nvl(prl.QUANTITY_CANCELLED, 0) +
                                        nvl(prl.QUANTITY_DELIVERED, 0) ),
                       prl.unit_meas_lookup_code,
                       prl.need_by_date,
                       prl.need_by_date,
                       prl.destination_type_code,
                       prl.deliver_to_location_id,
                       prl.source_organization_id,
                       prl.source_subinventory,
                       prl.destination_organization_id,
                       prl.destination_subinventory,
                       'Y'
                FROM   po_requisition_lines_all prl
                WHERE  prl.requisition_header_id = p_entity_id
                AND    nvl(prl.modified_by_agent_flag,'N') <> 'Y'
                AND    nvl(prl.CLOSED_CODE,'OPEN') = 'OPEN'
                AND    nvl(prl.CANCEL_FLAG, 'N') = 'N'
                -- : Filter out amount basis
                AND    prl.matching_basis <> 'AMOUNT'
                AND    prl.line_location_id is null
                AND    not exists
                       (SELECT 'supply exists'
                        FROM   mtl_supply ms
			                  WHERE  ms.supply_type_code = 'REQ'
			                  AND ms.supply_source_id = prl.requisition_line_id);
Line: 2307

    INSERT INTO mtl_supply
               (supply_type_code,
                supply_source_id,
                last_updated_by,
                last_update_date,
                last_update_login,
                created_by,
                creation_date,
                req_header_id,
                req_line_id,
                item_id,
                item_revision,
                quantity,
                unit_of_measure,
                receipt_date,
                need_by_date,
                destination_type_code,
                location_id,
                from_organization_id,
                from_subinventory,
                to_organization_id,
                to_subinventory,
                change_flag)
                SELECT 'REQ',
                       prl.requisition_line_id,
                       last_updated_by,
                       last_update_date,
                       last_update_login,
                       created_by,
                       creation_date,
                       prl.requisition_header_id,
                       prl.requisition_line_id,
                       prl.item_id,
                       decode(prl.source_type_code,'INVENTORY', null,
                              prl.item_revision),
                       prl.quantity - ( nvl(prl.QUANTITY_CANCELLED, 0) +
                                        nvl(prl.QUANTITY_DELIVERED, 0) ),
                       prl.unit_meas_lookup_code,
                       prl.need_by_date,
                       prl.need_by_date,
                       prl.destination_type_code,
                       prl.deliver_to_location_id,
                       prl.source_organization_id,
                       prl.source_subinventory,
                       prl.destination_organization_id,
                       prl.destination_subinventory,
                       'Y'
                FROM   po_requisition_lines_all prl
                WHERE  prl.requisition_line_id = p_entity_id
                AND    nvl(prl.modified_by_agent_flag,'N') <> 'Y'
                AND    nvl(prl.CLOSED_CODE, 'OPEN') = 'OPEN'
                AND    nvl(prl.CANCEL_FLAG, 'N') = 'N'
                AND    prl.line_location_id IS NULL
                -- : Add filters from Pro*C
                AND    prl.matching_basis <> 'AMOUNT'
                AND    NOT EXISTS
                          (
                            SELECT 'supply exists'
                            FROM mtl_supply
               			        WHERE supply_type_code = 'REQ'
   			                      AND supply_source_id = prl.requisition_line_id
                          );
Line: 2376

    PO_LOG.stmt(d_module, d_progress, 'Inserted ' || SQL%ROWCOUNT || ' rows');
Line: 2450

    insert into mtl_supply(supply_type_code,
                           supply_source_id,
                           last_updated_by,
                           last_update_date,
                           last_update_login,
                           created_by,
                           creation_date,
                           req_header_id,
                           req_line_id,
                           item_id,
                           item_revision,
                           quantity,
                           unit_of_measure,
                           receipt_date,
                           need_by_date,
                           destination_type_code,
                           location_id,
                           from_organization_id,
                           from_subinventory,
                           to_organization_id,
                           to_subinventory,
                           change_flag)
                    select 'REQ',
                           prl.requisition_line_id,
                           prl.last_updated_by,
                           prl.last_update_date,
                           prl.last_update_login,
                           prl.created_by,
                           prl.creation_date,
                           prl.requisition_header_id,
                           prl.requisition_line_id,
                           prl.item_id,
                           prl.item_revision,
                           prl.quantity - (nvl(prl.quantity_cancelled, 0) +
                                           nvl(prl.quantity_delivered, 0)),
                           prl.unit_meas_lookup_code,
                           prl.need_by_date,
                           prl.need_by_date,
                           prl.destination_type_code,
                           prl.deliver_to_location_id,
                           prl.source_organization_id,
                           prl.source_subinventory,
                           prl.destination_organization_id,
                           prl.destination_subinventory,
                           'Y'
                      from po_requisition_lines_all prl
                     where prl.requisition_line_id in
                          (select prl1.requisition_line_id
                             from po_requisition_lines_all prl1
                            where prl1.requisition_header_id =
                                 (select prl2.requisition_header_id
                                    from po_requisition_lines_all prl2
                                   where prl2.requisition_line_id = p_lineid
                                     and prl2.modified_by_agent_flag = 'Y'))
                       and nvl(prl.modified_by_agent_flag, 'N') <> 'Y'
                       and nvl(prl.closed_code, 'OPEN') = 'OPEN'
                       and nvl(prl.cancel_flag, 'N') = 'N'
                       and prl.line_location_id is null
                       and not exists
                          (select 'Supply Exists'
                             from mtl_supply
                            where supply_type_code = 'REQ'
                              and supply_source_id = prl.requisition_line_id);
Line: 2552

FUNCTION update_req_line_qty(
  p_lineid IN NUMBER
, p_qty    IN NUMBER
) RETURN BOOLEAN
IS

d_module        VARCHAR2(70) := 'po.plsql.PO_SUPPLY.update_req_line_qty';
Line: 2571

  UPDATE mtl_supply
  SET quantity = p_qty
    , change_flag = 'Y'
  WHERE supply_type_code = 'REQ'
    AND req_line_id = p_lineid;
Line: 2578

    PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows');
Line: 2599

END update_req_line_qty;
Line: 2607

FUNCTION update_req_line_date(
  p_lineid IN NUMBER
, p_receipt_date IN DATE
) RETURN BOOLEAN
IS

d_module        VARCHAR2(70) := 'po.plsql.PO_SUPPLY.update_req_line_date';
Line: 2626

  UPDATE mtl_supply
  SET receipt_date = p_receipt_date
    , need_by_date = p_receipt_date  -- Bug 3443313
    , change_flag = 'Y'
  WHERE supply_type_code = 'REQ'
    AND req_line_id = p_lineid;
Line: 2634

    PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows');
Line: 2655

END update_req_line_date;
Line: 2676

FUNCTION update_planned_po(
  p_docid       IN     NUMBER
, p_shipid      IN     NUMBER DEFAULT 0
, p_entity_type IN     VARCHAR2
, p_supply_flag IN OUT NOCOPY BOOLEAN
) RETURN BOOLEAN
IS

d_module        VARCHAR2(70) := 'po.plsql.PO_SUPPLY.update_planned_po';
Line: 2703

  IF (p_entity_type = 'UPDATE PLANNED') THEN

    d_progress := 20;
Line: 2710

    UPDATE mtl_supply ms
    SET ms.quantity =
         (
           SELECT ms.quantity +
				                      NVL( sum(nvl(pd.quantity_cancelled,0)),0)
			     FROM po_distributions_all pd
			     WHERE pd.po_release_id = p_docid
			       AND pd.line_location_id = p_shipid
			       AND pd.source_distribution_id = ms.supply_source_id
         )
      , ms.change_flag = 'Y'
    WHERE ms.supply_type_code = 'PO'
      AND ms.po_line_location_id =
           (
             SELECT poll. source_shipment_id
				     FROM po_line_locations_all poll
				     WHERE poll.line_location_id = p_shipid
           );
Line: 2744

    SELECT pod.source_distribution_id, pod.quantity_ordered
    BULK COLLECT INTO l_ppo_dist_id_tbl, l_ppo_dist_qty_tbl
    FROM po_distributions_all pod
    WHERE pod.po_release_id = p_docid
      AND (pod.po_line_id IS NOT NULL AND pod.line_location_id IS NOT NULL);
Line: 2753

      UPDATE mtl_supply mts
      SET mts.quantity = l_ppo_dist_qty_tbl(i) -
                         (
                          SELECT NVL(sum(pod.quantity_ordered -
                                       NVL(pod.quantity_cancelled, 0)), 0)
                          FROM po_distributions_all pod
                          WHERE pod.source_distribution_id = l_ppo_dist_id_tbl(i)
                            AND pod.po_line_id IS NOT NULL
                            AND pod.line_location_id IS NOT NULL
                         )
        , mts.change_flag = 'Y'
      WHERE mts.po_distribution_id = l_ppo_dist_id_tbl(i);
Line: 2777

    PO_LOG.stmt(d_module, d_progress, 'Updated ' || SQL%ROWCOUNT || ' rows');
Line: 2798

END update_planned_po;