Вы находитесь на странице: 1из 19

Oracle XML Publisher

Oracle XML Publisher is a template-based publishing solution delivered with the Oracle E-Business Suite. It provides a new approach to report design and publishing by integrating familiar desktop word processing tools with existing E-Business Suite data reporting. At runtime, XML Publisher merges the custom templates with the concurrent request data extracts to generate output in PDF, HTML, RTF, EXCEL (HTML), or even TEXT for use with EFT and EDI transmissions.

Classic Reporting Tools


The classic approach to reporting for example reports6i is to combine all of the elements of a report into a single entity, the data definition, the layout and the translation. This report file is very unwieldy and causes problems due to its inflexibility. If a report is required that has even a minor layout change then a new report (RDF) file must be created to support the new requirement even though the data definition is exactly the same. Also if another version of a report is required at runtime in a different language then also a new report file has to be created to support the new language. This approach leads to more time and expense in maintaining the report files. So oracle came up with a new concept called XML Publisher. XML Publisher breaks the three components apart and treats them separately at design time; at runtime the three are brought back together by XML Publisher to generate the final formatted, translated output. So tomorrow if any there is any change in layout we just need to add/modify the Layout file. This leads to less time and expense in maintaining the reports.

Data Logic Data extracted from database and converted into an XML string. Layout - The layout templates to be used for the final output are stored and managed in the Template Manager. These templates are created using familiar desktop tools such as MS Word, MS Excel or Adobe Acrobat Translation -The translation handler will manage the translation that is required at runtime

At runtime, XML Publisher merges your designed template files with the report data to create a variety of outputs to meet a variety of business needs, including: Customer-ready PDF documents, such as financial statements, marketing materials, contracts, invoices, and purchase orders utilizing colors, images, font styles, headers and footers and many other formatting and design options. HTML output for optimum online viewing. Excel output to create a spreadsheet of your report data. "Filled-out" third-party provided PDF documents. You can download a PDF document, such as a government form, to use as a template for your report. At runtime, the data and template produce a "filled-out" form. Flat text files to exchange with business partners for EDI and EFT transmission.

Requirements for XDO Reports (XML Data Objects)


1) Oracle XML Publisher Release 5.5 patch 4206181 2) Template Builder 5.5 Template builder is used to create template/layout for your report. Usually Template builder 5.5 is available in Oracle XML Publisher patch itself but you can also download it from http://edelivery.oracle.com. First select Oracle Application Server Products then select your platform and then locate the XML Publisher CD Pack, as below:

When you download the XML Publisher CD/Media Pack you get a Zip file containing two directories - XML Publisher Desktop, XML Publisher Server and a tutorial document. The Desktop install is an Install Shield installer that installs some components into Microsoft Word 2000 or higher.

After installing the Word add-in, when you open up Word you see an additional menu just below the toolbar. This menu lets you attach an XML data source document, add the XML data to your template, set preferences and preview the output.

Steps to Create XDO Reports:1) 2) 3) 4) 5) 6)

Create a procedure that will write XML tags into an Out file Create a concurrent Program that will call above mentioned procedure Create Template/Layout for the report using Template Builder Upload the Template/Layout into Oracle Application Run the Concurrent Program Republish the Report

1) Create a procedure that will write XML tags into an Out file Create a PL/SQL procedure that will fetch data from HR tables and write into an Out file in XML format. Please refer sample procedure
CREATE OR REPLACE PACKAGE Demo_XDO_pkg AS PROCEDURE Demo_RTF(o_errbuf OUT VARCHAR2 ,o_retcode OUT VARCHAR2 ); END Demo_XDO_pkg; CREATE OR REPLACE PACKAGE BODY Demo_XDO_pkg as PROCEDURE Demo_RTF( o_errbuf OUT VARCHAR2 ,o_retcode OUT VARCHAR2 ) AS /*Cursor to fetch Employee Records*/ CURSOR csr_employee IS SELECT papf.person_id prsn_id ,papf.full_name prsn_name ,employee_number emp_no ,pg.name grade FROM per_all_people_f papf, per_all_assignments_f paaf, per_grades pg WHERE papf.person_id=paaf.person_id AND paaf.grade_id=pg.grade_id AND paaf.assignment_type='E' AND paaf.primary_flag='Y' AND TRUNC(SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date AND TRUNC(SYSDATE) BETWEEN paaf.effective_start_date AND paaf.effective_end_date AND TRUNC(SYSDATE) BETWEEN NVL(pg.date_from,sysdate) AND NVL(pg.date_to,sysdate) AND papf.business_group_id=5603 AND ROWNUM<2; /*Cursor to fetch employees dependent(Children) records*/ CURSOR csr_children(p_person_id NUMBER) IS SELECT papf.person_id child_id ,papf.full_name child_name ,papf.date_of_birth dob FROM per_contact_relationships pcr, per_all_people_f papf

WHERE AND AND AND AND BEGIN

pcr.contact_person_id=papf.person_id pcr.person_id=p_person_id pcr.contact_type='C' TRUNC(SYSDATE) BETWEEN NVL(pcr.date_start,sysdate) AND NVL(pcr.date_end,sysdate) TRUNC(SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date;

/*First line of XML data should be <?xml version="1.0"?>*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<?xml version="1.0"?>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<PERDUMMY1>'); FOR v_employee IN csr_employee LOOP /*For each record create a group tag <G_EMP_NAME> at the start*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<G_EMP_NAME>'); /*Embed data between XML tags for ex:- <EMP_NAME>Abeesh</EMP_NAME>*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<EMP_NAME>' || v_employee.prsn_name || '</EMP_NAME>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<EMP_NO>' || v_employee.emp_no || '</EMP_NO>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<GRADE>' || v_employee.grade ||'</GRADE>'); FOR v_children IN csr_children(v_employee.prsn_id) LOOP /*For each child record create a group tag <G_NO_CHILD> at the start*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<G_NO_CHILD>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<CHILD_NAME>' || v_children.child_name || '</CHILD_NAME>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<CHILD_DOB>' || v_children.dob || '</CHILD_DOB>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<CHILD_CLASS> I</CHILD_CLASS>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<CHILD_SCHOOL>BHAVANS </CHILD_SCHOOL>'); FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<CHILD_FEES>100 </CHILD_FEES>'); /*Close the group tag </G_NO_CHILD> at the end of child record*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</G_NO_CHILD>'); END LOOP; /*Close the group tag </G_EMP_NAME> at the end of employee record*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</G_EMP_NAME>'); END LOOP; /*Finally Close the starting Report tag*/ FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'</PERDUMMY1>'); END Demo_RTF; END Demo_XDO_pkg;

2) Create a concurrent Program


