Login
Register

Home

Trainings

Fusion Blog

EBS Blog

Authors

Contact Us

OA Framework - All Articles
  • Register

Oracle Gold Partners, our very popular training packages, training schedule is listed here
Designed by Five Star Rated Oracle Press Authors & Oracle ACE's.

webinar new Click here to raise Support Ticket. Get reply within 48 hours.

Search Courses

User Rating: 3 / 5

Star ActiveStar ActiveStar ActiveStar InactiveStar Inactive
 

Hope you guys like my last article about “How To Get a PDF output on Button Click in OAF page in R12.2.X – using VO approach” as linked at Display PDF output from OAF – R12.2.X 

 

As I promised in my last article, I would share an approach of calling BI publisher /XDO report on button click in OAF page (R12.2.X). So this article talks about that approach. 

 

 

In a real time scenario oracle Report (RDF) can handle business complexity in an efficient manner by using formula column, summary column and even report trigger plays crucial role to handle our requirement and provide lots of options to developer. But the VO approach which I explained in my last article unfortunately is not very efficient to handle business complexity. 

 

Keeping into consideration, that you guys are expert enough to convert oracle RDF report into BI publisher/XDO, I will explain how to call XDO/BI Publisher report and display PDF output in OAF page. But if you are completely unaware about how to get data template from RDF, have patience I will help you guys in my next article.


But instead of going into much specific right now, a brief idea you can get from below screenshot

 

gen_pdgen pdf BI 01

 

From above screen you can easily figure out that we get 4 file after converting RDF


• Data Template file – Now create Data definition using XML publisher responsibility and upload XML file
• RTF file - As of now place it in local folder in your system. While in business scenario, you can move RTF file to server
• Compile package specification and body in data base.


Now our actual coding starts. We are not going to change our requirement; it would be same as of previous article.


Requirement: User wants a button in OAF page, which on click gives a PDF output.

 

gen_pdf_01.jpggen pdf 01

 

 

From above screenshot it is clear enough that we are going to use the RTF template and also the XML data.


In last article we get a XML data from VO, but now in this article our XML get generated by Data template rather than VO.

 

Step 1: Create an OAF page with button and text box with ID: EmpID to take input and also attach controller to page


Step 2: Place RTF file in C: drive

 

Step 3: Write below code in controller, prcocessFormRequest method

 

 

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

{
super.processFormRequest(pageContext, webBean);

//Get Session and Response
OAApplicationModule am= (OAApplicationModule)pageContext.getApplicationModule(webBean);
DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");

// Set the Output Report File Name and Content Type
String contentDisposition = "attachment;filename=EmpOutput.pdf";
response.setHeader("Content-Disposition",contentDisposition);
response.setContentType("application/pdf");

if(pageContext.getParameter("PrintPDFBtn") != null) {
try{

ServletOutputStream os = response.getOutputStream();

//Get Application context
AppsContext appsContext = ((OADBTransactionImpl)am.getOADBTransaction()).getAppsContext();

//Data Template Initilization
DataTemplate dataTemplate = new DataTemplate(appsContext, "<Application Short name>", "<Data Definition Code>");

//Getting and setting Parameters
Hashtable parameters = new Hashtable();
parameters.put("P_EMP_ID",pageContext.getParameter("EmpID"));
// ("<Data Template paramter which you want to pass to your query>",<OAF page item id>)

dataTemplate.setParameters(parameters);

//setting xml output to output stream
ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
dataTemplate.setOutput(localByteArrayOutputStream);
dataTemplate.processData();
ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(localByteArrayOutputStream.toByteArray());


//Calling RTF Processor
//RTF Processor generate XSL
RTFProcessor rtfProcessor = new RTFProcessor("C:\\EMPTemplate.rtf");
ByteArrayOutputStream xlsOutputStream = new ByteArrayOutputStream();
rtfProcessor.setOutput(xlsOutputStream);
rtfProcessor.process();


//Calling FO Processor
//FO processor take XML data and RTF as XSL and generate PDF output
FOProcessor processor = new FOProcessor();
ByteArrayOutputStream pdfOutputStream = new ByteArrayOutputStream();
processor.setData(xmlInputStream); //set xml input Stream
ByteArrayInputStream xlsInputStream = new ByteArrayInputStream(xlsOutputStream.toByteArray());
processor.setTemplate(xlsInputStream); //set xsl input file
processor.setOutput(pdfOutputStream);
processor.setOutputFormat(FOProcessor.FORMAT_PDF);

try{
processor.generate();
}catch(XDOException e){
e.printStackTrace();
}

// Write the PDF Report to the HttpServletResponse object and flush.
byte[] b = pdfOutputStream.toByteArray();
response.setContentLength(b.length);
os.write(b, 0, b.length);
os.flush();
os.close();
pdfOutputStream.flush();
pdfOutputStream.close();

}
catch(Exception e){
throw new OAException("Deepak kessarwaani="+e.getMessage(), OAException.ERROR);
}
}

}


Step 4: Run a page, give employee id in text box and on button click you will get PDF output

 

Note: In both of my approaches I place RTF at a fixed path. So from the maintainability point of view it would be tough challenge for the developer. If any changes are required in the RTF layout, developer has to pull the RTF from the server and make changes and move back to same path. Personally I won’t like this, and tried from my end all option to make the solution dynamic similar to Data Template. So any time if any changes are required in the RTF, developer can pull from XML publisher responsibility and move back the modified file. As we all know learning is a continued process and I am also in same boat. If any of you guys find a solution share with me, I would love to learn from you all!!!

 


Techie DK

Comments   

0 #1 Swadhin 2015-10-05 11:09
Is it possible to pass the ByteArrayInputS tream object xmlInputStream in TemplateHelper. processTemplate which may eliminate the need of local template on file system.

Thanks for the nice post.
Quote

Add comment


Security code
Refresh

About the Author

Techie DK

Search Trainings

Fully verifiable testimonials

Apps2Fusion - Event List

<<  Jun 2021  >>
 Mon  Tue  Wed  Thu  Fri  Sat  Sun 
   1  2  3  4  5  6
  7  8  910111213
14151617181920
21222324252627
282930    

Enquire For Training

Fusion Training Packages

Get Email Updates


Powered by Google FeedBurner