The oracle applications is continuously evolving with the use of new technologies. 
It is shifting from a traditional form based application to a self service web based application using Oracle Applications Framework (OAF) .
Every application requires a seamless integration with the reporting tools.
OA Framework seamlessly integrates with XML Publisher to fulfill the Oracle Applications reporting requirement.
In this article we will discuss in detail the integration of OA Framework and XML Publisher with an example.
It is assumed that the reader has basic understanding of OA Framework and XML Publisher.
The article has the following section
1) XML Publisher Architecture
2) Designing the OAF BC4J Data Model.
3) Designing the OAF Page and generating the Data XML
4) Designing the RTF Template using Data XML
5) Registering the Template with Oracle Applications.
6) Integrating the OAF page With XML Publisher.
7) Invoking the report from OAF
Step 1 : XML Publisher Reporting Architecture
An XML publisher report consist of a report template designed in RTF or PDF Formatand a Data XML file. The template contains the report layout. During execution the Data XML File is merged with the template to generate a PDF, HTML, EXCEL or RTF report.
SELECT empno,ename,job,mgr,hiredate,comm,deptno FROM emp
The Jdevloper should look like this
Step 3 : Generating the XML for Template Design
Design a OAF Page EmpPG with the Following Code in the Controller EmpCO.
EmpCO :
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModuleImpl am= (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
am.invokeMethod("initEmpVO");
am.invokeMethod("getEmpDataXML");
}
public void initEmpVO()
{
EmpVOImpl vo = getEmpVO1();
if(vo == null)
{
MessageToken errTokens[] = {
new MessageToken("OBJECT_NAME", "EmpVO1")
};
throw new OAException("AK", "FWK_TBX_OBJECT_NOT_FOUND", errTokens);
} else
{
vo.executeQuery();
}
}
{
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OAViewObject vo = (OAViewObject)findViewObject("EmpVO1");
((XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS)).print(outputStream);
System.out.println(outputStream.toString());
}
catch(Exception e)
{
throw new OAException (e.getMessage());
}
}
<EmpVORow>
<Empno>7369</Empno>
<Ename>SMITH</Ename>
<Job>CLERK</Job>
<Mgr>7902</Mgr>
<Hiredate>1980-12-17</Hiredate>
<Deptno>20</Deptno>
</EmpVORow>
<EmpVORow>
<Empno>7499</Empno>
<Ename>ALLEN</Ename>
<Job>SALESMAN</Job>
<Mgr>7698</Mgr>
<Hiredate>1981-02-20</Hiredate>
<Comm>300</Comm>
<Deptno>30</Deptno>
</EmpVORow>
<EmpVORow>
<Empno>7521</Empno>
<Ename>WARD</Ename>
<Job>SALESMAN</Job>
<Mgr>7698</Mgr>
<Hiredate>1981-02-22</Hiredate>
<Comm>500</Comm>
<Deptno>30</Deptno>
</EmpVORow>
</EmpVO>
Install the Oracle XML Publisher Desktop available via patch 5887917. Open the Microsoft word. You should be able to see the following menus and toolbars.
Using the Table Wizard as below to create the 'Table Report Format' with all the columns of EMP.
Login with a user having "XML Publisher Administrator" Responsibility.Navigate to Home --> Data Definition and define the data definition.
Design the EmpPG page to appear as shown below.
Set the Action Type and Event property of the Tourch Image Item to FireAction and GenerateReport respectively. Modify the Controller and ApplicationModule as below
Imports :
import oracle.xml.parser.v2.XMLNode;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import oracle.apps.xdo.XDOException;
import oracle.apps.xdo.oa.schema.server.TemplateHelper;
import oracle.cabo.ui.data.DataObject;
import oracle.jbo.XMLInterface;
EmpCO :
private static final int DEPTH = 4;
private static final int APP_ID = 20035;
private static final String APP_NAME = "XXIGS";
private static final String TEMPLATE_CODE = "Emp_Template";
private static final int BUFFER_SIZE = 32000;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModuleImpl am= (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
am.invokeMethod("initEmpVO");
}
{
super.processFormRequest(pageContext, webBean);
OAApplicationModuleImpl am= (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
String event = pageContext.getParameter("event");
if("GenerateReport".equals(event))
{
// Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
try {
ServletOutputStream os = response.getOutputStream();
// Set the Output Report File Name and Content Type
String contentDisposition = "attachment;filename=EmpReport.pdf";
response.setHeader("Content-Disposition",contentDisposition);
response.setContentType("application/pdf");
// Get the Data XML File as the XMLNode
XMLNode xmlNode = (XMLNode) am.invokeMethod("getEmpDataXML");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
xmlNode.print(outputStream);
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
//Generate the PDF Report.
TemplateHelper.processTemplate(
((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
APP_NAME,
TEMPLATE_CODE,
((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
inputStream,
TemplateHelper.OUTPUT_TYPE_PDF,
null,
pdfFile);
// Write the PDF Report to the HttpServletResponse object and flush.
byte[] b = pdfFile.toByteArray();
response.setContentLength(b.length);
os.write(b, 0, b.length);
os.flush();
os.close();
}
catch(Exception e)
{
response.setContentType("text/html");
throw new OAException(e.getMessage(), OAException.ERROR);
}
pageContext.setDocumentRendered(false);
}
EMpAMImpl :
public void initEmpVO()
{
EmpVOImpl vo = getEmpVO1();
if(vo == null)
{
MessageToken errTokens[] = {
new MessageToken("OBJECT_NAME", "EmpVO1")
};
throw new OAException("AK", "FWK_TBX_OBJECT_NOT_FOUND", errTokens);
} else
{
vo.executeQuery();
}
}
{
OAViewObject vo = (OAViewObject)findViewObject("EmpVO1");
XMLNode xmlNode = (XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS);
return xmlNode;
}
Run the EmpPG page and click on the tourch icon. The File Download window appear. Click on the Open Button to view the report.
written by Ritu , May 11, 2008
Awesome article. I had been requesting Anil to publish something on this integration for a long time.
Did you not leverage the XDOCommonRN in your integration?
This one is actually a better way I think, it provides more flexibility.
Ritu
written by Anil Passi , May 11, 2008
Indeed you and others requested this in past.
But given that I myself had learnt this technique from Prabhakar, I wanted Prabhakar to publish this himelf.
For those who don't know, when Prabhakar was in Oracle Corp, he had developed various complicated XMLP reports that could be invoked from OAF in realtime.
Cheers,
Anil Passi
written by Rishi , June 16, 2008
written by This e-mail address is being protected from spambots. You need JavaScript enabled to view it , July 08, 2008
pls Explain it step by step ?
and
iam not able to run this xdo page from Jdeveloper itslelf.
can you help me out to achieve that ?
written by Dev , July 23, 2008
I want to create a pdf template instead of rtf template for my report, and make some fields as editable.
The generated pdf output should have some fields as editable which anyone can fill and save through adobe reader.
I tried creating such pdf template through adobe acrobat but facing issues. When I create a template through xml publisher admin responsibility and attach my template, it errors out. Also, if I create a rtf template with pdf form fields in it, it generate a static pdf output.
Any help is greatly appreciated.
Thanks,
Dev
written by jyo , August 12, 2008
'could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded)'
Would be glad if you help me debug this error message.
Thanks
Jyo
written by jyo , August 12, 2008
I did all the above listed steps .
I made it in ak module so i changed private static final int APP_ID = 601;
I get prompted to open/save the pdf file . I click on Open, gives me the follwoing error :
'could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded)'
Would be glad if you help me debug this error message.
Thanks
Jyo
written by Danny Parrish , October 14, 2008
The step where you are getting your XML Data source, would it be possible to define another data source for it that is now part of the page definition? (For example, a Concurrent Request where the output is in XML). Thanks, Danny
written by Barozkok , October 27, 2008
I try to call a report with data. When I use template and data in English there is no problem. But Template in Turkish containing some characters different from Engilish I can see only the empty template. What can be the reason?
Thsnks.
written by Suresh1784 , October 27, 2008
when I try open the PDF file
could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded
Please advice what shoud I do?
Thanks
Suresh
written by Barozkok , October 29, 2008
If the template needs two different queries(some fields in report may be repeated), how can I combine two xml data produced by different queries(diiferent view objects)?
Thanks in advance.
written by Dean , November 19, 2008
Even I am getting the same error as some above
when I try open the PDF file
could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded
Please advice what shoud I do?
Thanks,
Dean
written by kishor nagbhire , December 09, 2008
i'm a new user of ur site
can u help me on that topic
i want record in GL
'''''' undefined accounting periods in the current accounting calendar '''''''''''
help me
thanks
written by Sreeramvaskuri , January 05, 2009
What exactly use of this code and where do i get a sessionParameters for assigning to this.
Is it automatically populated,or we have to write some code for this.
Could you please advice me.how to get these values.
// Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
written by PrathapReddy K , January 06, 2009
I am also getting the same error as "not a supported file or file has been damaged".
when I try open the PDF file
could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded
Please advice what to do?
Regards--
Prathapreddy.
written by PrathapReddy K , January 06, 2009
for the same code I tried to generate HTML type report.
it is showing the below mentioned error message and query
No corresponding LOB data found :SELECT L.FILE_DATA FILE_DATA,DBMS_LOB.GETLENGTH(L.FILE_DATA) FILE_LENGTH, L.LANGUAGE LANGUAGE, L.TERRITORY TERRITORY, B.DEFAULT_LANGUAGE DEFAULT_LANGUAGE, B.DEFAULT_TERRITORY DEFAULT_TERRITORY,B.TEMPLATE_TYPE_CODE TEMPLATE_TYPE_CODE, B.USE_ALIAS_TABLE USE_ALIAS_TABLE, B.START_DATE START_DATE, B.END_DATE END_DATE, B.TEMPLATE_STATUS TEMPLATE_STATUS, B.USE_ALIAS_TABLE USE_ALIAS_TABLE, B.DS_APP_SHORT_NAME DS_APP_SHORT_NAME, B.DATA_SOURCE_CODE DATA_SOURCE_CODE, L.LOB_TYPE LOB_TYPE FROM XDO_LOBS L, XDO_TEMPLATES_B B WHERE L.APPLICATION_SHORT_NAME= :1 AND L.LOB_CODE = :2 AND L.APPLICATION_SHORT_NAME = B.APPLICATION_SHORT_NAME AND L.LOB_CODE = B.TEMPLATE_CODE AND (L.LOB_TYPE = 'TEMPLATE' OR L.LOB_TYPE = 'MLS_TEMPLATE') AND ( (L.LANGUAGE = :3 AND L.TERRITORY = :4) OR (L.LANGUAGE = :5 AND L.TERRITORY = :6) OR (L.LANGUAGE= B.DEFAULT_LANGUAGE AND L.TERRITORY= B.DEFAULT_TERRITORY ))
Also I have a Doubt that where we are assigning the data to the "pdfFile"?
Regards--
PrathapReddy
written by Sreeramvaskuri , January 06, 2009
I am tried to generate a .Pdf file.It is generating,but without data.
could you please help me out,where i am wrong.
Thanks & Regards
Sreerama Vaskuri
written by PrathapReddy K , January 06, 2009
I found some sample to call the concurrent programm in the OAF Page.
I have some doubts, below is the details.
When I try to call the Concurrent program from my controller class it is showing the following error message
oracle.apps.fnd.cp.request.RequestSubmissionException: Cannot submit concurrent request for program POSReport
below is t code I used to call the Concurrent program.
OAException oaexception1 = null;
Number number = 123;
OADBTransaction oadbtransaction = am.getOADBTransaction();
Vector vector = new Vector();
vector.addElement(String.valueOf(number));
try
{
ConcurrentRequest concurrentrequest = new ConcurrentRequest(oadbtransaction.getJdbcConnection());
int i = concurrentrequest.submitRequest("AK", "POSReport", "", null, false, vector);
oadbtransaction.commit();
It is exactly giving the error at the calling of the *concurrentrequest.submitRequest*
Pls advise me how to overcome this.
Also where can we find the JavaDoc for all these classes?
Also will it shows the report of the concurrent request after execution?
Im trying to run this to generate a report.
I have registered the report In the Apps.
I want to call that report in the OAF page.
Regards--
PrathapReddy
written by Eric Smith , January 09, 2009
written by Talluri Ajay , January 24, 2009
I am trying to initantiate a Datatemplate using oracle.apps.xdo.oa.util.Datatemplate for a Data Definition that I have defined earlier.
Later I have imported xdo directory and included it in the library (using Project settings). Then I was getting an error for oracle.apps.fnd.i18n
I have imported the same onto my system and included in the library .
Now I am getting an error saying java.lang.NoSuchMethodError, msg=oracle.apps.fnd.i18n.common.text.resources.CalendarResourceAccessor.getEraResources()
What could be the reason for this error.
And apart from the xdo package what other libraries should we import
written by Somasekhar , January 26, 2009
At present i am wokring EAM Module. Here i need to call one XML Publisher report.
In my OAF Page one button is there. After clicking this button i need to fire one report(The name of the report is "Maintenance Picking Slip Issued Report").
Please help me how to call report? I don't have any idea how to proceed for this.please explain clearly.
Thanks in advance..
Thanks,
Somasekhar.
Thnaks,
Somasekhar
written by PrathapReddy K , January 28, 2009
The PDF report is openiing perfectly.
The problem is we need to add all the fnd and xdo classes in the classes folder when we are trying with JDeveloper, then it is working fine.
Now my question is can we able to open the PDF Report directly, instead it prompts us for save or open options.
I think this can be done by modifying the parameters for TemplateHelper.processTemplate method.
I tried and I am unable to get it. Can you help me regarding this.
Regards--
PrathapReddy
written by chanu , March 16, 2009
How will we print output in XML from OAF page.
As i cant get the OAF files from the server, what should i do to get output in XML from instance as u said "System.out.println".
I have Access to XML publisher administrator can i do anything there??
Regrards,
Chanu
written by Caleb Heidebrechtt , March 27, 2009
written by GsrC , April 03, 2009
I am able to prepare a xml publisher PDF report with single VO(select query) with the help of above steps where as in my requirement I required to write more then one VO(select querys). Can you give some ideas how to proceed?
--
GsrC
written by rkumar1836 , May 06, 2009
have anyone found the specific reason for this.
written by Anitha.veerappa , May 14, 2009
I uninstalled the Adobe reader, then the page showed me the real reason why it was not working. I was getting the error because I had written the method "getEmpDataXML" in the controller and was trying to call it from AM just like how the code here is doing. Once I got the exact error, I fixed the error and installed adobe reader and issue was resolved!
written by Anitha.veerappa , May 14, 2009
I have a custom xml publisher report already developed which is being run from the SR window. Now the client requirement is to call the same xml publisher from a self service page. The existing code is a PL/SQL code which queries and generates the xml tags for a appraisal_id (Primary key for the whole data) that is passed. Is there a way to reuse the same code, that is create callable statement and execute that procedure to get the xml data. What are the classes that are to be used to get such data from the procedure and convert it to XMLNode in the controller of the page?
written by Setu , May 26, 2009
Excellent article !!!
I have an query regarding the above test program. I tried following steps as detailed above and am stuck at Step 5
Step 5:
Code = EmpDataDefinition
Is "EmpDataDefinition" a concurrent program or VO name ? If not a concurrent program where to deploy it and how to register it ?
My goal to try to use OAF-VO instead of rdf reports for data-model in XMLP. Can this be done ?
Cheers,
Setu
written by new_member , June 02, 2009
I am new in OAF. I am trying create OAF to call xml publisher.
Coudl you send to me all source of steps above.
Many thanks for your helps
written by Dupo , July 09, 2009
Is there a way in OA Framework such that when the user clicks a link,a pdf file contaning the output of report or concurrent program should get fired. The pdf file path will be stored in unix and can find out the path from a table.
Any suggestions....
Please help me out
written by rohit15v , July 10, 2009
Even I am getting the same error as some above
when I try open the PDF file
could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded
Please advice it's very urgent.
if any one got solution plz send me my mail id: \n This e-mail address is being protected from spambots. You need JavaScript enabled to view it '> This e-mail address is being protected from spambots. You need JavaScript enabled to view it
written by rohit15v , July 10, 2009
written by Hieu , July 15, 2009
Even I am getting the same error as some above. When I try to open the pdf file "could not open because it either not a supported file oor because file has been damaged..."
Please advice, it is very urgent. If you have any solution, please send me through email: \n This e-mail address is being protected from spambots. You need JavaScript enabled to view it '> This e-mail address is being protected from spambots. You need JavaScript enabled to view it
written by Periyasamy Rajamanickam , August 05, 2009
Doc ID: 429990.1 How to Submit a Concurrent Request Using a Self-Service Page
written by Periyasamy Rajamanickam , August 05, 2009
Doc ID: 334847.1
Subject:How to add a report to a 11i Self Service Menu
One More Way,
It seems to Submit Active Users, we can add a button(Create a New Item) to a any page using personalization and call FNDCPPROGRAMPAGE,
Destination URI: OA.jsp?akRegionCode=FNDCPPROGRAMPAGE&akRegionApplicationId=0&programApplName=FND&programName=FNDSCURS
Prompt: Active Users Report
written by Venkatd , August 31, 2009
Thanks for such a nice article. We have followed this and worked on a prototype of a project and everything worked fine. We then enhanced this to actual project, which is based based two queries (master/detail). It is producing two independent xml documents. What we need is root elements which includes these two xml documents. We tried to add two string variables and concatenate them to outputstreams but were unsuccessful (may be due our limited knowledge of the java classes).
Could you advise what we can do to get desired output? I request Prabhakar, Anil and all Jdeveloper experts in the forum to suggest what we can do and appreciate all your inputs.
Thanks,
Venkat
written by putchakayala , December 24, 2009
I can able to generate the pdf file from one view object but in my case I have to generate the pdf file from multiple VOs .
can any one suggest me how to do?
thanx
Rama putchakayala
written by khalifa , December 28, 2009
when I try open the PDF file
could not open because it either not a supported file or because the file has been damaged(for example , it was sent as an email attachement and wasnt correctly decoded
Please advice what to do? or send it to my email
thx
khalifa
written by khalifa , December 28, 2009
written by khalifa , December 28, 2009
i did wha you tell me but the i still got "could not open because it either not a supported file or because the file has been damaged " when the PDF file opens
i really don't know what to do
thx
khalifa
written by heba , December 29, 2009
can anyone help me i follow the previos steps and the PDF was generated but when i tried to open it an error message appear " file has been damaged"
although i have XDO folder in my classes folder
did anyone solve this problem or it because version of jdeveloper
my email is \n This e-mail address is being protected from spambots. You need JavaScript enabled to view it '> This e-mail address is being protected from spambots. You need JavaScript enabled to view it
thx
heba
written by khalifa , January 03, 2010
i want to know if i can use the previous code to generate report based on multipule view objects meaning that the report will be in form of master detail
or is there any other way to do that ??
my email is \n This e-mail address is being protected from spambots. You need JavaScript enabled to view it '> This e-mail address is being protected from spambots. You need JavaScript enabled to view it
thx
khalifa
written by jyoti jain , January 27, 2010
public XMLNode getpayDataXML()
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ByteArrayOutputStream outputStream1 = new ByteArrayOutputStream();
MainVOImpl mv = getMainVO1();
Leave_BalanceVOImpl lb = getLeave_BalanceVO1();
XMLDocument doc = new XMLDocument();
Element root = doc.createElement("root");
Element per= null;
Element sal= null;
Element deduction= null;
Element tpay = null;
Element tded = null;
Element total = null;
Element days_present = null;
Element leave_balance = null;
Double paym = 0.0;
Double ded = 0.0;
Element dummy = null;
mv.executeQuery();
while(mv.hasNext())
{
//System.out.println("4");
per = doc.createElement("PersonRow");
String ch = "";
Row p1= mv.next();
String s[] = p1.getAttributeNames();
int c = p1.getAttributeCount();
//System.out.println("Count =" + c);
for (int i=0;i
written by jyoti jain , January 27, 2010
written by jyoti jain , January 27, 2010
written by Ambika , February 18, 2010
I have an RDF Report which generates the XML data and XML template registered in BI publisher.
Requirement is to fire the custom existing report instead of standard report.
The standard controller seems to generate XML and generate OA framework report as shown in your example.
But I want to extend the existing controller / overwrite the standard to call my custom report.
Can you tell me how to do this?






Good Article. I believe we can levarage this approach to view the output of XMLP report with the user desired output format like Excel/HTML/PDF.
By providing a LOV to select the output format and change the PFR to set that output to TemplateHelper.processTemplate
Using this approach we can overcome the restriction to default output (PDF) from SRS.
Thanks for sharing.