DBA Data[Home] [Help]

APPS.PO_COMMUNICATION_PVT SQL Statements

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

Line: 192

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 218

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 284

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 295

      PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 315

  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 342

  PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 363

        PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 370

PROCEDURE DELETE_PDF_ATTACHMENTS  (itemtype IN VARCHAR2,
                                           itemkey  IN VARCHAR2,
                                           actid    IN NUMBER,
                                           funcmode IN VARCHAR2,
                                           resultout   OUT NOCOPY VARCHAR2) is
   l_document_id       number;
Line: 385

 x_progress := 'PO_COMMUNICATION_PVT.DELETE_PDF_ATTACHMENTS';
Line: 388

      PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 423

x_progress := 'PO_COMMUNICATION_PVT.DELETE_PDF_ATTACHMENTS :Calling the Delete attachments procedure';
Line: 426

      PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 429

FND_ATTACHED_DOCUMENTS2_PKG.delete_attachments(X_entity_name => l_entity_name,
                                             X_pk1_value    =>to_char(l_document_id),
                                             X_pk2_value    =>to_char(l_revision_num),
                                             X_pk3_value    =>null,
                                             X_pk4_value    =>null,
                                             X_pk5_value    =>null,
                                             X_delete_document_flag=>'Y',
                                             X_automatically_added_flag=>'N');
Line: 448

  x_progress :=  'PO_COMMUNICATION_PVT.DELETE_PDF_ATTACHMENTS:In Exception handler';
Line: 450

          PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 452

  wf_core.context('PO_COMMUNICATION_PVT','DELETE_PDF_ATTACHMENTS',x_progress);
Line: 456

END DELETE_PDF_ATTACHMENTS;
Line: 481

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

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

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

SELECT count(*) into l_count from fnd_lobs fl,fnd_attached_docs_form_vl fad
WHERE
fl.file_id = fad.media_id and
fad.pk2_value=to_char(l_document_id) and
fad.pk3_value=to_char(l_revision_num) and
fl.file_name =l_filename and
fad.entity_name in ('PO_HEAD', 'PO_REL');
Line: 554

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

SELECT count(*) into l_count from fnd_lobs fl,fnd_attached_docs_form_vl fad
WHERE
fl.file_id = fad.media_id and
fad.pk1_value=to_char(l_document_id) and
fad.pk2_value=to_char(l_revision_num) and
fl.file_name =l_filename and
fad.entity_name IN ('PO_HEAD', 'PO_REL');
Line: 589

              PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 640

select to_char (PO_WF_ITEMKEY_S.NEXTVAL) into l_seq_for_item_key from sys.dual;
Line: 650

 PO_WF_DEBUG_PKG.insert_debug (l_itemtype, l_itemkey,l_progress);
Line: 707

      SELECT hou.name
      into   l_operating_unit
      FROM
             hr_organization_units hou
      WHERE
             hou.organization_id = l_orgid;
Line: 731

select po_header_id,release_num  into l_document_id,l_release_num
from po_releases_all
where
po_release_id=p_document_id;
Line: 739

select segment1,global_agreement_flag into l_docNumber,l_ga_flag
from po_headers_all
where po_header_id = l_document_id;
Line: 749

select DECODE(p_document_subtype,'BLANKET',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_BLKT'),
        'CONTRACT',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_CNTR'),
        'STANDARD',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_STD'),
        'PLANNED',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_PLND')) into l_doc_display_name from dual;
Line: 787

 PO_WF_DEBUG_PKG.insert_debug (l_itemtype, l_itemkey,l_progress);
Line: 791

        select poh.vendor_site_id, pvs.vendor_site_code, pvs.language
        into l_vendor_site_id, l_vendor_site_code, l_vendor_site_lang
        from po_headers poh, po_vendor_sites pvs, po_releases por
        where pvs.vendor_site_id = poh.vendor_site_id
        and poh.po_header_id = por.po_header_id
        and por.po_release_id =  p_document_id;
Line: 798

        select poh.vendor_site_id, pvs.vendor_site_code, pvs.language
        into l_vendor_site_id, l_vendor_site_code, l_vendor_site_lang
        from po_headers poh, po_vendor_sites pvs
        where pvs.vendor_site_id = poh.vendor_site_id
        and poh.po_header_id =  p_document_id;
Line: 807

 SELECT wfl.nls_language, wfl.nls_territory INTO l_adhocuser_lang, l_adhocuser_territory
 FROM wf_languages wfl, fnd_languages_vl flv
 WHERE wfl.code = flv.language_code AND flv.nls_language = l_vendor_site_lang;
Line: 813

 SELECT wfl.nls_language, wfl.nls_territory into l_adhocuser_lang, l_adhocuser_territory
 FROM wf_languages wfl, fnd_languages_vl flv
 WHERE wfl.code = flv.language_code AND flv.installed_flag = 'B';
Line: 826

 PO_WF_DEBUG_PKG.insert_debug (l_itemtype, l_itemkey,l_progress);
Line: 830

select count(1) into l_performer_exists
from wf_users where name = l_po_email_performer;
Line: 855

PO_REQAPPROVAL_INIT1.update_print_count(p_document_id,p_document_type);
Line: 904

 PO_WF_DEBUG_PKG.insert_debug (l_itemtype, l_itemkey,l_progress);
Line: 916

   PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,l_progress);
Line: 955

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 994

   SELECT pv.language
   INTO   l_supp_lang
   FROM po_vendor_sites_all pv,
        po_headers_all ph
   WHERE  ph.po_header_id = l_header_id
   AND ph.vendor_site_id = pv.vendor_site_id;
Line: 1005

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1011

	SELECT nls_language
	INTO l_language
	FROM fnd_languages
	WHERE language_code = l_language_code;
Line: 1018

     SELECT nls_territory
     INTO l_territory
     FROM fnd_languages
     WHERE nls_language = l_supp_lang;
Line: 1088

    PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1101

    	 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 1143

       select fl.file_name,dbms_lob.getlength(fl.file_data)
       from   fnd_documents d,
              fnd_attached_documents ad,
              fnd_doc_category_usages dcu,
              fnd_attachment_functions af,
              fnd_lobs fl
       where ((ad.pk1_value=to_char(l_po_header_id) and ad.entity_name='PO_HEADERS')
              OR
              (ad.pk1_value=to_char((select vendor_id from po_headers_all
                              where po_header_id=l_po_header_id)) and ad.entity_name='PO_VENDORS')
              OR
              (ad.pk1_value in (select po_line_id from po_lines_all
                                 where po_header_id=l_po_header_id
                                ) and ad.entity_name='PO_LINES')
              OR
              (ad.pk1_value in (select from_header_id from po_lines_all
                                 where po_header_id=l_po_header_id
                                 and from_header_id is not null
                                ) and ad.entity_name='PO_HEADERS')
              OR
              (ad.pk1_value in (select from_line_id from po_lines_all
                                 where po_header_id=l_po_header_id
                                 and from_line_id is not null
                                ) and ad.entity_name='PO_LINES')
              OR
              (ad.pk1_value in (select line_location_id from po_line_locations_all
                                 where po_header_id=l_po_header_id
                                 and shipment_type in ('PRICE BREAK','STANDARD', 'PREPAYMENT')  -- 
                                ) and ad.entity_name='PO_SHIPMENTS')
              OR
              (ad.pk2_value in (select item_id from po_lines_all
                                 where po_header_id=l_po_header_id
                                 and to_char(PO_COMMUNICATION_PVT.getInventoryOrgId())=ad.pk1_value --Bug 4673653 Use Inventory OrgId
                                 and item_id is not null
                                ) and ad.entity_name='MTL_SYSTEM_ITEMS')
             )
       and d.document_id = ad.document_id
       and dcu.category_id = d.category_id
       and dcu.attachment_function_id = af.attachment_function_id
       and d.datatype_id=6
       and af.function_name='PO_PRINTPO'
       and d.media_id=fl.file_id
       and dcu.enabled_flag = 'Y'
       group by fl.file_name,dbms_lob.getlength(fl.file_data)
       order by fl.file_name;
Line: 1192

       select fl.file_name,dbms_lob.getlength(fl.file_data)
       from   fnd_documents d,
              fnd_attached_documents ad,
              fnd_doc_category_usages dcu,
              fnd_attachment_functions af,
              fnd_lobs fl
       where ((ad.pk1_value=to_char((select po_header_id from po_releases_all
                              where po_release_id=l_po_release_id
                             )) and ad.entity_name='PO_HEADERS')
              OR
              (ad.pk1_value=to_char(l_po_release_id) and ad.entity_name='PO_RELEASES')
              OR
              (ad.pk1_value=to_char((select pha.vendor_id
                              from po_headers_all pha,po_releases_all pra
                              where pra.po_release_id=l_po_release_id
                              and pha.po_header_id=pra.po_header_id
                             )) and ad.entity_name='PO_VENDORS')
              OR
              (ad.pk1_value in (select po_line_id from po_line_locations_all
                                 where po_release_id=l_po_release_id
                                 and shipment_type='BLANKET'
                                ) and ad.entity_name='PO_LINES')
              OR
              (ad.pk1_value in (select line_location_id from po_line_locations_all
                                 where po_release_id=l_po_release_id
                                 and shipment_type='BLANKET'
                                ) and ad.entity_name='PO_SHIPMENTS')
              OR
              (ad.pk2_value in (select pl.item_id
                                 from po_lines_all pl, po_line_locations_all pll
                                 where pll.po_release_id=l_po_release_id
                                 and pll.shipment_type='BLANKET'
                                 and pll.po_line_id=pl.po_line_id
                                 and to_char(PO_COMMUNICATION_PVT.getInventoryOrgId())=ad.pk1_value --Bug 4673653 Use Inventory OrgId
                                 and pl.item_id is not null
                                ) AND ad.entity_name='MTL_SYSTEM_ITEMS')
             )
       and d.document_id = ad.document_id
       and dcu.category_id = d.category_id
       and dcu.attachment_function_id = af.attachment_function_id
       and d.datatype_id=6
       and af.function_name='PO_PRINTPO'
       and d.media_id=fl.file_id
       and dcu.enabled_flag = 'Y'
       group by fl.file_name,dbms_lob.getlength(fl.file_data)
       order by fl.file_name;
Line: 1244

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1309

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1345

                    PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1377

                        select 'Y' into l_duplicate_filenames from dual
                        where exists
                        (
                            select fl.file_name
                            from fnd_documents d,
                                 fnd_attached_documents ad,
                                 fnd_doc_category_usages dcu,
                                 fnd_attachment_functions af,
                                 fnd_lobs fl
                            where ((ad.pk1_value=to_char((select po_header_id from po_releases_all
                                                   where po_release_id=l_document_id
                                                  )) and ad.entity_name='PO_HEADERS')
                                   OR
                                   (ad.pk1_value=to_char(l_document_id) and ad.entity_name='PO_RELEASES')
                                   OR
                                   (ad.pk1_value=(select pha.vendor_id
                                                   from po_headers_all pha,po_releases_all pra
                                                   where pra.po_release_id=l_document_id
                                                   and pha.po_header_id=pra.po_header_id
                                                  ) and ad.entity_name='PO_VENDORS')
                                   OR
                                   (ad.pk1_value in (select po_line_id from po_line_locations_all
                                                      where po_release_id=l_document_id
                                                      and shipment_type='BLANKET'
                                                     ) and ad.entity_name='PO_LINES')
                                   OR
                                   (ad.pk1_value in (select line_location_id from po_line_locations_all
                                                      where po_release_id=l_document_id
                                                      and shipment_type='BLANKET'
                                                     ) and ad.entity_name='PO_SHIPMENTS')
                                   OR
                                   (ad.pk2_value in (select pl.item_id
                                                      from po_lines_all pl, po_line_locations_all pll
                                                      where pll.po_release_id=l_document_id
                                                      and pll.shipment_type='BLANKET'
                                                      and pll.po_line_id=pl.po_line_id
                                                      and to_char(PO_COMMUNICATION_PVT.getInventoryOrgId())=ad.pk1_value --Bug 4673653 Use Inventory OrgId
                                                      and pl.item_id is not null
                                                     ) AND ad.entity_name='MTL_SYSTEM_ITEMS')
                                  )
                            and d.document_id = ad.document_id
                            and dcu.category_id = d.category_id
                            and dcu.attachment_function_id = af.attachment_function_id
                            and d.datatype_id=6
                            and af.function_name='PO_PRINTPO'
                            and d.media_id=fl.file_id
                            and dcu.enabled_flag = 'Y'
                            group by fl.file_name
                            having count(*)>1
                        );
