DBA Data[Home] [Help]

APPS.PO_REQCHANGEREQUESTWF_PVT SQL Statements

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

Line: 131

 *          corresponding PO part, and also update the status to 'ACCEPTED'
 *          of the req change
 *
 *          'ACCEPTANCE is to process the buyer's acceptance of
 *          change request. It will call movechangetopo to move the accepted
 *          change request to PO, and then update the req with the
 *          new value. also update the corresponding req change status.
 *
 *          the process will commit when it exits.
 *
 * Returns:
 ************************************************************************/
procedure ProcessBuyerAction(p_change_request_group_id in number,
        p_action in varchar2, p_launch_approvals_flag IN VARCHAR2 default 'N', p_supplier_change IN varchar2 default 'N');
Line: 147

 * Private Procedure: InsertActionHist
 * Effects: insert into action history table.
 *
 *          It is called when the change request is submitted (by requester
 *          or buyer) and when buyer responds to the change request.
 *
 *          the action can be 'SUBMIT CHANGE', 'ACCEPTED', 'REJECTED'
 *          or 'RESPOND'
 *
 *          the process will commit when it exits.
 *
 * Returns:
 ************************************************************************/
PROCEDURE InsertActionHist(itemtype varchar2,
        itemkey varchar2,
        p_doc_id number,
        p_doc_type varchar2,
        p_doc_subtype varchar2,
        p_employee_id number,
        p_action varchar2,
        p_note varchar2,
        p_path_id number);
Line: 177

 *          call the procedure AutoApprove to update the status of the
 *          change request and the corresponding requisition.
 *
 *          the process will commit when it exits.
 *
 * Returns:
 ************************************************************************/
PROCEDURE CheckPOAutoApproval(p_change_request_group_id in number);
Line: 189

 *          update the corresponding req change record and the requisition.
 *
 *          called by CheckPOAutoApproval, and will be committed in that
 *          procedure.
 *
 * Returns:
 ************************************************************************/
procedure AutoApprove(p_change_request_id in number);
Line: 207

 * Private Procedure: UpdateReqDistribution
 * Effects: update the quantity of a requisition distribution.
 *
 * Returns:
 ************************************************************************/
procedure UpdateReqDistribution(p_req_line_id in number,
        p_req_distribution_id in number,
        p_new_quantity in number,
        p_old_quantity in number,
        p_new_dist_amount number,
        p_old_dist_amount number,
        p_new_currency_dist_amount number,
        p_old_currency_dist_amount number);
Line: 226

 *          update the corresponding req change record and the requisition.
 *          call validate api to check if the request is valid or not.
 *          if yes, save the request to database
 *
 * Returns:
 ************************************************************************/
procedure ValidateAndSaveRequest(
        p_po_header_id         in number,
        p_po_release_id        in number,
        p_revision_num         in number,
        p_po_change_requests   in out nocopy pos_chg_rec_tbl);
Line: 239

 * Private Procedure: UpdateReqLine
 * Effects: update the need by date and/or price of a requisition line
 *
 * Returns:
 ************************************************************************/
procedure UpdateReqLine(p_req_line_id in number,
        p_new_need_by_date in DATE,
        p_new_unit_price in number,
        p_new_currency_unit_price in number,
        p_new_start_date date,
        p_new_end_date date);
Line: 275

 * Private Procedure: UpdatePODocHeaderTables
 * Effects: This procedure gets invoked from PO_ReqChangeRequestWF_PVT.New_PO_Change_Exists
 *
 *           When there is a change request,updating of the table po_header_all/po_release_all
 *           based on the status of the  change requests can also be done by an autonomous block
 *           which there by can create a deadlock.Hence included the updating of tables in
 *           this separate autonomous transaction procedure to avoid any deadlock error.
 ********************************************************************************************/
 procedure UpdatePODocHeaderTables(p_document_type varchar2, p_document_id number);
Line: 303

    SELECT ooh.ORG_ID
    INTO l_org_id
    from po_requisition_lines_all prl,
         po_requisition_headers_all prh,
         oe_order_headers_all ooh,
         po_system_parameters_all psp
    WHERE prl.requisition_header_id = nvl(p_req_hdr_id,prh.requisition_header_id)
    AND prl.requisition_line_id = nvl(p_req_line_id,prl.requisition_line_id)
    AND prh.requisition_header_id = nvl(p_req_hdr_id,prh.requisition_header_id)
    AND prh.requisition_header_id = ooh.source_document_id
    AND prh.segment1 = ooh.orig_sys_document_ref
    AND psp.org_id = prh.org_id
    AND psp.order_source_id = ooh.order_source_id
    AND nvl(p_req_hdr_id,p_req_line_id) IS NOT NULL
    and rownum =1;
Line: 332

    SELECT prh.org_id
    INTO l_org_id
    from po_requisition_lines_all prl,
         po_requisition_headers_all prh
    WHERE prl.requisition_header_id = nvl(p_req_hdr_id,prh.requisition_header_id)
    AND prh.requisition_header_id = nvl(p_req_hdr_id,prh.requisition_header_id)
    AND prl.requisition_line_id = nvl(p_req_line_id,prl.requisition_line_id)
    AND nvl(p_req_hdr_id,p_req_line_id) IS NOT NULL
     and rownum =1;
Line: 413

  SELECT  default_rate_type
  INTO l_rate_type
  FROM po_system_parameters;
Line: 419

     /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 426

    SELECT user_id
    INTO l_user_id
    FROM fnd_user
    WHERE user_name = l_approver_user_name;
Line: 433

       /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 449

     /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 466

     /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 484

     /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 503

     /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 521

     /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 534

 *          update the corresponding req change record and the requisition.
 *          call validate api to check if the request is valid or not.
 *          if yes, save the request to database
 *
 * Returns:
 ************************************************************************/
procedure ValidateAndSaveRequest(
    p_po_header_id         in number,
    p_po_release_id        in number,
    p_revision_num         in number,
    p_po_change_requests   in out nocopy pos_chg_rec_tbl) is

l_doc_check_rec_type Doc_Check_Return_Type;
Line: 567

        select nvl(authorization_status, 'IN PROCESS')
            into l_doc_status
            from po_headers_all
            where po_header_id=p_po_header_id;
Line: 572

        select nvl(authorization_status, 'IN PROCESS')
            into l_doc_status
            from po_releases_all
            where po_release_id=p_po_release_id;
Line: 618

                        update po_change_requests
                            set request_status='REJECTED',
                                change_active_flag='N',
                                response_reason=substr(fnd_message.get_string('PO',
                                                   'PO_RCO_VALIDATION_ERROR')||':'||
                                                   l_error_message1, 1, 2000),
                                response_date=sysdate,
                                validation_error=l_error_message
                            where change_request_id=
                                  p_po_change_requests(i).parent_change_request_id;
Line: 656

                    update po_change_requests
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_PO_REJECTED')
                where change_request_id=
                      p_po_change_requests(i).parent_change_request_id;
Line: 687

            update po_change_requests
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_SAVING')
                where change_request_id=
                      p_po_change_requests(i).parent_change_request_id;
Line: 704

 * Private Procedure: UpdateReqDistribution
 * Effects: update the quantity of a requisition distribution.
 *
 * Returns:
 ************************************************************************/
procedure UpdateReqDistribution(
        p_req_line_id in number,
        p_req_distribution_id in number,
        p_new_quantity in number,
        p_old_quantity in number,
        p_new_dist_amount number,
        p_old_dist_amount number,
        p_new_currency_dist_amount number,
        p_old_currency_dist_amount number) is
l_quantity number;
Line: 738

        raise g_update_data_exp;
Line: 740

    update po_req_distributions_all
    set req_line_quantity=p_new_quantity,
        req_line_amount = p_new_dist_amount,
        req_line_currency_amount = p_new_currency_dist_amount,
        recoverable_tax=l_recoverable_tax,
        nonrecoverable_tax=l_nonrecoverable_tax
    where distribution_id=p_req_distribution_id;
Line: 749

    update po_requisition_lines_all
    set
      quantity = quantity + decode(p_new_quantity,null,0,(p_new_quantity-p_old_quantity)),
      amount = amount + decode(p_new_dist_amount,null,0,(p_new_dist_amount - p_old_dist_amount)),
      currency_amount = currency_amount + decode(p_new_currency_dist_amount,null,0,
                                         (p_new_currency_dist_amount-p_old_currency_dist_amount))

    where requisition_line_id=p_req_line_id;
Line: 761

                        'UpdateReqDistribution',x_progress||sqlerrm);
Line: 763

end UpdateReqDistribution;
Line: 767

 * Private Procedure: UpdateReqLine
 * Effects: update the need by date and/or price of a requisition line
 *
 * Returns:
 ************************************************************************/
procedure UpdateReqLine(
        p_req_line_id in number,
        p_new_need_by_date in DATE,
        p_new_unit_price in number,
        p_new_currency_unit_price in number,
        p_new_start_date date,
        p_new_end_date date) is
l_quantity number;
Line: 787

    select distribution_id
    from po_req_distributions_all
    where requisition_line_id=p_req_line_id;
Line: 809

                raise g_update_data_exp;
Line: 814

            update po_req_distributions_all
                set recoverable_tax=l_recoverable_tax,
                    nonrecoverable_tax=l_nonrecoverable_tax
                where distribution_id=l_distributions_id;
Line: 824

    update po_requisition_lines_all
    set need_by_date=nvl(p_new_need_by_date, need_by_date),
        unit_price=nvl(p_new_unit_price, unit_price),
        currency_unit_price=nvl(p_new_currency_unit_price, currency_unit_price),        assignment_start_date = nvl(p_new_start_date, assignment_start_date),
        assignment_end_date = nvl(p_new_end_date, assignment_end_date)
    where requisition_line_id=p_req_line_id;
Line: 833

    wf_core.context('PO_ReqChangeRequestWF_PVT','UpdateReqLine',x_progress||sqlerrm);
Line: 836

end UpdateReqLine;
Line: 866

    select parent_change_request_id
    into l_req_change_request_id
    from po_change_requests
    where change_request_id=p_change_request_id;
Line: 871

    update po_change_requests
    set request_status='ACCEPTED',
        change_active_flag='N',
        response_date=sysdate,
        response_reason=fnd_message.get_string('PO','PO_RCO_AUTO_ACCEPTED')
    where change_request_id in (l_req_change_request_id, p_change_request_id);
Line: 878

    select document_header_id, document_line_id, document_distribution_id, action_type, request_level
    into l_header_id, l_line_id, l_distribution_id, l_action_type, l_request_level
    from po_change_requests
    where change_request_id=l_req_change_request_id;
Line: 885

            update po_requisition_headers_all
            set cancel_flag='Y'
            where requisition_header_id=l_header_id;
Line: 890

            update po_requisition_lines_all
            set cancel_flag='Y'
            where requisition_line_id=l_line_id;
Line: 897

            select new_need_by_date, new_price, new_currency_unit_price,
               new_start_date, new_expiration_date
            into l_new_need_by_date, l_new_unit_price,
              l_new_currency_unit_price, l_new_start_date,
              l_new_expiration_date
            from po_change_requests
            where change_request_id=l_req_change_request_id;
Line: 905

            UpdateReqLine(l_line_id, l_new_need_by_date,
                        l_new_unit_price, l_new_currency_unit_price,
                        l_new_start_date, l_new_expiration_date);
Line: 909

            select new_quantity, old_quantity
            into l_new_quantity, l_old_quantity
            from po_change_requests
            where change_request_id=l_req_change_request_id;
Line: 914

            UpdateReqDistribution(l_line_id, l_distribution_id,
                l_new_quantity, l_old_quantity);
Line: 954

    select pcr1.change_request_id,
           pcr1.parent_change_request_id,
           pcr2.request_level,
           pcr2.new_need_by_date,
           pcr2.new_quantity,
           pcr2.old_quantity,
           pcr2.new_amount,
           pcr2.old_amount,
           pcr2.new_currency_amount,
           pcr2.old_currency_amount,
           pcr2.document_line_id,
           pcr2.document_distribution_id,
           pcr2.change_request_group_id
      from po_change_requests pcr1, po_change_requests pcr2
     where pcr1.change_request_group_id=p_change_request_group_id
           and pcr1.document_line_location_id=p_line_location_id
           and pcr1.parent_change_request_id=pcr2.change_request_id;
Line: 995

        update po_change_requests
        set request_status='ACCEPTED',
            change_active_flag='N',
            response_date=sysdate,
            response_reason=fnd_message.get_string('PO','PO_RCO_AUTO_ACCEPTED')
        where change_request_id in (l_request_id, l_parent_request_id);
Line: 1004

            UpdateReqLine(l_line_id, l_new_need_by_date,
                        null, null, null, null);
Line: 1007

            UpdateReqDistribution(l_line_id, l_distribution_id,
                l_new_quantity, l_old_quantity, l_new_amount, l_old_amount,
                l_new_currency_amount, l_old_currency_amount);
Line: 1014

        update po_change_requests
           set request_status='ACCEPTED',
               change_active_flag='N',
               response_date=sysdate,
               response_reason=fnd_message.get_string('PO','PO_RCO_AUTO_ACCEPTED')
         where change_request_group_id=p_change_request_group_id
               and document_line_location_id=p_line_location_id
               and parent_change_request_id is null;
Line: 1029

        select new_price, new_currency_unit_price
        into l_new_price, l_new_currency_unit_price
        from po_change_requests
        where change_request_group_id=l_req_change_group_id1
              and document_line_id=l_line_id1
              and action_type='DERIVED'
              and new_price is not null;
Line: 1037

        UpdateReqLine(l_line_id1, null, l_new_price, l_new_currency_unit_price, null, null);
Line: 1098

    select  pcr.document_type,
            pcr.document_header_id,
            pcr.document_line_id,
            pcr.document_line_location_id,
            pcr.document_distribution_id,
            pcr.po_release_id,
            pcr.change_request_id,
            pcr.request_level,
            pcr.action_type,
            pcr.new_need_by_date,
            pcr.new_price,
            pcr.new_quantity,
            pcr.new_start_date,
            pcr.new_expiration_date,
            pcr.new_amount,
            pol.unit_price line_price,
            pll.need_by_date ship_need_by_date,
            pod.quantity_ordered dist_quantity,
            pol.start_date line_start_date,
            pol.expiration_date line_end_date,
            pod.amount_ordered dist_amount,
            nvl(por.cancel_flag, poh.cancel_flag) header_cancel_flag,
            pol.cancel_flag line_cancel_flag,
            pll.cancel_flag shipment_cancel_flag,
            poh.currency_code,
            pol.org_id
    from po_change_requests pcr,
         po_headers_all poh,
         po_lines_all pol,
         po_line_locations_all pll,
         po_distributions_all pod,
         po_releases_all por
    where pcr.change_request_group_id=p_change_request_group_id
        and pcr.request_status='PENDING'
        and pcr.parent_change_request_id is not null
        and pcr.document_header_id=poh.po_header_id
        and pcr.document_line_id=pol.po_line_id(+)
        and pcr.document_line_location_id=pll.line_location_id(+)
        and pcr.document_distribution_id=pod.po_distribution_id(+)
        and pcr.po_release_id=por.po_release_id(+)
    order by document_line_id, nvl(document_line_location_id, 0), nvl(document_distribution_id,0);
