DBA Data[Home] [Help]

APPS.PO_AUTOCREATE_DOC SQL Statements

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

Line: 68

     po_wf_debug_pkg.insert_debug(Itemtype,Itemkey,x_progress);
Line: 73

   * If a process is not passed then the selector function defined in
   * item type will be determine which process to run
   */

  IF  ( ItemType is NOT NULL )   AND
      ( ItemKey is NOT NULL)     AND
      ( req_header_id is NOT NULL ) THEN

        --Bug 5490243. Removed the commit introduced in Bug 3293852

        wf_engine.CreateProcess(itemtype => itemtype,
                                itemkey  => itemkey,
                                process  => workflow_process );
Line: 89

           po_wf_debug_pkg.insert_debug(Itemtype,Itemkey,x_progress);
Line: 134

           select org_id
       into x_org_id
             from po_requisition_headers
      where requisition_header_id = req_header_id;
Line: 175

    po_wf_debug_pkg.insert_debug(Itemtype,Itemkey,x_progress);
Line: 223

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 231

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 290

     select pol.requisition_line_id
       from po_requisition_headers poh, po_requisition_lines pol
      where line_location_id                is null           AND
      nvl(pol.cancel_flag,'N')            ='N'    AND
      nvl(pol.closed_code,'OPEN')     <> 'FINALLY CLOSED' AND
            nvl(modified_by_agent_flag,'N') ='N'          AND
            source_type_code        = 'VENDOR'          AND
      authorization_status      = 'APPROVED'  AND
      (poh.requisition_header_id      = x_req_header_id
       OR
       x_req_header_id is null)       AND
      poh.requisition_header_id = pol.requisition_header_id
   order by poh.requisition_header_id, line_num;
Line: 311

select pol.requisition_line_id
  from po_requisition_headers_all poh,    -- 
       po_requisition_lines pol
 where x_req_header_id is null                            AND
      line_location_id                is null            AND
      nvl(pol.cancel_flag,'N')            ='N'            AND
      nvl(pol.closed_code,'OPEN')    <> 'FINALLY CLOSED' AND
      nvl(modified_by_agent_flag,'N') ='N'                AND
      source_type_code                = 'VENDOR'          AND
      authorization_status            = 'APPROVED'        AND
      poh.requisition_header_id = pol.requisition_header_id
union all
select pol.requisition_line_id
  from po_requisition_headers_all poh,     -- 
       po_requisition_lines pol
 where x_req_header_id is not null                        AND
      poh.requisition_header_id      = x_req_header_id    AND
      line_location_id                is null            AND
      nvl(pol.cancel_flag,'N')            ='N'            AND
      nvl(pol.closed_code,'OPEN')    <> 'FINALLY CLOSED' AND
      nvl(modified_by_agent_flag,'N') ='N'                AND
      source_type_code                = 'VENDOR'          AND
      authorization_status            = 'APPROVED'        AND
      poh.requisition_header_id = pol.requisition_header_id;
Line: 354

SELECT prl.requisition_line_id
  FROM po_lines pol,
       po_requisition_lines prl,
       po_requisition_headers_all prh    -- 
 WHERE pol.po_header_id=l_consume_req_demand_doc_id
   AND prl.auction_header_id = pol.auction_header_id
   AND prl.bid_line_number = pol.bid_line_number
   AND prl.bid_number = pol.bid_number
   AND prl.line_location_id is null
   AND nvl(prl.cancel_flag,'N') ='N'
   AND nvl(prl.closed_code,'OPEN') <> 'FINALLY CLOSED'
   AND nvl(prl.modified_by_agent_flag,'N') ='N'
   AND prl.source_type_code   = 'VENDOR'
   AND prh.authorization_status = 'APPROVED'
   AND prh.requisition_header_id = prl.requisition_header_id;
Line: 402

       select to_char(PO_WF_GROUP_S.NEXTVAL)
           into x_group_id
           from sys.dual;
Line: 426

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 438

            po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 443

         select to_char(PO_WF_ITEMKEY_S.NEXTVAL)
           into x_seq_for_item_key
           from sys.dual;
Line: 466

            po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 485

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 495

      SELECT to_char(PO_WF_GROUP_S.NEXTVAL)
         INTO x_group_id
         FROM sys.dual;
Line: 515

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 528

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 533

    SELECT to_char(PO_WF_ITEMKEY_S.NEXTVAL)
      INTO x_seq_for_item_key
      FROM sys.dual;
Line: 554

              po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 573

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 614

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 618

   * If a process is not passed then the selector function defined in
   * item type will be determine which process to run
   */

  IF  (ItemType    is NOT NULL ) AND
      (ItemKey     is NOT NULL)  AND
      (req_line_id is NOT NULL ) then
        wf_engine.CreateProcess(itemtype => itemtype,
                                itemkey  => itemkey,
                                process  => workflow_process );
Line: 631

    po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 665

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 677

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 740

  select pls.org_id,
   pls.suggested_buyer_id,
   pls.suggested_vendor_name,
         pls.suggested_vendor_location,
     pls.document_type_code,
         pls.blanket_po_header_id,
   pls.blanket_po_line_num,
         pls.rfq_required_flag,
   pls.on_rfq_flag,
         pls.item_id,
   pls.category_id,
         pls.currency_code,
   pls.rate_type,
   pls.rate_date,
   pls.rate,
   pls.pcard_flag,
   /* Supplier PCard FPH */
   decode(pls.pcard_flag, 'Y', phs.pcard_id,'S',-99999,'N', null),
         pls.destination_organization_id,
   pls.catalog_type,
         pls.vendor_id, /* Bug 2577940 */
         pls.vendor_site_id,
         pls.job_id,  -- 
         pls.labor_req_line_id  -- 
    into x_org_id,
   x_suggested_buyer_id,
         x_suggested_vendor_name,
         x_suggested_vendor_location,
         x_source_doc_type_code,
   x_source_doc_po_header_id,
   x_source_doc_line_num,
   x_rfq_required_flag,
   x_on_rfq_flag,
         x_item_id,
   x_category_id,
   x_currency_code,
   x_rate_type,
   x_rate_date,
   x_rate,
   x_pcard_flag,
   x_pcard_id,
         x_organization_id,
   x_catalog_type,
         x_suggested_vendor_id,
         x_suggested_vendor_site_id,
         l_job_id,  -- 
         l_labor_req_line_id  -- 
    from po_requisition_headers_all phs,   -- 
         po_requisition_lines pls
   where pls.requisition_line_id = x_req_line_id
     and phs.requisition_header_id = pls.requisition_header_id;
Line: 796

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 846

     select global_agreement_flag
     into x_ga_flag
     from po_headers_all
     where po_header_id = x_source_doc_po_header_id;
Line: 947

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1013

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1021

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1118

     select 'Y',
            vendor_name
     into x_valid_vendor,
          x_vendor
     from po_suppliers_val_v
     where vendor_id = x_suggested_vendor_id;