Create an executable DEMOXDO2 that will call above mentioned procedure
Demo_XDO_pkg.Demo_RTF .

Go to Application Developer Responsibility -> Concurrent ->Executable

Create a new concurrent Program New Demo XDO Reports that will call above mentioned executable DEMOXDO2 Go to Application Developer Responsibility -> Concurrent ->Program

Add this new concurrent program to your Request Group.

From the appropriate responsibility, use the Submit Request form to run the concurrent request and cross check the XML output that is generated.

Note: We have not yet attached any Template Or layout to this concurrent program thats why Layout Block is Blank.

After executing the concurrent program click on Output button to view the XML string.

Now open the notepad and copy the XML string generated by concurrent program New XDO Reports into it. Save this file as Demo.xml on your desktop.

Note : Before saving the XML string in notepad remove the dashes -

3) Create Template/Layout for the report using Template Builder


Creating an RTF template file consists of two basic steps: a. Design your template layout. Use the formatting features of your word processing application and save the file as RTF. b. Mark up your template layout. Insert the XML Publisher simplified tags. a) Design your template layout Consider following template for report generation

Note the following: The data fields that are defined on the template For example: Name, Employee number, and Grade The elements of the template that will repeat when the report is run. For example, Name of Children, their date of birth , name of school and amount. All these fields on the template will repeat for each Employee that is reported. b) Mark up your template layout. Like a mail-merge document there's placeholders for the data you're going to add, and then you can add whatever formatting you like. Now the next step is to select Data > Load XML Data from the toolbar menu, then pick up the XML data a file ie. Demo.xml. Once the data is loaded, a "Data Loaded Successfully" dialog box comes up and you can then start adding data items to the template.

To add data items from the XML file into your report, you locate in the document the placeholder for the field you're going to add, highlight it and then select Insert > Field from the toolbar. A dialog box comes up with all of the available data items, you select the one you want and then press OK, like this:

You can add repeating rows into your document by selecting Insert > Table/Form from the toolbar. This brings up a different dialog box that lets you drag a parent node - in this case, "G_NO_CHILD" - into the middle section, which becomes your repeating rows.

For summation of amount field again select Insert > Field from the toolbar. Then Select the tag that needs to be summed and then select calculation as Sum.

Once you've done all this you end up with a template document with all your fields added, like this:

Note: You can then preview this report using the Preview toolbar menu item

4) Upload the Template/Layout into Oracle Application


Add XML Publisher Administrator Responsibility to your User. Using this responsibility you can upload the template.

a. First step is to Register your concurrent request as a Data Definition in the XML Publisher Template Manager. Go to XML Publisher Administrator-> Data Definitions-> Create Data Definition. Enter the required fields for data definition. Note : The data definition Code must match the concurrent programs short name. At runtime this allows the Concurrent Manager to provide the list of templates that are available for the concurrent program. For XML Schema field you can upload the sample xml i.e. DEMO.xml file

b. Register the template with template manager From the XML Publisher Administrator responsibility, navigate to the Create Template page. Navigation path: Templates > Create Template. When you register your template, you assign it an existing Data Definition. At publishing time, the concurrent managers Request Submission interface will present you with the list of available templates that have been registered for the Data Definition. Upload the RTF template file and select the language and territory.

Note: You can upload multiple templates for different language/territory combinations.

5) Run the concurrent Program


From the appropriate responsibility, use the Submit Request form to run the concurrent request. The default template is displayed in the Layout field. If you do not wish to use the default template, select the Options button.

In the Layout section of the Upon Completion window you can select the Template, Template Language, and output Format. From the Upon Completion window you can invoke XML Publishers Preview feature. If you loaded preview data with your Data Definition, select the Preview button to view a sample generated report in the selected template and output format. (Note that this action spawns an OA Framework page).

After submitting your request, use the Requests page to monitor the request and view the output. The figure below shows the completed request in PDF output.

6) Republish the report


The Concurrent Manager allows you to republish the data from a completed request with a different template, or new output type. From the Forms interface, select Reprint/Republish from the Tools menu. This action spawns an OA Framework page.

The Republish and Reprint Request page offers the following options: Republish and Print allows you to select a new template and output format for the completed request data. The data, layout, and output selections are sent to XML Publisher to republish the request data. This action spawns a new concurrent request. Republish and View this option allows you to select a new template and output format for the completed request data for viewing only. The formatting is performed without generating a new request. Reprint sends the published request to the selected printer

Вам также может понравиться