Line: 1219

                SELECT sob.currency_code
                INTO  l_functional_currency_code
                FROM  gl_sets_of_books sob, financials_system_params_all fsp
                WHERE fsp.org_id = l_org_id
                AND  fsp.set_of_books_id = sob.set_of_books_id;
Line: 1292

    select document_header_id,
           po_release_id,
           document_type
      from po_change_requests
     where change_request_group_id=p_change_request_group_id
           and request_status='PENDING';
Line: 1333

    select
        document_header_id,
        po_release_id,
        document_num,
        action_type,
        document_type,
        request_level,
        document_revision_num,
        created_by,
        document_line_id,
        document_line_number,
        document_line_location_id,
        document_shipment_number,
        document_distribution_id,
        document_distribution_number,
        request_reason,
        old_need_by_date,
        new_need_by_date,
        old_price,
        new_price,
        old_quantity,
        new_quantity,
        old_start_date,
        new_start_date,
        old_expiration_date,
        new_expiration_date,
        old_amount,
        new_amount,
        parent_change_request_id
    from po_change_requests
    where change_request_group_id=p_change_request_group_id
        and request_status='PENDING';
Line: 1374

        select nvl(authorization_status, 'IN PROCESS'), revision_num
            into l_doc_status,ll_document_revision_num
            from po_headers_all
            where po_header_id=ll_document_header_id;
Line: 1380

        select nvl(authorization_status, 'IN PROCESS'), revision_num
            into l_doc_status, ll_document_revision_num
            from po_releases_all
            where po_release_id=ll_po_release_id;
Line: 1391

        update po_change_requests
           set request_status='REJECTED',
               change_active_flag='N',
               response_date=sysdate,
               response_reason=fnd_message.get_string('PO', 'PO_RCO_PO_REJECTED')
         where change_request_id in (
                select parent_change_request_id
                  from po_change_requests
                 where change_request_group_id=p_change_request_group_id
                       and request_status='PENDING');
Line: 1403

        update po_change_requests
           set request_status='REJECTED',
               change_active_flag='N',
               response_date=sysdate,
               response_reason=fnd_message.get_string('PO', 'PO_RCO_PO_REJECTED')
         where change_request_group_id=p_change_request_group_id
               and request_status='PENDING';
Line: 1532

            update po_change_requests
               set request_status='REJECTED',
                   change_active_flag='N',
                   response_date=sysdate,
                   response_reason=substr(fnd_message.get_string('PO',
                                           'PO_RCO_VALIDATION_ERROR')||':'||
                                           l_error_message1, 1, 2000)
             where change_request_id in (
                    select parent_change_request_id
                      from po_change_requests
                     where change_request_group_id=p_change_request_group_id
                           and request_status='PENDING');
Line: 1546

            update po_change_requests
               set request_status='REJECTED',
                   change_active_flag='N',
                   response_date=sysdate,
                   response_reason=substr(fnd_message.get_string('PO',
                                           'PO_RCO_VALIDATION_ERROR')||':'||
                                           l_error_message1, 1, 2000)
             where change_request_group_id=p_change_request_group_id
                   and request_status='PENDING';
Line: 1586

 *          corresponding PO part, and also update the status to 'ACCEPTED'
 *          of the req change
 *
 *          'ACCEPTANCE is to process the buyer's acceptance of
 *          change request. It will call movechangetopo to move the accepted
 *          change request to PO, and then update the req with the
 *          new value. also update the corresponding req change status.
 *
 *          the process will COMMIT when it exits.
 *
 * Returns:
 ************************************************************************/
procedure ProcessBuyerAction(p_change_request_group_id in number, p_action in varchar2, p_launch_approvals_flag IN VARCHAR2 default 'N', p_supplier_change IN varchar2 default 'N') is
pragma AUTONOMOUS_TRANSACTION;
Line: 1658

    select decode (document_type, 'RELEASE', null, document_line_id), document_line_location_id,
        change_request_id, request_reason
    from po_change_requests
    where change_request_group_id=p_change_request_group_id
        and request_status='BUYER_APP'
        and action_type='CANCELLATION';
Line: 1666

    select request_level, document_type, document_header_id,
            document_line_id, document_distribution_id, po_release_id,
            change_request_id, old_need_by_date, new_need_by_date,
            old_price, new_price, old_quantity, new_quantity,
            old_currency_unit_price, new_currency_unit_price,
            old_start_date, new_start_date,
            old_expiration_date, new_expiration_date,
            old_amount, new_amount,
            old_currency_amount, new_currency_amount,
            change_request_group_id
    from po_change_requests
    where change_request_id in
            (select parent_change_request_id
            from po_change_requests
            where   change_request_group_id=p_change_request_group_id
                and request_status='BUYER_APP'
                and action_type='MODIFICATION')
    order by document_line_id, document_distribution_id;
Line: 1686

    select request_level, document_type, document_header_id,
            document_line_id, document_distribution_id, po_release_id,
            change_request_id, old_need_by_date, new_need_by_date,
            old_price, new_price, old_quantity, new_quantity,
            old_currency_unit_price, new_currency_unit_price,
            old_start_date, new_start_date,
            old_expiration_date, new_expiration_date,
            old_amount, new_amount,
            old_currency_amount, new_currency_amount,
            change_request_group_id
    from po_change_requests
    where change_request_group_id in
            (select parent_change_request_id
            from po_change_requests
            where   change_request_group_id=p_change_request_group_id
                and request_status='BUYER_APP'
                and action_type='MODIFICATION')
    order by document_line_id, document_distribution_id;
Line: 1706

    select document_type, document_header_id, po_release_id, nvl(requester_id, created_by)
        from po_change_requests
        where change_request_group_id =p_change_request_group_id;
Line: 1711

    select change_request_id
        from po_change_requests
        where change_request_group_id=p_change_request_group_id
            and request_status in ('PENDING', 'BUYER_APP')
            and action_type='MODIFICATION';
Line: 1721

  select document_line_id,change_request_group_id
  from po_change_requests
  where document_type = 'REQ'
  and change_request_id in
    (select parent_change_request_id
            from po_change_requests pcr2
            where pcr2.change_request_group_id=p_change_request_group_id
                  and pcr2.action_type='MODIFICATION'
                  and ( pcr2.new_start_date is not null
                       or pcr2.new_expiration_date is not null ) );
Line: 1743

        update PO_CHANGE_REQUESTS pcr1
        set (pcr1.request_status,
             pcr1.change_active_flag,
             pcr1.response_date,
             pcr1.response_reason,
             pcr1.responded_by,
             pcr1.last_updated_by,
             pcr1.last_update_login,
             pcr1.last_update_date) =
            (select 'REJECTED',
                    'N',
                    pcr2.response_date,
                    pcr2.response_reason,
                    pcr2.responded_by,
                    fnd_global.user_id,
                    fnd_global.login_id,
                    sysdate
             from po_change_requests pcr2
             where pcr2.parent_change_request_id=pcr1.change_request_id
                   and pcr2.change_request_group_id=p_change_request_group_id
                   and pcr2.request_status='REJECTED')
        where pcr1.change_request_id in
            (select parent_change_request_id
                from po_change_requests
                where change_request_group_id=p_change_request_group_id
                    and request_status='REJECTED');
Line: 1786

        update PO_CHANGE_REQUESTS pcr1
        set (pcr1.request_status,
             pcr1.change_active_flag,
             pcr1.response_date,
             pcr1.response_reason,
             pcr1.responded_by,
             pcr1.last_updated_by,
             pcr1.last_update_login,
             pcr1.last_update_date) =
             (select 'REJECTED',
                    'N',
                    pcr2.response_date,
                    pcr2.response_reason,
                    pcr2.responded_by,
                    fnd_global.user_id,
                    fnd_global.login_id,
                    sysdate
             from po_change_requests pcr2
             where pcr2.parent_change_request_id in
                   ( select pcr3.change_request_id
                     from  po_change_requests pcr3
                     where
                     pcr3.change_request_group_id=pcr1.change_request_group_id
                     and pcr3.document_line_id = pcr1.document_line_id
                   )
                   and pcr2.change_request_group_id=p_change_request_group_id
                   and pcr2.request_status='REJECTED' and rownum=1
             )
        where  pcr1.change_request_id in (
             select pcr5.change_request_id
             from
             po_change_requests pcr,
             po_change_requests pcr4,
             po_change_requests pcr5,
             po_requisition_lines_all por
             where
             pcr.change_request_group_id=p_change_request_group_id
             and pcr.parent_change_request_id=pcr4.change_request_id
             and pcr4.change_request_group_id=pcr5.change_request_group_id
             and pcr4.document_line_id = pcr5.document_line_id
             and pcr.request_status='REJECTED'
             and por.requisition_line_id = pcr4.document_line_id
             and por.purchase_basis='TEMP LABOR' );
Line: 1835

        UPDATE po_line_locations_all
        SET
          approved_flag = 'Y',
          last_update_date = sysdate,
          last_updated_by = fnd_global.user_id,
          last_update_login = fnd_global.login_id
        WHERE line_location_id IN
          (SELECT document_line_location_id
           FROM po_change_requests
           WHERE
             request_level = 'SHIPMENT' AND
             change_request_group_id = p_change_request_group_id AND
             action_type IN ('MODIFICATION', 'CANCELLATION') AND
             initiator = 'REQUESTER') AND
           approved_flag = 'R';
Line: 1876

            update po_headers_all
            set AUTHORIZATION_STATUS = 'APPROVED',
                approved_flag='Y',
                CHANGE_REQUESTED_BY=null,
                last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate
            where po_header_id = l_document_id;
Line: 1888

            update po_releases_all
            set AUTHORIZATION_STATUS = 'APPROVED',
                approved_flag='Y',
                CHANGE_REQUESTED_BY=null,
                last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate
            where po_release_id = l_release_id;
Line: 1909

              select count(1)
              into l_num_of_shipments
              from po_line_locations_all
              where po_line_id = l_document_line_id
                    and nvl(cancel_flag, 'N') = 'N';
Line: 1963

        update PO_CHANGE_REQUESTS pcr1
        set (pcr1.request_status,
             pcr1.change_active_flag,
             pcr1.response_date,
             pcr1.response_reason,
             pcr1.responded_by,
             pcr1.last_updated_by,
             pcr1.last_update_login,
             pcr1.last_update_date) =
            (select 'ACCEPTED',
                    'N',
                    pcr2.response_date,
                    pcr2.response_reason,
                    pcr2.responded_by,
                    fnd_global.user_id,
                    fnd_global.login_id,
                    sysdate
             from po_change_requests pcr2
             where pcr2.parent_change_request_id=pcr1.change_request_id
                   and pcr2.change_request_group_id=p_change_request_group_id
                   and pcr2.request_status in ('BUYER_APP', 'ACCEPTED')
                   and pcr2.action_type='CANCELLATION')
        where pcr1.change_request_id in
            (select parent_change_request_id
             from po_change_requests
             where change_request_group_id=p_change_request_group_id
                 and request_status in ('BUYER_APP', 'ACCEPTED')
                 and action_type='CANCELLATION');
Line: 1993

        update PO_CHANGE_REQUESTS
        set request_status='ACCEPTED',
            change_active_flag='N'
        where change_request_group_id=p_change_request_group_id
            and request_status='BUYER_APP'
            and action_type='CANCELLATION';
Line: 2016

                update po_headers_all   set
                AUTHORIZATION_STATUS = 'IN PROCESS',
--                approved_flag='N',
                CHANGE_REQUESTED_BY='REQUESTER',
                last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate
                where po_header_id = l_document_id;
Line: 2028

                update po_releases_all   set
                AUTHORIZATION_STATUS = 'IN PROCESS',
--                approved_flag='N',
                CHANGE_REQUESTED_BY='REQUESTER',
                last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate
                where po_release_id = l_release_id;
Line: 2063

                update PO_CHANGE_REQUESTS
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_PROCESS') ||
                       decode(l_validation_error, NULL, '', ' : ' || l_validation_error ),
                    validation_error =l_validation_error
                where change_request_id in (select parent_change_request_id
                                    from po_change_requests
                                    where change_request_group_id=p_change_request_group_id
                                        and request_status='BUYER_APP'
                                        and action_type='CANCELLATION');
Line: 2076

                update PO_CHANGE_REQUESTS
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_PROCESS') ||
                       decode(l_validation_error, NULL, '', ' : ' || l_validation_error ),
                    validation_error =l_validation_error
                where change_request_group_id=p_change_request_group_id
                    and request_status='BUYER_APP'
                    and action_type='CANCELLATION';
Line: 2176

                            select new_price, new_currency_unit_price
                            into l_new_price1, l_new_currency_unit_price1
                            from po_change_requests
                            where change_request_group_id=l_group_id
                                  and document_line_id=l_document_line_id
                                  and action_type='DERIVED'
                                  and new_price is not null;
Line: 2184

                            UpdateReqLine(l_document_line_id,
                               null,
                               l_new_price1,
                               l_new_currency_unit_price1, null, null);
Line: 2204

                      select new_start_date
                      into l_new_start_date
                      from po_change_requests
                      where change_request_group_id = l_group_id
                      and document_type = 'REQ'
                      and document_line_id = l_document_line_id
                      and request_level= 'LINE'
                      and action_type = 'MODIFICATION'
                      and new_expiration_date is null
                      and new_start_date is not null;
Line: 2221

                      select new_expiration_date
                      into l_new_expiration_date
                      from po_change_requests
                      where change_request_group_id = l_group_id
                      and document_type = 'REQ'
                      and document_line_id = l_document_line_id
                      and request_level= 'LINE'
                      and action_type = 'MODIFICATION'
                      and new_start_date is null
                      and new_expiration_date is not null;
Line: 2237

                    UpdateReqLine(l_document_line_id,
                               l_new_need_by_date,
                               l_new_price,
                               l_new_currency_unit_price,
                               l_new_start_date,
                               l_new_expiration_date);
Line: 2245

                    UpdateReqDistribution(l_document_line_id,
                               l_document_distribution_id,
                               l_new_quantity,
                               l_old_quantity,
                               l_new_amount,
                               l_old_amount,
                               l_new_currency_amount,
                               l_old_currency_amount);
Line: 2315

            update PO_CHANGE_REQUESTS pcr1
            set (pcr1.request_status,
                 pcr1.change_active_flag,
                 pcr1.response_date,
                 pcr1.response_reason,
                 pcr1.responded_by,
                 pcr1.last_updated_by,
                 pcr1.last_update_login,
                 pcr1.last_update_date) =
                (select 'ACCEPTED',
                        'N',
                        pcr2.response_date,
                        pcr2.response_reason,
                        pcr2.responded_by,
                        fnd_global.user_id,
                        fnd_global.login_id,
                        sysdate
                 from po_change_requests pcr2
                 where pcr2.parent_change_request_id=pcr1.change_request_id
                       and pcr2.change_request_group_id=p_change_request_group_id
                       and pcr2.request_status='BUYER_APP'
                       and pcr2.action_type='MODIFICATION')
            where pcr1.change_request_id in
                (select parent_change_request_id
                 from po_change_requests
                 where change_request_group_id=p_change_request_group_id
                     and request_status='BUYER_APP'
                     and action_type='MODIFICATION');