Line: 1137

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1150

     select 'Y',
      vendor_id
       into x_valid_vendor,
      x_vendor_id
       from po_suppliers_val_v
      where vendor_name = x_suggested_vendor_name;
Line: 1169

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1192

     select 'Y',
            vendor_site_code
       into x_valid_vendor_site,
            x_vendor_site
       from po_vendor_sites_all
      where vendor_id = x_vendor_id
        and vendor_site_id = x_suggested_vendor_site_id
        --
        and purchasing_site_flag = 'Y'
        and NVL(rfq_only_site_flag, 'N') = 'N'
        and sysdate < NVL(inactive_date, sysdate + 1);
Line: 1217

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1228

     select 'Y',
      vendor_site_id
       into x_valid_vendor_site,
      x_vendor_site_id
       from po_supplier_sites_val_v
      where vendor_id = x_vendor_id
        and vendor_site_code = x_suggested_vendor_site;
Line: 1248

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1286

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1351

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1372

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1382

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1439

  SELECT POH.po_header_id,
         POH.global_agreement_flag,
         POH.currency_code
  FROM   po_headers_all POH
  WHERE  POH.vendor_id = x_supplier_id
  AND    POH.currency_code = nvl(x_item_currency, l_base_currency)
  AND    POH.type_lookup_code = 'CONTRACT'
  /* R12 GCPA
  + If Profile ALLOW_REFERENCING_CPA_UNDER_AMENDMENT is Y, then we can refer any Contract Which is approved Once
  + Else Contract should be in APPROVED state  */
  AND    ( (NVL(FND_PROFILE.VALUE('ALLOW_REFERENCING_CPA_UNDER_AMENDMENT'),'N') = 'Y'
           AND POH.Approved_Date Is Not Null
	    )
	 or (  POH.authorization_status = 'APPROVED' )
	 )
  AND    NVL(POH.cancel_flag, 'N') = 'N'
  AND    NVL(POH.frozen_flag, 'N') = 'N'
  AND    NVL(POH.closed_code, 'OPEN') = 'OPEN'
  AND    TRUNC(SYSDATE) BETWEEN NVL(TRUNC(POH.start_date), SYSDATE - 1)
                        AND     NVL(TRUNC(POH.end_date),   SYSDATE + 1)
  AND    POH.global_agreement_flag = 'Y'
  /* R12 GCPA
  + Vendor Site validation needs to be skipped if Enable All Sites on Contracts is Set to Y.   */
  AND    EXISTS (SELECT 1
              FROM   po_ga_org_assignments PGOA
              WHERE  PGOA.po_header_id = POH.po_header_id
              AND    PGOA.vendor_site_id = decode(Nvl(poh.Enable_All_Sites,'N'),'Y',PGOA.vendor_site_id, x_supplier_site_id)
              AND    PGOA.organization_id = l_current_org_id
              AND    PGOA.enabled_flag = 'Y')
  ORDER BY POH.creation_date desc;
Line: 1471

  SELECT POH.po_header_id,
         POH.global_agreement_flag,
         POH.currency_code
  FROM   po_headers_all POH
  WHERE  POH.vendor_id = x_supplier_id
  AND    POH.type_lookup_code = 'CONTRACT'
  /* R12 GCPA
  + If Profile ALLOW_REFERENCING_CPA_UNDER_AMENDMENT is Y, then we can refer any Contract Which is approved Once
  + Else Contract should be in APPROVED state
  */
  AND    ( (NVL(FND_PROFILE.VALUE('ALLOW_REFERENCING_CPA_UNDER_AMENDMENT'),'N') = 'Y'
           AND POH.Approved_Date Is Not Null
	    )
	 or (  POH.authorization_status = 'APPROVED' )
	 )
  AND    NVL(POH.cancel_flag, 'N') = 'N'
  AND    NVL(POH.frozen_flag, 'N') = 'N'
  AND    NVL(POH.closed_code, 'OPEN') = 'OPEN'
  AND    TRUNC(SYSDATE) BETWEEN NVL(TRUNC(POH.start_date), SYSDATE - 1)
                        AND     NVL(TRUNC(POH.end_date),   SYSDATE + 1)
  AND    POH.global_agreement_flag = 'Y'
  /* R12 GCPA
  + Vendor Site validation needs to be skipped if Enable All Sites on Contracts is Set to Y.    */
  AND    EXISTS (SELECT 1
              FROM   po_ga_org_assignments PGOA
              WHERE  PGOA.po_header_id = POH.po_header_id
              AND    PGOA.vendor_site_id = decode(Nvl(poh.Enable_All_Sites,'N'),'Y',PGOA.vendor_site_id, x_supplier_site_id)
              AND    PGOA.organization_id = l_current_org_id
              AND    PGOA.enabled_flag = 'Y')
  ORDER BY POH.creation_date desc;
Line: 1706

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1716

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1767

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1775

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1831

  select inventory_organization_id
    into x_inv_org_id
    from financials_system_params_all
     where org_id = l_purchasing_org_id;
Line: 1842

      select buyer_id
        into x_buyer_id
        from mtl_system_items
        where inventory_item_id = x_item_id
              and organization_id = x_inv_org_id;
Line: 1866

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1879

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1930

      select agent_id
      into x_agent_id
      from po_agents
      where category_id = x_category_id
       and trunc(sysdate) between start_date_active
                          and nvl(end_date_active, sysdate+1);
Line: 1947

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1956

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1968

      select agent_id
      into x_agent_id
      from po_agents poa, per_people_f ppf, financials_system_parameters fsp
      where poa.agent_id = ppf.person_id
        and ppf.business_group_id = fsp.business_group_id
        and trunc(sysdate) between ppf.effective_start_date
                           and nvl(ppf.effective_end_date, sysdate+1)
        and poa.category_id = x_category_id
        and trunc(sysdate) between poa.start_date_active
                           and nvl(poa.end_date_active, sysdate+1);
Line: 1990

            po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 1999

            po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2019

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2033

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2089

      select agent_id
      into   x_agent_id
      from   po_headers_all
      where  po_header_id  = x_source_doc_po_header_id;
Line: 2098

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2120

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2134

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2179

    select agent_id
      into x_agent_id
      from po_headers_all
     where po_header_id  = x_contract_id;
