Wednesday, 12 June 2013

How to retrigger PO Requisition Account Generator (in iProcurement)?


“PO Requisition Account Generator Workflow” (POWFRQAG) gets triggered to default the distribution accounts – and usually this WF is customized in most of the EBS implementation projects to support the business rule for defaulting charge account.
This process also gets retriggered automatically for change in some entities like (category, requestor etc.) depending on the line type of the PR. But the process does not retrigger for update in any other field (or DFF) in PR line and that’s where this extension is required.
This solution below will describe how to retrigger the “PO Requisition Account Generator Workflow” for change in ‘Quantity’ and this is limited to the iProcurement page [iProcurement >> Shopping Cart >> Checkout >> Requisition (Lines)] only – and it is not applicable to the ‘Requisitions’ Forms.

Solution Approach

All the fields for PR line are available in the entity object oracle.apps.icx.por.schema.server.PoRequisitionLineEO. The account generator gets retriggered for the attributes where the property AccountLineBizAttrSet is set to ‘Y’
So, here we need to extend the PoRequisitionLineEO to xxcusPoRequisitionLineEO to set the AccountLineBizAttrSet property of ‘Unit Price’ attribute to ‘Y’

Technical Details

Following steps to be done to address the customization:
  1. Copy and download entire directory structure and files from $JAVA_TOP/oracle/apps/icx
  2. To extend the PoRequisitionLineEO, create a new project and then open the package oracle.apps.icx.por.schema.server in the project. Now select the EO in the “Extends Entity” field.Save the new EO as xxcusPoRequisitionLineEO.

  1. Entity Object Wizard, click the “New from Table…” button and select your target attribute(s) [e.g. QUANTITY].  Click “OK”.  Accept the defaults for the rest of the steps in the wizard.
  1. In the System Navigator panel, highlight the EO created above.  The Structures panel will list all the attributes in the EO.
  1. Highlight the attribute QUANTITY in the Structures panel and the right-click to select the “Edit” option.  The Attribute Editor will come up. 
  2. Select Properties from the left-hand panel. Enter “AccountLineBizAttrSet” in the name field and “Y” in the value field.  Click “Add”, then Hit “OK” and save the changes.
  1. Now create the substitution for the parent (seeded) EO.


  1. Copy and to $JAVA_TOP/oracle/apps/icx/por/schema/server.
  2. Compile java files using javac command and change the permission of the class files to 777
  3. Copy xxcusPoRequisitionLineEO.xml $JAVA_TOP/oracle/apps/icx/por/schema/server and change the permission to 777
  4. FTP the substitution file xxcusIProc.jpx (in general this file is created under ‘MyClasses’ folder where the project is created) and execute the following command:
    java  $JAVA_TOP/oracle/apps/icx/por/schema/server/xxeocIProc.jpx -username apps -password <password> -dbconnection "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS= (COMMUNITY=TCP_COMMUNITY)(PROTOCOL=TCP)(Host= <host>)(Port=<port>)))(CONNECT_DATA=(SID= <sid>)))"
  1. Bounce OACORE and OC4J in the middle tire.

Tuesday, 4 June 2013

How to Send "To Supplier" Attachments with Purchasing Notifications

How can Header and Line level attachments of the type To Supplier be sent with the Supplier Notification, at time of Purchase Order Approval?