Line: 1433

                            PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1440

                        select 'Y' into l_duplicate_filenames from dual
                        where exists
                        (
                            select fl.file_name
                            from fnd_documents d,
                                 fnd_attached_documents ad,
                                 fnd_doc_category_usages dcu,
                                 fnd_attachment_functions af,
                                 fnd_lobs fl
                            where ((ad.pk1_value=to_char(l_document_id) and ad.entity_name='PO_HEADERS')
                                   OR
                                   (ad.pk1_value=to_char((select vendor_id from po_headers_all
                                                   where po_header_id=l_document_id)) and ad.entity_name='PO_VENDORS')
                                   OR
                                   (ad.pk1_value in (select po_line_id from po_lines_all
                                                      where po_header_id=l_document_id
                                                     ) and ad.entity_name='PO_LINES')
                                   OR
                                   (ad.pk1_value in (select from_header_id from po_lines_all
                                                      where po_header_id=l_document_id
                                                      and from_header_id is not null
                                                     ) and ad.entity_name='PO_HEADERS')
                                   OR
                                   (ad.pk1_value in (select from_line_id from po_lines_all
                                                      where po_header_id=l_document_id
                                                      and from_line_id is not null
                                                     ) and ad.entity_name='PO_LINES')
                                   OR
                                   (ad.pk1_value in (select line_location_id from po_line_locations_all
                                                      where po_header_id=l_document_id
                                                      and shipment_type in ('PRICE BREAK','STANDARD','PREPAYMENT')  -- 
                                                     ) and ad.entity_name='PO_SHIPMENTS')
                                   OR
                                   (ad.pk2_value in (select item_id from po_lines_all
                                                      where po_header_id=l_document_id
                                                      and to_char(PO_COMMUNICATION_PVT.getInventoryOrgId())=ad.pk1_value --Bug 4673653 Use Inventory OrgId
                                                      and item_id is not null
                                                     ) and ad.entity_name='MTL_SYSTEM_ITEMS')
                                  )
                            and d.document_id = ad.document_id
                            and dcu.category_id = d.category_id
                            and dcu.attachment_function_id = af.attachment_function_id
                            and d.datatype_id=6
                            and af.function_name='PO_PRINTPO'
                            and d.media_id=fl.file_id
                            and dcu.enabled_flag = 'Y'
                            group by fl.file_name
                            having count(*)>1
                        );
Line: 1495

                            PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1510

                        PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 1536

                        PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 1548

            PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1549

            PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,'PO_COMMUNICATION_PVT.generate_pdf_buyer: Caught Zip generation exception '||SQLERRM);
Line: 1613

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,l_progress);
Line: 1626

     PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Line: 1662

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1700

SELECT po_header_id into l_header_id FROM po_releases_all
WHERE  po_release_id = l_document_id;
Line: 1704

 SELECT pv.language into l_supp_lang
 FROM po_vendor_sites_all pv,po_headers_all ph
 WHERE
 ph.po_header_id = l_header_id and ph.vendor_site_id = pv.vendor_site_id;
Line: 1713

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1718

	SELECT nls_language INTO l_language
	FROM fnd_languages
	WHERE language_code = l_language_code;
Line: 1725

   select nls_territory into l_territory  from fnd_languages where
   nls_language = l_supp_lang;
Line: 1789

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1807

       PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 1836

 PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1845

 select nls_territory into l_territory  from fnd_languages where
 language_code = l_language_code;
Line: 1872

   PO_WF_DEBUG_PKG.INSERT_DEBUG(ITEMTYPE, ITEMKEY,x_progress);
Line: 1879

 select nls_language,nls_territory into l_language , l_territory  from fnd_languages where
 language_code = l_language_code;
Line: 1949

         PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
Line: 2233

 * Modified the SQLs used for selecting from PO and OKC Repository
 * Now selecting release revision number from po_release_archives_all
 */
procedure   Communicate(p_authorization_status in varchar2,
                        p_with_terms in varchar2,
                        p_language_code in varchar2,
                        p_mode     in varchar2,
                        p_document_id in number ,
                        p_revision_number in number,
                        p_document_type in varchar2,
                        p_fax_number in varchar2,
                        p_email_address in varchar2,
                        p_request_id out nocopy number)
IS

l_conterm_exists_flag        po_headers_all.CONTERMS_EXIST_FLAG%type;
Line: 2322

      select pvs.language into l_supp_lang from po_vendor_sites pvs , po_headers_all ph
        where po_header_id = p_document_id and ph.vendor_site_id = pvs.vendor_site_id ;
Line: 2326

      select pvs.language into l_supp_lang from po_vendor_sites pvs , po_headers_all ph,po_releases_all pr
        where  ph.po_header_id = pr.po_header_id and pr.po_release_id = p_document_id and
                 ph.vendor_site_id = pvs.vendor_site_id ;
Line: 2346

    select language_code,nls_territory into l_language_code,l_territory  from fnd_languages fl where
      fl.nls_language =  l_supp_lang;
Line: 2352

    select NVL(conterms_exist_flag, 'N') into l_conterm_exists_flag from po_headers_all
    where
      po_header_id = p_document_id and revision_num = p_revision_number;
Line: 2377

      select count(1) into l_pdf_tc_buyer_exists from fnd_lobs fl,fnd_attached_documents fad, fnd_documents_vl fdl
      where
        fad.pk2_value = TO_CHAR(p_document_id) and
        fad.pk3_value = TO_CHAR(l_revision_num) and
        fad.entity_name = 'OKC_CONTRACT_DOCS' and
        fdl.document_id = fad.document_id and
        fdl.media_id = fl.file_id and
        fl.file_name = l_pdf_file_name;
Line: 2404

             select count(1) into l_pdf_tc_sup_exists from fnd_lobs fl,fnd_attached_documents fad, fnd_documents fd, fnd_documents_tl fdl
             where
             fad.pk1_value = TO_CHAR(p_document_id) and
             fad.pk2_value = TO_CHAR(l_revision_num) and
             fad.entity_name = l_entity_name and
             fdl.document_id = fad.document_id and
             fd.media_id = fl.file_id and
             fd.document_id  = fdl.document_id and
             fdl.language = l_language_code and
             fl.file_name = l_pdf_file_name;
Line: 2437

    select count(1) into l_pdf_nt_buyer_exists from fnd_lobs fl,fnd_attached_documents fad, fnd_documents_vl fdl
    where
      fad.pk1_value = TO_CHAR(p_document_id) and
      fad.pk2_value = TO_CHAR(l_revision_num) and
      fad.entity_name = l_entity_name and
      fdl.document_id = fad.document_id and
      fdl.media_id = fl.file_id and
      fl.file_name =  l_pdf_file_name;
Line: 2464

      select count(1) into l_pdf_nt_sup_exists from fnd_lobs fl,fnd_attached_documents fad, fnd_documents fd, fnd_documents_tl fdl
      where
        fad.pk1_value = TO_CHAR(p_document_id) and
        fad.pk2_value = TO_CHAR(l_revision_num) and
        fad.entity_name = l_entity_name and
        fdl.document_id = fad.document_id and
        fd.media_id = fl.file_id and
        fd.document_id = fdl.document_id and
        fdl.language = l_language_code and
        fl.file_name = l_pdf_file_name;
Line: 2482

          select max(revision_num)
          into l_revision_num
          from po_headers_archive_all
          where po_header_id = p_document_id
          and authorization_status = 'APPROVED';
Line: 2488

          select max(revision_num)
          into l_revision_num
          from po_releases_archive_all
          where po_release_id = p_document_id
          and authorization_status = 'APPROVED';
Line: 2551

      select nls_language,nls_territory into l_supp_lang,l_territory  from fnd_languages fl where
        fl.language_code = p_language_code ;
Line: 2590

      select nls_language,nls_territory into l_supp_lang,l_territory  from fnd_languages fl where
        fl.language_code = p_language_code ;
Line: 2678

    select nls_language,nls_territory into l_supp_lang,l_territory  from fnd_languages fl where
      fl.language_code = l_buyer_language_code;
Line: 2700

    select nls_language,nls_territory into l_supp_lang,l_territory  from fnd_languages fl where
      fl.language_code = l_buyer_language_code;
Line: 2722

      select pvs.language into l_supp_lang from po_vendor_sites pvs , po_headers_all ph
        where po_header_id = p_document_id and ph.vendor_site_id = pvs.vendor_site_id ;
Line: 2725

      select pvs.language into l_supp_lang from po_vendor_sites pvs , po_headers_all ph,po_releases_all pr
        where  ph.po_header_id = pr.po_header_id and pr.po_release_id = p_document_id and
                 ph.vendor_site_id = pvs.vendor_site_id ;
Line: 2734

      select language_code,nls_territory into l_language_code,l_territory  from fnd_languages fl where
        fl.nls_language =  l_supp_lang;
Line: 2760

      select language_code,nls_territory into l_language_code,l_territory  from fnd_languages fl where
        fl.nls_language =  l_supp_lang;
Line: 2804

select po_output_format into l_format from po_system_parameters;
Line: 2910

            SELECT fdl.media_id
            INTO x_media_id
            FROM fnd_attached_documents fad,
                 fnd_documents_vl  fdl
            WHERE fad.pk1_value=to_char(p_document_id)
            and fad.pk2_value=to_char(p_revision_number)
            and fad.entity_name = l_entity_name
            and fdl.document_id = fad.document_id;
Line: 2937

SELECT category_id into l_category_id from fnd_document_categories
where  name   = 'CUSTOM2446' ;
Line: 2941

        FND_DOCUMENTS_PKG.Insert_Row(
        row_id_tmp,
        document_id_tmp,
        SYSDATE,
        1,              --NVL(X_created_by,0),
        SYSDATE,
        1,             --NVL(X_created_by,0),
        1,              --X_last_update_login,
        6,
        l_category_id, --Get the value for the category id 'PO Documents'
        1,--null,--security_type,
        null,--security_id,
        'Y',--null,--publish_flag,
        null,--image_type,
        null,--storage_type,
        'O',--usage_type,
        sysdate,--start_date_active,
        null,--end_date_active,
        null,--X_request_id, --null
        null,--X_program_application_id, --null
        null,--X_program_id,--null
        SYSDATE,
        null,--language,
        null,--description,
        l_file_name,
        x_media_id);
Line: 2970

       INSERT INTO fnd_lobs (
          file_id,
          File_name,
          file_content_type,
          upload_date,
          expiration_date,
          program_name,
          program_tag,
          file_data,
          language,
          oracle_charset,
          file_format)
          VALUES
           (x_media_id,
          l_file_name, -- Changed p_file_name to l_file_name
          l_file_content_type, -- Changed hardcoded value to l_file_content_type
          sysdate,
          null,
          null,
          null,
          l_blob_data,
          null,
          null,
                'binary');