Line: 2206

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2221

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2276

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2290

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2298

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2307

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2348

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2356

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2458

  	 This query has been modified in such a way that it could select a release generation method even for the asl at commodity level  Earlier the query selects release generation method only for item.
    */


   select paa.release_generation_method
          into x_rel_gen_method
          from po_asl_attributes_val_v paa
          WHERE (Paa.Item_Id = x_item_id
               OR (Paa.Item_Id IS NULL
                   AND x_category_id = Paa.Category_Id
                   AND NOT EXISTS (SELECT 'commodity level ASL should be used only if there is no item level ASL'
                                   FROM   po_Asl_Attributes_val_v Paa4
                                   WHERE  Paa4.Item_Id = x_item_id
                                          AND Paa4.Vendor_Id = Paa.Vendor_Id
                                          AND Nvl(Paa4.Vendor_Site_Id,- 1) = Nvl(Paa.Vendor_Site_Id,- 1)
                                          AND Paa4.UsIng_Organization_Id IN (- 1,x_organization_id))))
         AND Paa.Vendor_Id = x_suggested_vendor_id
         AND (Paa.Vendor_Site_Id IS NULL
               OR ( x_suggested_vendor_site_id  = Paa.Vendor_Site_Id
                   AND NOT EXISTS (SELECT 'select supplier line with null supplier site'
                                   FROM   po_Asl_Attributes_val_v Paa3
                                   WHERE  Nvl(Paa.Item_Id,- 1) = Nvl(Paa3.Item_Id,- 1)
                                          AND Nvl(Paa.Category_Id,- 1) = Nvl(Paa3.Category_Id,- 1)
                                          AND Paa.Vendor_Id = Paa3.Vendor_Id
                                          AND Paa3.Vendor_Site_Id IS NULL
                                          AND Paa3.UsIng_Organization_Id IN (- 1,
                                                                             x_organization_id))))
         AND Paa.UsIng_Organization_Id = (SELECT MAX(Paa2.UsIng_Organization_Id)
                                          FROM   po_Asl_Attributes_val_v Paa2
                                          WHERE  Nvl(Paa.Item_Id,- 1) = Nvl(Paa2.Item_Id,- 1)
                                                 AND Nvl(Paa.Category_Id,- 1) = Nvl(Paa2.Category_Id,- 1)
                                                 AND Paa.Vendor_Id = Paa2.Vendor_Id
                                                 AND Nvl(Paa.Vendor_Site_Id,- 1) = Nvl(Paa2.Vendor_Site_Id,- 1)
                                                 AND Paa2.UsIng_Organization_Id IN (- 1,x_organization_id));
Line: 2511

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2519

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2566

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2574

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2590

 *  Procedure:  insert_cand_req_lines_into_tbl
 *
 *  Description:  Inserts a req line into the temp table.
 *      This means its possible to try and autocreate this
 *      line.
 *
 **************************************************************************/
procedure insert_cand_req_lines_into_tbl (itemtype   IN   VARCHAR2,
                                          itemkey    IN   VARCHAR2,
                                          actid      IN   NUMBER,
                                          funcmode   IN   VARCHAR2,
                                          resultout  OUT NOCOPY  VARCHAR2 ) is


x_group_id      number;
Line: 2730

  /* Insert the req line into the the temp table.
   * The req lines in this table will then be picked up
   * later to be autocreated.
   */

   x_progress := '10:insert_cand_req_lines_into_tbl: inserting into temp table for ' ||
     'req line = ' || to_char(x_req_line_id);
Line: 2739

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2743

      INSERT INTO po_wf_candidate_req_lines_temp
        (group_id,
     requisition_header_id,
     requisition_line_id,
     suggested_buyer_id,
     source_doc_type_code,
       source_doc_id,
     source_doc_line,
     suggested_vendor_id,
     suggested_vendor_site_id,
                 contract_id,
     currency_code,
     rate_type,
     rate_date,
     rate,
     pcard_id,
     process_code,
     release_generation_method,
     item_id,
                 job_id)  -- 
   VALUES (x_group_id,
     x_req_header_id,
     x_req_line_id,
     x_suggested_buyer_id,
     x_source_doc_type_code,
       x_source_doc_id,
     x_source_doc_line,
     x_suggested_vendor_id,
     x_suggested_vendor_site_id,
                 x_contract_id,
     x_currency_code,
     x_rate_type,
     x_rate_date,
     x_rate,
     x_pcard_id,
     'PENDING',
     x_rel_gen_method,
     x_item_id,
                 l_job_id);  -- 
Line: 2784

       x_progress := '15: insert_cand_req_lines_into_tbl: IN EXCEPTION when inserting' ||
         'into po_wf_candidate_req_lines_temp';
Line: 2787

          po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2798

   x_progress:= '20: insert_cand_req_lines_into_tbl: ACTIVITY_PERFORMED';
Line: 2800

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 2805

    wf_core.context('po_autocreate_doc','insert_cand_req_lines_into_tbl',x_progress);
Line: 2807

end insert_cand_req_lines_into_tbl;
Line: 2815

 *      header and line records which it then inserts into
 *      the interface tables.
 *
 **************************************************************************/
procedure group_req_lines (itemtype   IN   VARCHAR2,
                           itemkey    IN   VARCHAR2,
                           actid      IN   NUMBER,
                           funcmode   IN   VARCHAR2,
                           resultout  OUT NOCOPY  VARCHAR2 ) is


c1_group_id     number;
Line: 2917

 * We need the 'for update' since we are going to update the
 * process_code.
 */
/* Bug # 1721991.
   The 'for update' clause was added to update the row which was processed
   in the Cursor c2 but this led to another problem in Oracle 8.1.6.3 or above
   where you can't have a commit inside a 'for update' Cursor loop.
   This let to the Runtime Error 'fetch out of sequence'
   The commit was actually issued in the procedure insert_into_header_interface.
   To solve this we removed the for update in the cursor and instead used rowid
   to update the row processed by the Cursor.
*/
-- 
-- Added labor_req_line_id to the select statement
cursor c1  is       /* x_group_id is a parameter */
  select prlt.group_id,
         prlt.requisition_header_id,
         prlt.requisition_line_id,
   prlt.suggested_buyer_id,
         prlt.source_doc_type_code,
   prlt.source_doc_id,
   prlt.source_doc_line,
   prlt.suggested_vendor_id,
         prlt.suggested_vendor_site_id,
   prlt.currency_code,
         prlt.rate_type,
   prlt.rate_date,
   prlt.rate,
   prlt.process_code,
   prlt.release_generation_method,
   prlt.item_id,
   prlt.pcard_id,
         prlt.contract_id,
         hrl.location_code,
         prl.destination_organization_id,
         prl.destination_type_code,
         prl.labor_req_line_id
         --
        ,prl.line_type_id,
         prl.purchase_basis
         --
    from po_wf_candidate_req_lines_temp prlt,
         po_requisition_lines prl,
         hr_locations_all hrl
   where prlt.process_code = 'PENDING'
     and prlt.group_id     = x_group_id
     and prlt.requisition_line_id = prl.requisition_line_id
     and prl.deliver_to_location_id = hrl.location_id(+)    -- bug 2709046
     and prl.reqs_in_pool_flag = 'Y' -- 
   for update; -- 