1.  Set-up the Purchasing Options:

    •  Navigate to Setup => Organization => Purchasing Options
    •  Set the Output format to:  PDF
    •  Set the Maximum Attachment Size in MB to any value that email server can handle(e.g. 10)
    •  Set the Email Attachment File name (for example

2.  Create an attachment file on ones system
     (Word Doc, Excel File, etc.)

3.  Create a Purchase Order (PO) with Attachments

     •  Navigate: Purchase Orders => Purchase Orders
     •  Enter the required data for the PO and save
     •  Add an attachment at the header level and attachment at line level
        (Use Attachments icon - Use  'To Supplier' as the Category)

     •  Click on Save
     •  Click on the Approval button
     •  In the Email field, enter the Supplier Email Address
     •  Submit the PO for Approval

4.  The email will be received at the address entered above
5.  Save the attached file attachment to ones desktop for review

Here is the Oracle Support Document for the same
R12: Sending "To Supplier" Attachments with Purchasing Notifications [ID 797329.1]


Sunday, 2 June 2013

How to Create Custom Customer Statement Report??

Client business needs to generate and send the statements with outstanding balance to their customers. Oracle eBS provides the functionality to generate the statement from ‘Receivables’ application:
Receivables > Print Documents > Statements

However, the output generated by the program (AR Customer Balance Statement Letter) needs to be formatted as per the business standard layout and additionally the output needs to be emailed to the customers based on the registered contacts.

Following section describes the seeded process and the constraints around the extension to cater the requirements.
Once the application user enters the statement data from the ‘Print Statement’ form and ‘Submit’ the program, it submits the ‘Statement Generation Program’ concurrent request.
This is a ‘Spawn’ process and it populates the temp tables based on the data entered by the user in the form.
Finally it submits the ‘AR Customer Balance Statement Letter’. This is a java concurrent program which executes the query in the temp table and generates the PDF output as per Oracle defined template. The SQL query is attached as a XML data template in its data definition in ‘XML Publisher Administrator’.
The data in the temp table is purged once the process is completed.

The navigation to Submit Customer Statement Print Documents -> Statements
Select the Operating Unit and then Select Cycle and Statement Date and Click Submit. It actually Submits AR Customer Balance Statement Program

The program is submitted in all installed languages concurrently.

To fulfill the requirement, following customizations are required:
1.      Create a new custom XML data template to include the new field ‘EMAIL_ID’ for the customer contact.
2.      Create a bursting control file so that the output PDF is split based on the ‘EMAIL_ID’.
3.      Upload the custom XML data template and the bursting control file to the data definition of the concurrent program ‘AR Customer Balance Statement Letter’ (identified by the short name ‘ARCUSBALSL’).
4.      Create a new rich text template (RTF) based on the proposed layout and upload the document to XML template related to the above data definition.
Thus the ‘AR Customer Balance Statement Letter’ will be submitted by the seeded process but it will execute the query in the custom data template and generate the output as per the custom layout. The bursting program will split and send the email to the intended recipients.
Oracle has restricted to upload any custom data template or bursting control file against the data definition ‘ARCUSBALSL’. Thus generic customization approach stated in above section can not be done in this case.
A parallel custom process (like ‘XXX AR Customer Balance Statement Letter’) can not be designed because it can’t be executed alone. It has to be submitted by the parent program ‘Statement Generation Program’, spawned from the ‘Print Statement’ form to generate all the data required for the report.

Since there was no alternative, the technical team has completed a PoC by altering seeded Oracle process which violates the Oracle standard practice of implementation.
This section highlights the steps to be done to implement the solution:
1.      Create a custom data definition (XX_ARCUSBALSL) and add new RTF layout.
2.      Download the XML data template ARXSGPO.xml and Save it as XX_ARXSGPO.xml.
-          Modify to add the new field ‘EMAIL_ID’ element
-          Add code in “beforeReport” trigger to update the template name in the table FND_CONC_PP_ACTIONS for the current request id.
   SET argument1 = 'XXCUSTOM'
      ,argument2 = 'XX_ARCUSBALSL'
 WHERE action_type = 6
   AND concurrent_request_id = P_CONC_REQUEST_ID;

By updating the FND_CONC_PP_ACTIONS table you ask Post Processor to pickup the custom Data Definitions and Templates
XXCUSTOM is the Custom Application Name
-          Add the code “AfterReport” trigger to execute the bursting program.
3.      Create a bursting control file for sending email.
4.      Attach the ‘XML data template’ and ‘Bursting Control File’ with the data definition XX_ARCUSBALSL.
5.      Now ARCUSBALSL (‘AR Customer Balance Statement Letter’) executes the java class oracle.apps.xdo.oa.cp.JCP4XDODataEngine (executable name XDODTEXE)      .
Create a new java class XXJCP4XDODataEngine to call the custom data definition ‘XX_ARCUSBALSL’ instead of the seeded data template.
Create a new executable XX_XDODTEXE with the new java program and attach it with the seeded concurrent program ‘ARCUSBALSL’.
6.      Thus the seeded ‘Statement Generation Program’ will invoke the ‘AR Customer Balance Statement Letter’ and this will execute the query in the custom XML data template to create desired PDF files which will be emailed by the bursting program.

The approach described above does not alter any process in ‘Statement Generation Program’. It is only altering the mechanism of producing output; yet there are some potential risks in this solution.
1. The executable of the seeded concurrent program ‘ARCUSBALSL’ is changed to a custom executable – so this can be reverted after the patch application.
2. New functionality will not be available after patch application since ‘ARCUSBALSL’ will be executing a custom query. Although this is not much relevant since for a custom report (which is a copy of seeded report with extended functionality) is never upgraded with the patch application.
3. Oracle Support may not be available for this program.
1. A script will be provided which can be executed as a post patching activity. This script will replace the seeded executable with the custom one.
2. If ARXSGPO.xml is upgraded then XX_ARXSGPO.xml can be rebuild based on that. This is however may not require at all.
3. In case of any issue in live instance, it can be reproduced in any support instance by replacing the executable of the concurrent program with the seeded one. Then it can be observed if there is issue exists with the seeded process and accordingly it can be reported to the Oracle Support.


How to use Hook to print custom PO Report???

When PO is submitted for approval , in the PDF generation flow standard XML is generated by the routine POXMLGEN in package PO_COMMUNICATION_PVT (file: POXVCOMB.pls). In order to support the custom extensions in the XML generation logic a new custom hook GENERATE_XML_FRAGMENT in package PO_CUSTOM_XMLGEN_PKG is added. This new procedure will be called from the standard XML generation logic - POXMLGEN. In order to have this hook available in the PO_COMMUNICATION_PVT the Patch set: 14677799:R12.PO.B [Metal ink ID: 1505737.1] should be available in environment.

The custom hook has the following logic:
-          Generate XML from the custom source under the tag PO_CUSTOM_DATA.
The returned XML will be merged into the standard XML and it will be sent to the publisher for rendering the template.


1.       Before extending the custom hook, check if the requirement can be met by the standard XML itself. One option could be to use the DFF attributes to capture the required attribute. It is recommended to use the standard XML attribute instead of extending the hook wherever applicable. In this case, the customer is trying to determine the Legal Entity name based on a different attribute (instead of using the default legal entity for that operating unit).
2.       Backup the custom hook source files. Modify the custom hook source files to generate the custom XML based on the custom source (refer the example below). The XML can be either hand built or generated using the dbms_xml routines. Make sure that
a)     the XML is complete (match the tags)
b)     No invalid characters in the XML
Exceptions are handled gracefully