Line: 2359

              update PO_CHANGE_REQUESTS pcr1
              set (pcr1.request_status,
                 pcr1.change_active_flag,
                 pcr1.response_date,
                 pcr1.response_reason,
                 pcr1.responded_by,
                 pcr1.last_updated_by,
                 pcr1.last_update_login,
                 pcr1.last_update_date) =
                (select 'ACCEPTED',
                        'N',
                        pcr2.response_date,
                        pcr2.response_reason,
                        pcr2.responded_by,
                        fnd_global.user_id,
                        fnd_global.login_id,
                        sysdate
                 from po_change_requests pcr2
                 where pcr2.document_type= 'REQ'
                       and pcr2.change_request_group_id=l_req_change_grp_id
                       and pcr2.document_line_id = l_req_doc_id
                       and pcr2.request_status= 'ACCEPTED'
                       and pcr2.action_type ='MODIFICATION'
                       and pcr2.request_level ='LINE')

                where pcr1.change_request_group_id =l_req_change_grp_id
                and pcr1.document_line_id = l_req_doc_id
                and pcr1.request_status <>'ACCEPTED'
                and pcr1.action_type='MODIFICATION'
                and pcr1.request_level = 'LINE';
Line: 2402

                update PO_CHANGE_REQUESTS
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_PROCESS') ||
                       decode(l_validation_error, NULL, '', ' : ' || l_validation_error ),
                    validation_error=l_err_msg
                where change_request_id in (select parent_change_request_id
                                    from po_change_requests
                                    where change_request_group_id=p_change_request_group_id
                                        and request_status='BUYER_APP'
                                        and action_type='MODIFICATION');
Line: 2415

                update PO_CHANGE_REQUESTS
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_PROCESS') ||
                        decode(l_validation_error, NULL, '', ' : ' || l_validation_error ),
                    validation_error=l_err_msg
                where change_request_group_id=p_change_request_group_id
                    and request_status='BUYER_APP'
                    and action_type='MODIFICATION';
Line: 2512

    select request_level, document_type, document_header_id,
            document_line_id, document_distribution_id, po_release_id,
            change_request_id, old_need_by_date, new_need_by_date,
            old_price, new_price, old_quantity, new_quantity,
            old_currency_unit_price, new_currency_unit_price,
            old_start_date, new_start_date,
            old_expiration_date, new_expiration_date,
            old_amount, new_amount,
            old_currency_amount, new_currency_amount,
            change_request_group_id
    from po_change_requests
    where change_request_group_id in
            (select parent_change_request_id
            from po_change_requests
            where   change_request_group_id=p_change_request_group_id
                and request_status='BUYER_APP'
                and action_type='MODIFICATION')
    order by document_line_id, document_distribution_id;
Line: 2532

    select document_type, document_header_id, po_release_id, nvl(requester_id, created_by)    from po_change_requests
    where change_request_group_id =p_change_request_group_id;
Line: 2585

                            select new_price, new_currency_unit_price
                            into l_new_price1, l_new_currency_unit_price1
                            from po_change_requests
                            where change_request_group_id=l_group_id
                                  and document_line_id=l_document_line_id
                                  and action_type='DERIVED'
                                  and new_price is not null;
Line: 2593

                            UpdateReqLine(l_document_line_id,
                               null,
                               l_new_price1,
                               l_new_currency_unit_price1, null, null);
Line: 2612

                      select nvl(pcr1.new_start_date, pcr2.new_start_date),
                             nvl(pcr1.new_expiration_date, pcr2.new_expiration_date),
                             pcr1.change_request_id,
                             pcr2.change_request_id
                      into   l_new_start_date,
                             l_new_expiration_date,
                             l_date_change_id1,
                             l_date_change_id
                      from po_change_requests pcr1, po_change_requests pcr2
                      where pcr1.change_request_group_id = pcr2.change_request_group_id
                          --  and pcr1.change_request_id in
                              and pcr1.change_request_group_id in
                               (select parent_change_request_id
                                from po_change_requests
                                where   change_request_group_id=p_change_request_group_id
                                         and request_status='BUYER_APP'
                                        and action_type='MODIFICATION')
                           and (pcr2.new_start_date is not null
                                or pcr2.new_expiration_date is not null)
                           and pcr1.change_request_id <> pcr2.change_request_id
                           and (pcr1.new_start_date is not null
                                or pcr1.new_expiration_date is not null)
                           and pcr2.request_level='LINE'
                           and pcr2.action_type='MODIFICATION';
Line: 2642

                    UpdateReqLine(l_document_line_id,
                               l_new_need_by_date,
                               l_new_price,
                               l_new_currency_unit_price,
                               l_new_start_date,
                               l_new_expiration_date);
Line: 2649

                    UpdateReqDistribution(l_document_line_id,
                               l_document_distribution_id,
                               l_new_quantity,
                               l_old_quantity,
                               l_new_amount,
                               l_old_amount,
                               l_new_currency_amount,
                               l_old_currency_amount);
Line: 2708

            select   pcr.response_date,
                     pcr.response_reason,
                     pcr.responded_by
            into    l_temp_date,
                    l_temp_reason,
                    l_temp_responder
            from po_change_requests pcr
            where pcr.change_request_group_id=p_change_request_group_id
            and pcr.action_type='MODIFICATION'
            and rownum=1;
Line: 2719

            update PO_CHANGE_REQUESTS pcr1
              set (pcr1.request_status,
                   pcr1.change_active_flag,
                   pcr1.response_date,
                   pcr1.response_reason,
                   pcr1.responded_by,
                   pcr1.last_updated_by,
                   pcr1.last_update_login,
                   pcr1.last_update_date) =
                   (select 'ACCEPTED',
                        'N',
                        l_temp_date,
                        l_temp_reason,
                        l_temp_responder,
                        fnd_global.user_id,
                        fnd_global.login_id,
                        sysdate
                  from dual)
              where pcr1.change_request_group_id in
                (select parent_change_request_id
                 from po_change_requests
                 where change_request_group_id=p_change_request_group_id
                     and action_type='MODIFICATION');
Line: 2744

              update PO_CHANGE_REQUESTS pcr1
              set (pcr1.request_status,
                 pcr1.change_active_flag,
                 pcr1.response_date,
                 pcr1.response_reason,
                 pcr1.responded_by,
                 pcr1.last_updated_by,
                 pcr1.last_update_login,
                 pcr1.last_update_date) =
                (select 'ACCEPTED',
                        'N',
                        pcr2.response_date,
                        pcr2.response_reason,
                        pcr2.responded_by,
                        fnd_global.user_id,
                        fnd_global.login_id,
                        sysdate
                 from po_change_requests pcr2
                 where pcr2.parent_change_request_id=l_date_change_id1
                       and pcr2.change_request_group_id=p_change_request_group_id
                       and pcr2.action_type='MODIFICATION'
                       and rownum=1)
              where pcr1.change_request_id = l_date_change_id;
Line: 2777

               update PO_CHANGE_REQUESTS
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_PROCESS'),
                    validation_error=l_err_msg
                where change_request_group_id in (select parent_change_request_id
                                    from po_change_requests
                                    where change_request_group_id=p_change_request_group_id
                                        and action_type='MODIFICATION');
Line: 2788

                update PO_CHANGE_REQUESTS
                set request_status='REJECTED',
                    change_active_flag='N',
                    response_date=sysdate,
                    response_reason=fnd_message.get_string('PO', 'PO_RCO_EXCEPTION_WHEN_PROCESS'),
                    validation_error=l_err_msg
                where change_request_group_id=p_change_request_group_id
                    and action_type='MODIFICATION';
Line: 2829

    update PO_CHANGE_REQUESTS
    set last_updated_by         = fnd_global.user_id,
        last_update_login       = fnd_global.login_id,
        last_update_date        = sysdate,
        request_status=p_request_status,
        response_date=sysdate,
        responded_by=fnd_global.user_id,
        response_reason = nvl(p_response_reason, response_reason),
        change_active_flag=decode(p_request_status, 'ACCEPTED', 'N',
                                 'REJECTED', 'N', 'Y')
    where change_request_group_id=p_change_request_group_id
        and request_status not in ('ACCEPTED', 'REJECTED');
Line: 2927

select * from (
select max(pll.po_header_id) document_header_id,
max(pll.po_release_id) po_release_id,
max(decode(pll.po_release_id, null, poh.segment1, poh.segment1||'-'||to_char(por.release_num))) document_num,
max(pcr.action_type) action_type,
max(decode(pll.po_release_id, null, 'PO', 'RELEASE')) document_type,
'LINE' request_level,
max(pcr.document_revision_num) document_revision_num,
max(pcr.created_by) created_by,
max(pol.po_line_id) document_line_id,
max(pol.line_num) document_line_number,
to_number(null) document_line_location_id,
to_number(null) document_shipment_number,
to_number(null) document_distribution_id,
to_number(null) document_distribution_num,
max(pcr.request_reason) request_reason,
max(nvl(pcr.old_need_by_date, pll.need_by_date)) old_need_by_date,
max(pcr.new_need_by_date) new_need_by_date,
max((pcr.old_price)/nvl(poh.rate,1)) old_price, -- If Order is in trn currency divide price by rate, else leave it as it is
max((pcr.new_price)/nvl(poh.rate,1)) new_price,
to_number(null) old_quantity,
to_number(null) new_quantity,
max(pcr.change_request_id) parent_change_request_id,
max(pll.quantity) ship_quantity,
to_number(null) dist_quantity,
max(pll.SHIP_TO_ORGANIZATION_ID),
max(pll.SHIP_TO_LOCATION_ID),
max(prl.item_id),
max(prl.unit_meas_lookup_code) req_uom,
max(nvl(pll.unit_meas_lookup_code,pol.unit_meas_lookup_code)) po_uom,
max(pol.start_date) old_start_date,
max(pcr.new_start_date) new_start_date,
max(pol.expiration_date) old_expiration_date,
max(pcr.new_expiration_date) new_expiration_date,
to_number(null) old_amount,
to_number(null) new_amount,
max(pll.amount) ship_amount,
to_number(null) dist_amount,
max(prl.matching_basis),
max(pcr.requester_id) requester_id   -- Bug # 3862383
from po_change_requests pcr,
po_line_locations_all pll,
po_requisition_lines_all prl,
po_headers_all poh,
po_releases_all por,
po_lines_all pol
where pcr.change_request_group_id=l_change_request_group_id
and pcr.request_status='MGR_APP'
and pcr.document_distribution_id is null
and pcr.document_line_id=prl.requisition_line_id
and prl.purchase_basis = 'TEMP LABOR'
and prl.line_location_id=pll.line_location_id
and poh.po_header_id=pll.po_header_id
and por.po_release_id(+)=pll.po_release_id
and pol.po_line_id=pll.po_line_id
group by pol.po_line_id
union select pll.po_header_id document_header_id,
pll.po_release_id po_release_id,
decode(pll.po_release_id, null, poh.segment1, poh.segment1||'-'||to_char(por.release_num)) document_num,
pcr.action_type action_type,
decode(pll.po_release_id, null, 'PO', 'RELEASE') document_type,
decode(pcr.new_price, null, 'SHIPMENT', 'LINE') request_level,
pcr.document_revision_num document_revision_num,
pcr.created_by created_by,
pol.po_line_id document_line_id,
pol.line_num document_line_number,
decode(pcr.new_price, null, pll.line_location_id, null) document_line_location_id,
decode(pcr.new_price, null, pll.shipment_num, null) document_shipment_number,
to_number(null) document_distribution_id,
to_number(null) document_distribution_num,
pcr.request_reason request_reason,
nvl(pcr.old_need_by_date, pll.need_by_date) old_need_by_date,
pcr.new_need_by_date new_need_by_date,
(pcr.old_price)/nvl(poh.rate,1)  old_price, -- If Order is in trn currency divide price by rate, else leave it as it is
(pcr.new_price)/nvl(poh.rate,1) new_price,
to_number(null) old_quantity,
to_number(null) new_quantity,
pcr.change_request_id parent_change_request_id,
pll.quantity ship_quantity,
to_number(null) dist_quantity,
pll.SHIP_TO_ORGANIZATION_ID,
pll.SHIP_TO_LOCATION_ID,
prl.item_id,
prl.unit_meas_lookup_code req_uom,
nvl(pll.unit_meas_lookup_code,pol.unit_meas_lookup_code) po_uom,
pol.start_date old_start_date,
pcr.new_start_date new_start_date,
pol.expiration_date old_expiration_date,
pcr.new_expiration_date new_expiration_date,
to_number(null) old_amount,
to_number(null) new_amount,
pll.amount ship_amount,
to_number(null) dist_amount,
prl.matching_basis,
pcr.requester_id requester_id   -- Bug # 3862383
from po_change_requests pcr,
po_line_locations_all pll,
po_requisition_lines_all prl,
po_headers_all poh,
po_releases_all por,
po_lines_all pol
where pcr.change_request_group_id=l_change_request_group_id
and pcr.request_status='MGR_APP'
and pcr.document_distribution_id is null
and pcr.document_line_id=prl.requisition_line_id
and prl.purchase_basis <> 'TEMP LABOR'
and prl.line_location_id=pll.line_location_id
and poh.po_header_id=pll.po_header_id
and por.po_release_id(+)=pll.po_release_id
and pol.po_line_id=pll.po_line_id
union
select pll.po_header_id document_header_id,
pll.po_release_id po_release_id,
decode(pll.po_release_id, null, poh.segment1, poh.segment1||'-'||to_char(por.release_num)) document_num,
pcr.action_type action_type,
decode(pll.po_release_id, null, 'PO', 'RELEASE') document_type,
'DISTRIBUTION' request_level,
pcr.document_revision_num document_revision_num,
pcr.created_by created_by,
pol.po_line_id document_line_id,
pol.line_num document_line_number,
pll.line_location_id document_line_location_id,
pll.shipment_num document_shipment_number,
pod.po_distribution_id document_distribution_id,
pod.distribution_num document_distribution_num,
pcr.request_reason request_reason,
nvl(pcr.old_need_by_date, pll.need_by_date) old_need_by_date,
pcr.new_need_by_date new_need_by_date,
decode(prl.ORDER_TYPE_LOOKUP_CODE,'AMOUNT',pcr.old_price,(pcr.old_price)/nvl(pod.rate,1)) old_price, /* If Order is in trn currency divide price by rate if order_type is not AMOUNT. Beacuse we are dividing qty by rate in that case. */
decode(prl.ORDER_TYPE_LOOKUP_CODE,'AMOUNT',pcr.new_price,(pcr.new_price)/nvl(pod.rate,1)) new_price,
decode(prl.ORDER_TYPE_LOOKUP_CODE,'AMOUNT', (pcr.old_quantity/nvl(pod.RATE,1)), pcr.old_quantity) old_quantity,--Divide qty by rate for amt based reqs only
decode(prl.ORDER_TYPE_LOOKUP_CODE,'AMOUNT', (pcr.new_quantity/nvl(pod.RATE,1)), pcr.new_quantity) new_quantity,
pcr.change_request_id parent_change_request_id,
pll.quantity ship_quantity,
pod.quantity_ordered dist_quantity,
pll.SHIP_TO_ORGANIZATION_ID,
pll.SHIP_TO_LOCATION_ID,
prl.item_id,
prl.unit_meas_lookup_code req_uom,
nvl(pll.unit_meas_lookup_code,pol.unit_meas_lookup_code) po_uom,
to_date(null) old_start_date,
to_date(null) new_start_date,
to_date(null) old_expiration_date,
to_date(null) new_expiration_date,
(pcr.old_amount)/nvl(pod.rate,1) old_amount,
(pcr.new_amount)/nvl(pod.rate,1) new_amount,
pll.amount ship_amount,
pod.amount_ordered dist_amount,
prl.matching_basis,
pcr.requester_id requester_id   -- Bug # 3862383
from po_change_requests pcr,
po_line_locations_all pll,
po_requisition_lines_all prl,
po_headers_all poh,
po_releases_all por,
po_distributions_all pod,
po_req_distributions_all prd,
po_lines_all pol
where pcr.change_request_group_id=l_change_request_group_id
and pcr.request_status='MGR_APP'
and pcr.document_distribution_id is not null
and pcr.document_line_id=prl.requisition_line_id
and prl.line_location_id=pll.line_location_id
and poh.po_header_id=pll.po_header_id
and por.po_release_id(+)=pll.po_release_id
and pcr.document_distribution_id=prd.distribution_id
and pcr.document_distribution_id=pod.req_distribution_id
and pll.line_location_id=pod.line_location_id
and pol.po_line_id=pll.po_line_id
)
order by document_header_id, po_release_id, document_line_id,
    document_line_location_id, document_distribution_id;