Line: 2973

  select prlt.rowid,   -- Bug# 1721991 , Added rowid to update row processed
         prlt.group_id,
         prlt.requisition_header_id,
         prlt.requisition_line_id,
   prlt.suggested_buyer_id,
         prlt.source_doc_type_code,
   prlt.source_doc_id,
   prlt.source_doc_line,
   prlt.suggested_vendor_id,
         prlt.suggested_vendor_site_id,
   prlt.currency_code,
         prlt.rate_type,
   prlt.rate_date,
   prlt.rate,
   prlt.process_code,
   prlt.release_generation_method,
   prlt.item_id,
   prlt.pcard_id,
         prlt.contract_id,
   prl.suggested_vendor_contact,
   prl.vendor_contact_id,
         hrl.location_code,
         prl.destination_organization_id,
         prl.destination_type_code,
         prl.labor_req_line_id
         --
        ,prl.line_type_id,
         prl.purchase_basis
         --

    from po_wf_candidate_req_lines_temp prlt,
   po_requisition_lines prl,
         hr_locations_all hrl
   where prlt.process_code = 'PENDING'
     and prlt.group_id     = x_group_id
     and prlt.requisition_line_id = prl.requisition_line_id
     and prl.deliver_to_location_id = hrl.location_id(+)  -- bug 2709046
     and prl.reqs_in_pool_flag = 'Y' -- 
     --Bug# 1721991, for update;
Line: 3012

   for update; -- 
Line: 3097

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3104

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3109

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3119

                po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3149

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3154

            select global_agreement_flag
            into c1_ga_flag
            from po_headers_all
            where po_header_id = c1_source_doc_id;
Line: 3263

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3269

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3274

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3283

	         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3313

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3318

            select global_agreement_flag
            into c2_ga_flag
            from po_headers_all
            where po_header_id = c2_source_doc_id;
Line: 3384

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3399

    if (c1_req_line_id = c2_req_line_id) /* Always insert if c1 and c2 is the same line */
             OR
             ( /* (x_grouping_allowed = 'Y') AND Bug 2974129 */
             (x_group_one_time_address = 'Y' OR
              (x_group_one_time_address = 'N' AND
               c1_deliver_to_location_code <> nvl(fnd_profile.value('POR_ONE_TIME_LOCATION'),-99) AND	--bug 4449781 : added nvl
               c2_deliver_to_location_code <> nvl(fnd_profile.value('POR_ONE_TIME_LOCATION'),-99))) AND
             (c1_suggested_buyer_id     = c2_suggested_buyer_id)       AND
	     (c1_style_id = c2_style_id)  AND                         --
       (c1_suggested_vendor_id    = c2_suggested_vendor_id)    AND
       (c1_suggested_vendor_site_id = c2_suggested_vendor_site_id) AND
       (nvl(c1_source_doc_type_code ,'QUOTATION')    =
              nvl(c2_source_doc_type_code,'QUOTATION'))                  AND
             (nvl(c1_ga_flag,'N')         = nvl(c2_ga_flag,'N'))         AND      -- FPI GA
             (nvl(c1_contract_id,-1)    = nvl(c2_contract_id,-1))  AND
             (nvl(c1_currency_code,'ok')  = nvl(c2_currency_code, 'ok')) AND
       (nvl(c1_rate_type, 'ok')   = nvl(c2_rate_type, 'ok'))   AND
             ((c1_rate is NULL AND c2_rate is NULL)     --
              OR
        (nvl(c1_rate_date, trunc(sysdate))  = nvl(c2_rate_date, trunc(sysdate))))  AND
       (nvl(c1_rate,-1)     = nvl(c2_rate, -1))    AND
       (nvl(c1_pcard_id,-1)   = nvl(c2_pcard_id,-1))   AND
       ((nvl(c1_source_doc_id,-1)   = nvl(c2_source_doc_id,-1))
        OR
              (nvl(c1_source_doc_type_code ,'QUOTATION')   = 'QUOTATION')
              OR
              ((nvl(c1_source_doc_type_code,'QUOTATION') = 'BLANKET') AND (nvl(c1_ga_flag,'N') = 'Y'))) -- FPI GA   AND
             )
             -- 
             OR
             (nvl(c1_req_line_id, -1) = nvl(c2_labor_req_line_id, -1))
             OR
             (nvl(c1_labor_req_line_id, -1) = nvl(c2_req_line_id, -1))
             -- 
          THEN

        x_progress := '20: group_req_lines: c1 and c2 match ';
Line: 3437

          po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3441

       /* Update the process code of the current line in the temp table so
          * it doesn't get picked up again by the cursor for processing.
        */

       update po_wf_candidate_req_lines_temp
       set process_code = 'PROCESSED'
             where rowid=c2_rowid;
Line: 3450

       x_progress:= '30:group_req_lines: Updated process_code ';
Line: 3452

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3465

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3476

                if(po_autocreate_doc.insert_into_headers_interface
                     (itemtype,
                      itemkey,
                      c2_group_id,
                      c2_suggested_vendor_id,
                      c2_suggested_vendor_site_id,
                      c2_suggested_buyer_id,
                      c2_source_doc_type_code,
                      c2_source_doc_id,
                      c2_currency_code,
                      c2_rate_type,
                      c2_rate_date,
                      c2_rate,
                      l_pcard_id,  --
                      c2_style_id,  --
                      x_interface_header_id) = FALSE) then
                  exit; --bug 3401653: po creation failed, skip out of inner loop
Line: 3497

          po_autocreate_doc.insert_into_lines_interface (itemtype,
                  itemkey,
                  x_interface_header_id,
                  c2_req_line_id,
                  c2_source_doc_line,
                  c2_source_doc_type_code,
                                                            c2_contract_id,
                                                            c2_source_doc_id,         -- GA FPI
                                                            c2_cons_from_supp_flag);  -- Consigned FPI
Line: 3513

         select vendor_contact_id
         into   x_source_contact_id
         from   po_headers_all
         where  po_header_id=c2_contract_id;
Line: 3520

          select vendor_contact_id
          into   x_source_contact_id
          from   po_headers_all           -- To take care of GAs in Diff Operating unit
          where  po_header_id=c2_source_doc_id;
Line: 3533

          x_progress := '40: group_req_lines: inserted header'||
          ' and line for req line = ' || to_char(c2_req_line_id);
Line: 3536

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3539

   Added code to update vendor_contact_id when  po_headers is inserted for first time. */
     if (x_carry_contact_to_po_flag = 'TRUE' and
              valid_contact(c2_suggested_vendor_site_id, x_suggested_vendor_contact_id)) then
     begin
                      update po_headers_interface
                set vendor_contact_id = x_suggested_vendor_contact_id
          where interface_header_id = x_interface_header_id;
Line: 3549

                         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3567

           * as a previous one, so only insert a new line into the
                 * po_lines_interface table.
           */

                po_autocreate_doc.insert_into_lines_interface (itemtype,
                  itemkey,
                  x_interface_header_id,
                  c2_req_line_id,
                  c2_source_doc_line,
                  c2_source_doc_type_code,
                                                            c2_contract_id,
                                                            c2_source_doc_id,          -- GA FPI
                                                            c2_cons_from_supp_flag);   -- Consigned FPI
