• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
An Insider to XML Publisher
 

An Insider to XML Publisher

on

  • 2,398 views

 

Statistics

Views

Total Views
2,398
Views on SlideShare
2,398
Embed Views
0

Actions

Likes
0
Downloads
122
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    An Insider to XML Publisher An Insider to XML Publisher Document Transcript

    • An Insider to XML Publisher Oracle XML Publisher has gained a lot of popularity among developersand also among the businesses as its very easy to create a report usingXML Publisher and even more easy to generate reports in variousformats like PDF, EXCEL, RTF etc.
    • A short guide to XML Publisher XML PublisherOracle XML Publisher has gained a lot of popularity among developers and also among the businesses as its very easy tocreate a report using XML Publisher and even more easy to generate reports in various formats like PDF, EXCEL, RTF etc.Oracle created XML Publisher is as a template based tool for publishing reports and much more along with Oracle E-business Suite. XML Publisher is powerful enough to populate the data fetched by a PL SQL package into a custom, yescustom, template and then generate the report in any of the desired form such as PDF, HTML, RTF, EXCEL (HTML) andeven PLAIN TEXT for transmission using EFT and EDI.Difference between Classical Reporting Tools and XML Publisher:The classical reporting tool had very different approach from that of XML Publisher e.g. in Report 6i used to combine allthe aspects of report generation i.e. the data definition, the report layout and the translation in to a single entity. In thiscase it became very complex and cumbersome even if the report needed minor changes. Also if the same report isrequired in another language then one more report needs to be generated in other language. All these and many morehiccups made Oracle to come up with XML Publisher.With XML Publisher things were very different in a positive way. XML Publisher treats all the three aspects of reportgeneration i.e. the data definition, the report layout and the translation separately at design time, but at run time all thethree aspects are brought together and the final report is generated. So if the report needs changes at the report layoutlevel then Data Definition and the Translation part are not supposed to be touched and only the Report Design can bechanged alone. This means less time and money is being spent in maintenance of these reports.The working of the XML Publisher can be understood with the help of the following diagram:Business Logic: In this part or aspect the required data (as per the business logic) is extracted/fetched from thedatabase and is converted in to XML Strings.Report Layout: In this aspect or section of the XML Publisher the layout or the template of the final report to begenerated is stored and Managed in the Template Manager. These layouts or template can be very easily created usingfamiliar word processing software like Microsoft Word, Microsoft Excel etc.Translation: The translation handler will manage the translation that is required at runtime. www.oracleappsframework.com www.oracleappsframework.com/blog 2
    • A short guide to XML PublisherHow to generate reports using XML PublisherPre-Requisites: 1. Oracle XML Publisher Release 5.5 or higher. 2. Template builder (Usually gets installed with Oracle XML Publisher 5.5 itself). 3. MS Office 2000 or higher to create templates. Steps to install XML Publisher: 1. Go to XML Publisher Desktop and double click the setup.exe, this will start the Install Shield Wizard which will guide you throughout the process 2. After the installation is completed Open MS Word, you will be able to see one more menu item named “Template Builder” as shown in the image below. This menu will enable you embed the XML data into your template, set many preferences and preview the output of the report. www.oracleappsframework.com www.oracleappsframework.com/blog 3
    • A short guide to XML PublisherSteps to generate a report using XML Publisher: 1. Create a PL SQL Package or Procedure that will fetch the required data as per the business requirement and then place the data to be displayed in XML tags into an output file. 2. Create an AOL concurrent program that will execute the PL SQL stored procedure created in step 1. 3. Create a template or the desired layout of the report to be generated using Template Builder. 4. Upload the finalized template or layout of the report to Oracle Application using XML Publisher Administrator responsibility. 5. Run the AOL concurrent program so that it in turn executes the PL SQL stored procedure to generate the data for the report. 6. Republish the Report.Now let’s elaborate each and every point mentioned above:  We will create a PL SQL package that will fetch the data from the data base tables and then populate the same data in to XML tags. Below is a simple example of such a PL SQL package./*Demo Package Specification*/ CREATE OR REPLACE PACKAGE Demo_XDO_pkg AS PROCEDURE Demo_RTF(o_errbuf OUT VARCHAR2,o_retcode OUT VARCHAR2 ); END Demo_XDO_pkg;/*Demo Package Definition*/ 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 www.oracleappsframework.com www.oracleappsframework.com/blog 4
    • A short guide to XML Publisher 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 employee’s 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 pcr.contact_person_id=papf.person_id AND pcr.person_id=p_person_id AND pcr.contact_type=C AND TRUNC(SYSDATE) BETWEEN NVL(pcr.date_start,sysdate) AND NVL(pcr.date_end,sysdate) AND TRUNC(SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date; BEGIN/*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 www.oracleappsframework.com www.oracleappsframework.com/blog 5
    • A short guide to XML Publisher/*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;  Now we will have to create an executable and attach the newly created executable to a concurrent program, so that the PL SQL stored procedure can be executed. We will name the executable as DEMOXDO2 that will call above mentioned procedure Demo_XDO_pkg.Demo_RTF. Here’s the navigation for creating an Executable Application Developer Responsibility -> Concurrent ->Executable www.oracleappsframework.com www.oracleappsframework.com/blog 6
    • A short guide to XML PublisherAlso we need to create a new concurrent Program say (“New Demo XDO Reports”) that will call above mentionedexecutable DEMOXDO2To create new concurrent program just go to Application Developer Responsibility -> Concurrent ->ProgramAttach the newly created Concurrent Program to a specific Request Group from where the Concurrent Program issupposed to run. This step can be understood from the screen shot below.www.oracleappsframework.com www.oracleappsframework.com/blog 7
    • A short guide to XML PublisherFrom the appropriate responsibility, use the Submit Request form to run the concurrent request and cross check theXML output that is generated.As you can see that the block mentioning the Layout is blank, this is because we haven’t yet attached any layout ortemplate to the report being generated. www.oracleappsframework.com www.oracleappsframework.com/blog 8
    • A short guide to XML PublisherOnce you run the concurrent program, click on the view output button so as to see the XML file along with the data thathas been generated as a result of the concurrent program run.Please save this XML file on your desktop computer with some name say (“Demo.xml”), but make sure that you removeall the dashes “-“ that appear in the file.  For the next step we will create a template which will act as the layout for the final report that will be generated soon. Creation of a template in itself is a two step process. 1. Designing the template as specified in the business requirement. 2. Marking up the XML template layout with the XML tags.Let’s have a look at how each step is supposed to be performed. 1. Designing the template as specified in the business requirement. For this step we need to use the Microsoft MS Word application to design a template and then save the template a “RTF” file on your desktop computer. A screen shot of a demo template is shown below for reference. www.oracleappsframework.com www.oracleappsframework.com/blog 9
    • A short guide to XML Publisher 2. Marking up the XML template layout with the XML tags. Once done with the creation of the template, we need to insert the XML tags into the template; these tags will be replaced by data at runtime. In order to achieve this go to the “Template Builder” menu and the select Data and then Load XML Data. We will be asked to select the XML data, remember the “Demo.xml” file that we have saved previously to our desktop computer? We just need to select that file. The next step is to add the XML tags to the report template layout; this is a very easy step and fun to do. In the report layout, locate the place where the data will be inserted at runtime, highlight that place and then from the “Template Builder” menu select the “Insert” menu and then select the “Field” item. This will open up a popup containing all the XML tags that we got in our “Demo.xml” file. Just select the appropriate tag and click on the “Insert” button. The screen shot below displays the insertion of “Emp_Name” tag into the report layout.www.oracleappsframework.com www.oracleappsframework.com/blog 10
    • A short guide to XML PublisherNote: 1. To insert the repeating tags into the XML report layout, we have to select the “Insert” and then “Table/Form” from the “Template Builder” menu. This will open a different popup window which will ask to select the parent node, in our case the parent node is “G_NO_CHILD”. The popup window opened by selecting “Insert”, and then “Table/Form” will look as shown in the screen shot below.Suppose we want to add the summation of a column also at some place in the report layout, then we need to select the“Insert” and then “Field” and then select the tag whose summation is supposed to be displayed. This will become clearby the following screen shot. www.oracleappsframework.com www.oracleappsframework.com/blog 11
    • A short guide to XML PublisherOnce all the above mentioned steps are over, our report template will look as the one shown in the below screen shot.XML Publisher gives you the freedom to preview the report before running it. But you must be thinking that we don’thave data, then how come we can preview the report? Remember the “Demo.xml” file that we have saved on ourdesktop? The data from the same file will be used to preview the report. To preview the report select “Preview” fromthe menu under “Template Builder” menu. www.oracleappsframework.com www.oracleappsframework.com/blog 12
    • A short guide to XML Publisher Add the report layout template in to Oracle Application. To achieve this we should have “XML Publisher Administrator” responsibility to the user. Using this responsibility we can add a template to the report. The process of adding a template to the report is again broken into steps for easy understanding and remembrance. Step- 1 Initially we have to register our concurrent request as a data definition. To achieve this go to XML Publisher Administrator -> Data Definitions -> Create Data Definition. Give a name to the data definition. The most important point to remember here is that, the data definition code (shown highlighted) should be the same as that of the concurrent program short name, as this allows the concurrent manager to get a list of templates that are available for that concurrent program at runtime. In the XML Schema field browse to the “Demo.xml” that we have save to our desktop. Here’s the screen shot of the Data Definition creation page with the data definition code highlighted.www.oracleappsframework.com www.oracleappsframework.com/blog 13
    • A short guide to XML Publisher Step- 2 now we will register our template with the use of template manager. Doing this is simple, go to the XML Publisher Administrator and then templates and Create Template. While registering the template we will be asked to assign an already existing Data Definition to it, hence we will assign the data definition that we have created in the previous step to our template. Then upload the RTF template layout and select the language and territory.www.oracleappsframework.com www.oracleappsframework.com/blog 14
    • A short guide to XML Publisher This will be the final step in the generation of the report. To complete this step, run the concurrent program from the appropriate responsibility. Since, we have attached the template to the concurrent program we can see that the Layout Block displays the name of the template that has been attached to the report. In the layout section of the submit request window we can select the template (if there are more than one template), template language and also the output format for the report to be generated. Also, from this window we can activate the XML Publisher’s preview feature.www.oracleappsframework.com www.oracleappsframework.com/blog 15
    • A short guide to XML Publisher Upon the completion of the concurrent program run click on the view output run button to view the final report that has been generated. Below screen shot shows the report generated in the PDF format. There are many other options also available on the Concurrent Manager menu. We can republish and print the report, we can even republish and view the report or simply we can reprint the report.www.oracleappsframework.com www.oracleappsframework.com/blog 16
    • A short guide to XML Publisher The difference between these actions is given below.  Republish and Print – This action allows us to select a new template and output format for the completed concurrent request data. The data, layout, and output selections are sent to XML Publisher to republish the request data.  Republish and View – this option allows us to select a new template and output format for the completed request data for viewing only. The formatting is performed without creating a new concurrent request.  Reprint – sends the published request to the selected printer Hope that this guide helps you. Thanks for reading www.oracleappsframework.com www.oracleappsframework.com/blogwww.oracleappsframework.com www.oracleappsframework.com/blog 17