Line: 3515

            update PO_CHANGE_REQUESTS
            set last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate,
                request_status='MGR_APP'
            where change_request_group_id=p_change_request_group_id
                and action_type='CANCELLATION'
                and request_status='NEW';
Line: 3532

            update PO_CHANGE_REQUESTS
            set last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate,
                request_status='MGR_APP'
            where change_request_group_id=p_change_request_group_id
                and action_type='MODIFICATION'
                and request_status in ('NEW', 'MGR_PRE_APP');
Line: 3547

            update PO_CHANGE_REQUESTS
            set last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate,
                request_status='MGR_PRE_APP'
            where change_request_group_id=p_change_request_group_id
                and action_type='MODIFICATION'
                and request_status ='NEW';
Line: 3560

            update PO_CHANGE_REQUESTS
            set last_updated_by         = fnd_global.user_id,
                last_update_login       = fnd_global.login_id,
                last_update_date        = sysdate,
                request_status='REJECTED',
                change_active_flag='N',
                responded_by=p_responder_id,
                response_reason=p_response_reason,
                response_date = sysdate
            where change_request_group_id=p_change_request_group_id
                and action_type='MODIFICATION'
                and request_status in ('NEW', 'MGR_PRE_APP');
Line: 3612

    update po_requisition_headers_all
    set last_updated_by         = nvl(fnd_global.user_id, last_updated_by),
        last_update_login       = nvl(fnd_global.login_id, last_update_login),
        last_update_date        = sysdate,
        change_pending_flag=p_change_flag
    where requisition_header_id = p_document_id;
Line: 3622

        update po_change_requests
        set wf_item_type=p_itemtype,
            wf_item_key=p_itemkey
        where change_request_group_id=p_change_request_group_id;
Line: 3639

 * Private Procedure: InsertActionHist
 * Effects: insert into action history table.
 *
 *          It is called when the change request is submitted (by requester
 *          or buyer) and when buyer responds to the change request.
 *
 *          the action can be 'SUBMIT CHANGE', 'ACCEPTED', 'REJECTED'
 *          or 'RESPOND'
 *
 *          the process will commit when it exits.
 *
 * Returns:
 ************************************************************************/
PROCEDURE InsertActionHist(
        itemtype varchar2,
        itemkey varchar2,
        p_doc_id number,
        p_doc_type varchar2,
        p_doc_subtype varchar2,
        p_employee_id number,
        p_action varchar2,
        p_note varchar2,
        p_path_id number) is

pragma AUTONOMOUS_TRANSACTION;
Line: 3672

   select max(sequence_num)
   from po_action_history
   where object_id= doc_id and
   object_type_code = doc_type;
Line: 3678

   select action_code
   from po_action_history
   where object_id = doc_id and
   object_type_code = doc_type and
   sequence_num = seq_num;
Line: 3691

  ** First insert a row with  a SUBMIT action.
  ** Then insert a row with a NULL ACTION_CODE to simulate the forward-to
  */

  x_progress := '001';
Line: 3703

      select revision_num
             into l_revision_num
      from PO_HEADERS_ALL
      where po_header_id = p_doc_id;
Line: 3712

      select revision_num
             into l_revision_num
      from PO_RELEASES_ALL
      where po_release_id = p_doc_id;
Line: 3743

      INSERT into PO_ACTION_HISTORY
             (object_id,
              object_type_code,
              object_sub_type_code,
              sequence_num,
              last_update_date,
              last_updated_by,
              creation_date,
              created_by,
              action_code,
              action_date,
              employee_id,
              note,
              object_revision_num,
              last_update_login,
              request_id,
              program_application_id,
              program_id,
              program_update_date,
              approval_path_id,
              offline_code)
             VALUES
             (p_doc_id,
              p_doc_type,
              p_doc_subtype,
              l_sequence_num,
              sysdate,
              nvl(fnd_global.user_id, 1),
              sysdate,
              nvl(fnd_global.user_id, 1),
              p_action,
              decode(p_action, '',to_date('', 'YYYY-MM-DD'), sysdate),
              p_employee_id,
              p_note,
              l_revision_num,
              nvl(fnd_global.login_id, 1),
              0,
              0,
              0,
              '',
              l_approval_path_id,
              '' );
Line: 3791

        UPDATE PO_ACTION_HISTORY
          set object_id = p_doc_id,
              object_type_code = p_doc_type,
              object_sub_type_code = p_doc_subtype,
              sequence_num = l_sequence_num,
              last_update_date = sysdate,
              last_updated_by = nvl(fnd_global.user_id, 1),
              creation_date = sysdate,
              created_by = nvl(fnd_global.user_id, 1),
              action_code = p_action,
              action_date = decode(p_action, '',to_date('', 'YYYY-MM-DD'), sysdate),
              employee_id = p_employee_id,
              note = p_note,
              object_revision_num = l_revision_num,
              last_update_login = nvl(fnd_global.login_id, 1),
              request_id = 0,
              program_application_id = 0,
              program_id = 0,
              program_update_date = '',
              approval_path_id = l_approval_path_id,
              offline_code = ''
        WHERE
              object_id= p_doc_id and
              object_type_code = p_doc_type and
              sequence_num = l_sequence_num;
Line: 3827

      INSERT into PO_ACTION_HISTORY
             (object_id,
              object_type_code,
              object_sub_type_code,
              sequence_num,
              last_update_date,
              last_updated_by,
              creation_date,
              created_by,
              action_code,
              action_date,
              employee_id,
              note,
              object_revision_num,
              last_update_login,
              request_id,
              program_application_id,
              program_id,
              program_update_date,
              approval_path_id,
              offline_code)
             VALUES
             (p_doc_id,
              p_doc_type,
              p_doc_subtype,
              l_sequence_num + 1,
              sysdate,
              nvl(fnd_global.user_id, 1),
              sysdate,
              nvl(fnd_global.user_id, 1),
              NULL,              -- ACTION_CODE
              decode(p_action, '',to_date('', 'YYYY-MM-DD'), sysdate),
              p_employee_id,
              NULL,
              l_revision_num,
              nvl(fnd_global.login_id,1),
              0,
              0,
              0,
              '',
              0,
              '' );
Line: 3877

                               'InsertActionHist'||sqlerrm,x_progress);
Line: 3880

END InsertActionHist;
Line: 3904

    update po_headers_all set
    AUTHORIZATION_STATUS = 'IN PROCESS',
--    approved_flag='N',
    CHANGE_REQUESTED_BY='REQUESTER',
    last_updated_by         = fnd_global.user_id,
    last_update_login       = fnd_global.login_id,
    last_update_date        = sysdate
    where po_header_id = p_document_id;
Line: 3915

    UPDATE po_line_locations_all
    SET
      approved_flag='R',
      last_update_date = sysdate,
      last_updated_by = fnd_global.user_id,
      last_update_login = fnd_global.login_id
    WHERE
     line_location_id in
       (select document_line_location_id
        from po_change_requests
        where
          request_level = 'SHIPMENT' and
          document_header_id = p_document_id and
          action_type        IN ('MODIFICATION', 'CANCELLATION') and
          initiator          = 'REQUESTER' and
          request_status     ='PENDING') and
    approved_flag='Y';
Line: 3963

    update po_releases_all   set
    AUTHORIZATION_STATUS = 'IN PROCESS',
--    approved_flag='N',
    CHANGE_REQUESTED_BY='REQUESTER',
    last_updated_by         = fnd_global.user_id,
    last_update_login       = fnd_global.login_id,
    last_update_date        = sysdate
    where po_release_id = p_document_id;
Line: 3974

    UPDATE po_line_locations_all
    SET
      approved_flag = 'R',
      last_update_date = sysdate,
      last_updated_by = fnd_global.user_id,
      last_update_login = fnd_global.login_id
    WHERE  line_location_id in (select document_line_location_id
                                from   po_change_requests
                                where  request_level  = 'SHIPMENT' and
                                po_release_id  = p_document_id and
                                action_type    IN ('MODIFICATION', 'CANCELLATION') and
                                initiator      = 'REQUESTER' and
                                request_status = 'PENDING') and
              approved_flag='Y';
Line: 4027

    select pcr.wf_item_type, pcr.wf_item_key
    from po_change_requests pcr, po_change_requests pcr2
    where pcr2.change_request_group_id=l_change_request_group_id
          and pcr.change_request_id=pcr2.parent_change_request_id
          and pcr.wf_item_type is not null;
Line: 4036

    select PO_REQUESTER_CHANGE_WF_S.nextval into l_count from dual;
Line: 4104

    select document_header_id, nvl(pcr.requester_id, por.preparer_id),
      document_num
    from po_change_requests pcr, po_requisition_headers_all por
    where pcr.change_request_group_id=l_change_request_group_id
          and pcr.document_header_id=por.requisition_header_id;
Line: 4135

    select org_id
        into l_org_id
        from po_requisition_headers_all
        where requisition_header_id=l_document_id;
Line: 4304

    select document_type,
           document_header_id,
           document_revision_num,
           po_release_id,
           wf_item_type,
           wf_item_key
    from po_change_requests
    where change_request_group_id=l_change_request_group_id;
Line: 4317

    select por.preparer_id
    from po_requisition_headers_all por,
         po_change_requests pcr1,
         po_change_requests pcr2
    where pcr2.change_request_group_id=l_change_request_group_id
        and pcr2.parent_change_request_id=pcr1.change_request_id
        and pcr1.document_header_id=por.requisition_header_id;
Line: 4326

    select change_request_group_id
    from po_change_requests
    where change_request_id in
        (select parent_change_request_id
            from po_change_requests
            where change_request_group_id=l_change_request_group_id);
Line: 4334

    select prh.segment1, pcr.wf_item_type, pcr.wf_item_key, prh.requisition_header_id
    from po_requisition_headers_all prh, po_change_requests pcr
    where prh.requisition_header_id=pcr.document_header_id
        and pcr.change_request_group_id=l_change_request_group_id;
Line: 4394

        select por.org_id, por.agent_id, poh.segment1||'-'||to_char(por.release_num)
        into l_org_id, l_agent_id, l_document_num
        from po_releases_all por, po_headers_all poh
        where por.po_release_id=l_document_id
            and por.po_header_id=poh.po_header_id;
Line: 4405

        select org_id, agent_id, segment1
        into l_org_id, l_agent_id, l_document_num
        from po_headers_all
        where po_header_id=l_document_id;
Line: 4510

       SELECT gsb.currency_code
       INTO   l_currency_code
       FROM   financials_system_params_all fsp,
            gl_sets_of_books gsb
       WHERE  fsp.set_of_books_id = gsb.set_of_books_id
       AND  fsp.org_id          = l_org_id;
Line: 4518

       SELECT nvl(SUM(nvl(decode(matching_basis, 'AMOUNT', amount, quantity * unit_price), 0)), 0)
       into l_req_amount
       FROM   po_requisition_lines_all
       WHERE  requisition_header_id = l_req_header_id
       AND  NVL(cancel_flag,'N') = 'N'
       AND  NVL(modified_by_agent_flag, 'N') = 'N';
Line: 4529

       SELECT nvl(sum(nonrecoverable_tax), 0)
       into l_tax_amount
       FROM   po_requisition_lines_all rl,
          po_req_distributions_all rd
       WHERE  rl.requisition_header_id = l_req_header_id
       AND  rd.requisition_line_id = rl.requisition_line_id
       AND  NVL(rl.cancel_flag,'N') = 'N'
       AND  NVL(rl.modified_by_agent_flag, 'N') = 'N';
Line: 4662

        update po_change_requests
           set wf_item_type=item_type,
               wf_item_key=item_key
         where change_request_group_id=p_change_request_group_id;
Line: 4693

procedure UpdatePODocHeaderTables(p_document_type varchar2, p_document_id number)
is
pragma AUTONOMOUS_TRANSACTION;
Line: 4699

    x_progress := 'PO_ReqChangeRequestWF_PVT.UpdatePODocHeaderTables';
Line: 4702

        update po_headers_all
           set change_requested_by = null,
           last_updated_by         = fnd_global.user_id,
           last_update_login       = fnd_global.login_id,
           last_update_date        = sysdate
         where po_header_id = p_document_id;
Line: 4709

        update po_releases_all
           set change_requested_by = null,
           last_updated_by         = fnd_global.user_id,
           last_update_login       = fnd_global.login_id,
           last_update_date        = sysdate
         where po_release_id = p_document_id;
Line: 4720

      wf_core.context('PO_ReqChangeRequestWF_PVT','UpdatePODocHeaderTables',x_progress|| sqlerrm);
Line: 4722

END UpdatePODocHeaderTables;
Line: 4748

    select max(change_request_group_id)
    from po_change_requests
    where document_header_id=l_doc_id
            and initiator='REQUESTER'
            and request_status='NEW';
Line: 4830

 * Public Procedure: Update_Req_Change_Flag
 * Effects: workflow procedure, called at the beginning of POREQCHA
 *
 *          set the change_pending_flag in the po_requisition_headers_all
 *          table to 'Y'
 *
 ************************************************************************/
procedure Update_Req_Change_Flag(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    ) is

l_document_id           NUMBER;
Line: 4853

    x_progress := 'PO_ReqChangeRequestWF_PVT.Update_Req_Change_Flag: 01';
Line: 4892

    x_progress := 'PO_REQAPPROVAL_INIT1.Update_Req_Change_Flag: 02';
Line: 4901

               'Update_Req_Change_Flag',x_progress);
Line: 4904

               sqlerrm, 'PO_ReqChangeRequestWF_PVT.Update_Req_Change_Flag');
Line: 4907

END Update_Req_Change_Flag;
Line: 4911

 * Public Procedure: Insert_into_History_CHGsubmit
 * Effects: workflow procedure, called in workflow POREQCHA and
 *          PORPOCHA (INFORM_BUYER_PO_CHANGE)
 *
 *          inserting into action history table 'submit change'
 *
 ************************************************************************/
procedure Insert_into_History_CHGsubmit(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    ) is