Line: 3581

           x_progress := '50: group_req_lines: inserted just line for '||
             'req line = ' || to_char(c2_req_line_id);
Line: 3584

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3616

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3622

/* Commented this code as we are updating vendor_contact_id when header is inserted first time.
      if (x_carry_contact_to_po_flag = 'TRUE' and
          valid_contact(c2_suggested_vendor_site_id, x_suggested_vendor_contact_id)) then
            begin
                    x_progress := '55: group_req_lines: updating header with vendor contact :'||x_interface_header_id;
Line: 3627

                    update po_headers_interface
                    set vendor_contact_id = x_suggested_vendor_contact_id
                    where interface_header_id = x_interface_header_id;
Line: 3633

                       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3642

 /* Bug 3586181 Update the contact id if the either Contract or GA has
                got a valid contact */
       if (c2_found='Y') then
       Begin

         if ( x_source_contact_id is not null) then
        update po_headers_interface
              set    vendor_contact_id = x_source_contact_id
              where  interface_header_id = x_interface_header_id;
Line: 3653

              update po_headers_interface
              set    vendor_contact_id = NULL
              where  interface_header_id = x_interface_header_id;
Line: 3657

              update po_headers_interface
        set    vendor_contact_id = x_prev_sug_vendor_contact_id
              where  interface_header_id = x_interface_header_id;
Line: 3668

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3685

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3699

 *  Procedure:  insert_into_headers_interface
 *
 *  Description:  Inserts a row into the po_headers_interface
 *  Returns false if creating PO header fails, and true otherwise (bug 3401653)
 *
 **************************************************************************/
function insert_into_headers_interface (itemtype         IN  VARCHAR2,
           itemkey         IN  VARCHAR2,
           x_group_id        IN  NUMBER,
           x_suggested_vendor_id       IN  NUMBER,
           x_suggested_vendor_site_id  IN  NUMBER,
           x_suggested_buyer_id      IN  NUMBER,
           x_source_doc_type_code      IN  VARCHAR2,
           x_source_doc_id       IN  NUMBER,
           x_currency_code       IN  VARCHAR2,
           x_rate_type         IN  VARCHAR2,
           x_rate_date         IN  DATE,
           x_rate          IN  NUMBER,
           x_pcard_id        IN  NUMBER,
                     p_style_id                  IN  NUMBER,  --
           x_interface_header_id   IN OUT NOCOPY  NUMBER)
RETURN boolean is --bug 3401653


x_batch_id      number;
Line: 3725

x_last_update_date    date  := sysdate;
Line: 3727

x_last_updated_by   number;
Line: 3770

    x_progress := '10:insert_into_headers_interface:' ||
      'just before set_purchasing_org_id';
Line: 3783

    x_progress:= '20: insert_into_headers_interface: org_id = ' ||
    to_char(x_org_id) || ' purchasing_org_id = ' ||
    to_char(l_purchasing_org_id);
Line: 3811

   x_last_updated_by  := to_number(FND_PROFILE.VALUE('user_id'));
Line: 3816

   select po_headers_interface_s.nextval
     into x_interface_header_id
     from sys.dual;
Line: 3837

     select global_agreement_flag, currency_code
     into x_ga_flag, l_source_doc_currency_code
     from po_headers_all
     where po_header_id = x_source_doc_id;
Line: 3887

        x_progress := '30: insert_into_headers_interface: Just about to get doc' ||
           'num from po_unique_identifier_control';
Line: 3891

    po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3898

   done as the Commit after the UPDATE of the PO_UNIQUE_IDENTIFIER_CONTROL
   table was also affecting the Workflow transactions.
   The function get_document_num is an autonomous transaction.
*/
        --
        --Get document num in purchasing org
        x_document_num := get_document_num(l_purchasing_org_id);
Line: 3906

        x_progress := '40: insert_into_headers_interface: Got doc' ||
           'num from po_unique_identifier_control';
Line: 3909

    po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3919

        select 'PO EXISTS'
          into x_found
          from po_headers_all
         where segment1 = x_document_num
           and org_id = l_purchasing_org_id    -- 
           and type_lookup_code IN ('STANDARD', 'PLANNED', 'BLANKET', 'CONTRACT');
Line: 3932

             x_progress := '45: insert_into_headers_interface: document_num is a ' ||
         'duplicate - not going to insert into po_headers_interface';
Line: 3935

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 3946

    select sob.currency_code, fsp.set_of_books_id
      into l_pou_currency_code, l_pou_sob_id
      from financials_system_params_all fsp,
           gl_sets_of_books sob
     where fsp.set_of_books_id = sob.set_of_books_id
           and fsp.org_id = l_purchasing_org_id;  -- 
Line: 3953

    select default_rate_type
      into l_pou_default_rate_type
      from po_system_parameters_all psp  --
     where psp.org_id = l_purchasing_org_id;    --  removed nvl                  --
Line: 3958

    select sob.currency_code
      into l_rou_currency_code
      from financials_system_params_all fsp,
           gl_sets_of_books sob
     where fsp.set_of_books_id = sob.set_of_books_id
           and fsp.org_id = x_org_id;
Line: 3995

                    x_progress := '47: insert_into_headers_interface: Purchasing Operating unit' ||
              ' has no default rate type, cannot create PO';
Line: 3997

                    po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 4017

                    x_progress := '47: insert_into_headers_interface: Purchasing Operating unit' ||
              ' has no default rate type, cannot create PO';
Line: 4019

                    po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 4034

                    x_progress := '48: insert_into_headers_interface: No rate defined to' ||
              ' convert from Requesting OU currency to PO currency, cannot create PO';
Line: 4036

                    po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 4061

     select segment1
       into x_document_num
       from po_headers
      where po_header_id = x_source_doc_id;
Line: 4068

     select nvl(max(release_num),0)+1
       into x_release_num
       from po_releases_all por,    -- 
            po_headers poh
      where poh.po_header_id = x_source_doc_id
        and poh.po_header_id = por.po_header_id;
Line: 4077

      * this could conflict with a release_num that we have inserted into
      * the po_headers_interface table previously that has yet to converted
      * into a release eg. when we have two req lines that will be created
      * onto two diff. releases.
      */

     -- Bug 722352, lpo, 08/26/98
     -- Commented out the release_num filters for the next 2 queries.

     select count (*)
       into x_no_releases
       from po_headers_interface phi
      where phi.document_num = x_document_num;
Line: 4093

       select max(release_num)+1
   into x_release_num1
         from po_headers_interface phi
        where phi.document_num = x_document_num;
Line: 4124

   /* Insert into po_headers_inteface */

   x_progress := '50: insert_into_headers_interface: Just about to insert into ' ||
      'po_headers_interface';