Below is the sample code for generating Custom XML for Std PO 
   PROCEDURE generate_xml_fragment (
      p_document_id        IN              NUMBER,
      p_revision_num       IN              NUMBER,
      p_document_type      IN              VARCHAR2,
      p_document_subtype   IN              VARCHAR2,
      x_custom_xml         OUT NOCOPY      CLOB
      --1). Declare context
      CONTEXT           DBMS_XMLGEN.ctxhandle;
      context1          DBMS_XMLGEN.ctxhandle;
      w_document_type   VARCHAR2 (1000);
      -- Custom Function
      w_document_type := PO_COMMUNICATION_PVT.getdocumenttype ();

             --- Query for Standard PO
         CONTEXT := DBMS_XMLGEN.newcontext
       TO_CHAR(ph.creation_date,''fmddth Month YYYY'')      xx_order_date,
       TO_CHAR(ph.start_date,''fmddth Month YYYY'')         xx_aggrement_start_date,
       TO_CHAR(ph.end_date,''fmddth Month YYYY'')           xx_aggrement_end_date ,
          (NVL (ph.bill_to_location_id, -1),
           -1, NULL,
           PO_COMMUNICATION_PVT.getlocationinfo (ph.bill_to_location_id)
          ) bill_to_location_id, 
       DECODE (NVL (ph.ship_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getlocationname ()
              )||chr(10) bill_to_location_name,
       ''Email : ''||pap1.email_address ap_email,       
       DECODE (NVL (ph.bill_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressline1 ()
              )||chr(10) bill_to_address_line1,
       DECODE (NVL (ph.bill_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressline2 ()
              )||chr(10) bill_to_address_line2,
       DECODE (NVL (ph.bill_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressline3 ()
              )||chr(10) bill_to_address_line3,
       DECODE (NVL (ph.bill_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressline4 ()
              ) bill_to_address_line4,
       DECODE (NVL (ph.bill_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressinfo ()
              )||chr(10) bill_to_address_info,
       DECODE (NVL (ph.bill_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getterritoryshortname ()
              )||chr(10) bill_to_country,                   
       DECODE (NVL (ph.ship_to_location_id, -1),
           -1, NULL,
           PO_COMMUNICATION_PVT.getlocationinfo (ph.ship_to_location_id)
          ) ship_to_location_id,
       DECODE (NVL (ph.ship_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressline1 ()
              )||chr(10) ship_to_address_line1,
       DECODE (NVL (ph.ship_to_location_id, -1),
               -1, NULL,
               PO_COMMUNICATION_PVT.getaddressline2 ()
              )||chr(10) ship_to_address_line2,
       CURSOR(SELECT xx_po_long_text_f(fad.media_id, ''SHORTTEXT'') xx_to_supplier_text 
                 FROM fnd_attached_docs_form_vl fad
                WHERE fad.pk1_value(+)     = TO_CHAR(ph.po_header_id)
                  AND entity_name          =''PO_HEADERS''
                  AND Category_Description =''To Supplier''
                  AND function_name        =''PO_POXPOEPO''
                  AND datatype_name        = ''Short Text''
              ORDER BY fad.seq_num ASC
               )                                                                       hdr_short_text,
       CURSOR (SELECT xx_po_long_text_f(fad.media_id, ''LONGTEXT'') xx_to_supplier_text
                 FROM fnd_attached_docs_form_vl fad
                WHERE fad.pk1_value(+)     = TO_CHAR(ph.po_header_id)
                  AND entity_name          = ''PO_HEADERS''
                  AND category_description = ''To Supplier''
                  AND function_name        = ''PO_POXPOEPO''
                  AND datatype_name        = ''Long Text''
              ORDER BY fad.seq_num ASC
               )                                                                        hdr_long_text,
              SELECT pl.line_num                                                        line_num, 
                     item_description                                                   item_description, 
                     (pl.note_to_vendor||chr(10))                                       line_note_to_vendor,
                     pl.unit_meas_lookup_code                                           unit_meas_lookup_code,
                     TRIM(TO_CHAR(pl.unit_price,''999,999,999,999.99''))                unit_price, 
                     TRIM(TO_CHAR(pl.quantity,''999,999,999,999.99''))                  quantity, 
                           (NVL (pll.ship_to_location_id, -1),
                            -1, NULL,
                            PO_COMMUNICATION_PVT.getlocationinfo (pll.ship_to_location_id)
                            )                                                           ship_to_location_id,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getlocationname ()
                            )                                                           xx_ship_to_location_name,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getaddressline1 ()
                            )                                                           xx_ship_to_address_line1,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getaddressline2 ()
                            )                                                           xx_ship_to_address_line2,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getaddressline3 ()
                            )                                                           xx_ship_to_address_line3,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getaddressline4 ()
                            )                                                           xx_ship_to_address_line4,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getaddressinfo ()
                            )                                                           xx_ship_to_address_info,
                     DECODE (NVL (pll.ship_to_location_id, -1),
                             -1, NULL,
                             PO_COMMUNICATION_PVT.getterritoryshortname ()
                            )                                                           xx_ship_to_country,
                     TO_CHAR (pl.committed_amount)                                      committed_amount,
                     TRIM(TO_CHAR((pl.QUANTITY * pl.unit_price),''999,999,999,999.99''))line_amount,
                     TO_CHAR (NVL (pll.need_by_date, pll.promised_date), ''dd/mm/yyyy'') due_date,
                     CURSOR (
                             SELECT xx_po_long_text_f(fad.media_id,''SHORTTEXT'') to_supplier_line_text
                               FROM fnd_attached_docs_form_vl fad
                              WHERE fad.pk1_value(+)     = TO_CHAR(pl.po_line_id)
                                AND entity_name          = ''PO_LINES''
                                AND category_description = ''To Supplier''
                                AND function_name        = ''PO_POXPOEPO''
                                AND datatype_name        = ''Short Text''
                           ORDER BY fad.seq_num ASC
                            ) line_short_text,
                     CURSOR (
                             SELECT xx_po_long_text_f(fad.media_id,''LONGTEXT'') to_supplier_line_text
                               FROM fnd_attached_docs_form_vl fad
                              WHERE fad.pk1_value(+)     = TO_CHAR(pl.po_line_id)
                                AND entity_name          = ''PO_LINES''
                                AND category_description = ''To Supplier''
                                AND function_name        = ''PO_POXPOEPO''
                                AND datatype_name        = ''Long Text''
                           ORDER BY fad.seq_num ASC
                            ) line_long_text
                FROM po_line_types_b       plt,
                     po_lines_all          pl,
                     po_line_locations_all pll
               WHERE pl.line_type_id           = plt.line_type_id
                 AND pl.po_line_id             = pll.po_line_id
                 AND ph.po_header_id           = pl.po_header_id
                 AND pll.po_header_id          = pl.po_header_id
                 AND pll.po_header_id          = ph.po_header_id
                 AND NVL(pl.cancel_flag,''N'') = ''N''
                 AND NVL(pll.cancel_flag,''N'')= ''N''
              ) as xx_lines
       FROM  po_headers_all              ph,
             hr_operating_units          hou,
             fnd_lookup_values           plc,
             ap_suppliers                vn,
             ap_supplier_sites_all       pvs,
             hr_all_organization_units   hao,
             hr_locations                hl,
             fnd_territories_vl          ftv,
             fnd_common_lookups          fcl,
             fnd_territories_tl          fte3,
             po_agents                   pa,
             fnd_currencies_tl           fcc,
             ap_terms                    at,
             apps.fnd_attached_documents fadf,
             apps.fnd_lobs               fl,
             fnd_documents               fd,
             per_phones                  pph,
             per_phones                  pph1,
             per_phones                  pph2,
             per_all_people_f            pap,
             per_all_assignments_f       paa,
             per_jobs                    pj,
             per_all_people_f            pap1,
              SELECT fll2.attribute10, 
                     fll2.lookup_code ou_code
                FROM fnd_lookup_values fll2
               WHERE fll2.lookup_type   = ''xx_CUSTOM_LOOKUP''
                 AND fll2.enabled_flag  = ''Y''
                 AND TRUNC(SYSDATE)     BETWEEN TRUNC(fll2.start_date_active) 
                                           AND TRUNC(NVL(fll2.end_date_active, SYSDATE))
             ) ap_email,
              SELECT fl3.lookup_code,
                FROM fnd_lookup_values fl3
               WHERE fl3.lookup_type     = ''xx_PO_PAY_ON_TO_PREFIX_MAP''
                 AND fl3.enabled_flag    = ''Y''
                 AND TRUNC(SYSDATE)      BETWEEN TRUNC(fl3.start_date_active) 
                                                AND TRUNC(NVL(fl3.end_date_active, SYSDATE))
              ) pay_lookup
       WHERE   ph.org_id                     = hou.organization_id
         AND                      = plc.lookup_code(+)
         AND   plc.lookup_type(+)            =''xx_CUSTOM_LOOKUP''
         AND   NVL(plc.enabled_flag,''N'')   = ''Y''
         AND   TRUNC(SYSDATE)                BETWEEN NVL(plc.start_date_active,TRUNC(SYSDATE))
                                                    AND NVL(plc.end_date_active,TRUNC(SYSDATE))
         AND   vn.vendor_id                  = ph.vendor_id
         AND   pvs.vendor_site_id            = ph.vendor_site_id
         AND   hou.organization_id           = hao.organization_id
         AND   hao.location_id               = hl.location_id
         AND                    = ftv.territory_code
         AND   hl.region_1                   = fcl.lookup_code(+)
         AND   fcl.lookup_type(+)            = ''IE_COUNTY''
         AND   fcl.language(+)               = USERENV(''LANG'')
         AND   NVL(fcl.enabled_flag,''N'')   = ''Y''
         AND   TRUNC(SYSDATE)                BETWEEN NVL(fcl.start_date_active,TRUNC(SYSDATE)) 
                                                    AND NVL(fcl.start_date_active,TRUNC(SYSDATE)) 
         AND   fcl.lookup_type               = ''IE_COUNTY''
         AND                   = fte3.territory_code(+)
         AND   fte3.language                 = USERENV(''LANG'')
         AND   pa.agent_id                   = ph.agent_id
         AND   fcc.currency_code             = ph.currency_code
         AND   fcc.language                  = USERENV(''LANG'')
         AND   ph.terms_id                   = at.term_id(+)
         AND   pay_lookup.lookup_code(+)     = pvs.pay_on_code
         AND   fadf.pk1_value(+)             = ph.agent_id
         AND   fd.document_id(+)             = fadf.document_id
         AND   fd.media_id                   = fl.file_id(+)
         AND   fadf.entity_name(+)           = ''Xxx_PO_BUYER_SIGNATURE''
         AND   pph.parent_id(+)              = pap.person_id
         AND   pap.person_id                 = ph.agent_id
         AND   pph.parent_table(+)           = ''PER_ALL_PEOPLE_F''
         AND   pph.phone_type(+)             = ''W1''
         AND   pph1.parent_id(+)             = pap.person_id
         AND   pph1.parent_table(+)          = ''PER_ALL_PEOPLE_F''
         AND   pph1.phone_type(+)            = ''M''
         AND   pph2.parent_id(+)             = pap.person_id
         AND   pph2.parent_table(+)          = ''PER_ALL_PEOPLE_F''
         AND   pph2.phone_type(+)            = ''WF''
         AND   ap_email.attribute10          = pap1.employee_number(+)
         AND                      = ap_email.ou_code(+)
         AND   ph.authorization_status       = ''APPROVED''
         AND   NVL(ph.cancel_flag,''N'')     = ''N''
         AND   pap.person_id                 = paa.person_id
         AND   paa.job_id                    = pj.job_id
         AND   TRUNC (SYSDATE)               BETWEEN NVL(pap1.effective_start_date,TRUNC(SYSDATE)) 
                                                    AND NVL(pap1.effective_end_date,TRUNC(SYSDATE))
         AND   TRUNC (SYSDATE)               BETWEEN NVL(pap.effective_start_date,TRUNC(SYSDATE))  
                                                    AND NVL(pap.effective_end_date,TRUNC(SYSDATE))
         AND   TRUNC (SYSDATE)               BETWEEN NVL (pph.date_from, TRUNC (SYSDATE))   
                                                    AND NVL (pph.date_to, TRUNC (SYSDATE))
         AND   TRUNC (SYSDATE)               BETWEEN NVL (pph2.date_from, TRUNC (SYSDATE))  
                                                    AND NVL (pph1.date_to, TRUNC (SYSDATE))
         AND   TRUNC (SYSDATE)               BETWEEN NVL (pph2.date_from, TRUNC (SYSDATE))  
                                                    AND NVL (pph2.date_to, TRUNC (SYSDATE))                  
         AND   ph.po_header_id               = PO_COMMUNICATION_PVT.getDocumentId()
         AND   EXISTS (SELECT ''X''
                         FROM  fnd_user fu
                              ,po_agents buyer
                              ,per_all_people_f pap_buyer
                        WHERE  fu.user_id     = FND_GLOBAL.user_id
                          AND  fu.employee_id = buyer.agent_id
                          AND  buyer.agent_id = pap_buyer.person_id
                          AND  TRUNC (SYSDATE) BETWEEN NVL(pap_buyer.effective_start_date,TRUNC(SYSDATE)) 
                                                      AND NVL(pap_buyer.effective_end_date,TRUNC(SYSDATE))
         --3). Set XML tag of the XML fragment for the result set
         DBMS_XMLGEN.setrowsettag (CONTEXT, 'PO_CUSTOM_DATA');
         --4). Set XML tag for each row of the result set
         DBMS_XMLGEN.setrowtag (CONTEXT, 'CUSTOM_PO');
         DBMS_XMLGEN.setconvertspecialchars (CONTEXT, TRUE);
         --5). Call dbms_xmlgen to get XML and assign it to output CLOB
         x_custom_xml := DBMS_XMLGEN.getxml (CONTEXT, DBMS_XMLGEN.NONE);
         DBMS_XMLGEN.closecontext (CONTEXT);