l_doc_id number;
Line: 4939

    select requester_id
    from po_change_requests
    where change_request_group_id=l_change_request_group_id;
Line: 4946

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 01';
Line: 4959

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 02';
Line: 4964

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 03';
Line: 4977

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 04';
Line: 4992

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 05';
Line: 4995

            select agent_id
            into l_employee_id
            from po_headers_all
            where po_header_id=l_doc_id;
Line: 5000

            select preparer_id
            into l_employee_id
            from po_requisition_headers_all
            where requisition_header_id=l_doc_id;
Line: 5005

            select agent_id
            into l_employee_id
            from po_releases_all
            where po_release_id=l_doc_id;
Line: 5012

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 06';
Line: 5013

    InsertActionHist(itemtype,itemkey,l_doc_id, l_doc_type,
                     l_doc_subtype, l_employee_id,
                     'SUBMIT CHANGE', l_note, null);
Line: 5019

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit: 07';
Line: 5027

                    'Insert_into_History_CHGsubmit',x_progress||sqlerrm);
Line: 5030

                    'PO_ReqChangeRequestWF_PVT.Insert_into_History_CHGsubmit');
Line: 5033

END Insert_into_History_CHGsubmit;
Line: 5062

    select approval_required_flag
    from po_change_requests
    where change_request_group_id=l_change_request_group_id
        and action_type='MODIFICATION'
        and request_status = 'NEW';
Line: 5318

select change_request_id
from po_change_requests
where change_request_group_id=l_change_request_group_id
    and request_status='MGR_PRE_APP';
Line: 5556

    select request_status
    from po_change_requests
    where change_request_group_id=l_change_request_group_id
            and request_status='MGR_APP';
Line: 5610

procedure Update_Action_History(p_object_id in number,
                   p_employee_id in number,
                   p_action_code in varchar2) is
pragma AUTONOMOUS_TRANSACTION;
Line: 5615

    po_forward_sv1.update_action_history (
        p_object_id,
        'REQUISITION',
        p_employee_id,
        p_action_code,
        null,
        fnd_global.user_id,
        fnd_global.login_id
    );
Line: 5625

end Update_Action_History;
Line: 5628

procedure Insert_Action_History(l_document_id      in NUMBER,
                                l_document_type    in VARCHAR2,
                                l_document_subtype in VARCHAR2,
                                l_sequence_num     in NUMBER,
                                l_employee_id      in NUMBER,
                                l_new_action_code  in VARCHAR2,
                                l_object_rev_num   in NUMBER,
                                l_approval_path_id in NUMBER) is

pragma AUTONOMOUS_TRANSACTION;
Line: 5640

          INSERT into PO_ACTION_HISTORY
             (object_id,
              object_type_code,
              object_sub_type_code,
              sequence_num,
              last_update_date,
              last_updated_by,
              creation_date,
              created_by,
              action_code,
              action_date,
              employee_id,
              note,
              object_revision_num,
              last_update_login,
              request_id,
              program_application_id,
              program_id,
              program_update_date,
              approval_path_id,
              offline_code)
             VALUES
             (l_document_id,
              l_document_type,
              l_document_subtype,
              l_sequence_num + 1,
              sysdate,
              l_employee_id,
              sysdate,
              l_employee_id,
              l_new_action_code,
              sysdate,
              l_employee_id,
              NULL,
              l_object_rev_num,
              l_employee_id,
              0,
              0,
              0,
              '',
              l_approval_path_id,
              '' );
Line: 5685

end Insert_Action_History;
Line: 5690

 * Public Procedure: Update_Action_History_App_Rej
 * Effects: workflow procedure, used in POREQCHA
 *
 *          if a change request is responded because of PO Cancel
 *          This procedure will insert into the action history table
 *          a record with action 'RETURN'
 *
************************************************************************/
procedure Update_Action_History_App_Rej(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2) IS

  l_progress                  VARCHAR2(100) := '000';
Line: 5730

    select change_request_id
      from po_change_requests
     where change_request_group_id=grp_id
           and request_status='MGR_APP'
           and action_type='MODIFICATION';
Line: 5736

    select change_request_id
      from po_change_requests
     where change_request_group_id=grp_id
           and request_status='REJECTED'
           and action_type='MODIFICATION';
Line: 5742

    select change_request_id
      from po_change_requests
     where change_request_group_id=grp_id
           and request_status='MGR_APP'
           and action_type='CANCELLATION';
Line: 5749

    l_progress := 'Update_Action_History_App_Rej: 001';
Line: 5752

      PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'Entering Update_Action_History_App_Rej...' );
Line: 5782

     SELECT max(sequence_num)
       INTO l_sequence_num
       FROM PO_ACTION_HISTORY
      WHERE object_type_code = 'REQUISITION'
        AND object_id = l_document_id;
Line: 5788

    select action_code, employee_id, object_revision_num, approval_path_id
      into l_action_code, l_employee_id, l_object_rev_num, l_approval_path_id
      from po_action_history
     where object_id=l_document_id
           and object_type_code='REQUISITION'
           and sequence_num=l_sequence_num;
Line: 5796

      PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, '  l_action_code = ' || l_action_code );
Line: 5797

      PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, '  l_sequence_num = ' || l_sequence_num );
Line: 5829

          PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, '  l_new_action_code = ' || l_new_action_code );
Line: 5833

          Insert_Action_History(l_document_id,
                                l_document_type,
                                l_document_subtype,
                                l_sequence_num,
                                l_employee_id,
                                l_new_action_code,
                                l_object_rev_num,
                                l_approval_path_id);
Line: 5843

          Update_Action_History(l_document_id,
                                l_employee_id,
                                l_new_action_code);
Line: 5851

    l_progress := 'Update_Action_History_App_Rej: 006';
Line: 5854

       PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'Leaving Update_Action_History_App_Rej...');
Line: 5861

    l_progress := 'Update_Action_History_App_Rej: 999';
Line: 5867

    wf_core.context('PO_ReqChangeRequestWF_PVT','Update_Action_History_App_Rej',l_progress,sqlerrm);
Line: 5868

    PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_ReqChangeRequestWF_PVT.Update_Action_History_App_Rej');
Line: 5871

END Update_Action_History_App_Rej;
Line: 5876

 * Public Procedure: Update_Action_History_Return
 * Effects: workflow procedure, used in POREQCHA
 *
 *          if a change request is responded because of PO Cancel
 *          This procedure will insert into the action history table
 *          a record with action 'RETURN'
 *
************************************************************************/
procedure Update_Action_History_Return(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2) IS

  l_progress                  VARCHAR2(100) := '000';
Line: 5906

    l_progress := 'Update_Action_History_Return: 001';
Line: 5938

     l_progress := 'Update_Action_History_Return: 002-'||
                           to_char(l_document_id)||'-'||
                           l_document_type||'-'||l_document_subtype;
Line: 5942

     /* update po action history */
     PO_APPROVAL_LIST_HISTORY_SV.Update_Action_History(itemtype=>itemtype,
                                         itemkey=>itemkey,
                                         x_action=>l_action,
                                         x_req_header_id=>l_document_id,
                                         x_last_approver=>l_result,
                                         x_note=>l_note);
Line: 5951

     l_progress := 'Update_Action_History_Return: 006';
Line: 5957

    l_progress := 'Update_Action_History_Return: 999';
Line: 5963

    wf_core.context('PO_ReqChangeRequestWF_PVT','Update_Action_History_Return',l_progress,sqlerrm);
Line: 5964

    PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_ReqChangeRequestWF_PVT.Update_Action_History_Return');
Line: 5967

END Update_Action_History_Return;
Line: 6036

    select distinct pcr1.change_request_group_id
    from po_change_requests pcr1, po_change_requests pcr2
    where pcr1.parent_change_request_id=pcr2.change_request_id
        and pcr2.change_request_group_id=l_change_request_group_id
        and pcr1.request_status='PENDING';
Line: 6258

  select  nvl(sum(nvl(decode(pcr4.action_type, 'CANCELLATION', 0,
            decode(prl.unit_price, 0, 0, decode(prl.matching_basis, 'AMOUNT',nvl(pcr3.new_amount, prl.amount) * por_view_reqs_pkg.get_line_nonrec_tax_total(
                        prl.requisition_line_id)/prl.amount,
            nvl(pcr1.new_price, prl.unit_price)*
            nvl(pcr2.new_quantity, prl.quantity)*
            por_view_reqs_pkg.get_line_nonrec_tax_total(
                        prl.requisition_line_id)/
            (prl.unit_price*prl.quantity)))),0)),0),
          nvl(sum(decode(pcr4.action_type, 'CANCELLATION', 0, decode(prl.matching_basis, 'AMOUNT', nvl(pcr3.new_amount, prl.amount),
            nvl(pcr1.new_price, prl.unit_price)*
            nvl(pcr2.new_quantity, prl.quantity)))), 0)
  into l_new_tax_amount, l_new_req_amount
  from po_requisition_lines_all prl,
        po_change_requests pcr1,
        po_change_requests pcr2,
        po_change_requests pcr3,
        po_change_requests pcr4
  where prl.requisition_line_id=pcr1.document_line_id(+)
        and pcr1.change_request_group_id(+)=l_change_request_group_id
        and pcr1.request_level(+)='LINE'
        and pcr1.new_price(+) is not null
        and prl.requisition_line_id=pcr2.document_line_id(+)
        and pcr2.change_request_group_id(+)=l_change_request_group_id
        and pcr2.request_level(+)='LINE'
        and pcr2.action_type(+)='DERIVED'
        and pcr2.new_quantity(+) is not null
        and prl.requisition_line_id=pcr3.document_line_id(+)
        and pcr3.change_request_group_id(+)=l_change_request_group_id
        and pcr3.request_level(+)='LINE'
        and pcr3.action_type(+)='DERIVED'
        and pcr3.new_amount(+) is not null
        and prl.requisition_line_id=pcr4.document_line_id(+)
        and pcr4.change_request_group_id(+)=l_change_request_group_id
        and pcr4.request_level(+)='LINE'
        and pcr4.action_type(+)='CANCELLATION'
        and prl.requisition_header_id=l_document_id
    AND NVL(prl.modified_by_agent_flag, 'N') = 'N'
    and NVL(prl.cancel_flag, 'N')='N';
Line: 6298

  select sum(decode(pcr1.action_type, 'CANCELLATION', 0,
                     decode(prl.unit_price, 0, 0,
                     nvl(pcr1.new_price, prl.unit_price)*
                     nvl(pcr2.new_quantity,prd.req_line_quantity)*
                     prd.nonrecoverable_tax /
                     (prl.unit_price*prd.req_line_quantity)))),
         nvl(sum(decode(pcr1.action_type, 'CANCELLATION', 0,
                     nvl(pcr1.new_price, prl.unit_price)*
                     nvl(pcr2.new_quantity,prd.req_line_quantity))), 0)
  into l_new_tax_amount, l_new_req_amount
  from po_requisition_lines_all prl,
        po_req_distributions_all prd,
        po_change_requests pcr1,
        po_change_requests pcr2
  where prl.requisition_line_id=pcr1.document_line_id(+)
        and pcr1.change_request_group_id(+)=l_change_request_group_id
        and pcr1.request_level(+)='LINE'
        and pcr1.change_active_flag(+)='Y'
        and prl.requisition_line_id=prd.requisition_line_id
        and prd.distribution_id=pcr2.document_distribution_id(+)
        and pcr2.change_request_group_id(+)=l_change_request_group_id
        and pcr2.change_active_flag(+)='Y'
        and prl.requisition_header_id=l_document_id
    AND NVL(prl.modified_by_agent_flag, 'N') = 'N'
    and NVL(prl.cancel_flag, 'N')='N';
Line: 6436

        select AUTHORIZATION_STATUS
        into l_authorization_status
        from po_headers_all
        where PO_HEADER_ID = l_doc_id;
Line: 6443

        select AUTHORIZATION_STATUS
        into l_authorization_status
        from po_releases_all
        where  PO_RELEASE_ID = l_doc_id;
Line: 6618

        select revision_num
        into l_doc_revision
        from po_headers_all
        where po_header_id=l_doc_id;
Line: 6623

        select revision_num
        into l_doc_revision
        from po_releases_all
        where po_release_id=l_doc_id;
Line: 6657

 *          this function will update the status to 'REJECTED'
 *
 ************************************************************************/
procedure Record_Buyer_Rejection(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    ) is

l_doc_id number;
Line: 6731

 *          this function will update the status to 'BUYER_APP'
 *
 ************************************************************************/
procedure Record_Buyer_Acceptance(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    ) is

l_doc_id number;
Line: 6872

 * Public Procedure: Insert_Buyer_Action_History
 * Effects: workflow procedure, called in workflow
 *          PORPOCHA (PROCESS_BUYER_RESPONSE)
 *
 *          inserting into action history table buyer's response
 *
 ************************************************************************/
procedure Insert_Buyer_Action_History(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    ) is

l_doc_id number;
Line: 6902

    select request_status
    from po_change_requests
    where change_request_group_id=l_change_request_group_id;
Line: 6909

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_Buyer_Action_History: 01';
Line: 6923

    select count(distinct(request_status))
    into l_count
    from po_change_requests
    where change_request_group_id=l_change_request_group_id;
Line: 6967

        select agent_id
        into l_employee_id
        from po_headers_all
        where PO_HEADER_ID = l_doc_id;
Line: 6974

        select agent_id
        into l_employee_id
        from po_releases_all
        where  PO_RELEASE_ID = l_doc_id;
Line: 6981

    InsertActionHist(itemtype,itemkey,l_doc_id, l_doc_type,
                   l_doc_subtype, l_employee_id, l_action, l_note, null);
Line: 6986

    x_progress := 'PO_ReqChangeRequestWF_PVT.Insert_Buyer_Action_History: 02';
Line: 6994

                       'Insert_Buyer_Action_History',x_progress);
Line: 6997

                       'PO_ReqChangeRequestWF_PVT.Insert_Buyer_Action_History');
Line: 7000

END Insert_Buyer_Action_History;
Line: 7013

 *          which is rejected by the buyer by update the related req change
 *          requests to 'REJECTED'.
 *
 *          it commits when it exits.
 *
 ************************************************************************/
procedure Process_Buyer_Rejection(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    )
is
l_orgid       number;
Line: 7087

 *          which is accepted by the buyer by update the related req change
 *          requests to 'accepted', and cancel the req line.
 *
 *          it commits when it exits.
 *
 ************************************************************************/
procedure Process_Cancel_Acceptance(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    )
is
l_orgid       number;
Line: 7193

select change_request_id
from po_change_requests
where change_request_group_id=l_change_request_group_id
    and request_status='BUYER_APP';
Line: 7253

 *          which is accepted by the buyer by update the related req change
 *          requests to 'accepted', and update the req line/distribution.
 *          it will also call MoveChangeToPO to move the changes to PO
 *
 *          it commits when it exits.
 *
************************************************************************/
procedure Process_Change_Acceptance(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    )
is
l_orgid       number;
Line: 7381

select document_header_id, po_release_id
from po_change_requests
where change_request_group_id=l_change_request_group_id
    and request_status='BUYER_APP';
Line: 7390

select document_header_id, po_release_id
from po_change_requests
where change_request_group_id=l_change_request_group_id
    and request_status='REJECTED';