Line: 4129

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4135

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4139

      insert into po_headers_interface
              (wf_group_id,
         interface_header_id,
               interface_source_code,
               batch_id,
               process_code,
               action,
                 document_type_code,
               document_subtype,
               document_num,
               group_code,
               vendor_id,
               vendor_site_id,
         release_num,
               release_date,
               agent_id,
         currency_code,
         rate_type_code,
         rate_date,
         rate,
         creation_date,
         created_by,
             last_update_date,
         last_updated_by,
         pcard_id,
                 style_id     --
                 )
            values
              (x_group_id,
         x_interface_header_id,
               'PO',
               x_batch_id,
         'NEW',
               'NEW',
               'PO',                -- PO for both po's and releases
               x_doc_type_to_create,
               x_document_num,
               x_group_code, /* Bug 2974129 */
               x_suggested_vendor_id,
               x_suggested_vendor_site_id,
         x_release_num,
         x_release_date,
               x_suggested_buyer_id,
         x_currency_code_doc,
         l_interface_rate_type, --bug 3401653
         l_interface_rate_date, --bug 3401653
         l_interface_rate, --bug 3401653
         x_creation_date,
         x_created_by,
         x_last_update_date,
         x_last_updated_by,
         x_pcard_id,
                 p_style_id     --
                 );
Line: 4198

    x_progress := '55: insert_into_headers_interface: IN EXCEPTION when '||
      'inserting into po_headers_interface';
Line: 4201

             po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4207

    x_progress := '60: insert_into_headers_interface: Inserted into ' ||
      'po_headers_interface';
Line: 4210

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4220

    wf_core.context('po_autoinsert_into_headers_interface','create_doc',x_progress);
Line: 4222

end insert_into_headers_interface;
Line: 4227

 *  Procedure:  insert_into_lines_interface
 *
 *  Description:  Inserts a row in the po_lines_interface table
 *
 *
 **************************************************************************/
procedure insert_into_lines_interface (itemtype         IN VARCHAR2,
               itemkey          IN VARCHAR2,
               x_interface_header_id  IN NUMBER,
               x_req_line_id        IN NUMBER,
               x_source_doc_line      IN NUMBER,
               x_source_doc_type_code IN VARCHAR2,
                                       x_contract_id          IN NUMBER,
                                       x_source_doc_id        IN NUMBER,            -- GA FPI
                                       x_cons_from_supp_flag  IN VARCHAR2) is       -- Consigned FPI

--  : removed variable x_contract_num

x_interface_line_id       number;
Line: 4247

x_last_update_date    date  := sysdate;
Line: 4249

x_last_updated_by   number;
Line: 4274

   x_last_updated_by  := to_number(FND_PROFILE.VALUE('user_id'));
Line: 4279

     select global_agreement_flag
     into x_ga_flag
     from po_headers_all
     where po_header_id = x_source_doc_id;
Line: 4329

    select po_lines_interface_s.nextval
      into x_interface_line_id
      from sys.dual;
Line: 4341

         Select  po_line_id
         into x_source_line_id
         From po_lines_all
         Where  po_header_id = x_source_doc_id
         And line_num = x_source_doc_line;
Line: 4351

    /* Insert into po_lines */

    x_progress :=  '10: insert_into_lines_interface: Just about to insert into ' ||
       'po_lines_interface';
Line: 4357

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4363

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4367

      insert into po_lines_interface
                  (interface_header_id,
                interface_line_id,
          action,
                line_num,
                shipment_num,
                requisition_line_id,
                                contract_id,     -- 
                                from_header_id, -- GA FPI
                                from_line_id,   -- GA FPI
                                consigned_flag,  -- Bug 2798503
        creation_date,
        created_by,
            last_update_date,
        last_updated_by)
            values
              (x_interface_header_id,
                 x_interface_line_id,
           x_action_type_code_line,
                 x_line_num,
                 null,
                 x_req_line_id,
                                 x_contract_id,   -- 
                                 decode(x_cons_from_supp_flag,'Y',null,x_source_doc_id) ,  -- Consigned FPI
                                 decode(x_cons_from_supp_flag,'Y',null,x_source_line_id),  -- Consigned FPI
                                 x_cons_from_supp_flag,    -- Bug 2798503
         x_creation_date,
         x_created_by,
         x_last_update_date,
         x_last_updated_by);
Line: 4400

           x_progress:= '15: insert_into_lines_interface: IN EXCEPTION when' ||
      'inserting into po_lines_interface';
Line: 4403

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4408

     x_progress := '20: insert_into_lines_interface: Inserted into ' ||
       'po_lines_interface';
Line: 4411

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4417

    wf_core.context('po_autoinsert_into_lines_interface','insert_into_lines_interface',
                      x_progress);
Line: 4420

end insert_into_lines_interface;
Line: 4453

     select interface_header_id,
      document_subtype,
      agent_id,
            vendor_site_id --
       from po_headers_interface
      where wf_group_id = x_group_id
   order by interface_header_id;
Line: 4517

        PO_WF_DEBUG_PKG.insert_debug(itemtype   => itemtype,
                                     itemkey    => itemkey,
                                     x_progress => x_progress);
Line: 4526

      select to_char(PO_WF_ITEMKEY_S.NEXTVAL)
        into x_seq_for_item_key
        from sys.dual;
Line: 4547

         po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4570

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4608

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4613

   * If a process is not passed then the selector function defined in
   * item type will be determine which process to run
   */

  IF  (ItemType    is NOT NULL ) AND
      (ItemKey     is NOT NULL)  AND
      (interface_header_id is NOT NULL ) then
        wf_engine.CreateProcess(itemtype => itemtype,
                                itemkey  => itemkey,
                                process  => workflow_process );
Line: 4626

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4676

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4688

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4753

     *      - insert into the main tables from the
     *        the interface tables.
     *
     * x_document_id is populated with po_header_id for pos
     * and po_release_id for releases
     */


     x_progress:= '10: create_doc: Kicking off backend with' ||
            'interface_header_id = '|| to_char(x_interface_header_id);
Line: 4764

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4791

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4816

          po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4824

          po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 4891

     select displayed_field
       into x_doc_type_created_disp
       from po_lookup_codes
      where lookup_type = 'NOTIFICATION TYPE'
        and lookup_code = x_doc_type_to_create;
Line: 4914

     select segment1,
            style_id
       into x_segment1,
            l_style_id
       from po_headers_all
      where po_header_id = x_autocreated_doc_id;
Line: 4940

                                    p_mode         => 'update');
Line: 4954

     select poh.segment1,
      por.release_num
       into x_segment1,
      x_release_num
       from po_headers_all  poh,    -- 
            po_releases por
      where por.po_release_id = x_autocreated_doc_id
  and por.po_header_id  = poh.po_header_id;