Line: 2997

        INSERT INTO fnd_attached_documents (attached_document_id,
        document_id,
        creation_date,
         created_by,
         last_update_date,
        last_updated_by,
          last_update_login,
        seq_num,
         entity_name,
        pk1_value,
         pk2_value,
        pk3_value,
        pk4_value,
         pk5_value,
        automatically_added_flag,
        program_application_id,
         program_id,
         program_update_date,
        request_id,
        attribute_category,
         attribute1,
        attribute2,
        attribute3,
        attribute4,
        attribute5,
        attribute6,
        attribute7,
        attribute8,
         attribute9,
         attribute10,
        attribute11,
        attribute12,
         attribute13,
        attribute14,
         attribute15,
         column1)
        VALUES
         (fnd_attached_documents_s.nextval,
        document_id_tmp,
        sysdate,
        1,--NVL(X_created_by,0),
        sysdate,
        1,--NVL(X_created_by,0),
        null,-- X_last_update_login,
        10,
         l_entity_name,
         to_char(p_document_id),
         to_char(p_revision_number),
         null,
         null,
         null,
         'N',
        null,
        null,
        sysdate,
        null,
        null,
        null,
        null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null);
Line: 3114

   PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3167

SELECT file_data into l_document
FROM fnd_lobs fl,
     fnd_attached_documents fad,
     fnd_documents fd,
     fnd_documents_tl fdl
WHERE fad.pk1_value=to_char(l_document_id)  and fad.pk2_value=to_char(l_revision_number)
and fdl.document_id = fad.document_id and fdl.document_id = fd.document_id and fd.media_id = fl.file_id
and fad.entity_name = l_entity_name and fdl.language=l_language
and fl.file_name = l_filename ;
Line: 3189

   PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3230

        PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3266

        SELECT file_data into l_document
        FROM fnd_lobs fl,
             fnd_attached_documents fad,
             fnd_documents fd,
             fnd_documents_tl  fdl
        WHERE fad.pk2_value=to_char(l_document_id)  and fad.pk3_value=to_char(l_revision_number)
        and fdl.document_id = fad.document_id and fdl.document_id = fd.document_id and fd.media_id = fl.file_id
        and fad.entity_name = 'OKC_CONTRACT_DOCS' and fdl.language=l_language
        and fl.file_name = l_filename;   -- Bug 4047688
Line: 3284

        SELECT file_data into l_document
        FROM fnd_lobs fl,
             fnd_attached_documents fad,
             fnd_documents fd,
             fnd_documents_tl  fdl
        WHERE fad.pk1_value=to_char(l_document_id)  and fad.pk2_value=to_char(l_revision_number)
        and fdl.document_id = fad.document_id and fd.media_id = fl.file_id
        and fd.document_id = fdl.document_id
        and fad.entity_name = l_entity_name and fl.file_name = l_filename and fdl.language=l_language;
Line: 3304

        PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3344

   PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3386

            select fl.language_code into l_language
            from po_vendor_sites_all pvs,po_headers_all ph,fnd_languages fl
            where ph.vendor_site_id = pvs.vendor_site_id
            and ph.po_header_id = l_document_id
            and pvs.language = fl.nls_language;
Line: 3392

            select fl.language_code into l_language
            from po_vendor_sites_all pvs , po_headers_all ph,
                 po_releases_all pr, fnd_languages fl
            where ph.po_header_id = pr.po_header_id
            and pr.po_release_id = l_document_id
            and ph.vendor_site_id = pvs.vendor_site_id
            and pvs.language = fl.nls_language;
Line: 3421

SELECT file_data into l_document
FROM fnd_lobs fl,
     fnd_attached_documents fad,
     fnd_documents_vl  fdl
WHERE fad.pk2_value=to_char(l_document_id)  and fad.pk3_value=to_char(l_revision_number)
and fdl.document_id = fad.document_id and fdl.media_id = fl.file_id and fad.entity_name = 'OKC_CONTRACT_DOCS'
and fl.file_name = l_filename; --Bug 4047688
Line: 3446

SELECT file_data into l_document
FROM fnd_lobs fl,
     fnd_attached_documents fad,
     fnd_documents fd,
    fnd_documents_tl  fdl
WHERE fad.pk1_value=to_char(l_document_id)  and fad.pk2_value=to_char(l_revision_number)
and fdl.document_id = fad.document_id and fd.media_id = fl.file_id and fd.document_id = fdl.document_id
and fad.entity_name = l_entity_name and fl.file_name = l_filename and fdl.language=l_language;
Line: 3469

   PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3537

    PO_WF_DEBUG_PKG.insert_debug(l_itemtype, l_itemkey, x_progress);
Line: 3578

    PO_WF_DEBUG_PKG.insert_debug(l_itemtype, l_itemkey, x_progress);
Line: 3594

    PO_WF_DEBUG_PKG.insert_debug(l_itemtype, l_itemkey, x_progress);
Line: 3603

    SELECT fl.file_name, fl.file_content_type, fl.file_data
    INTO l_okc_file_name, l_okc_file_content_type, l_okc_file_data
    FROM fnd_lobs fl
    WHERE fl.file_id = l_okc_file_id;
Line: 3624

    PO_WF_DEBUG_PKG.insert_debug(l_itemtype, l_itemkey, x_progress);
Line: 3634

       PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,x_progress);
Line: 3704

        PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,l_progress);
Line: 3747

        SELECT fl.file_data,fl.file_content_type
        INTO l_document,l_filecontent_type
        FROM fnd_lobs fl,
             fnd_attached_documents fad,
             fnd_documents fd,
             fnd_documents_tl  fdl
        WHERE fad.pk1_value=to_char(l_document_id)
        and fad.pk2_value=to_char(l_revision_number)
        and fad.entity_name = l_entity_name
        and fdl.document_id = fad.document_id
        and fdl.document_id = fd.document_id
        and fdl.language = l_language
        --Bug 5017976 selecting media_id from fd instead of fdl
        and fd.media_id = fl.file_id
        and fl.file_name = l_filename;
Line: 3782

            PO_WF_DEBUG_PKG.INSERT_DEBUG(l_itemtype, l_itemkey,l_progress||' '||SQLERRM);
Line: 3913

        PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_progress);
Line: 3915

    select nvl(psp.max_attachment_size,0)
    into l_max_attachment_size
    from po_system_parameters psp;
Line: 3920

        PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_progress);
Line: 3927

            PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_progress);
Line: 3970

        select 'Y' into l_attachments_exist from dual
        where exists
        (
            select fl.file_name
            from   fnd_documents d,
                   fnd_attached_documents ad,
                   fnd_doc_category_usages dcu,
                   fnd_attachment_functions af,
                   fnd_lobs fl
            where ((ad.pk1_value=to_char((select po_header_id from po_releases_all
                                   where po_release_id=p_document_id
                                  )) and ad.entity_name='PO_HEADERS')
                   OR
                   (ad.pk1_value=to_char(p_document_id) and ad.entity_name='PO_RELEASES')
                   OR
                   (ad.pk1_value=to_char((select pha.vendor_id
                                   from po_headers_all pha,po_releases_all pra
                                   where pra.po_release_id=p_document_id
                                   and pha.po_header_id=pra.po_header_id
                                  )) and ad.entity_name='PO_VENDORS')
                   OR
                   (ad.pk1_value in (select po_line_id from po_line_locations_all
                                      where po_release_id=p_document_id
                                      and shipment_type='BLANKET'
                                     ) and ad.entity_name='PO_LINES')
                   OR
                   (ad.pk1_value in (select line_location_id from po_line_locations_all
                                      where po_release_id=p_document_id
                                      and shipment_type='BLANKET'
                                     ) and ad.entity_name='PO_SHIPMENTS')
                   OR
                   (ad.pk2_value in (select pl.item_id
                                      from po_lines_all pl, po_line_locations_all pll
                                      where pll.po_release_id=p_document_id
                                      and pll.shipment_type='BLANKET'
                                      and pll.po_line_id=pl.po_line_id
                                      and to_char(PO_COMMUNICATION_PVT.getInventoryOrgId())=ad.pk1_value --Bug 4673653 Use Inventory OrgId
                                      and pl.item_id is not null
                                     ) AND ad.entity_name='MTL_SYSTEM_ITEMS')
                  )
            and d.document_id = ad.document_id
            and dcu.category_id = d.category_id
            and dcu.attachment_function_id = af.attachment_function_id
            and d.datatype_id=6
            and af.function_name='PO_PRINTPO'
            and d.media_id=fl.file_id
            and dcu.enabled_flag = 'Y'
        );
Line: 4023

        select 'Y' into l_attachments_exist from dual
        where exists
        (
            select fl.file_name
            from fnd_documents d,
                 fnd_attached_documents ad,
                 fnd_doc_category_usages dcu,
                 fnd_attachment_functions af,
                 fnd_lobs fl
            where ((ad.pk1_value=to_char(p_document_id) and ad.entity_name='PO_HEADERS')
                   OR
                   (ad.pk1_value=to_char((select vendor_id from po_headers_all
                                   where po_header_id=p_document_id)) and ad.entity_name='PO_VENDORS')
                   OR
                   (ad.pk1_value in (select po_line_id from po_lines_all
                                      where po_header_id=p_document_id
                                     ) and ad.entity_name='PO_LINES')
                   OR
                   (ad.pk1_value in (select from_header_id from po_lines_all
                                      where po_header_id=p_document_id
                                      and from_header_id is not null
                                     ) and ad.entity_name='PO_HEADERS')
                   OR
                   (ad.pk1_value in (select from_line_id from po_lines_all
                                      where po_header_id=p_document_id
                                      and from_line_id is not null
                                     ) and ad.entity_name='PO_LINES')
                   OR
                   (ad.pk1_value in (select line_location_id from po_line_locations_all
                                      where po_header_id=p_document_id
                                      and shipment_type in ('PRICE BREAK','STANDARD','PREPAYMENT')  -- 
                                     ) and ad.entity_name='PO_SHIPMENTS')
                   OR
                   (ad.pk2_value in (select item_id from po_lines_all
                                      where po_header_id=p_document_id
                                      and to_char(PO_COMMUNICATION_PVT.getInventoryOrgId())=ad.pk1_value --Bug 4673653 Use Inventory OrgId
                                      and item_id is not null
                                     ) and ad.entity_name='MTL_SYSTEM_ITEMS')
                  )
            and d.document_id = ad.document_id
            and dcu.category_id = d.category_id
            and dcu.attachment_function_id = af.attachment_function_id
            and d.datatype_id=6
            and af.function_name='PO_PRINTPO'
            and d.media_id=fl.file_id
            and dcu.enabled_flag = 'Y'
        );
Line: 4196

SELECT TYPE_NAME into PO_COMMUNICATION_PVT.g_documentType FROM PO_DOCUMENT_TYPES_TL
WHERE document_type_code = p_document_type and document_subtype = p_document_subtype and language = USERENV('LANG');
Line: 4224

  /* SELECT hle.name, vn.vendor_name, ph.segment1, ph.change_summary, ph.vendor_id, ph.currency_code
	INTO po_communication_pvt.g_buyer_org, l_supp_org, l_po_number, l_change_summary, l_vendor_id, g_current_currency_code
    FROM hr_all_organization_units hle,  po_vendors vn, po_headers_all ph
    WHERE to_char(hle.organization_id) =  (select org_information2 from hr_organization_information where
    org_information_context = 'Operating Unit Information'  and organization_id = ph.org_id) AND vn.vendor_id = ph.vendor_id
    AND ph.po_header_id = p_document_id AND ph.revision_num = p_revision_num; */
Line: 4231

    SELECT vn.vendor_name, ph.segment1, ph.change_summary, ph.vendor_id, ph.currency_code
	INTO  l_supp_org, l_po_number, l_change_summary, l_vendor_id, g_current_currency_code
    FROM  po_vendors vn, po_headers_all ph
    WHERE vn.vendor_id = ph.vendor_id
    AND ph.po_header_id = p_document_id AND ph.revision_num = p_revision_num;