Line: 7461

    UPDATE po_releases_all
    SET    authorization_status='APPROVED'
    WHERE  po_release_id = l_release_id;
Line: 7465

    UPDATE po_headers_all
    SET    authorization_status='APPROVED'
    WHERE  po_header_id = l_header_id;
Line: 7513

    select pcr3.change_request_id
    from po_change_requests pcr1,
         po_change_requests pcr2,
         po_change_requests pcr3
    where pcr2.change_request_group_id=p_change_request_group_id
        and pcr2.parent_change_request_id=pcr1.change_request_id
        and pcr1.change_request_group_id=pcr3.change_request_group_id
        and pcr3.action_type in ('MODIFICATION', 'CANCELLATION')
        and pcr3.request_status not in ('ACCEPTED', 'REJECTED');
Line: 7727

  SELECT wf_item_type, wf_item_key
  INTO l_req_item_type, l_req_item_key
  FROM po_change_requests
  WHERE
    change_request_group_id = l_req_change_group_id and rownum=1;
Line: 7737

   select 'Y'
   into l_rco_wf_available
   from wf_items
   where item_type = l_req_item_type
   and item_key = l_req_item_key;
Line: 7815

  SELECT nvl(sum(nvl(nonrecoverable_tax, 0)), 0)
    INTO l_new_tax_currency
    FROM po_requisition_lines_all rl,
         po_req_distributions_all rd
   WHERE rl.requisition_header_id = l_document_id
     AND rd.requisition_line_id = rl.requisition_line_id
     AND  NVL(rl.modified_by_agent_flag, 'N') = 'N'
     and NVL(rl.cancel_flag, 'N')='N';
Line: 7824

   SELECT nvl(SUM(nvl(decode(matching_basis, 'AMOUNT', amount, quantity * unit_price), 0)), 0)
   into l_new_amount_currency
   FROM   po_requisition_lines_all
   WHERE  requisition_header_id = l_document_id
     AND  NVL(cancel_flag,'N') = 'N'
     AND  NVL(modified_by_agent_flag, 'N') = 'N';
Line: 7899

     SELECT document_header_id
     INTO l_document_id
     FROM po_change_requests pcr
     WHERE pcr.change_request_group_id = l_req_change_group_id and rownum=1;
Line: 7911

     select NVL(CONTRACTOR_REQUISITION_FLAG, 'N'), NOTE_TO_AUTHORIZER
     into   l_contractor_req_flag,l_note
     from po_requisition_headers_all
     where REQUISITION_HEADER_ID = l_document_id;
Line: 7924

     SELECT gsb.currency_code
     INTO   l_functional_currency
     FROM   financials_system_params_all fsp,
            gl_sets_of_books gsb
     WHERE  fsp.set_of_books_id = gsb.set_of_books_id
       AND  fsp.org_id = l_orgid;
Line: 7937

     SELECT nvl(SUM(nvl(decode(matching_basis, 'AMOUNT', amount, quantity * unit_price), 0)), 0)
     into l_req_amount
     FROM   po_requisition_lines_all
     WHERE  requisition_header_id = l_document_id
     AND  NVL(cancel_flag,'N') = 'N'
     AND  NVL(modified_by_agent_flag, 'N') = 'N';
Line: 7948

      SELECT nvl(sum(nonrecoverable_tax), 0)
      into l_tax_amount
      FROM   po_requisition_lines_all rl,
          po_req_distributions_all rd
      WHERE  rl.requisition_header_id = l_document_id
      AND  rd.requisition_line_id = rl.requisition_line_id
      AND  NVL(rl.cancel_flag,'N') = 'N'
      AND  NVL(rl.modified_by_agent_flag, 'N') = 'N';
Line: 8023

    select pcr1.change_request_group_id
    from po_change_requests pcr1, po_change_requests pcr2
    where pcr2.change_request_group_id=p_change_request_group_id
        and pcr2.parent_change_request_id=pcr1.change_request_id;
Line: 8030

    select pcr1.change_request_id
    from po_change_requests pcr1
    where pcr1.change_request_group_id=p_change_request_group_id
        and pcr1.request_status not in ('ACCEPTED', 'REJECTED');
Line: 8036

    select pcr1.change_request_id
    from po_change_requests pcr1, po_change_requests pcr2
    where pcr2.change_request_group_id=p_change_request_group_id
        and pcr1.parent_change_request_id=pcr2.change_request_id
        and pcr1.request_status not in ('ACCEPTED', 'REJECTED');
Line: 8144

    select change_request_group_id, wf_item_type, wf_item_key
        from po_change_requests
        where document_header_id=l_document_id
            and document_type=l_document_type
            and initiator='REQUESTER'
            and request_status in ('PENDING', 'BUYER_APP');
Line: 8151

    select change_request_group_id, wf_item_type, wf_item_key
        from po_change_requests
        where po_release_id=l_document_id
            and document_type=l_document_type
            and initiator='REQUESTER'
            and request_status in ('PENDING', 'BUYER_APP');
Line: 8158

    select change_request_group_id
        from po_change_requests
        where change_request_id in
            (select parent_change_request_id
                from po_change_requests
                where change_request_group_id=l_change_request_group_id);
Line: 8165

    select nvl(pcr.requester_id, por.preparer_id)
    from po_change_requests pcr, po_requisition_headers_all por
    where pcr.change_request_group_id=l_change_request_group_id
          and pcr.document_header_id=por.requisition_header_id;
Line: 8259

    select change_request_id
    from po_change_requests
    where change_request_group_id=p_change_request_group_id
        and request_status='PENDING';
Line: 8303

    UpdatePODocHeaderTables(l_document_type, l_document_id);
Line: 8329

 *          when the po is approved, update the status of the corresponding
 *          PO change requests to ACCEPTED
 *
************************************************************************/
procedure Record_PO_Approval(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    ) is
l_orgid       number;
Line: 8395

 *          when the po is rejected, update the status of the corresponding
 *          PO change requests to REJECTED
 *
************************************************************************/
procedure Record_PO_Rejection(itemtype        in varchar2,
                                itemkey         in varchar2,
                                actid           in number,
                                funcmode        in varchar2,
                                resultout       out NOCOPY varchar2    )is
l_orgid       number;
Line: 8546

    select change_request_id
        from po_change_requests
        where document_header_id=l_document_id
            and request_status in ('BUYER_APP', 'PENDING')
            and initiator='REQUESTER'
            and document_type='PO';
Line: 8553

    select change_request_id
        from po_change_requests
        where po_release_id=l_document_id
            and request_status in ('BUYER_APP', 'PENDING')
            and initiator='REQUESTER'
            and document_type='RELEASE';
Line: 8619

    select PO_REQUESTER_CHANGE_WF_S.nextval into l_seq from dual;
Line: 8683

    select change_request_id
        from po_change_requests
        where change_request_group_id=group_id
            and request_status in ('NEW', 'MGR_PRE_APP');
Line: 8688

    select pcr1.change_request_id, pcr1.document_header_id,
           pcr1.action_type, pcr1.change_request_group_id,
           pcr1.wf_item_type, pcr1.wf_item_key
        from po_change_requests pcr1
        where pcr1.document_type='REQ'
            and pcr1.document_line_id=requisition_line_id
            and pcr1.action_type <>'DERIVED'
            and pcr1.request_status in ('NEW', 'MGR_PRE_APP', 'MGR_APP')
            and not exists
                (select pcr2.change_request_id
                 from po_change_requests pcr2
                 where pcr2.parent_change_request_id=pcr1.change_request_id);
Line: 8728

                update po_requisition_lines_all
                    set cancel_flag='Y'
                    where requisition_line_id=p_CanceledReqLineIDs_tbl(l_index);
Line: 8731

                update po_change_requests
                    set request_status='ACCEPTED',
                        change_active_flag='N',
                        response_date=sysdate,
                        response_reason=fnd_message.get_string('PO', 'PO_RCO_PO_CANCELLED')
                    where change_request_id=l_change_request_id;
Line: 8740

            UPDATE po_requisition_headers_all h
            SET    h.AUTHORIZATION_STATUS  = 'CANCELLED'
            WHERE  h.REQUISITION_HEADER_ID = l_document_id
                AND NOT EXISTS
                    (SELECT 'UNCANCELLED LINE EXISTS'
                    FROM    po_requisition_lines_all prl
                    WHERE   prl.requisition_header_id = l_document_id
                        AND NVL(prl.cancel_flag,'N')  = 'N'
                    );
Line: 8755

                update po_change_requests
                    set request_status='REJECTED',
                        change_active_flag='N',
                        response_date=sysdate,
                        response_reason=fnd_message.get_string('PO', 'PO_RCO_PO_CANCELLED')
                    where change_request_group_id=l_change_request_group_id
                          and document_line_id=p_CanceledReqLineIDs_tbl(l_index);
Line: 8778

                    PO_APPROVAL_LIST_HISTORY_SV.Update_Action_History(
                                         itemtype=>l_wf_item_type,
                                         itemkey=>l_wf_item_key,
                                         x_action=>l_action,
                                         x_req_header_id=>l_document_id,
                                         x_last_approver=>l_result,
                                         x_note=>l_note);
Line: 8854

    select max(change_request_group_id)
        from po_change_requests
        where document_header_id = p_req_header_id
            and initiator='REQUESTER'
            and request_status='NEW';
Line: 8875

    SELECT to_char(p_req_header_id) || '-'
                ||to_char(l_change_request_group_id)||'-'
                || to_char(PO_REQUESTER_CHANGE_WF_S.nextval)
    INTO p_item_key
    FROM sys.dual;
Line: 8881

    select preparer_id, segment1
    into l_preparer_id, l_req_num
    from po_requisition_headers_all
    where requisition_header_id= p_req_header_id;
Line: 8944

    select pcr.wf_item_type, pcr.wf_item_key
    from po_change_requests pcr, po_change_requests pcr2
    where pcr2.change_request_group_id=l_change_request_group_id
          and pcr.change_request_id=pcr2.parent_change_request_id
          and pcr.wf_item_type is not null;
Line: 8952

    select PO_REQUESTER_CHANGE_WF_S.nextval into l_count from dual;
Line: 8998

    select wfn.status, wfn.notification_id
     from wf_item_activity_statuses_v was, wf_notifications wfn
     where was.item_type=l_item_type
           and was.item_key=l_item_key
           and was.activity_name=activity
           and was.notification_id=wfn.notification_id;
Line: 9012

    update po_change_requests
       set request_status=p_acceptance_flag,
           change_active_flag=decode(p_acceptance_flag, 'REJECTED', 'N', 'Y'),
           response_date=sysdate,
           response_reason=p_response_reason,
           responded_by=p_responded_by
     where change_request_id=p_change_request_id;
Line: 9020

    select wf_item_type, wf_item_key
      into l_item_type, l_item_key
      from po_change_requests
     where change_request_id=p_change_request_id;
Line: 9031

                update wf_notifications
                   set status='CLOSED'
                 where notification_id=l_notification_id;
Line: 9088

    select pcr.wf_item_type, pcr.wf_item_key
    from po_change_requests pcr, po_change_requests pcr2
    where pcr2.change_request_group_id=l_change_request_group_id
          and pcr.change_request_id=pcr2.parent_change_request_id
          and pcr.wf_item_type is not null;
Line: 9123

    select PO_REQUESTER_CHANGE_WF_S.nextval into l_count from dual;
Line: 9136

      select 'Y'
      into l_parent_wf_available
      from wf_items
      where item_type = l_parent_item_type
      and item_key = l_parent_item_key;
Line: 9254

    select max(change_request_id)
    into l_change_request_id
    from po_change_requests
    where po_release_id=l_document_id
      and request_status in ('BUYER_APP', 'PENDING')
      and initiator='REQUESTER'
      and document_type='RELEASE'
      and action_type='CANCELLATION';
Line: 9266

    select max(change_request_id)
    into l_change_request_id
    from po_change_requests
    where document_header_id=l_document_id
      and request_status in ('BUYER_APP', 'PENDING')
      and initiator='REQUESTER'
      and document_type='PO'
      and action_type='CANCELLATION';
Line: 9340

    select pcr.document_header_id,
           pcr.document_line_id,
           pcr.document_line_location_id,
           pcr.old_amount,
           pol.amount,
           pol.quantity,
           pcr.old_price,
           pll.amount,
           pll.quantity,
           pll.quantity_cancelled,
           pll.price_override,
           pol.matching_basis,
           pcr.new_amount,
           pcr.new_price,
           pcr.action_type,
           pol.item_id,
           pll.unit_meas_lookup_code,
           pol.unit_price
    FROM   po_change_requests pcr, po_lines_all pol,
           po_line_locations_all pll
    WHERE  pcr.change_request_group_id= p_change_request_group_id
      AND pcr.request_status IN ('PENDING', 'ACCEPTED')
      AND pcr.document_header_id=pol.po_header_id
      AND pcr.document_line_id=pol.po_line_id
      AND nvl(pcr.document_line_location_id,-1)=pll.line_location_id(+)
      AND pcr.request_level<>'DISTRIBUTION';
Line: 9370

   SELECT sob.currency_code
   INTO  l_functional_currency_code
   FROM  gl_sets_of_books sob, financials_system_params_all fsp
   WHERE fsp.org_id = p_org_id
   AND  fsp.set_of_books_id = sob.set_of_books_id;
Line: 9376

   select poh.rate
   into l_rate
   from po_headers_all poh
   where poh.po_header_id in (
     select document_header_id from po_change_requests
     where change_request_group_id = p_change_request_group_id ) ;
Line: 9424

              SELECT 1
              into l_shipment_chg_exists_amt
              FROM   po_change_requests pcr
              WHERE  pcr.change_request_group_id= p_change_request_group_id
              AND pcr.request_status IN ('PENDING', 'ACCEPTED')
              AND pcr.document_header_id= l_header_id
              AND pcr.document_line_id=  l_line_id
              AND pcr.document_line_location_id IS NOT NULL
              AND pcr.request_level='SHIPMENT';
Line: 9489

              SELECT 1
              into l_shipment_chg_exists_qty
              FROM   po_change_requests pcr
              WHERE  pcr.change_request_group_id= p_change_request_group_id
              AND pcr.request_status IN ('PENDING', 'ACCEPTED')
              AND pcr.document_header_id= l_header_id
              AND pcr.document_line_id=  l_line_id
              AND pcr.document_line_location_id IS NOT NULL
              AND pcr.request_level='SHIPMENT';
Line: 9615

        select creation_date, currency_code
        into l_order_date, l_po_currency
        from po_headers_all
        where PO_HEADER_ID = l_doc_id;
Line: 9622

        select pr.creation_date, ph.currency_code
        into l_order_date, l_po_currency
        from po_releases_all pr, po_headers_all ph
        where pr.po_release_id = l_doc_id
          and pr.po_header_id = ph.po_header_id;
Line: 9712

  select change_request_group_id
  INTO l_po_request_group_id
  FROM po_change_requests
  WHERE parent_change_request_id = l_change_request_group_id
  and rownum=1;
Line: 9727

  SELECT document_header_id, document_revision_num, document_type, po_release_id
  INTO l_document_header_id, l_document_revision_num, l_document_type, l_release_id
  FROM po_change_requests
  WHERE change_request_group_id = l_po_request_group_id
    AND rownum=1;