Line: 5012

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5026

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5115

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,'Tax Errored ');
Line: 5126

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5134

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5283

    * Deleted  the  code which gets teh preparer_id if it is null since
    * x_preparer_id will be derived in get_transmission_defaults if
    * this is null. Also deleted the code which gets the default supplier
    * communication method from po_vendor_site and now call
    * PO_VENDOR_SITES_SV.Get_Transmission_Defaults which does this now.
    * Also deleted the code which defaults item_type, item_key from
    * po_document_types as this is done now in start_wf_process.
   */

    /* Bug 1845764 :
    Check if the supplier site on the PO/Release has email as the default notification method.
    if so set the email flag and address from the site */

  -- included bug fix 2342323. Modified changes are to retrieve segment1
        -- from po_headers into x_doc_num
  -- for release, PO or PA
        -- Bug 2567900 Included fax number in the select

        /* bug 4638656 - start */
        /* We donot consider transaction subtype POCO, since a
	   document cannot be in requires reapproval when
	   launching approval from create doc */

	 --Bug4956479 Included agent_id/preparer_id in select/into clause
	 --for doctype of both PO/RELEASE

        l_transaction_subtype := 'POO';
Line: 5313

             select      pvs.tp_header_id,
                         nvl(etd.edi_flag,'N'),
                         ph.agent_id
             into        l_tp_header_id,
                         l_edi_flag,
                         x_preparer_id
             from        ece_tp_details etd,
                         po_vendor_sites pvs,
                         po_vendors pv,
                         po_headers ph
             where       pv.vendor_id       = pvs.vendor_id
             and         pvs.tp_header_id   = etd.tp_header_id
             and         etd.document_id    = l_transaction_subtype
             and         ph.vendor_id       = pv.vendor_id
             and         ph.vendor_site_id  = pvs.vendor_site_id
             and         ph.po_header_id    = x_doc_id
             and         ph.type_lookup_code= x_doc_subtype
             and         etd.document_type  = ph.type_lookup_code;
Line: 5341

             select      pvs.tp_header_id,
                         nvl(etd.edi_flag,'N'),
                         pr.agent_id
             into        l_tp_header_id,
                         l_edi_flag,
                         x_preparer_id
             from        ece_tp_details etd,
                         po_vendor_sites pvs,
                         po_vendors pv,
                         po_headers ph ,
                         po_releases pr
             where       pv.vendor_id       = pvs.vendor_id
             and         pvs.tp_header_id   = etd.tp_header_id
             and         etd.document_id    = l_transaction_subtype
             and         ph.vendor_id       = pv.vendor_id
             and         ph.vendor_site_id  = pvs.vendor_site_id
             and         pr.po_header_id    = ph.po_header_id
             and         pr.po_release_id   = x_doc_id
	     and         etd.document_type  = 'RELEASE';
Line: 5436

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5464

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5504

  /* Delete all rows belonging to this group_id */

  delete from po_wf_candidate_req_lines_temp
        where group_id = x_group_id;
Line: 5517

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5551

     SELECT   emergency_po_num
     INTO     x_emergency_po_num
     FROM     po_requisition_headers
     WHERE    requisition_header_id=x_req_header_id;
Line: 5561

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5570

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5577

        po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5593

 *                      insert into the interface tables
 *      Remark:         This is for processing emergency requisitions
 *                      where only one PO number is reserved for each
 *                      requisition
 *
 **************************************************************************/
procedure put_on_one_po(itemtype   IN   VARCHAR2,
                        itemkey    IN   VARCHAR2,
                        actid      IN   NUMBER,
                        funcmode   IN   VARCHAR2,
                        resultout  OUT NOCOPY  VARCHAR2 ) is

c_rowid       rowid;
Line: 5648

 * We need the 'for update' since we are going to update the
 * process_code.
 */

/* Bug # 1721991.
   The 'for update' clause was added to update the row which was processed
   in the Cursor c1 but this led to another problem in Oracle 8.1.6.3 or above
   where you can't have a commit inside a 'for update' Cursor loop.
   This let to the Runtime Error 'fetch out of sequence'
   The commit was actually issued in the procedure insert_into_header_interface.
   To solve this we removed the for update in the cursor and instead used rowid
   to update the row processed by the Cursor.
*/

cursor c1  is       /* x_group_id is a parameter */
  select prlt.rowid, -- Bug# 1721991, Added rowid to update row
         prlt.group_id,
         prlt.requisition_header_id,
         prlt.requisition_line_id,
   prlt.suggested_buyer_id,
         prlt.source_doc_type_code,
   prlt.source_doc_id,
   prlt.source_doc_line,
   prlt.suggested_vendor_id,
         prlt.suggested_vendor_site_id,
   prlt.currency_code,
         prlt.rate_type,
   prlt.rate_date,
   prlt.rate,
   prlt.process_code,
   prlt.release_generation_method,
   prlt.item_id,
   prlt.pcard_id,
         prlt.contract_id,
   prl.suggested_vendor_contact,
   prl.vendor_contact_id,
         prl.destination_organization_id,
         prl.destination_type_code
    from po_wf_candidate_req_lines_temp  prlt,
   po_requisition_lines prl
   where prlt.process_code = 'PENDING'
     and prlt.group_id     = x_group_id
     and prlt.requisition_header_id = prl.requisition_header_id
     and prlt.requisition_line_id = prl.requisition_line_id;
Line: 5711

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5748

     update po_wf_candidate_req_lines_temp
     set process_code = 'PROCESSED'
     where rowid=c_rowid;
Line: 5787

       if(po_autocreate_doc.insert_into_headers_interface
               (itemtype,
                itemkey,
                c_group_id,
                c_suggested_vendor_id,
                c_suggested_vendor_site_id,
                c_suggested_buyer_id,
                null,
                null,
                c_currency_code,
                c_rate_type,
                c_rate_date,
                c_rate,
                c_pcard_id,
                            l_style_id,  --
                x_interface_header_id) = FALSE) then
                    return; --bug 3401653: po creation failed
Line: 5809

        po_autocreate_doc.insert_into_lines_interface (itemtype,
                itemkey,
                x_interface_header_id,
                c_req_line_id,
                null,
                null,
                                                    null,
                null,
                c_cons_from_supp_flag);        -- Consigned FPI
Line: 5819

        x_progress := '20: put_on_one_po: inserted header'||
                ' and line for req line = ' ||
                      to_char(c_req_line_id);
Line: 5823

    po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5837

         * as a previous one, so only insert a new line into the
         * po_lines_interface table.
         */

        po_autocreate_doc.insert_into_lines_interface (itemtype,
                itemkey,
                x_interface_header_id,
                c_req_line_id,
                null,
                null,
                                                    null,
                null,
                c_cons_from_supp_flag);   -- Consigned FPI
Line: 5860

         x_progress := '30: put_on_one_po: inserted just line for '||
             'req line = ' || to_char(c_req_line_id);
Line: 5863

     po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5878

                    update po_headers_interface
                    set vendor_contact_id = x_suggested_vendor_contact_id
                    where interface_header_id = x_interface_header_id;
Line: 5885

                       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5895

      po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 5940

  l_update_req_url     varchar2(1000);