Line: 4238

    SELECT count(distinct(plla.SHIP_TO_LOCATION_ID)) INTO PO_COMMUNICATION_PVT.g_dist_shipto_count
    FROM po_line_locations_all plla
    WHERE plla.po_header_id = p_document_id
    AND NVL(plla.payment_type, 'NONE') NOT IN ('ADVANCE', 'DELIVERY');  -- 
Line: 4248

    SELECT vn.vendor_name, ph.segment1, ph.change_summary, ph.vendor_id, ph.currency_code
	INTO  l_supp_org, l_po_number, l_change_summary, l_vendor_id, g_current_currency_code
    FROM  po_vendors vn, po_headers_archive_all ph
    WHERE  vn.vendor_id = ph.vendor_id
    AND ph.po_header_id = p_document_id AND ph.revision_num = p_revision_num;
Line: 4254

    SELECT count(distinct(plla.SHIP_TO_LOCATION_ID)) INTO PO_COMMUNICATION_PVT.g_dist_shipto_count
    FROM po_line_locations_archive_all plla
    WHERE plla.po_header_id = p_document_id
    and plla.revision_num = p_revision_num
    AND NVL(plla.payment_type, 'NONE') NOT IN ('ADVANCE', 'DELIVERY');  -- 
Line: 4264

     select org_id into l_org_id from po_headers_all where po_header_id= p_document_id ;
Line: 4288

        insert into  PO_COMMUNICATION_GT(po_header_id, po_release_id, revision_number, format_mask)
                      values(p_document_id, null, p_revision_num, PO_COMMUNICATION_PVT.getFormatMask);
Line: 4295

    SELECT po_header_id INTO PO_COMMUNICATION_PVT.g_release_header_id FROM po_releases_all WHERE po_release_id = p_document_id;
Line: 4297

    SELECT  ph.vendor_id, ph.currency_code INTO l_vendor_id, g_current_currency_code
    FROM po_vendors vn, po_headers_all ph
    WHERE  vn.vendor_id = ph.vendor_id
    AND ph.po_header_id = PO_COMMUNICATION_PVT.g_release_header_id ;
Line: 4303

      SELECT count(distinct(plla.SHIP_TO_LOCATION_ID)) INTO PO_COMMUNICATION_PVT.g_dist_shipto_count
      FROM po_line_locations_all plla
      WHERE plla.po_release_id = p_document_id;
Line: 4308

      SELECT count(distinct(plla.SHIP_TO_LOCATION_ID)) INTO PO_COMMUNICATION_PVT.g_dist_shipto_count
      FROM po_line_locations_archive_all plla
      WHERE plla.po_release_id = p_document_id
      and plla.revision_num  = p_revision_num;
Line: 4318

        insert into  PO_COMMUNICATION_GT(po_header_id, po_release_id, revision_number, format_mask)
                            values(null, p_document_id, p_revision_num, PO_COMMUNICATION_PVT.getFormatMask);
Line: 4441

     SELECT name, gmt_deviation_hours into l_timezone, l_offset from HZ_TIMEZONES_VL where timezone_id=to_number(l_timezone_id);
Line: 4486

l_head_short_attachment_query := 'CURSOR( SELECT fds.short_text
				  FROM
					fnd_attached_docs_form_vl fad,
					fnd_documents_short_text fds
				 WHERE  ((entity_name=''PO_HEADERS'' AND
					  pk1_value=to_char(phx.po_header_id))OR
					(entity_name = ''PO_RELEASES'' AND
					pk1_value = to_char(phx.po_release_id)) OR
					(entity_name = ''PO_VENDORS'' AND
				        pk1_value = to_char(phx.vendor_id))  OR
                                        (entity_name = ''PO_VENDOR_SITES'' AND
                                        pk1_value = to_char(phx.vendor_site_id))) AND  -- bug6154354
				        function_name = ''PO_PRINTPO''
				        AND fad.media_id = fds.media_id
					AND fad.datatype_id=1
					order by entity_name, seq_num) AS header_short_text'; --bug6133951
Line: 4504

        SELECT fad.url web_page --Bug#4958642
        FROM fnd_attached_docs_form_vl fad
        WHERE ((fad.entity_name=''PO_HEADERS'' AND fad.pk1_value=to_char(phx.po_header_id)) OR
               (fad.entity_name=''PO_RELEASES'' AND fad.pk1_value=to_char(phx.po_release_id)) OR
               (fad.entity_name=''PO_VENDORS'' AND fad.pk1_value=to_char(phx.vendor_id)) OR
               (fad.entity_name=''PO_VENDOR_SITES'' AND fad.pk1_value=to_char(phx.vendor_site_id)) --bug6154354
              )
        AND fad.datatype_id=5
        AND fad.function_name=''PO_PRINTPO''
        order by fad.entity_name,fad.seq_num) AS header_url_attachments'; --bug6133951
Line: 4516

        SELECT fad.file_name
        FROM fnd_attached_docs_form_vl fad
        WHERE ((fad.entity_name=''PO_HEADERS'' AND fad.pk1_value=to_char(phx.po_header_id)) OR
               (fad.entity_name=''PO_RELEASES'' AND fad.pk1_value=to_char(phx.po_release_id)) OR
               (fad.entity_name=''PO_VENDORS'' AND fad.pk1_value=to_char(phx.vendor_id)) OR
               (fad.entity_name=''PO_VENDOR_SITES'' AND fad.pk1_value=to_char(phx.vendor_site_id))  --bug6154354
              )
        AND fad.datatype_id=6
        AND fad.function_name=''PO_PRINTPO''
        order by fad.entity_name,fad.seq_num) AS header_file_attachments';  --bug6133951
Line: 4533

l_head_short_attachment_query := 'CURSOR( SELECT fds.short_text
				  FROM
					fnd_attached_docs_form_vl fad,
					fnd_documents_short_text fds
				 WHERE  ((entity_name = ''PO_HEADERS'' AND
					pk1_value = to_char(phx.po_header_id)) OR
					(entity_name = ''PO_VENDORS'' AND
				        pk1_value = to_char(phx.vendor_id))  OR
                                        (entity_name = ''PO_VENDOR_SITES'' AND
                                        pk1_value = to_char(phx.vendor_site_id))) AND  -- bug6154354
				        function_name = ''PO_PRINTPO''
				        AND fad.media_id = fds.media_id
					AND fad.datatype_id=1 order by fad.seq_num) AS header_short_text'; --bug6133951
Line: 4549

        SELECT fad.url web_page --Bug#4958642
        FROM fnd_attached_docs_form_vl fad
        WHERE ((fad.entity_name=''PO_HEADERS'' AND fad.pk1_value=to_char(phx.po_header_id)) OR
               (fad.entity_name=''PO_VENDORS'' AND fad.pk1_value=to_char(phx.vendor_id)) OR
               (fad.entity_name=''PO_VENDOR_SITES'' AND fad.pk1_value=to_char(phx.vendor_site_id))  --bug6154354
              )
        AND fad.datatype_id=5
        AND fad.function_name=''PO_PRINTPO''
        order by fad.entity_name,fad.seq_num) AS header_url_attachments';  --bug6133951
Line: 4560

        SELECT fad.file_name
        FROM fnd_attached_docs_form_vl fad
        WHERE ((fad.entity_name=''PO_HEADERS'' AND fad.pk1_value=to_char(phx.po_header_id)) OR
               (fad.entity_name=''PO_VENDORS'' AND fad.pk1_value=to_char(phx.vendor_id)) OR
               (fad.entity_name=''PO_VENDOR_SITES'' AND fad.pk1_value=to_char(phx.vendor_site_id))  --bug6154354
              )
        AND fad.datatype_id=6
        AND fad.function_name=''PO_PRINTPO''
        order by fad.entity_name,fad.seq_num) AS header_file_attachments';   --bug6133951
Line: 4585

	l_line_short_attachment_query := ' CURSOR( SELECT plx.po_line_id , fds.short_text
	 FROM
		fnd_attached_docs_form_vl fad,
		fnd_documents_short_text fds
	 WHERE ((fad.entity_name=''PO_LINES'' AND fad.pk1_value=to_char(plx.po_line_id))
	         OR
	         (fad.entity_name=''MTL_SYSTEM_ITEMS'' AND
	          fad.pk1_value=to_char(PO_COMMUNICATION_PVT.getInventoryOrgId()) AND --Bug6139548
	          fad.pk2_value=to_char(plx.item_id) AND plx.item_id is not null)
	       ) AND
	       function_name = ''PO_PRINTPO''
	       AND fad.media_id = fds.media_id
   	       AND fad.datatype_id=1 order by fad.seq_num) AS line_short_text';  --bug6133951
Line: 4602

        SELECT fad.url web_page --Bug#4958642
        FROM fnd_attached_docs_form_vl fad
        WHERE ((fad.entity_name=''PO_LINES'' AND fad.pk1_value=to_char(plx.po_line_id))
               OR
               (fad.entity_name=''PO_HEADERS'' AND fad.pk1_value=to_char(plx.from_header_id)
                AND plx.from_header_id IS NOT NULL)
               OR
               (fad.entity_name=''PO_LINES'' AND fad.pk1_value=to_char(plx.from_line_id)
                AND plx.from_line_id IS NOT NULL)
               OR
               (fad.entity_name=''MTL_SYSTEM_ITEMS'' AND
                fad.pk1_value=to_char(PO_COMMUNICATION_PVT.getInventoryOrgId()) AND
                fad.pk2_value=to_char(plx.item_id) AND plx.item_id is not null)
              )
        AND fad.datatype_id=5
        AND fad.function_name=''PO_PRINTPO'' order by fad.seq_num) AS line_url_attachments'; --bug6133951
Line: 4621

        SELECT fad.file_name
        FROM fnd_attached_docs_form_vl fad
        WHERE ((fad.entity_name=''PO_LINES'' AND fad.pk1_value=to_char(plx.po_line_id))
               OR
               (fad.entity_name=''PO_HEADERS'' AND fad.pk1_value=to_char(plx.from_header_id)
                AND plx.from_header_id IS NOT NULL)
               OR
               (fad.entity_name=''PO_LINES'' AND fad.pk1_value=to_char(plx.from_line_id)
                AND plx.from_line_id IS NOT NULL)
               OR
               (fad.entity_name=''MTL_SYSTEM_ITEMS'' AND
                fad.pk1_value=to_char(PO_COMMUNICATION_PVT.getInventoryOrgId()) AND
                fad.pk2_value=to_char(plx.item_id) AND plx.item_id is not null)
              )
        AND fad.datatype_id=6
        AND fad.function_name=''PO_PRINTPO''
        order by fad.seq_num) AS line_file_attachments'; --bug6133951
Line: 4649

	 l_shipment_short_attach_query := 'CURSOR( SELECT pllx.line_location_id, fds.short_text
	 FROM
		fnd_attached_docs_form_vl fad,
		fnd_documents_short_text fds
	 WHERE entity_name = ''PO_SHIPMENTS'' AND
		 pk1_value = to_char(pllx.line_location_id) AND
	       function_name = ''PO_PRINTPO''
	       AND fad.media_id = fds.media_id
  	       AND fad.datatype_id=1
               order by fad.seq_num) AS line_loc_short_text';  --bug6133951
Line: 4662

        SELECT fad.url web_page --Bug#4958642
        FROM fnd_attached_docs_form_vl fad
        WHERE fad.entity_name=''PO_SHIPMENTS''
        AND fad.pk1_value=to_char(pllx.line_location_id)
        AND fad.datatype_id=5
        AND fad.function_name=''PO_PRINTPO''
        order by fad.seq_num ) AS line_loc_url_attachments';  --bug6133951
Line: 4671

        SELECT fad.file_name
        FROM fnd_attached_docs_form_vl fad
        WHERE fad.entity_name=''PO_SHIPMENTS''
        AND fad.pk1_value=to_char(pllx.line_location_id)
        AND fad.datatype_id=6
        AND fad.function_name=''PO_PRINTPO''
        order by fad.seq_num) AS line_loc_file_attachments';  --bug6133951