Line: 9789

  SELECT change_request_group_id
  INTO l_po_chg_request_group_id
  FROM po_change_requests
  WHERE parent_change_request_id = l_change_request_group_id
    AND rownum=1;
Line: 9819

 *    Kickoff_POChange_WF cannot be updated because of upgrade issues.
 *    That is why we created this new procedure to handle the new
 *    functionality.
 ************************************************************************/
PROCEDURE Start_POChange_WF( itemtype        IN VARCHAR2,
                             itemkey         IN VARCHAR2,
                             actid           IN NUMBER,
                             funcmode        IN VARCHAR2,
                             resultout       OUT NOCOPY VARCHAR2 )
IS

  l_po_chg_request_group_id number;
Line: 9918

      PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,'PO_CO_Tolerances_Grp.get_tolerances API failed:' || l_return_status || ' ' || l_msg_data);
Line: 9964

      SELECT poh.document_creation_method, poh.org_id
      INTO l_creation_method, l_po_org_id
      FROM
        po_headers_all poh,
        po_change_requests pcr
      WHERE poh.po_header_id =pcr.document_header_id
        AND pcr.change_request_group_id = l_po_chg_group_id
        AND rownum=1;
Line: 9977

      SELECT por.document_creation_method, por.org_id
      INTO l_creation_method, l_po_org_id
      FROM
        po_releases_all por,
        po_change_requests pcr
      WHERE por.po_release_id = pcr.po_release_id
        AND pcr.change_request_group_id = l_po_chg_group_id
        AND rownum = 1;
Line: 10060

  SELECT MIN(po_change.change_request_group_id)
  INTO l_next_po_grp_id
  FROM
    po_change_requests po_change,
    po_change_requests req_change
  WHERE
    po_change.parent_change_request_id = req_change.change_request_id AND
    req_change.change_request_group_id = l_change_request_grp_id AND
    po_change.change_request_group_id > l_po_chg_request_group_id
  ORDER BY po_change.change_request_group_id;
Line: 10081

    SELECT document_type, document_revision_num,
           decode(document_type, 'RELEASE', po_release_id,document_header_id)
    into l_po_document_type, l_po_document_rev, l_po_document_id
    FROM po_change_requests
    WHERE change_request_group_id = l_next_po_grp_id AND rownum=1;
Line: 10160

  SELECT document_type, decode(document_type, 'RELEASE', po_release_id, document_header_id), document_num
  INTO l_document_type, l_document_id, l_document_number
  FROM po_change_requests
  WHERE change_request_group_id = l_po_change_request_group_id
    AND rownum=1;
Line: 10176

    SELECT agent_id, creation_date
    INTO l_buyer_id, l_order_date
    FROM po_headers_all
    WHERE PO_HEADER_ID = l_document_id;
Line: 10183

    SELECT agent_id, creation_date
    INTO l_buyer_id, l_order_date
    FROM po_releases_all
    WHERE  PO_RELEASE_ID = l_document_id;
Line: 10216

  InsertActionHist(itemtype, itemkey, l_document_id, l_document_type,
                   l_document_subtype, l_buyer_id, 'ACCEPT', '', null);
Line: 10237

    SELECT document_header_id, po_release_id
    INTO l_po_header_id, l_po_release_id
    FROM po_change_requests
    WHERE change_request_group_id=l_po_change_request_group_id
      and request_status='BUYER_APP' and rownum=1;
Line: 10319

     SELECT currency_code
     INTO l_po_currency
     FROM po_headers_all
     WHERE PO_HEADER_ID = l_po_doc_id;
Line: 10326

     SELECT ph.currency_code
     INTO l_po_currency
     FROM po_releases_all pr, po_headers_all ph
     WHERE pr.po_release_id = l_po_doc_id
          and pr.po_header_id = ph.po_header_id;
Line: 10393

  SELECT 'N'
  INTO l_return_val
  FROM dual
  WHERE exists (
    SELECT 'N'
    FROM
      po_change_requests pcr,   -- for quantity/amount change
      po_change_requests pcr1,  -- for unit price change
      po_lines_all pl,
      po_distributions_all pod
    WHERE pl.po_line_id = pod.po_line_id
      AND pcr.change_request_group_id = p_pochggrp_id
      AND pcr.action_type(+) = 'MODIFICATION'
      AND pcr.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
      AND pcr.request_level(+) = 'DISTRIBUTION'
      AND pcr.initiator(+) = 'REQUESTER'
      AND pcr.document_distribution_id(+) = pod.po_distribution_id
      AND pcr1.change_request_group_id(+) = p_pochggrp_id
      AND pcr1.document_line_id(+) = pl.po_line_id
      AND pcr1.action_type(+) = 'MODIFICATION'
      AND pcr1.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
      AND pcr1.request_level (+) = 'LINE'
      AND pcr1.initiator(+) = 'REQUESTER'
      AND pcr1.new_price(+) IS NOT NULL
    GROUP BY pcr.document_line_location_id
    HAVING
      ((PO_RCOTOLERANCE_PVT.changes_within_tol(
         sum(decode(pl.matching_basis, 'AMOUNT', pod.amount_ordered, pl.unit_price * (pod.quantity_ordered-nvl(pod.quantity_cancelled,0)))),
         sum(decode(pl.matching_basis, 'AMOUNT',  nvl(pcr.new_amount, pod.amount_ordered), nvl(pcr.new_quantity,pod.quantity_ordered)*nvl(pcr1.new_price, pl.unit_price))),
         p_tolerances_tab(TOL_SHIPAMT_IND).max_increment,
         p_tolerances_tab(TOL_SHIPAMT_IND).max_decrement,
         p_tolerances_tab(TOL_SHIPAMT_AMT_IND).max_increment,
         p_tolerances_tab(TOL_SHIPAMT_AMT_IND).max_decrement) = 'N')
           OR
       (PO_RCOTOLERANCE_PVT.change_within_tol_percent(
         sum(pod.quantity_ordered-nvl(pod.quantity_cancelled,0)),
         sum(nvl(pcr.new_quantity, pod.quantity_ordered-nvl(pod.quantity_cancelled, 0))),
         p_tolerances_tab(TOL_SHIPQTY_IND).max_increment,
         p_tolerances_tab(TOL_SHIPQTY_IND).max_decrement) = 'N')));
Line: 10434

    PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value:' || l_return_val);
Line: 10443

        PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value(No data Found):Y');
Line: 10476

    select distinct pcr.document_line_id, document_type
    from po_change_requests pcr,
         po_lines_all pol
    where change_request_group_id = p_pochggrp_id
          and pol.po_line_id = pcr.document_line_id
          and action_type <> 'DERIVED'
          and request_status not in ('ACCEPTED', 'REJECTED')
          and pcr.initiator(+) = 'REQUESTER'
          and pcr.request_level <> 'DISTRIBUTION';
Line: 10493

  SELECT 'N'
  INTO l_return_val
  FROM dual
  WHERE exists (
    SELECT 'N'
    FROM po_change_requests pcr
    WHERE change_request_group_id = p_pochggrp_id
      AND action_type='MODIFICATION'
      AND request_status not in ('ACCEPTED', 'REJECTED')
      AND request_level='SHIPMENT'
      AND
        PO_RCOTOLERANCE_PVT.change_within_tol_date(
          old_need_by_date,
          new_need_by_date,
          p_tolerances_tab(TOL_NEEDBY_IND).max_increment,
          p_tolerances_tab(TOL_NEEDBY_IND).max_decrement) = 'N');
Line: 10516

    PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value(need by date check):' || l_return_val);
Line: 10524

      SELECT 'N'
      INTO l_return_val
      FROM dual
      WHERE exists (
        SELECT 'N'
        FROM po_change_requests pcr
        WHERE change_request_group_id = p_pochggrp_id
          AND action_type='MODIFICATION'
          AND request_status not in ('ACCEPTED', 'REJECTED')
          AND request_level='LINE'
          AND (
        (PO_RCOTOLERANCE_PVT.change_within_tol_date(
           old_start_date,
           new_start_date,
           p_tolerances_tab(TOL_STARTDATE_IND).max_increment,
           p_tolerances_tab(TOL_STARTDATE_IND).max_decrement) = 'N')
        OR
        (PO_RCOTOLERANCE_PVT.change_within_tol_date(
           old_expiration_date,
           new_expiration_date,
           p_tolerances_tab(TOL_ENDDATE_IND).max_increment,
           p_tolerances_tab(TOL_ENDDATE_IND).max_decrement) = 'N')
        OR
        (PO_RCOTOLERANCE_PVT.change_within_tol_percent(
           old_price,
           new_price,
           p_tolerances_tab(TOL_UNITPRICE_IND).max_increment,
           p_tolerances_tab(TOL_UNITPRICE_IND).max_decrement) = 'N'))
        );
Line: 10561

    PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value(start/end date check):' || l_return_val);
Line: 10617

    PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value(line amount check):' || l_return_val);
Line: 10627

      PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value(line level check):' || l_return_val);
Line: 10657

  select distinct document_type
  into l_document_type
  from po_change_requests
  where change_request_group_id =  p_pochggrp_id;
Line: 10664

  SELECT PO_RCOTOLERANCE_PVT.changes_within_tol(
    sum(decode(pl.matching_basis,
               'AMOUNT',
               pod.amount_ordered,
               pl.unit_price * (pod.quantity_ordered-nvl(pod.quantity_cancelled,0)))),
    sum(decode(pcr2.action_type, 'CANCELLATION',
               0,
               decode(pl.matching_basis,
                      'AMOUNT',
                      decode(pcr2.action_type,
                             'CANCELLATION',
                             0,
                             nvl(pcr.new_amount, pod.amount_ordered)),
                      nvl(pcr.new_quantity, pod.quantity_ordered) * nvl(pcr1.new_price, pl.unit_price)))),
    p_tolerances_tab(TOL_POTOTAL_IND).max_increment,
    p_tolerances_tab(TOL_POTOTAL_IND).max_decrement,
    p_tolerances_tab(TOL_POTOTAL_AMT_IND).max_increment,
    p_tolerances_tab(TOL_POTOTAL_AMT_IND).max_decrement)  INTO l_return_val
  FROM
    po_change_requests pcr,
    po_change_requests pcr1,
    po_change_requests pcr2,
    po_lines_all pl,
    po_distributions_all pod
  WHERE  pl.po_line_id = pod.po_line_id
    AND pcr.change_request_group_id(+) = p_pochggrp_id
    AND pcr.action_type(+) = 'MODIFICATION'
    AND pcr.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
    AND pcr.request_level(+) = 'DISTRIBUTION'
    AND pcr.initiator(+) = 'REQUESTER'
    AND pcr.document_distribution_id(+) = pod.po_distribution_id
--    AND pcr.document_line_id = pcr1.document_line_id
    AND pcr1.change_request_group_id(+) = p_pochggrp_id
    AND pl.po_header_id = p_poheader_id
    AND pcr1.document_line_id(+) = pl.po_line_id
    AND pcr1.action_type(+) = 'MODIFICATION'
    AND pcr1.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
    AND pcr1.request_level (+) = 'LINE'
    AND pcr1.initiator(+) = 'REQUESTER'
    AND pcr1.new_price(+) IS NOT NULL
    AND pcr2.change_request_group_id(+) = p_pochggrp_id
    AND pcr2.document_line_id(+) = pl.po_line_id
    AND pcr2.action_type(+) = 'CANCELLATION';
Line: 10710

    SELECT
    sum ( nvl(pcr.old_quantity, nvl(pll.quantity,0))
                           *pll.price_override ),
    sum ( decode ( pcr.document_line_location_id, null, 0,
            decode (pcr.action_type , 'CANCELLATION', 0,
    PO_ReqChangeRequestNotif_PVT.get_goods_shipment_new_amount
    (  pol.org_id,p_pochggrp_id,pol.po_line_id,
       pol.item_id,pll.unit_meas_lookup_code,
       nvl(pcr.old_price, nvl(pll.price_override, pol.unit_price)),
       pll.line_location_id)) ) )

    into l_old_amount_release, l_new_amount_release

    FROM  po_change_requests pcr,
          po_lines_all pol,
          po_line_locations_all pll
    WHERE pcr.change_request_group_id= p_pochggrp_id
    AND   pcr.po_release_id = p_poheader_id
    AND   pcr.document_line_id = pol.po_line_id
    AND   pcr.request_status NOT IN ('ACCEPTED', 'REJECTED')
    AND   pcr.document_line_location_id =pll.line_location_id (+)
    AND   pcr.request_level<>'DISTRIBUTION'
    AND   pcr.initiator(+) = 'REQUESTER';
Line: 10745

    PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value:' || l_return_val);
Line: 10754

      PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_api_name || ' Return Value(No Data Found):Y');
Line: 10800

    PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, l_api_name || '.Begin');
Line: 10801

    PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'l_pochggrp_id:' || l_pochggrp_id || ' l_poheader_id:' || l_poheader_id);
Line: 10816

      select poh.currency_code, poh.org_id
      into l_po_currency_code, l_org_id
      from po_headers_all poh, po_releases_all pr
      where pr.po_release_id = l_poheader_id
      and poh.po_header_id = pr.po_header_id;
Line: 10822

      select poh.currency_code, poh.org_id
      into l_po_currency_code, l_org_id
      from po_headers_all poh
      where poh.po_header_id = l_poheader_id;
Line: 10830

    SELECT sob.currency_code
    INTO  l_functional_currency_code
    FROM  gl_sets_of_books sob, financials_system_params_all fsp
    WHERE fsp.org_id = l_org_id
    AND  fsp.set_of_books_id = sob.set_of_books_id;
Line: 10841

    PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'doc type: '||l_po_doc_type|| ' func currency code: '||l_functional_currency_code||' po curr code: '||l_po_currency_code );
Line: 10854

         PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'Return Value(shipmnt_level_changes_wthn_tol):' || l_return_val);
Line: 10863

        PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'Return Value(line_level_changes_wthn_tol):' || l_return_val);
Line: 10871

        PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, 'Return Value(doc_level_changes_wthn_tol):' || l_return_val);
Line: 10876

      PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, l_api_name || ' Return Value:' || l_return_val);
Line: 10887

    PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, l_progress || 'SQL ERROR:' || sqlerrm);
Line: 10940

  SELECT MIN(req_change.change_request_group_id)
  INTO l_next_req_grp_id
  FROM
    po_change_requests po_change,
    po_change_requests req_change
  WHERE
    po_change.change_request_group_id = l_po_request_group_id AND
    po_change.parent_change_request_id = req_change.change_request_id AND
    req_change.change_request_group_id > l_req_request_group_id;
Line: 10960

    SELECT document_header_id, document_num
    INTO l_document_id, l_document_num
    FROM po_change_requests
    WHERE change_request_group_id = l_next_req_grp_id AND rownum=1;
Line: 11063

  SELECT po_requester_change_wf_s.nextval INTO l_count FROM dual;
Line: 11156

select document_line_location_id,action_type,
       decode(pol.matching_basis, 'AMOUNT',
                  ( nvl(pll.amount,0)-nvl(pll.amount_cancelled,0) ),
                  ( nvl(pll.quantity,0)- nvl(pll.quantity_cancelled,0)) * pol.unit_price
              )
   from po_change_requests,
        po_lines_all pol,
        po_line_locations_all pll
   where change_request_group_id = p_chg_request_grp_id
          and document_line_id = p_po_line_id
          and document_line_location_id = pll.line_location_id
          and pol.po_line_id = document_line_id
          and request_status not in ('ACCEPTED', 'REJECTED')
          and request_level = 'SHIPMENT'
          and action_type <> 'DERIVED' ;