Line: 5963

    select st.DISPLAYED_FIELD,
           ty.DISPLAYED_FIELD,
           hd.SEGMENT1,
           hd.ORG_ID,
           hd.PREPARER_ID,
           hd.TYPE_LOOKUP_CODE
      into l_doc_subtype,
           l_doc_type,
           l_req_num,
           l_org_id,
           l_preparer_id,
           doc_subtype
      from po_requisition_headers hd,
           po_lookup_codes ty,
           po_lookup_codes st
     where hd.requisition_header_id = p_req_header_id
       and ty.lookup_type = 'DOCUMENT TYPE'
       and ty.lookup_code = 'REQUISITION'
       and st.lookup_type = 'REQUISITION TYPE'
       and st.lookup_code = hd.TYPE_LOOKUP_CODE;
Line: 5985

    select ty.DOCUMENT_TYPE_CODE,
           ty.DOCUMENT_SUBTYPE,
           ty.type_name,
           hd.SEGMENT1,
           hd.ORG_ID,
           hd.PREPARER_ID,
           hd.TYPE_LOOKUP_CODE,
           ty.wf_approval_itemtype
      into l_doc_type_code,
           l_doc_subtype,
           l_doc_type,
           l_req_num,
           l_org_id,
           l_preparer_id,
           doc_subtype,
           ItemType
      from po_requisition_headers hd,
           po_document_types ty
     where hd.requisition_header_id = p_req_header_id
       and ty.document_type_code = 'REQUISITION'
       and ty.document_subtype = hd.TYPE_LOOKUP_CODE;
Line: 6016

     select wf_approval_itemtype
       into ItemType
       from PO_DOCUMENT_TYPES
      where DOCUMENT_TYPE_CODE = 'REQUISITION'
        and DOCUMENT_SUBTYPE =  doc_subtype;
Line: 6041

     l_update_req_url := por_util_pkg.jumpIntoFunction(
                     p_application_id=> 178,
                     p_function_code => 'POR_UPDATE_REQ',
                     p_parameter1    => to_char(p_req_header_id),
                     p_parameter11   => to_char(l_org_id) );
Line: 6056

     select pr.FULL_NAME
       into l_agent_name
       from per_people_f pr
      where pr.person_id = p_agent_id
        and trunc(sysdate) between pr.effective_start_date
                               and pr.effective_end_date;
Line: 6067

     select to_char(PO_WF_ITEMKEY_S.NEXTVAL) into l_seq from sys.dual;
Line: 6077

        /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 6162

                                 aname      => 'REQ_UPDATE_URL' ,
                                 avalue     => l_update_req_url);
Line: 6195

       /* DEBUG */  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 6385

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 6473

     select POH.po_header_id, poh.currency_code
       into x_contract_id_valid, x_contract_currency_code
       from po_headers_all POH        -- : Use ALL table
      where
        POH.po_header_id = x_source_doc_po_header_id
        and POH.type_lookup_code = 'CONTRACT'
        and nvl(POH.cancel_flag,'N') = 'N'
        and TRUNC(sysdate) between nvl(TRUNC(start_date), sysdate - 1)
                           and     nvl(TRUNC(end_date), sysdate + 1)
        and POH.authorization_status = 'APPROVED'
        and nvl(POH.closed_code,'OPEN') = 'OPEN'
        AND NVL(POH.frozen_flag, 'N') = 'N'
        AND (NVL(POH.global_agreement_flag, 'N') = 'N'
             OR EXISTS (SELECT 1
                        FROM   po_ga_org_assignments PGOA,
                               po_system_parameters  PSP
                        WHERE  PGOA.po_header_id = POH.po_header_id
                        AND    PGOA.organization_id = PSP.org_id
                        AND    PGOA.vendor_site_id = l_vendor_site_id
                        AND    PGOA.enabled_flag = 'Y'));
Line: 6532

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 6555

           po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);
Line: 6626

    select count(*) into x_count
    from po_vendor_contacts
    where vendor_site_id = p_vendor_site_id
    and vendor_contact_id = p_vendor_contact_id
    and nvl(inactive_date, sysdate+1) > sysdate;
Line: 6649

    select max(vendor_contact_id)
    into x_contact_id
    from po_supplier_contacts_val_v
    where vendor_site_id = p_vendor_site_id
    and contact = p_contact_name;
Line: 6704

     select org_id
     into x_owning_org_id
     from po_headers_all
     where po_header_id = x_source_doc_po_header_id;
Line: 6721

        po_wf_debug_pkg.insert_debug(Itemtype,Itemkey,x_progress);
Line: 6742

         select 'Y'
         into   x_ref_is_valid
         from   po_headers_all poh
         where  poh.po_header_id = p_ga_po_header_id and
                nvl(poh.cancel_flag, 'N') = 'N' and
                nvl(poh.closed_code, 'OPEN')  <> 'FINALLY CLOSED';
Line: 6780

  SELECT 'Y'
  INTO   l_result
  FROM   po_buyers_val_v
  WHERE  employee_id = p_agent_id;
Line: 6886

            SELECT 'Y'
            INTO   l_return_status
            FROM   po_headers_all poh,
                   per_people_f ppf,
                   financials_system_parameters fsp
            WHERE  poh.agent_id = ppf.person_id
                   AND ppf.business_group_id = fsp.business_group_id
                   AND TRUNC(SYSDATE) BETWEEN ppf.effective_start_date
                                               AND NVL (ppf.effective_end_date, SYSDATE + 1)
            AND    poh.po_header_id = x_source_doc_po_header_id;
Line: 6918

      po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 6998

         SELECT 'Y'
         INTO   l_return_status
         FROM   po_headers_all poh,
                per_people_f ppf,
                financials_system_parameters fsp
         WHERE  poh.agent_id = ppf.person_id
                AND ppf.business_group_id = fsp.business_group_id
                AND TRUNC(SYSDATE) BETWEEN ppf.effective_start_date
                                              AND NVL(ppf.effective_end_date, SYSDATE + 1)
                AND poh.po_header_id = x_contract_id;
Line: 7035

     po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 7113

    po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 7240

      SELECT prl.destination_organization_id
      INTO l_dest_org_id
      FROM po_requisition_lines_all prl
      WHERE requisition_line_id = l_req_line_id;
Line: 7286

      po_wf_debug_pkg.insert_debug (itemtype, itemkey, x_progress);
Line: 7348

      SELECT org_id
      INTO l_purchasing_org_id
      FROM po_vendor_sites_all
      WHERE vendor_site_id = p_suggested_vendor_site_id;
Line: 7451

            po_wf_debug_pkg.insert_debug(itemtype,
                                         itemkey,
                                         l_progress);
Line: 7462

            po_wf_debug_pkg.insert_debug(itemtype,
                                         itemkey,
                                         l_progress);
Line: 7526

    DELETE FROM po_wf_candidate_req_lines_temp
    WHERE       requisition_line_id = (
                    SELECT requisition_line_id
                    FROM   po_requisition_lines
                    WHERE  labor_req_line_id = l_req_line_id);
Line: 7572

       po_wf_debug_pkg.insert_debug(itemtype,itemkey,x_progress);