Line: 4691

l_xml_message_query :='CURSOR (SELECT message_name message, message_text text FROM fnd_new_messages WHERE message_name in (
''PO_WF_NOTIF_REVISION'',
''PO_WF_NOTIF_VENDOR_NO'',
''PO_WF_NOTIF_PAYMENT_TERMS'',
''PO_WF_NOTIF_FREIGHT_TERMS'',
''PO_WF_NOTIF_FOB'',
''PO_WF_NOTIF_SHIP_VIA'',
''PO_WF_NOTIF_CONFIRM_TO_TELE'',
''PO_WF_NOTIF_REQUESTER_DELIVER'',
''PO_WF_NOTIF_DESCRIPTION'',
''PO_WF_NOTIF_TAX'',
''PO_WF_NOTIF_UOM'',
''PO_WF_NOTIF_UNIT_PRICE'',
''PO_WF_NOTIF_QUANTITY'',
''PO_WF_NOTIF_PURCHASE_ORDER'',
''PO_WF_NOTIF_BUYER'',
''PO_WF_NOTIF_AMOUNT'',
''PO_WF_NOTIF_EFFECTIVE_DATE'',
''PO_WF_NOTIF_HEADER_NOTE'',
''PO_WF_NOTIF_LINE_NUMBER'',
''PO_WF_NOTIF_LINE_PAYITEM_NUM'',  -- 
''PO_WF_NOTIF_MULTIPLE'',
''PO_WF_NOTIF_PART_NO_DESC'',
''PO_WF_NOTIF_SUPPLIER_ITEM'',
''PO_WF_NOTIF_TOTAL'',
''PO_WF_NOTIF_NOTE'',
''PO_FO_PACKING_INSTRUCTION'',
''PO_FO_CUST_PO_NUMBER'',
''PO_FO_CUST_ITEM_DESC'',
''PO_FO_LINE_NUMBER'',
''PO_FO_SHIP_NUMBER'',
''PO_FO_AMOUNT_BASED'',
''PO_FO_CONTRACTOR_NAME'',
''PO_FO_START_DATE'',
''PO_FO_END_DATE'',
''PO_FO_WORK_SCHEDULE'',
''PO_FO_SHIFT_PATTERN'',
''PO_FO_PRICE_DIFFERENTIALS'',
''PO_FO_DELIVER_TO_LOCATION'',
''PO_FO_EFFECTIVE_START_DATE'',
''PO_FO_AMOUNT_AGREED'',
''PO_FO_ADVANCE'',                  -- 
''PO_FO_RETAINAGE_RATE'',           -- 
''PO_FO_MAX_RETAINAGE_AMOUNT'',     -- 
''PO_FO_PROGRESS_PAYMENT_RATE'',    -- 
''PO_FO_RECOUPMENT_RATE'',          -- 
''PO_FO_PRICE_BREAK'',
''PO_FO_CHARGE_ACCOUNT'',
''PO_FO_CONTRACTOR'',
''PO_FO_CONTACT_NAME'',
''PO_FO_TELEPHONE'',
''PO_FO_FAX'',
''PO_FO_NAME'',
''PO_FO_TITLE'',
''PO_FO_DATE'',
''PO_FO_REVISION'',
''PO_FO_AMENDMENT'',
''PO_FO_SHIP_METHOD'',
''PO_FO_SHIPPING_INSTRUCTION'',
''PO_FO_DRAFT'',
''PO_FO_PROPRIETARY_INFORMATION'',
''PO_FO_TRANSPORTAION_ARRANGED'',
''PO_FO_DELIVER_TO_LOCATION'',
''PO_FO_NO'',
''PO_FO_COMPANY'',
''PO_FO_SUBMIT_RESPONSE'',
''PO_FO_EMAIL'',
''PO_WF_NOTIF_EXPIRES_ON'',
''PO_FO_TEST'',
''PO_FO_ORG_AGR_ASS'',
''PO_FO_EFFECTIVE_END_DATE'',
''PO_FO_PURCHASING_ORGANIZATION'',
''PO_FO_PURCHASING_SUPPLIER_SITE'',
''PO_FO_TRANSPORTATION_ARRANGED'',
''PO_WF_NOTIF_ADDRESS'',
''PO_WF_NOTIF_ORDER'',
''PO_WF_NOTIF_ORDER_DATE'',
''PO_FO_VENDOR'',
''PO_FO_SHIP_TO'',
''PO_FO_BILL_TO'',
''PO_FO_CONFIRM_NOT_DUPLICATE'',
''PO_FO_AGREEMENT_CANCELED'',
''PO_FO_FORMAL_ACCEPT'',
''PO_FO_TYPE'',
''PO_FO_REVISION_DATE'',
''PO_FO_REVISED_BY'',
''PO_FO_PRICES_EXPRESSED'',
''PO_FO_NOTES'',
''PO_WF_NOTIF_PREPARER'',
''PO_FO_SUPPLIER_CONFIGURATION'',
''PO_FO_DELIVER_DATE_TIME'',
''PO_FO_LINE_REF_BPA'',
''PO_FO_LINE_REF_CONTRACT'',
''PO_FO_LINE_SUPPLIER_QUOTATION'',
''PO_FO_USE_SHIP_ADDRESS_TOP'',
''PO_FO_LINE_CANCELED'',
''PO_FO_ORIGINAL_QTY_ORDERED'',
''PO_FO_QUANTITY_CANCELED'',
''PO_FO_SHIPMENT_CANCELED'',
''PO_FO_ORIGINAL_SHIPMENT_QTY'',
''PO_FO_CUSTOMER_ACCOUNT_NO'',
''PO_FO_RELEASE_CANCELED'',
''PO_FO_PO_CANCELED'',
''PO_FO_TOTAL'',
''PO_FO_SUPPLIER_ITEM'',
''PO_FO_ORIGINAL_AMOUNT_ORDERED'',
''PO_FO_AMOUNT_CANCELED'',
''PO_FO_UN_NUMBER'',
''PO_WF_NOTIF_PROMISED_DATE'',
''PO_WF_NOTIF_NEEDBY_DATE'',
''PO_FO_HAZARD_CLASS'',
''PO_FO_PAGE'',
''PO_FO_REFERENCE_DOCUMENTS'',
''PO_FO_PAYITEM_CANCELED'', --
''PO_FO_ORIGINAL_PAYITEM_QTY'', --
''PO_FO_PAYITEM_QTY_CANCELED'', --
''PO_FO_ORIGINAL_PAYITEM_AMT'', --
''PO_FO_PAYITEM_AMT_CANCELED'' --
) AND application_id = 201 AND language_code = '''||userenv('LANG')||''') AS message';
Line: 4839

       ', CURSOR(SELECT del.* FROM po_line_locations_xml del'
    || ' WHERE del.po_line_id = plx.po_line_id AND del.payment_type = ''DELIVERY'')'
    || ' AS line_delivery ';
Line: 4844

       ', CURSOR(SELECT adv.* FROM po_distribution_xml adv, po_line_locations_xml pllx2'
    || ' WHERE pllx2.po_line_id = plx.po_line_id AND pllx2.payment_type = ''ADVANCE'''
    || ' AND adv.line_location_id = pllx2.line_location_id) AS line_advance_distributions,'
    || ' CURSOR(SELECT del.*, CURSOR(SELECT deldist.* FROM po_distribution_xml deldist'
    || ' WHERE deldist.line_location_id = del.line_location_id) AS distributions'
    || ' FROM po_line_locations_xml del WHERE del.po_line_id = plx.po_line_id'
    || ' AND del.payment_type = ''DELIVERY'') AS line_delivery ';
Line: 4861

       ', CURSOR(SELECT del.* FROM po_line_locations_archive_xml del'
    || ' WHERE del.po_line_id = plx.po_line_id AND del.payment_type = ''DELIVERY'''
    || ' AND del.revision_num = (SELECT max(dela.revision_num)'
    || ' FROM po_line_locations_archive_all dela WHERE del.line_location_id = '
    || ' dela.line_location_id AND del.revision_num <= pcgt.revision_number) '
    || ' ) AS line_delivery ';
Line: 4871

       ', CURSOR(SELECT adv.* FROM po_distribution_archive_xml adv,'
    || ' po_line_locations_archive_xml pllx2 WHERE pllx2.po_line_id = plx.po_line_id'
    || ' AND pllx2.payment_type = ''ADVANCE'' AND adv.line_location_id = pllx2.line_location_id'
    || ' AND adv.revision_num = (SELECT max(adva.revision_num)'
    || ' FROM po_distributions_archive_all adva WHERE adv.po_distribution_id ='
    || ' adv.po_distribution_id AND adva.revision_num <= pcgt.revision_number))'
    || ' AS line_advance_distributions, CURSOR(SELECT del.*, CURSOR(SELECT deldist.*'
    || ' FROM po_distribution_xml deldist WHERE deldist.line_location_id = del.line_location_id'
    || ' AND deldist.revision_num = (SELECT max(deldista.revision_num)'
    || ' FROM po_distributions_archive_all deldista WHERE deldist.po_distribution_id ='
    || ' deldista.po_distribution_id AND deldista.revision_num <= pcgt.revision_number))'
    || ' AS distributions FROM po_line_locations_xml del WHERE del.po_line_id = plx.po_line_id'
    || ' AND del.payment_type = ''DELIVERY'' AND del.revision_num = ('
    || ' SELECT max(dela.revision_num) FROM po_line_locations_archive_all dela'
    || ' WHERE del.line_location_id = dela.line_location_id'
    || ' AND del.revision_num <= pcgt.revision_number)) AS line_delivery';
Line: 4903

l_agreement_assign_query := ' CURSOR( select rownum, PO_COMMUNICATION_PVT.GETOPERATIONINFO(PGA.PURCHASING_ORG_ID) OU_NAME,
      PO_COMMUNICATION_PVT.getVendorAddressLine1(PGA.vendor_site_id) VENDOR_ADDRESS_LINE1,
      PO_COMMUNICATION_PVT.getVendorAddressLine2() VENDOR_ADDRESS_LINE2,
      PO_COMMUNICATION_PVT.getVendorAddressLine3() VENDOR_ADDRESS_LINE3,
      PO_COMMUNICATION_PVT.getVendorCityStateZipInfo() VENDOR_CITY_STATE_ZIP,
      PO_COMMUNICATION_PVT.getVendorCountry() VENDOR_COUNTRY
      FROM po_ga_org_assignments PGA
      WHERE PGA.ENABLED_FLAG = ''Y'' and PGA.PO_HEADER_ID = PHX.PO_HEADER_ID) as organization_details ';
Line: 4912

l_arc_agreement_assign_query := ' CURSOR( select rownum, PO_COMMUNICATION_PVT.GETOPERATIONINFO(PGA.PURCHASING_ORG_ID) OU_NAME,
      PO_COMMUNICATION_PVT.getVendorAddressLine1(PGA.vendor_site_id) VENDOR_ADDRESS_LINE1,
      PO_COMMUNICATION_PVT.getVendorAddressLine2() VENDOR_ADDRESS_LINE2,
      PO_COMMUNICATION_PVT.getVendorAddressLine3() VENDOR_ADDRESS_LINE3,
      PO_COMMUNICATION_PVT.getVendorCityStateZipInfo() VENDOR_CITY_STATE_ZIP,
      PO_COMMUNICATION_PVT.getVendorCountry() VENDOR_COUNTRY
      FROM po_ga_org_assignments_archive PGA
      WHERE PGA.ENABLED_FLAG = ''Y'' and PGA.PO_HEADER_ID = PHX.PO_HEADER_ID) as organization_details ';