Line: 11176

    select matching_basis,org_id,item_id,unit_price
    into l_po_matching_basis,l_po_org_id,l_item_id,l_unit_price
    from po_lines_all
    where po_line_id = p_po_line_id;
Line: 11184

    select sum( decode(l_po_matching_basis, 'AMOUNT',
                  ( nvl(pll.amount,0)-nvl(pll.amount_cancelled,0) ),
                  ( nvl(pll.quantity,0)- nvl(pll.quantity_cancelled,0)) * pol.unit_price
                  )
               )
    into l_old_amount
    FROM   po_lines_all pol,
           po_line_locations_all pll
    WHERE pol.po_line_id =  p_po_line_id
    AND pol.po_line_id = pll.po_line_id;
Line: 11205

            SELECT pcr.new_price,pcr.new_price
            into l_pcr_new_price,l_new_price
            FROM po_change_requests pcr

            WHERE pcr.change_request_group_id = p_chg_request_grp_id
            AND pcr.document_line_id =  p_po_line_id
            AND pcr.action_type(+) = 'MODIFICATION'
            AND pcr.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
            AND pcr.initiator(+) = 'REQUESTER'
            AND pcr.request_level = 'LINE'
            AND pcr.new_price is not null;
Line: 11220

            select pol.unit_price
            into l_new_price
            from po_lines_all pol
            where pol.po_line_id = p_po_line_id;
Line: 11251

             select (pcr.new_amount - pll.amount)
             into l_shipmt_amt_increase
             from po_change_requests pcr,
                  po_line_locations_all pll
             where pcr.change_request_group_id =  p_chg_request_grp_id
             and pcr.document_line_location_id =  l_pcr_line_loc_id
             and pll.line_location_id =  l_pcr_line_loc_id
             and pcr.request_level = 'SHIPMENT'
             and pcr.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
             and pcr.initiator(+) = 'REQUESTER'
             and pcr.new_amount is not null;
Line: 11275

            SELECT pcr.new_quantity,pcr.new_quantity,pll.unit_meas_lookup_code,pll.price_override
            into l_pcr_new_quantity,l_new_quantity,l_unit_lookup_code,l_price_override
            FROM po_change_requests pcr,
                 po_line_locations_all pll
            WHERE pcr.change_request_group_id = p_chg_request_grp_id
            AND pcr.document_line_location_id =  l_pcr_line_loc_id
            AND pll.line_location_id =  l_pcr_line_loc_id
            AND pcr.action_type(+) = 'MODIFICATION'
            AND pcr.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
            AND pcr.initiator(+) = 'REQUESTER'
            AND pcr.request_level = 'SHIPMENT'
            AND pcr.new_quantity is not null;
Line: 11291

             select (pll.quantity - pll.quantity_cancelled)
             into l_new_quantity
             from po_line_locations_all pll
             where pll.line_location_id = l_pcr_line_loc_id;
Line: 11317

         select ( (l_new_price * l_new_quantity) -
                   nvl(pll.price_override,pol.unit_price) * pll.quantity )
         into l_shipmt_amt_increase
         from po_lines_all pol,
              po_line_locations_all pll
         where pll.line_location_id = l_pcr_line_loc_id
         and pol.po_line_id = pll.po_line_id ;
Line: 11342

       select decode(pol.matching_basis, 'AMOUNT',pol.amount,
                      (nvl(pcr.new_price,pol.unit_price) * pol.quantity ))
       into l_new_amount
       from po_change_requests pcr,
            po_lines_all pol
       where pcr.change_request_group_id =  p_chg_request_grp_id
       and pol.po_line_id =  p_po_line_id
       and pcr.document_line_id =  p_po_line_id
       and pcr.request_level = 'LINE'
       and pcr.request_status(+) NOT IN ('ACCEPTED', 'REJECTED')
       and pcr.initiator(+) = 'REQUESTER' ;
Line: 11414

  SELECT MAX(change_request_group_id)
      FROM po_change_requests
      WHERE document_header_id = p_req_header_id
          AND initiator = 'REQUESTER'
          AND request_status = 'NEW';
Line: 11430

	  SELECT DISTINCT document_line_id
	  FROM po_change_requests
	  WHERE change_request_group_id = grp_id;
Line: 11458

    SELECT to_char(p_req_header_id) || '-'
                || to_char(l_change_request_group_id) || '-'
                || to_char(po_requester_change_wf_s.nextval)
    INTO p_item_key
    FROM sys.dual;
Line: 11465

    SELECT preparer_id, segment1,TYPE_LOOKUP_CODE
    INTO l_preparer_id, l_req_num,p_document_subtype
    FROM po_requisition_headers_all
    WHERE requisition_header_id = p_req_header_id;
Line: 11569

  SELECT     prl.requisition_header_id,
                 prl.requisition_line_id,
                 prl.line_num,
             pcr.old_quantity,
             pcr.new_quantity,
             pcr.old_need_by_date,
             pcr.new_need_by_date,
             pcr.action_type
  FROM po_change_requests pcr,
       po_requisition_lines_all prl
  WHERE pcr.change_request_group_id = l_change_request_group_id
    AND pcr.request_status = 'MGR_APP'
    AND pcr.document_line_id = prl.requisition_line_id
  ORDER BY  prl.line_num;
Line: 11588

  SELECT     prl.requisition_header_id,
                 prl.requisition_line_id
  FROM po_change_requests pcr,
       po_requisition_lines_all prl
  WHERE pcr.change_request_group_id = l_change_request_group_id
    AND pcr.request_status = 'REJECTED'
    AND pcr.document_line_id = prl.requisition_line_id
  ORDER BY  prl.line_num;
Line: 11689

      SELECT  min(CHANGE_REQUEST_ID)
      into L_CHANGE_REQUEST_ID
      FROM po_change_requests
      WHERE change_request_group_id = l_change_request_group_id
        AND request_status = 'ACCEPTED';
Line: 11750

     - for failed lines update change request as rejected and return
        = rollback to save point
     - for successful lines update the change request as accepted
        = adjust encumbrance
        = update po req tables
        = update mtl_supply

     */
    SAVEPOINT convertintosochange_sp;
Line: 11799

    select requisition_header_id
    into l_document_header_id
    from po_requisition_lines_all
    where requisition_line_id =  p_document_line_id;
Line: 11896

        UPDATE po_change_requests
        SET request_status = 'ACCEPTED'
        WHERE change_request_group_id = p_chn_request_group_id
        AND document_header_id = l_document_header_id
        AND document_line_id = p_document_line_id ;
Line: 11905

           update_req_line_date_changes(     p_req_line_id=>p_document_line_id,
                                             p_need_by_date=> p_new_need_by_date,
                                             x_return_status =>l_return_status);
Line: 11914

            update_reqline_quan_changes(p_req_line_id=>p_document_line_id,
                                             p_delta_quantity=> l_delta_quantity,
                                             x_return_status =>l_return_status);
Line: 11923

     - for successful lines update the change request as accepted and failed lines update change request as rejected
     - update po req tables    */

        l_progress := '012';
Line: 11928

        UPDATE po_change_requests
        SET request_status = 'ACCEPTED'
        WHERE change_request_group_id = p_chn_request_group_id
        AND document_header_id = l_document_header_id
        AND document_line_id = p_document_line_id ;
Line: 11935

         po_debug.debug_stmt(l_log_head, l_progress,'UPDATED po_change_requests');
Line: 11948

            po_debug.debug_stmt(l_log_head, l_progress,'update the change request as rejected');
Line: 11953

      UPDATE po_change_requests
      SET request_status = 'REJECTED',
          change_active_flag = 'N',
          request_reason=l_msg_data
      WHERE change_request_group_id = p_chn_request_group_id
      AND document_header_id = l_document_header_id
      AND document_line_id = p_document_line_id ;
Line: 12017

     The procedure updates the requisition line with changes
     of quntity.
     It retrives the existing quantity and adds the delta quntity
     to compute the new quantity
  */
  PROCEDURE update_reqline_quan_changes(p_req_line_id IN NUMBER,
                                             p_delta_quantity IN NUMBER,
                                             p_uom IN VARCHAR2 default null,
                                             x_return_status      OUT NOCOPY  VARCHAR2)
  IS
  l_mtl_quantity number;
Line: 12039

  l_api_name     CONSTANT VARCHAR(30) := 'update_reqline_quan_changes';
Line: 12056

  select DISTRIBUTION_ID
  from PO_REQ_DISTRIBUTIONS_ALL
  where REQUISITION_LINE_ID= req_line_id;
Line: 12062

  SELECT -- any quantity change
    prda.distribution_id,
    prla.unit_price,
    prla.quantity
  FROM
    po_req_distributions_all prda,
    po_requisition_lines_all prla
  WHERE
   prla.requisition_line_id = req_line_id AND
   prla.requisition_line_id = prda.requisition_line_id;
Line: 12078

                Step 2: Update the req line and dist with the quantity changes
                Step 3: Update the mtl_supply by the PO API
    */

  -- Step 1: ADJUST the encumberance
  l_progress := '001';
Line: 12101

      select prh.preparer_id  into l_preparer_id
      from po_requisition_headers_all prh,
           po_requisition_lines_all prl
      where prl.requisition_line_id = p_req_line_id
      and   prl.requisition_header_id =  prh.requisition_header_id;
Line: 12143

        l_distribution_id_tbl.delete;
Line: 12185

          UPDATE po_encumbrance_gt
          SET
            amount_ordered = l_new_amount,
            quantity_ordered = l_new_quantity,
            price = l_new_price,
            nonrecoverable_tax = l_new_tax
          WHERE
            distribution_id = l_req_dist_id AND
            adjustment_status = po_document_funds_grp.g_adjustment_status_new;
Line: 12260

        UPDATE po_requisition_lines_all
        SET quantity = quantity + p_delta_quantity
        WHERE requisition_line_id = p_req_line_id ;
Line: 12267

        UPDATE po_req_distributions_all
        SET req_line_quantity = req_line_quantity + p_delta_quantity
        WHERE requisition_line_id = p_req_line_id ;
Line: 12274

        select quantity into l_mtl_quantity
        from mtl_supply
        where supply_type_code = 'REQ'
        and req_line_id = p_req_line_id;
Line: 12285

                                                  , p_action => 'Update_Req_Line_Qty'
                                                  , p_recreate_flag => FALSE
                                                  , p_qty => l_mtl_quantity
                                                  , p_receipt_date => NULL
                                                  );
Line: 12297

        po_debug.debug_STmt(l_log_head, l_progress, 'Updated the req line and dist and mtl_supply with the quantity changes');
Line: 12298

        po_debug.debug_STmt(l_log_head, l_progress, 'Returning from update_reqline_quan_changes');
Line: 12303

  END update_reqline_quan_changes;
Line: 12311

     The procedure updates the requisition line with changes
     of need by date
     It retrives the existing quantity and adds the delta quntity
     to compute the new quantity
  */
  PROCEDURE update_req_line_date_changes(p_req_line_id IN NUMBER,
                                             p_need_by_date IN DATE,
                                             x_return_status      OUT NOCOPY  VARCHAR2)
  IS
  x_progress varchar2(3);
Line: 12322

  l_api_name VARCHAR2(50) := 'update_req_line_date_changes';
Line: 12328

    Algorithm : Step 1: Update the req line and dist with the need by date changes
                Step 2: Update the mtl_supply by the PO API

    */

       IF (p_need_by_date IS NOT NULL) THEN
          x_progress := '001';
Line: 12340

            UPDATE po_requisition_lines_all
            SET need_by_date = p_need_by_date
            WHERE requisition_line_id = p_req_line_id ;
Line: 12349

                                                      , p_action => 'Update_Req_Line_Date'
                                                      , p_recreate_flag => FALSE
                                                      , p_qty => NULL
                                                      , p_receipt_date => p_need_by_date
                                                      );
Line: 12368

   END update_req_line_date_changes;
Line: 12389

            UPDATE po_requisition_lines_all
            SET cancel_flag = 'Y',
  --          quantity_cancelled = p_old_quantity,
            cancel_date = SYSDATE
            WHERE requisition_line_id = p_req_line_id ;
Line: 12398

            Select REQUISITION_HEADER_ID into l_document_id
            from po_requisition_lines_all
            where requisition_line_id = p_req_line_id ;
Line: 12404

            UPDATE po_requisition_headers_all h
            SET    h.AUTHORIZATION_STATUS  = 'CANCELLED'
            WHERE  h.REQUISITION_HEADER_ID = l_document_id
                AND NOT EXISTS
                    (SELECT 'UNCANCELLED LINE EXISTS'
                    FROM    po_requisition_lines_all prl
                    WHERE   prl.requisition_header_id = l_document_id
                        AND NVL(prl.cancel_flag,'N')  = 'N'
                    );
Line: 12432

        po_debug.debug_stmt(l_log_head, x_progress,'Mtl_supply deleted and cancelling funds');
Line: 12458

      po_debug.debug_stmt(l_log_head, x_progress,'Mtl_supply deleted and cancelling funds');
Line: 12518

  SELECT mp.EMPLOYEE_ID
  into l_planner_id
  FROM po_change_requests pcr,
       po_requisition_lines_all prl,
       mtl_system_items_b mi,
       financials_system_params_all fsp,
       mtl_planners mp
  WHERE pcr.change_request_group_id =l_change_request_group_id
      AND pcr.change_request_id =L_CHANGE_REQUEST_ID
      AND pcr.request_status = 'ACCEPTED'
      AND pcr.DOCUMENT_LINE_ID = prl.requisition_line_id
      and prl.org_id = fsp.org_id
      AND prl.ITEM_ID = mi.INVENTORY_ITEM_ID
      AND mi.organization_id = fsp.inventory_organization_id
      and mi.PLANNER_CODE  = mp.planner_code
      AND mi.organization_id = mp.organization_id
      and prl.source_type_code = 'INVENTORY'
      and  mp.EMPLOYEE_ID NOT IN (planners already notified);
Line: 12545

  SELECT mp.EMPLOYEE_ID
  FROM po_change_requests pcr,
       po_requisition_lines_all prl,
       mtl_system_items_b mi,
       financials_system_params_all fsp,
       mtl_planners mp
  WHERE pcr.change_request_group_id =:1
      AND pcr.change_request_id =:2
      AND pcr.request_status = ''ACCEPTED''
      AND pcr.DOCUMENT_LINE_ID = prl.requisition_line_id
      and prl.org_id = fsp.org_id
      AND prl.ITEM_ID = mi.INVENTORY_ITEM_ID
      AND mi.organization_id = fsp.inventory_organization_id
      and mi.PLANNER_CODE  = mp.planner_code
      AND mi.organization_id = mp.organization_id
      and prl.source_type_code = ''INVENTORY''
      ';
Line: 12660

      SELECT  min(CHANGE_REQUEST_ID)
      into L_NEW_CHANGE_REQUEST_ID
      FROM po_change_requests
      WHERE change_request_group_id = l_change_request_group_id
        AND request_status = 'ACCEPTED'
        and CHANGE_REQUEST_ID > l_old_change_request_id;