Line: 4955

    l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type,
	PO_COMMUNICATION_PVT.getCoverMessage() cover_message,PO_COMMUNICATION_PVT.getTimezone() timezone,
    PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
    PO_COMMUNICATION_PVT.getDocumentName() document_name,
    PO_COMMUNICATION_PVT.IsDocumentSigned(PO_COMMUNICATION_PVT.getDocumentId()) Signed,
    fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile,
    PO_COMMUNICATION_PVT.getWithTerms() With_Terms , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '|| l_xml_message_query || ','|| l_head_short_attachment_query||','||l_head_url_attachment_query||','||l_head_file_attachment_query||'
      FROM PO_HEADERS_XML phx WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 4966

      SELECT count(*) into l_count FROM po_lines_all  WHERE po_header_id = p_document_id;
Line: 4976

          l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
              PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
              PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
              PO_COMMUNICATION_PVT.getDocumentName() document_name,
              PO_COMMUNICATION_PVT.IsDocumentSigned(PO_COMMUNICATION_PVT.getDocumentId()) Signed,
              fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile,PO_COMMUNICATION_PVT.getWithTerms() With_Terms , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
                            l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
              CURSOR(SELECT plx.*, '||l_adv_amount_query||' CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER,MIN_MULTIPLIER, MAX_MULTIPLIER FROM po_price_differentials_v
              WHERE entity_type='''||l_eventType||''' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
              '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||' FROM po_lines_xml plx
              WHERE  plx.po_header_id = phx.po_header_id and not exists
              (select ''x'' from po_lines_archive_all  plaa where
                plaa.po_line_id = plx.po_line_id and
                      plaa.cancel_flag= ''Y'' and plaa.revision_num< PO_COMMUNICATION_PVT.getRevisionNum() ) order by plx.line_num) AS lines
              FROM PO_HEADERS_XML phx WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 4994

      SELECT count(*) into l_count FROM po_line_locations_all  WHERE po_header_id = p_document_id;
Line: 5000

        l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
            PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
            PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
            PO_COMMUNICATION_PVT.getDocumentName() document_name,
            PO_COMMUNICATION_PVT.IsDocumentSigned( PO_COMMUNICATION_PVT.getDocumentId()) Signed,
            fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , '||
        ' PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , ' ||  l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
            CURSOR(SELECT plx.*, '||l_adv_amount_query||' CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER, MIN_MULTIPLIER,MAX_MULTIPLIER FROM po_price_differentials_v
              WHERE entity_type='''||l_eventType||''' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
              '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||',
            CURSOR(SELECT pllx.*,';
Line: 5012

              l_xml_query := l_xml_query||'CURSOR(SELECT PRICE_TYPE_DSP PRICE_TYPE, MIN_MULTIPLIER,  MAX_MULTIPLIER FROM po_price_differentials_v
              WHERE entity_type=''PRICE BREAK'' AND entity_id = pllx.line_location_id and enabled_flag=''Y'') AS price_break,';
Line: 5018

            (select ''x'' from po_line_locations_archive_all pllaa where pllaa.line_location_id = pllx.line_location_id
            and pllaa.cancel_flag=''Y'' and pllaa.revision_num < PO_COMMUNICATION_PVT.getRevisionNum()) order by pllx.shipment_num ) AS line_locations' || l_complex_lloc_query || '
            FROM po_lines_xml plx
            WHERE  plx.po_header_id = phx.po_header_id and not exists
              (select ''x'' from po_lines_archive_all  plaa where
                plaa.po_line_id = plx.po_line_id and
                      plaa.cancel_flag= ''Y'' and plaa.revision_num< PO_COMMUNICATION_PVT.getRevisionNum() ) order by plx.line_num) AS lines
            FROM PO_HEADERS_XML phx WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5029

        SELECT count(*) into l_count FROM po_distributions_all  WHERE po_header_id = p_document_id;
Line: 5033

          l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
              PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
              PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
              PO_COMMUNICATION_PVT.getDocumentName() document_name,
              PO_COMMUNICATION_PVT.IsDocumentSigned(PO_COMMUNICATION_PVT.getDocumentId()) Signed,
              fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile,PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , '||
             ' PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , ' || l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
              CURSOR(SELECT plx.*, '||l_adv_amount_query||' CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER FROM po_price_differentials_v
              WHERE entity_type=''PO LINE'' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
              '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||',
              CURSOR(SELECT pllx.*, '|| l_shipment_short_attach_query ||','||l_shipment_url_attach_query||','||l_shipment_file_attach_query||',
              CURSOR(SELECT pdx.* FROM po_distribution_xml pdx WHERE pdx.po_header_id = phx.po_header_id and pdx.LINE_LOCATION_ID = pllx.LINE_LOCATION_ID) AS distributions
              FROM po_line_locations_xml pllx WHERE pllx.po_line_id = plx.po_line_id AND NVL(pllx.payment_type,''NONE'') NOT IN (''ADVANCE'',''DELIVERY'') and not exists
            (select ''x'' from po_line_locations_archive_all pllaa where pllaa.line_location_id = pllx.line_location_id
            and pllaa.cancel_flag=''Y'' and pllaa.revision_num < PO_COMMUNICATION_PVT.getRevisionNum()) order by pllx.shipment_num ) AS line_locations' || l_complex_dist_query || '
              FROM po_lines_xml plx WHERE plx.po_header_id = phx.po_header_id and not exists
              (select ''x'' from po_lines_archive_all  plaa where
                plaa.po_line_id = plx.po_line_id and
                      plaa.cancel_flag= ''Y'' and plaa.revision_num< PO_COMMUNICATION_PVT.getRevisionNum() ) order by plx.line_num) AS lines
              FROM PO_HEADERS_XML phx WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND
              phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5070

  l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type,
    PO_COMMUNICATION_PVT.getCoverMessage() cover_message,PO_COMMUNICATION_PVT.getTimezone() timezone,
    PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag()
    test_flag,
    PO_COMMUNICATION_PVT.getDocumentName() document_name,
    PO_COMMUNICATION_PVT.IsDocumentSigned(PO_COMMUNICATION_PVT.getDocumentId()) Signed,
    fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
        l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||'
    FROM PO_HEADERS_ARCHIVE_XML phx WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5082

      SELECT count(*) into l_count FROM po_lines_archive_all  WHERE po_header_id = p_document_id;
Line: 5090

      l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
          PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
          PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
          PO_COMMUNICATION_PVT.getDocumentName() document_name,
          PO_COMMUNICATION_PVT.IsDocumentSigned(PO_COMMUNICATION_PVT.getDocumentId()) Signed,
          fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile,PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
                    l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
          CURSOR(SELECT plx.*, '||l_adv_amount_query||' CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER,MIN_MULTIPLIER, MAX_MULTIPLIER FROM po_price_differentials_v
              WHERE entity_type='''||l_eventType||''' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
          '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||' FROM PO_LINES_ARCHIVE_XML plx WHERE plx.po_header_id = phx.po_header_id
          AND plx.REVISION_NUM = (select max(revision_num) from po_lines_archive_all pla where pla.po_line_id = plx.po_line_id
          and pla.revision_num <= pcgt.revision_number ) and  ''Y'' = decode(nvl(plx.cancel_flag,''N''),''N'',''Y'',''Y'',decode(plx.revision_num,PO_COMMUNICATION_PVT.getRevisionNum(),''Y'',''N'') )  order by plx.line_num) AS lines
          FROM PO_HEADERS_ARCHIVE_XML phx, PO_COMMUNICATION_GT pcgt
          WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId()
          AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5108

      SELECT count(*) into l_count FROM po_line_locations_archive_all  WHERE po_header_id = p_document_id;
Line: 5112

      l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
          PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
          PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
          PO_COMMUNICATION_PVT.getDocumentName() document_name,
          PO_COMMUNICATION_PVT.IsDocumentSigned( PO_COMMUNICATION_PVT.getDocumentId()) Signed,
          fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
                    l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
          CURSOR(SELECT plx.*, '||l_adv_amount_query||' CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER, MIN_MULTIPLIER,MAX_MULTIPLIER FROM po_price_differentials_v
            WHERE entity_type='''||l_eventType||''' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
            '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||',
          CURSOR(SELECT pllx.*,';
Line: 5124

            l_xml_query := l_xml_query||'CURSOR(SELECT PRICE_TYPE_DSP PRICE_TYPE, MIN_MULTIPLIER,  MAX_MULTIPLIER FROM po_price_differentials_v
            WHERE entity_type=''PRICE BREAK'' AND entity_id = pllx.line_location_id and enabled_flag=''Y'') AS price_break,';
Line: 5130

          and pllx.revision_num = (SELECT MAX(plla.REVISION_NUM) FROM PO_LINE_LOCATIONS_ARCHIVE_ALL plla
          where plla.LINE_LOCATION_ID = pllx.LINE_LOCATION_ID and plla.revision_num <= pcgt.revision_number  )
          and ''Y'' = decode(nvl(pllx.cancel_flag,''N''),''N'',''Y'',''Y'',decode(pllx.revision_num,PO_COMMUNICATION_PVT.getRevisionNum(),''Y'',''N'') ) order by pllx.shipment_num ) AS line_locations' || l_complex_lloc_query || '
          FROM PO_LINES_ARCHIVE_XML plx WHERE plx.po_header_id = phx.po_header_id
          AND plx.REVISION_NUM = (select max(revision_num) from po_lines_archive_all pla where pla.po_line_id = plx.po_line_id
          and pla.revision_num <= pcgt.revision_number  ) and  ''Y'' = decode(nvl(plx.cancel_flag,''N''),''N'',''Y'',''Y'',decode(plx.revision_num,PO_COMMUNICATION_PVT.getRevisionNum(),''Y'',''N'') ) order by plx.line_num) AS lines
          FROM PO_HEADERS_ARCHIVE_XML phx, PO_COMMUNICATION_GT pcgt   WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5140

        SELECT count(*) into l_count FROM po_distributions_archive_all  WHERE po_header_id = p_document_id;
Line: 5144

        l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getIsComplexWorkPO() is_complex_work_po, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
            PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
            PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
            PO_COMMUNICATION_PVT.getDocumentName() document_name,
            PO_COMMUNICATION_PVT.IsDocumentSigned(PO_COMMUNICATION_PVT.getDocumentId()) Signed,
            fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
                        l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
            CURSOR(SELECT plx.*, '||l_adv_amount_query||' CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER FROM po_price_differentials_v
            WHERE entity_type=''PO LINE'' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
            '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||',
            CURSOR(SELECT pllx.*, '|| l_shipment_short_attach_query ||','||l_shipment_url_attach_query||','||l_shipment_file_attach_query||',
            CURSOR(SELECT pdx.* FROM po_distribution_archive_xml pdx WHERE pdx.po_header_id = phx.po_header_id and pdx.LINE_LOCATION_ID = pllx.LINE_LOCATION_ID
            and pdx.REVISION_NUM = (SELECT MAX(pda.REVISION_NUM) FROM PO_DISTRIBUTIONS_ARCHIVE_ALL pda
            WHERE pda.PO_DISTRIBUTION_ID = pdx.PO_DISTRIBUTION_ID AND pda.REVISION_NUM <= pcgt.revision_number ) ) AS distributions
            FROM PO_LINE_LOCATIONS_ARCHIVE_XML pllx WHERE pllx.po_line_id = plx.po_line_id and SHIPMENT_TYPE in (''BLANKET'',''STANDARD'',''PREPAYMENT'') AND NVL(pllx.payment_type,''NONE'') NOT IN (''ADVANCE'',''DELIVERY'')
            and pllx.revision_num = (SELECT MAX(plla.REVISION_NUM) FROM PO_LINE_LOCATIONS_ARCHIVE_ALL plla
            where plla.LINE_LOCATION_ID = pllx.LINE_LOCATION_ID and plla.revision_num <= pcgt.revision_number )
            and ''Y'' = decode(nvl(pllx.cancel_flag,''N''),''N'',''Y'',''Y'',decode(pllx.revision_num,PO_COMMUNICATION_PVT.getRevisionNum(),''Y'',''N'') ) order by pllx.shipment_num ) AS line_locations'|| l_complex_dist_query || '
            FROM PO_LINES_ARCHIVE_XML plx WHERE plx.po_header_id = phx.po_header_id
            AND plx.REVISION_NUM = (select max(revision_num) from po_lines_archive_all pla where pla.po_line_id = plx.po_line_id
            and pla.revision_num <= pcgt.revision_number ) and  ''Y'' = decode(nvl(plx.cancel_flag,''N''),''N'',''Y'',''Y'',decode(plx.revision_num,PO_COMMUNICATION_PVT.getRevisionNum(),''Y'',''N'') ) order by plx.line_num) AS lines
            FROM PO_HEADERS_ARCHIVE_XML phx, PO_COMMUNICATION_GT pcgt WHERE phx.PO_HEADER_ID = PO_COMMUNICATION_PVT.getDocumentId() AND
            phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5187

    l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
        PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
        PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
        PO_COMMUNICATION_PVT.getDocumentName() document_name,
        fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
                l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||'
        FROM PO_RELEASE_XML phx WHERE phx.PO_RELEASE_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5196

      SELECT count(*) into l_count FROM po_line_locations_all  WHERE po_release_id = p_document_id ;
Line: 5204

        l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,
            PO_COMMUNICATION_PVT.getTimezone() timezone,PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
            PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
            PO_COMMUNICATION_PVT.getDocumentName() document_name,
            fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
                        l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
            CURSOR(SELECT plx.*,CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER FROM po_price_differentials_v
              WHERE entity_type='''||l_eventType||''' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
              '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||',
            CURSOR(SELECT pllx.*,'|| l_shipment_short_attach_query ||','||l_shipment_url_attach_query||','||l_shipment_file_attach_query||',
            CURSOR(SELECT pd.*
            FROM po_distribution_xml pd WHERE pd.po_release_id = pllx.po_release_id and pd.LINE_LOCATION_ID = pllx.LINE_LOCATION_ID) AS distributions
            FROM po_line_locations_xml pllx WHERE pllx.po_release_id in (select po_release_id from PO_COMMUNICATION_GT) and pllx.po_line_id = plx.po_line_id
            and not exists (select ''x'' from po_line_locations_archive_all  pllaa where
                pllaa.line_location_id = pllx.line_location_id and
                      pllaa.cancel_flag= ''Y'' and pllaa.revision_num< PO_COMMUNICATION_PVT.getRevisionNum() ) order by pllx.shipment_num ) AS line_locations
            FROM po_lines_xml plx WHERE  exists (SELECT ''x'' from po_line_locations_all
            WHERE po_line_locations_all.po_line_id = plx.po_line_id and  po_release_id = phx.po_release_id and not exists (select ''x'' from po_line_locations_archive_all  pllaa where
                pllaa.line_location_id = po_line_locations_all.line_location_id and
                      pllaa.cancel_flag= ''Y'' and pllaa.revision_num< PO_COMMUNICATION_PVT.getRevisionNum() ) ) and plx.po_header_id = phx.po_header_id  order by plx.line_num) AS lines
            FROM PO_RELEASE_XML phx WHERE phx.PO_RELEASE_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5235

        /* The following query gets the release details, the outermost cursor selects headers information,
            and we move to the details (line, shipments, distributions) as we move inside each cursor. The
            lines have to be selected from the corresponding blanket since they are not present in the release */
        -- Bug 3727808. Use blanket revision number rather than release revision number. Added the max(pb.revision_num) query in lines SQL
        -- Bug 5506417: Added order by pllx.shipment_num and order by plx.line_num clauses
    l_xml_query := 'SELECT phx.*, PO_COMMUNICATION_PVT.getDocumentType() document_type, PO_COMMUNICATION_PVT.getCoverMessage() cover_message,PO_COMMUNICATION_PVT.getTimezone() timezone,
      PO_COMMUNICATION_PVT.getAmendmentMessage() ammendment_message,PO_COMMUNICATION_PVT.getTestFlag() test_flag,
      PO_COMMUNICATION_PVT.getDistinctShipmentCount() DIST_SHIPMENT_COUNT,
      PO_COMMUNICATION_PVT.getDocumentName() document_name,
      fnd_profile.value(''PO_GENERATE_AMENDMENT_DOCS'') amendment_profile, PO_COMMUNICATION_PVT.getWithTerms() With_Terms  , PO_COMMUNICATION_PVT.getIsContractAttachedDoc() Is_Attached_Doc , '||
            l_xml_message_query || ','|| l_head_short_attachment_query ||','||l_head_url_attachment_query||','||l_head_file_attachment_query||',
      CURSOR(SELECT plx.*,CURSOR(SELECT  PRICE_TYPE_DSP PRICE_TYPE, MULTIPLIER FROM po_price_differentials_v
        WHERE entity_type='''||l_eventType||''' AND entity_id = plx.po_line_id and enabled_flag=''Y'') AS price_diff,
        '|| l_line_short_attachment_query ||','||l_line_url_attachment_query||','||l_line_file_attachment_query||',
      CURSOR(SELECT pllx.*,'|| l_shipment_short_attach_query ||','||l_shipment_url_attach_query||','||l_shipment_file_attach_query||',
      CURSOR(SELECT pd.*
      FROM po_distribution_archive_xml pd WHERE pd.po_release_id = pllx.po_release_id and pd.line_location_id  = pllx.line_location_id
      and pd.REVISION_NUM = (SELECT MAX(pda.REVISION_NUM) FROM PO_DISTRIBUTIONS_ARCHIVE_ALL pda
      WHERE pda.PO_DISTRIBUTION_ID = pd.PO_DISTRIBUTION_ID AND pda.REVISION_NUM <= PO_COMMUNICATION_PVT.getRevisionNum() ) ) AS distributions
      FROM PO_LINE_LOCATIONS_ARCHIVE_XML pllx WHERE pllx.po_release_id = pcgt.po_release_id  and pllx.po_line_id = plx.po_line_id
      and pllx.revision_num = (SELECT MAX(plla.REVISION_NUM) FROM PO_LINE_LOCATIONS_ARCHIVE_ALL plla
      where plla.LINE_LOCATION_ID = pllx.LINE_LOCATION_ID and plla.revision_num <= pcgt.revision_number  ) order by pllx.shipment_num ) AS line_locations
      FROM PO_LINES_ARCHIVE_XML plx
      WHERE exists (SELECT ''x'' from po_line_locations_archive_all pllaa
      WHERE pllaa.po_line_id = plx.po_line_id and  po_release_id = phx.po_release_id
      and pllaa.REVISION_NUM = (select max(revision_num) from po_line_locations_archive_all pllaa1 where pllaa1.line_location_id = pllaa.line_location_id
      and pllaa1.revision_num <= pcgt.revision_number  )
      and ''Y'' = decode(nvl(pllaa.cancel_flag,''N''),''N'',''Y'',''Y'',decode(pllaa.revision_num,PO_COMMUNICATION_PVT.getRevisionNum(),''Y'',''N'') ) )
      and plx.po_header_id = phx.po_header_id
      AND plx.REVISION_NUM = (select max(revision_num) from po_lines_archive_all pla where pla.po_line_id = plx.po_line_id
      and pla.revision_num <= (select max(pb.revision_num)
                                                                 from po_headers_archive_all pb, po_releases_archive_all pr
                                                                 where pb.po_header_id = pr.po_header_id
                                                                 and pr.po_release_id = pcgt.po_release_id
                                                                 and pr.revision_num= pcgt.revision_number
                                                                 and pb.approved_date <= pr.approved_date
                                                                ) )   order by plx.line_num desc) AS lines
      FROM PO_RELEASE_ARCHIVE_XML phx, PO_COMMUNICATION_GT pcgt WHERE phx.PO_RELEASE_ID = PO_COMMUNICATION_PVT.getDocumentId() AND phx.revision_num = PO_COMMUNICATION_PVT.getRevisionNum()';
Line: 5300

	l_headerAttachmentsQuery := 'select PO_COMMUNICATION_PVT.get_clob(fdl.rowid) long_text
	 FROM
		fnd_attached_docs_form_vl fad,
		fnd_documents_long_text fdl
	 WHERE ( (entity_name=''PO_RELEASES'' AND
		 pk1_value= to_char(PO_COMMUNICATION_PVT.getDocumentId()) ) OR
		 (entity_name = ''PO_HEADERS'' AND
		 pk1_value = to_char(PO_COMMUNICATION_PVT.getReleaseHeaderId())) OR --Bug6139548
		 (entity_name = ''PO_VENDORS'' AND
		 pk1_value = to_char(PO_COMMUNICATION_PVT.getVendorId()))) AND
		 function_name = ''PO_PRINTPO''
		 and fad.media_id = fdl.media_id
		 and fad.datatype_id=2
		 order by entity_name,seq_num';  --bug6133951
Line: 5324

	l_headerAttachmentsQuery := 'select PO_COMMUNICATION_PVT.get_clob(fdl.rowid) long_text
	 FROM
		fnd_attached_docs_form_vl fad,
		fnd_documents_long_text fdl
	 WHERE ((entity_name = ''PO_HEADERS'' AND
		 pk1_value = to_char(PO_COMMUNICATION_PVT.getReleaseHeaderId())) OR --Bug6139548
		(entity_name = ''PO_VENDORS'' AND
		 pk1_value = to_char(PO_COMMUNICATION_PVT.getVendorId()))) AND
		 function_name = ''PO_PRINTPO''
		 and fad.media_id = fdl.media_id
		 AND fad.datatype_id=2
                 order by seq_num'; --bug6133951
Line: 5349

	l_lineAttachQuery :='SELECT  PO_COMMUNICATION_PVT.get_clob(fds.rowid) text, plx.po_line_id id
	 FROM
		fnd_attached_docs_form_vl fad,
		fnd_documents_long_text fds,
		po_lines_all plx
	WHERE ((fad.entity_name=''PO_LINES'' AND fad.pk1_value=to_char(plx.po_line_id))
	         OR
	         (fad.entity_name=''MTL_SYSTEM_ITEMS'' AND
	          fad.pk1_value=to_char(PO_COMMUNICATION_PVT.getInventoryOrgId()) AND --Bug6139548
	          fad.pk2_value=to_char(plx.item_id) AND plx.item_id is not null)
	       ) AND
	       function_name = ''PO_PRINTPO''
	       AND fad.media_id = fds.media_id
	       AND fad.datatype_id=2
	       AND plx.po_header_id = PO_COMMUNICATION_PVT.getReleaseHeaderId()
               order by seq_num';  --bug6133951
Line: 5378

	l_shipmentAttachmentQuery:=  'SELECT PO_COMMUNICATION_PVT.get_clob(fds.rowid) long_text, pllx.LINE_LOCATION_ID
	 FROM
		fnd_attached_docs_form_vl fad,
		fnd_documents_long_text fds,
		po_line_locations_all pllx
	WHERE entity_name = ''PO_SHIPMENTS'' AND
		 pk1_value =  to_char(pllx.LINE_LOCATION_ID) AND
	       function_name = ''PO_PRINTPO''
	       AND fad.media_id = fds.media_id
		   AND fad.document_description not like ''POR%''
	       AND fad.datatype_id=2
	       AND pllx.po_header_id = PO_COMMUNICATION_PVT.getReleaseHeaderId()
               order by seq_num'; --bug6133951
Line: 5392

select TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') into l_time from dual;
Line: 5421

      select TO_CHAR(SYSDATE, ''DD-MON-YYYY HH24:MI:SS'') into l_time from dual;
Line: 5433

      select TO_CHAR(SYSDATE, ''DD-MON-YYYY HH24:MI:SS'') into l_time from dual;
Line: 5445

      select TO_CHAR(SYSDATE, ''DD-MON-YYYY HH24:MI:SS'') into l_time from dual;
Line: 5457

      select TO_CHAR(SYSDATE, ''DD-MON-YYYY HH24:MI:SS'') into l_time from dual;
Line: 5469

      select TO_CHAR(SYSDATE, ''DD-MON-YYYY HH24:MI:SS'') into l_time from dual;
Line: 5476

            open refcur for ''select :l_fileClob1 as text_file from dual'' using l_fileClob;
Line: 5495

      select TO_CHAR(SYSDATE, ''DD-MON-YYYY HH24:MI:SS'') into l_time from dual;
Line: 5500

      /* Call PO_HR_LOCATION.populate_gt procedure to insert address values into global temp table from PL/SQL table*/
      PO_HR_LOCATION.populate_gt();
Line: 5504

        context := dbms_xmlgen.newContext(''select * from po_address_details_gt '');
Line: 5522

select TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') into l_time from dual;
Line: 5527

/*Delete the records from global temp table*/
DELETE po_address_details_gt;
Line: 5529

DELETE po_communication_gt ; -- Added this line for bug:3698674
Line: 5963

       SELECT
            pap.email_address,
            pph.phone_number
       INTO PO_COMMUNICATION_PVT.g_buyer_email_address,
            PO_COMMUNICATION_PVT.g_buyer_phone
       FROM per_phones pph,
            per_all_people_f pap
       WHERE pph.parent_id(+)=pap.person_id
            AND pph.parent_table(+)='PER_ALL_PEOPLE_F'
            AND pph.phone_type (+)= 'W1'
            AND pap.person_id = p_agent_id
            AND trunc(sysdate) BETWEEN pap.effective_start_date AND pap.effective_end_date
	    AND trunc(sysdate) BETWEEN nvl(pph.date_from,trunc(sysdate)) AND nvl(pph.date_to,trunc(sysdate))
	    AND ROWNUM = 1;  --	Bug5671523
Line: 5980

      SELECT
             pph.phone_number
        INTO PO_COMMUNICATION_PVT.g_buyer_fax
        FROM per_phones pph,
             per_all_people_f pap
       WHERE pph.parent_id(+)=pap.person_id
         AND pph.parent_table(+)='PER_ALL_PEOPLE_F'
         AND pph.phone_type(+)='WF'
         AND pap.person_id = p_agent_id
         AND trunc(sysdate) BETWEEN pap.effective_start_date AND pap.effective_end_date
         AND trunc(sysdate) BETWEEN nvl(pph.date_from,trunc(sysdate)) AND nvl(pph.date_to,trunc(sysdate))  -- bug#5999438
         AND ROWNUM = 1;
Line: 6041

    /*select name and location id from hr_all_organization_units*/

    SELECT name, location_id into PO_COMMUNICATION_PVT.g_ou_name, l_location_id
    FROM hr_all_organization_units
    WHERE organization_id = p_org_id;
Line: 6122

    Select ph.QUOTE_VENDOR_QUOTE_NUMBER, ph.SEGMENT1, ph.GLOBAL_AGREEMENT_FLAG into
      PO_COMMUNICATION_PVT.g_quote_number, PO_COMMUNICATION_PVT.g_agreement_number,
      PO_COMMUNICATION_PVT.g_agreement_flag
    FROM
      po_headers_all ph
    WHERE
      ph.PO_HEADER_ID =  p_header_id;
Line: 6158

    Select LINE_NUM into PO_COMMUNICATION_PVT.g_agreementLine_number
    FROM PO_LINES_ALL
    WHERE PO_LINE_ID = p_line_id;
Line: 6177

    SELECT  HRE.FIRST_NAME,
      HRE.LAST_NAME,
      HRE.TITLE,
      PHA.AGENT_ID
    INTO PO_COMMUNICATION_PVT.g_arcBuyer_fname, PO_COMMUNICATION_PVT.g_arcBuyer_lname,
         PO_COMMUNICATION_PVT.g_arcBuyer_title, PO_COMMUNICATION_PVT.g_arcAgent_id

    FROM
      PER_ALL_PEOPLE_F HRE,
      PO_HEADERS_ARCHIVE_ALL PHA
    WHERE
      HRE.PERSON_ID = PHA.AGENT_ID AND
      --HRE.EMPLOYEE_NUMBER IS NOT NULL AND    --
      TRUNC(SYSDATE) BETWEEN HRE.EFFECTIVE_START_DATE AND HRE.EFFECTIVE_END_DATE AND
      PHA.PO_HEADER_ID = p_header_id AND
      PHA.REVISION_NUM = 0 ;
Line: 6226

    SELECT  HRE.FIRST_NAME,
      HRE.LAST_NAME,
      PHA.AGENT_ID
    INTO PO_COMMUNICATION_PVT.g_arcBuyer_fname, PO_COMMUNICATION_PVT.g_arcBuyer_lname, PO_COMMUNICATION_PVT.g_arcAgent_id

    FROM
      PER_ALL_PEOPLE_F HRE,
      PO_RELEASES_ARCHIVE_ALL PHA
    WHERE
      HRE.PERSON_ID = PHA.AGENT_ID AND
      -- HRE.EMPLOYEE_NUMBER IS NOT NULL AND   --
      TRUNC(SYSDATE) BETWEEN HRE.EFFECTIVE_START_DATE AND HRE.EFFECTIVE_END_DATE AND
      PHA.PO_RELEASE_ID = p_release_id AND
      PHA.REVISION_NUM = 0 ;
Line: 6265

  SELECT  PVS.ADDRESS_LINE1 ,
    PVS.ADDRESS_LINE2 ,
    PVS.ADDRESS_LINE3 ,
    PVS.CITY ,
    DECODE(PVS.STATE, NULL, DECODE(PVS.PROVINCE, NULL, PVS.COUNTY, PVS.PROVINCE), PVS.STATE),
    PVS.ZIP ,
    FTE.TERRITORY_SHORT_NAME,
    PVS.ADDRESS_LINE4 --bug: 3463617
    INTO
    l_address_line_1, PO_COMMUNICATION_PVT.g_vendor_address_line_2, PO_COMMUNICATION_PVT.g_vendor_address_line_3,
    l_city, l_state, l_zip, PO_COMMUNICATION_PVT.g_vendor_country, PO_COMMUNICATION_PVT.g_vendor_address_line_4
  FROM
    PO_VENDOR_SITES_ALL PVS,
    FND_TERRITORIES_TL FTE
  WHERE
    PVS.COUNTRY = FTE.TERRITORY_CODE  AND
    DECODE(FTE.TERRITORY_CODE, NULL, '1', FTE.LANGUAGE) = DECODE(FTE.TERRITORY_CODE, NULL, '1', USERENV('LANG')) AND
    PVS.VENDOR_SITE_ID = p_vendor_site_id ;
Line: 6321

    SELECT
      name
    INTO
      PO_COMMUNICATION_PVT.g_job_name
    FROM
      PER_JOBS_VL
    WHERE
      job_id = p_job_id;
Line: 6370

         SELECT 'Y'
           INTO l_signatures
           FROM dual
          WHERE EXISTS (SELECT 1
                          FROM PO_ACTION_HISTORY
                         WHERE object_id = p_header_id
                           AND object_type_code IN ('PO','PA')
                           AND action_code = 'SIGNED'
         AND OBJECT_REVISION_NUM < PO_COMMUNICATION_PVT.g_revision_num);
Line: 6433

      SELECT userenv('LANG') INTO l_language_code FROM dual;
Line: 6446

      SELECT ph.segment1 into l_po_number
      FROM  po_headers_all ph
      WHERE po_header_id = p_document_id ;
Line: 6450

      SELECT ph.segment1  into l_po_number
      FROM po_headers_all ph,po_releases_all pr
      WHERE  ph.po_header_id = pr.po_header_id and pr.po_release_id = p_document_id ;
Line: 6604

    select nvl(psp.email_attachment_filename,'Attachments.zip')
    into l_email_attachment_filename
    from po_system_parameters_all psp
    where org_id = p_org_id;
Line: 6672

   /* SELECT name, LOCATION_ID
    INTO PO_COMMUNICATION_PVT.g_legal_entity_name, l_location_id
    FROM hr_all_organization_units
    WHERE to_char(organization_id) = ( SELECT org_information2 FROM hr_organization_information WHERE  org_information_context = 'Accounting Information'
              and organization_id = p_org_id ) ;  */
Line: 6783

  SELECT   action_date
  INTO l_cancel_date
  FROM     po_action_history        pah
  WHERE    pah.object_id            = p_po_header_id
  AND      ((pah.object_type_code   = 'PO'
  AND      pah.object_sub_type_code in ('PLANNED','STANDARD'))
  OR       (pah.object_type_code    = 'PA'
  AND      pah.object_sub_type_code in ('BLANKET','CONTRACT')))
  AND      pah.action_code          = 'CANCEL';
Line: 6824

  SELECT sum(AMOUNT_CANCELLED), pl.amount
  INTO l_canceled_amount, l_amount
        FROM po_line_locations_all pll,
             po_lines_all pl
        WHERE pll.po_line_id = p_po_line_id AND
        pll.po_header_id = p_po_header_id AND
        pl.po_line_id = pll.po_line_id AND
        pll.CANCEL_FLAG = 'Y'
        AND pll.shipment_type <> 'PREPAYMENT'  -- 
  group by pl.amount;
Line: 6842

        SELECT sum(AMOUNT_CANCELLED), pl.amount
        INTO l_canceled_amount, l_amount
        FROM po_line_locations_archive_all plla,
             po_lines_all pl
        WHERE plla.po_line_id = p_po_line_id AND
              plla.po_header_id = p_po_header_id AND
              plla.revision_num = p_po_revision_num AND
              pl.po_line_id = plla.po_line_id AND
              plla.CANCEL_FLAG = 'Y'
              AND plla.shipment_type <> 'PREPAYMENT'  -- 
              group by pl.amount;
Line: 6903

  SELECT NVL(poh.pending_signature_flag, 'N')
       , hou.name
  INTO x_pendingSignatureFlag
     , PO_COMMUNICATION_PVT.g_ou_name
  FROM po_headers_all poh
     , hr_all_organization_units hou
  WHERE poh.po_header_id = p_documentID
    AND hou.organization_id = poh.org_id;
Line: 6995

    SELECT poha.style_id
    INTO l_style_id
    FROM po_headers_archive_all poha
    WHERE poha.po_header_id = p_document_id
      AND poha.revision_num = p_revision_num;
Line: 7056

   SELECT INVENTORY_ORGANIZATION_ID
   INTO l_inventory_org_id
   FROM FINANCIALS_SYSTEM_PARAMETERS;
Line: 7104

     SELECT wf_item_type, wf_item_key
       INTO x_item_type, x_item_key
       FROM po_releases_all
      WHERE po_release_id = p_document_id;
Line: 7112

     SELECT wf_item_type, wf_item_key
       INTO x_item_type, x_item_key
       FROM po_headers_all
      WHERE po_header_id = p_document_id;
Line: 7210

	SELECT fds.long_text  INTO
	l_long
	FROM
	fnd_documents_long_text fds
	WHERE fds.ROWID= p_row_id;
Line: 7231

       SELECT location_id  into l_location_id FROM hr_locations
       where location_code=l_one_time_location;
Line: 7253

   SELECT fds.long_text
   INTO
    l_one_time_address_details
   FROM
   fnd_attached_docs_form_vl fad,
   fnd_documents_long_text fds
 	WHERE entity_name = 'PO_SHIPMENTS' AND
 	pk1_value =  To_Char(p_line_location_id) AND
    function_name = 'PO_PRINTPO'
    AND fad.media_id = fds.media_id
   AND fad.document_description like 'POR%'
   AND ROWNUM = 1;