80
XML REPORTS XML REPORTS With Screen shots Jainullabuddin B Jainullabuddin B Page 1

XML Basics1

Embed Size (px)

Citation preview

Page 1: XML Basics1

XML REPORTS

XML REPORTSWith Screen shots

Jainullabuddin B

Jainullabuddin B Page 1

Page 2: XML Basics1

XML REPORTS

INDEX

TITLEINTRODUCTIONVERSION OF XMLCREATING AN ORDINARY XML REPORTINSERTING INDIVIDUAL FIELDSGETTING TWO KIND OF OUTPUT AT A TIMERTF TEMPLATECREATING XML REPORT USING PROCEDURES

ERRORS FACEDSUMMARY

Jainullabuddin B Page 2

Page 3: XML Basics1

XML REPORTS INTRODUCTION

Oracle XML Publisher is a template-based publishing solution delivered with the Oracle E- Business Suite. XML Publisher is a tool which enables the users to produce

FlexibleHigh QualityTemplate-Based Reports

The main feature of XML Publisher is that it separates the Data Source from the presentation/Layout

XML Publisher enables user to design the check layout using Microsoft word or Adobe Acrobat

XML Data

RTF

One Template – Multiple Outputs

PDF

HTML

EXCEL

XML Publisher

RTF Templates are converted to XSL-FO, then formatted to multiple outputs

BENEFITS OF XML PUBLISHER

Jainullabuddin B Page 3

Reportoutput

Data Logic

Layout

Translationn

XML Publisher

Page 4: XML Basics1

XML REPORTS • Simplicity of Usage : It reduces the coding effort as the final output generation is

handled by XML Publisher. The developer has to concentrate only on developing the report logic

• Reusability : Single code can be used to generate output in Excel/PDF/RTF and other formats.

• Language Translations • Standard Image Inclusion : Images or logos can be embedded while template creation,

reference can also be made directly to gif/jpg images • Flexibility• Reduced Maintenance• Less labor intensive• Lesser Costs

VERSION OF XMLVersion 5.6 Build 45

Another way to find the VersionPDF Output : open the file in Adobe Acrobat-> menu File  -> Document Properties    -> tab Description       -> property ‘PDF Producer’ will show

Jainullabuddin B Page 4

Page 5: XML Basics1

XML REPORTS

1. CREATING AN ORDINARY XML REPORT

Create a Report using a Query in .rdf format.STEP1: Open the Report Builder and Select the option to build the report manually.The Query used is to bring the items created after 01-Jan-2008

SELECT inventory_item_id, segment1, description, creation_date FROM mtl_system_items_b WHERE creation_date > TO_DATE ('01-JAN-2008') AND organization_id = 204

Connect as apps/apps@prodCreate the Layout. [Actually, there is no need to create layout for XML report. Here, we have created it for demo purpose.]The Output will be like this.

Jainullabuddin B Page 5

Page 6: XML Basics1

XML REPORTS

Save this Report in the Inventory Top.

This is saved as D:\oracle\prodappl\inv\11.5.0\reports\US\xinv.RDF

STEP2: Generate XML File

Jainullabuddin B Page 6

Page 7: XML Basics1

XML REPORTS It will ask the location to save. It is saved as E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ xinv.xml

This is the XML coding for the RDF File.

STEP 3: CREATE XML TEMPLATE Now, we have to create a template for Output. For this open Microsoft word.

If XML was installed in Your system, You can see this.

Now Load the XML data.

Jainullabuddin B Page 7

Page 8: XML Basics1

XML REPORTS

Jainullabuddin B Page 8

Page 9: XML Basics1

XML REPORTS

You will get the result as

Create the Template.

Here, we are inserting all those fields. So, Select All Fields.You will get the layout as Follows

Jainullabuddin B Page 9

Page 10: XML Basics1

XML REPORTS

This is the Template, we have created. Save this as rtf file [Rich Text Format]. E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xtemplate1.rtf. You can see the preview here.

The output is in .pdf format because, we have selected the pdf format.

Jainullabuddin B Page 10

Page 11: XML Basics1

XML REPORTS

STEP4: REGISTER THE REPORT IN APPS

Open the Application. Goto System Administrator Responsibility. Create the Executable

Jainullabuddin B Page 11

Page 12: XML Basics1

XML REPORTS

Save it. Create the Concurrent Program

Jainullabuddin B Page 12

Page 13: XML Basics1

XML REPORTS

Save it.Now, we have to find the Request Group Name.

Query for Inventory, Vision Operations (USA)

Jainullabuddin B Page 13

Page 14: XML Basics1

XML REPORTS

Now, Add this Report to the Inventory request Group.

Query for Your Request group and Add the New Program.

Jainullabuddin B Page 14

Page 15: XML Basics1

XML REPORTS

Save It.Go to Inventory Responsibility.

Run the Program

You will get the result in the XML Format.

Jainullabuddin B Page 15

Page 16: XML Basics1

XML REPORTS

But this is not the format, we require. This was generated, because, we have not attached the template (Which we created) anywhere.

STEP5 : ATTACHING THE TEMPLATE Now GO to XML Publisher Administrator responsibility

Jainullabuddin B Page 16

Page 17: XML Basics1

XML REPORTS If You don’t have the XML Publisher Admin responsibility, Add it. This is explained in a separate sheet. E:\Selvam\Selvam P.S\Materials\Screen Shots\Selvam\Adding responsibility to a User.doc

Creating the Data De nitionWhen you create the data definition, you register the source of the data that will be merged with your template layout to create your published report.

We have to create the Data Definition Now.

By Default, it will be in the query mode. So Click CREATE DDF

Jainullabuddin B Page 17

Page 18: XML Basics1

XML REPORTS

One Important thing here is, Give the Code name same as the Conc Prgm Short Name in caps. Else it will not give the result.

If you are using the Oracle Applications concurrent manager to generate your report, the data definition Code must match the concurrent program short name of the report program (for example, RAXCUS for the Customer Listing Summary). This enables the concurrent manager to locate the templates available for the report concurrent program when you submit the request.

After the data definition is created, all the fields are updateable except Application and Code

Creating the TemplateWhen you create a template, you assign it a data definition and upload your template

layout files. Assigning the data definition makes the template available to the corresponding data source at runtime.

Now Attach the Template,

Jainullabuddin B Page 18

Page 19: XML Basics1

XML REPORTS

After the template definition is created, the following fields are not updateable: Application, Code, and Type

Now, you Run the Report in the Inventory Responsibility

Jainullabuddin B Page 19

Page 20: XML Basics1

XML REPORTS

If You see the output, it will come in the Format we have give. Here we have given as PDF

This is the Simple way of creating the XML Report.

POINTS TO REMEMBER

Jainullabuddin B Page 20

Page 21: XML Basics1

XML REPORTS If You have modified anything in the template, then update it in XML Template. Use Update button and Browse Button. Else it will work in the previously registered template only.

If You Click Download Button,

The corresponding RTF file will be opened

2. INSERTING INDIVIDUAL FIELDSIn the Previous Example, we have inserted all the field directly, by Giving Insert All Fields

In this situation, All the fields will be inserted directly. If we require some selected fields only, we can do it. For this, we have to do some modifications in the template. Here, we create a new template.

Open a word document. Load the Data as told beforeDraw a Layout by using Insert Table.

After drawing table, Type the Following things and keep ready the template.

Jainullabuddin B Page 21

Page 22: XML Basics1

XML REPORTS

This is just a skeleton, we have to insert the fields now.

You will get the options now

Now, Insert as per Your requirements

Jainullabuddin B Page 22

Page 23: XML Basics1

XML REPORTS

After inserting all those, Save the File in rtf format. E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xtemplate2.rtfYou can see the Preview now.

You will get only one row in this report. Because, we have nowhere specified to repeat for the next lines. For that we have to write one tag. You can see the tag in the automatically created tag.

We have to write it manually now. If You double-click it, You can see the tag.

Jainullabuddin B Page 23

Page 24: XML Basics1

XML REPORTS

You will see the tag now

For End Group,

Jainullabuddin B Page 24

Page 25: XML Basics1

XML REPORTS

Now Insert these codes in the newly created templates.

You can see the preview now.

Jainullabuddin B Page 25

Page 26: XML Basics1

XML REPORTS

You can test it by running in the Apps Also.

For this You have to make changes in the XML Publisher Templates only. You can create a new template also.

You can see that two templates are attached

Jainullabuddin B Page 26

Page 27: XML Basics1

XML REPORTS

Now Run the report in APPS.

You can see that the Old template was added here. If, You need to change this one,

Jainullabuddin B Page 27

Page 28: XML Basics1

XML REPORTS

Don’t Forget to Give OK.Now, Give Submit.If You give the Output,

Jainullabuddin B Page 28

Page 29: XML Basics1

XML REPORTS

The Output was got in the HTML Format.

3. GETTING TWO KIND OF OUTPUT AT A TIMEThe Unique feature of XML Report is to get two kind of reports at a time. For this, we have to do a minor Modification. Here, Let us imagine that there is a situation to get both the templates at a time. [Manager1 is asking a report in PDF format and Manager2 is asking a report in Excel format].

While Submitting a report, You can see the Layout field having only one option. Our requirement is adding two templates here. So, Go to Options,

Jainullabuddin B Page 29

Page 30: XML Basics1

XML REPORTS

Add Your New template and Save. You can’t see any Save Option here. So, Just Press CTRL+S.

{Here, XML Format is not working. SO I have changed it to HTML Format}

Jainullabuddin B Page 30

Page 31: XML Basics1

XML REPORTS

Then press OK.You can see that two templates are added here.

Now, Submit the Request, You will get two results.Two Requests will be submitted at a time.

You can see the results in two separate sheets.

POINTS TO REMEMBER

Jainullabuddin B Page 31

Page 32: XML Basics1

XML REPORTS Whenever You are submitting the request, The Template You have very first defined will

come as default one. If You need to change it,

Jainullabuddin B Page 32

Page 33: XML Basics1

XML REPORTS

It will take the second template. You can check this in VIEW DETAILS

Jainullabuddin B Page 33

Page 34: XML Basics1

XML REPORTS

If You give CTRL + S Here, You will get two templates

RTF TEMPLATERich Text Format (RTF) is a specification used by common word processing

applications, such as Microsoft Word.The RTF layout can be designed using the Standard features in Word.

Select the size, font, and alignment of text Insert bullets and numbering Draw borders around paragraphs Include a watermark Include images (jpg, gif,) Use table auto formatting features Insert a header and footer

Creating PlaceholdersThe placeholder maps the template field to the XML element data field. At runtime the

placeholder is replaced by the value of the element of the same name in the XML data file.

Enter placeholders in your document using the following syntax:<?XML element tag name?>

You can use the XML template without using the insert option in Template Builder. For this, we have to write the tags.

Jainullabuddin B Page 34

Page 35: XML Basics1

XML REPORTS Let us create a new template with the same XML data. But Only two columns in it.

Open a new word document and save it as E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xtemplate3.rtf Load the XML data into itCreate a table having two columns in it. Give the column Headings.

Now Write the tag to insert the item

Be Sure that the Field Names are given in upper-case. Else it will not give the result.If You see the Preview, You can see the result a single row.

De ning Groups

If, You need to have all the rows. Follow these stepsBy defining a group, you are notifying XML Publisher that for each occurrence of an

element, you want the included fields displayed. At runtime, XML Publisher will loop through the occurrences of the element and display the fields each time.Insert the following tag before the first element:<?for-each:XML group element tag name?>Insert the following tag after the final element:<?end for-each?>

Let us write this in our Query.

Jainullabuddin B Page 35

Page 36: XML Basics1

XML REPORTS

Ensure that it don’t have any spaces in it. If You give any space in Your tag, the following error will occur.

Because, we have left a space here.

Note that the group element must be a parent of the repeating elements in the XML input file.

If You want this Group tag is to be displayed as in the automatically created one. i.e FFor this, we have to enable the following

Jainullabuddin B Page 36

Page 37: XML Basics1

XML REPORTS

Keep the cursor in the place we have to insert the tag,

Jainullabuddin B Page 37

Page 38: XML Basics1

XML REPORTS Double click in it. You will get like this.

Type Your tag and close.

You can see the output

Headers and Footers. Use the following tags to enclose the body area of your report:

<?start:body?><?end body?>

Jainullabuddin B Page 38

Page 39: XML Basics1

XML REPORTS Create a New Template with Header . E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ xtemplate4.rtf

We have specified “Sample Header” as the Header here. Let us check whether the Header is coming.

In the same manner, do for footers also.

Jainullabuddin B Page 39

Page 40: XML Basics1

XML REPORTS

This header can be mingled with the ordinary header and Footer Also. Let us Add the ordinary Header

You can see this header with the previous header also.

Jainullabuddin B Page 40

Page 41: XML Basics1

XML REPORTS If You see the output, both will appear.

Background and Watermark SupportXML Publisher supports the "Background" feature in Microsoft Word. You can specify a single, graduated color or an image background for your template to be displayed in the PDF output. Note that this feature is supported for PDF output only.To add a background to your template, use the Format > Background menu option.

This is as usual in the Word.

Jainullabuddin B Page 41

Page 42: XML Basics1

XML REPORTS

Page Breaks

To create a page break after the occurrence of a specific element

To insert a page break between each occurrence of a group, insert the "split-by-page-break" form field within the group immediately before the <?end for-each?> tag that closes the group

IN Our Example,

Then You will see the result, in separate Page

Jainullabuddin B Page 42

Page 43: XML Basics1

XML REPORTS

SORTINGLet us use a new template for this purpose. This is saved as E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xtemplate7.rtf. The template is normal template with insertion of all the fields into it.

This have the output as

Jainullabuddin B Page 43

Page 44: XML Basics1

XML REPORTS

You may require the output to be sorted in the Inventory Item ID in ascending order.For this we have to include a tag.

Open the group tag

Jainullabuddin B Page 44

Page 45: XML Basics1

XML REPORTS

And the tag below the available tag and Press OK

Now see the output

Jainullabuddin B Page 45

Page 46: XML Basics1

XML REPORTS

You can see that it was sorted.

Conditional FormattingConditional formatting occurs when a formatting element appears only when a certain condition is met. XML Publisher supports the usage of simple "if" statements, as well as more complex "choose" expressions.

Insert the following syntax to designate the beginning of the conditional area.<?if:condition?>

Insert the following syntax at the end of the conditional area: <?end if?>.Let us create a new template for this purpose and Load the data into it.E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xtemplate5.rtf

Add the if statement into it

The Output will be

Jainullabuddin B Page 46

Page 47: XML Basics1

XML REPORTS

IF-THEN-ELSEXML Publisher supports the common programming construct "if-then-else". This is extremely useful when you need to test a condition and conditionally show a result.

Let us write a new Query for if-then-else in the old template itself.Use the following syntax to construct an if-then-else statement in your RTF template:<?xdofx:if element_condition then result1 else result2 end if?>

Type the tag as a single line [Don’t use Enter Anywhere]The Result is as per our requirement

Choose StatementsUse the choose, when, and otherwise elements to express multiple conditional tests.This is a very powerful feature of the RTF template. In regular XSL programming, if a condition is met in the choose command then further XSL code is executed.

Jainullabuddin B Page 47

Page 48: XML Basics1

XML REPORTS Use the following syntax for these elements:<?choose:?><?when:expression?><?otherwise?>

Let us create a new template for this purpose. E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xtemplate6.rtf

In the Template, write the Coding,

What our requirement is, If the Inventory_item_id = 11816, then, the contents to be highlighted in Blue color. Output is

Let us proceed with another condition in it.If The Inventory_item_id = 12816, then the words are to be highlighted.

Jainullabuddin B Page 48

Page 49: XML Basics1

XML REPORTS

The Output is

Now, Use otherwise into it.All the Records to be Highlighted in red Color.

Jainullabuddin B Page 49

Page 50: XML Basics1

XML REPORTS

The Output is

ADDITION

You can perform mathematical operations in the tag itself. Let us create a new column to show the addition of INVENTORY_ITEM_ID with 5. In the Template, Creat one Column and write the tag in it.

Jainullabuddin B Page 50

Page 51: XML Basics1

XML REPORTS

Output

Jainullabuddin B Page 51

Page 52: XML Basics1

XML REPORTS In the Same Way, You can add two columns also

Row StripingIf you would like a striped effect on your rows this can be achieved in the template. We now use two almost identical data rows in the table. The native XSL position() function is used to assign each row a numeric value, an ‘if’ statement is then used to test the value, so at the beginning of each row we get an if statement: 1st Row: if:position() mod 2=0 2nd Row: if:position() mod 2=1The position() function will return a number for the row of data starting at ‘1’. The mod or modulus function will return a 0 or a 1 depending on the result e.g. 2 mod 2 returns 0 and 3 mod 2 returns a 1. So we shade each row as required and add the if statement and at runtime the rows will be alternately shaded, in this case blue and yellow.

The template is

This is saved as E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\stripping effect.rtf

The output is

If You use this for 3 lines, the coding will be

Jainullabuddin B Page 52

Page 53: XML Basics1

XML REPORTS

Auto FormattingYou can also use Word’s Table Auto Format feature to apply a style to your tables. Highlight the

table then Table > Table AutoFormat then select the style you want from the dialog

You can choose the format as You desire.

CREATING XML REPORT USING PROCEDURES

In the Modern era, we are not using RDF file to generate XML file. We can use the Procedure for this Purpose.

1. First Declare the utlfile.2. Next give the path to save the .xml file name. This can be stored in the selected

directories only. This can be found out using the querySELECT *

Jainullabuddin B Page 53

Page 54: XML Basics1

XML REPORTS FROM all_directoriesThe Output is

Let us Use c:\temp to store the xml file.

Don’t forget to give the extension. Ie. Xinv.xml. Here it was not give. In the next step it was correctly given.3. Now Write the coding to create the procedure and create the xml file.

CODINGCREATE OR REPLACE PROCEDURE xmlproc (errbuf VARCHAR2, retcode NUMBER)IS myutlfile UTL_FILE.file_type;BEGIN myutlfile := UTL_FILE.fopen ('c:\temp', 'xinv.xml', 'W'); UTL_FILE.put_line (myutlfile, '<?xml version = "1.0"?>'); UTL_FILE.put_line (myutlfile, '<REC>');

FOR i IN (SELECT inventory_item_id, segment1, description, creation_date FROM mtl_system_items_b WHERE creation_date > TO_DATE ('01-JAN-2008') AND organization_id = 204) LOOP UTL_FILE.put_line (myutlfile, '<G_INVENTORY_ITEM_ID>'); UTL_FILE.put_line (myutlfile, '<INVENTORY_ITEM_ID>' || i.inventory_item_id || '</INVENTORY_ITEM_ID>' ); UTL_FILE.put_line (myutlfile, '<SEGMENT1>' || i.segment1 || '</SEGMENT1>' ); UTL_FILE.put_line (myutlfile, '<DESCRIPTION>' || i.description || '</DESCRIPTION>' ); UTL_FILE.put_line (myutlfile, '<CREATION_DATE>' || i.creation_date || '</CREATION_DATE>' ); UTL_FILE.put_line (myutlfile, '</G_INVENTORY_ITEM_ID>'); END LOOP;

UTL_FILE.put_line (myutlfile, '</REC>'); UTL_FILE.fclose (myutlfile);

Jainullabuddin B Page 54

Page 55: XML Basics1

XML REPORTS END;

This was saved as Now Compile the Program.BEGIN xmlproc ('a', 1);END;

You can check the xml in the c:\temp path.

The Coding is saved in the File. E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\Generating XML File.prc

Now, Write the Coding to show output in APPS. You have to k\make slight changes in the above coding. Instead of UTL File, Give FND File. Also, Instead of MYUTLFILE give FND_FILE. Also delete fopen and fclose.

Jainullabuddin B Page 55

Page 56: XML Basics1

XML REPORTS CODINGCREATE OR REPLACE PROCEDURE xmloutproc (errbuf VARCHAR2, retcode NUMBER)ISBEGIN fnd_file.put_line (fnd_file.output, '<?xml version = "1.0"?>'); fnd_file.put_line (fnd_file.output, '<REC>');

FOR i IN (SELECT inventory_item_id, segment1, description, creation_date FROM mtl_system_items_b WHERE creation_date > TO_DATE ('01-JAN-2008') AND organization_id = 204) LOOP fnd_file.put_line (fnd_file.output, '<G_INVENTORY_ITEM_ID>'); fnd_file.put_line (fnd_file.output, '<INVENTORY_ITEM_ID>' || i.inventory_item_id || '</INVENTORY_ITEM_ID>' ); fnd_file.put_line (fnd_file.output, '<SEGMENT1>' || i.segment1 || '</SEGMENT1>' ); fnd_file.put_line (fnd_file.output, '<DESCRIPTION>' || i.description || '</DESCRIPTION>' ); fnd_file.put_line (fnd_file.output, '<CREATION_DATE>' || i.creation_date || '</CREATION_DATE>' ); fnd_file.put_line (fnd_file.output, '</G_INVENTORY_ITEM_ID>'); END LOOP;

fnd_file.put_line (fnd_file.output, '</REC>');END;

Compile the ProcedureBEGIN xmloutproc ('a', 1);END;

The Same is Saved in E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\XML Output in Apps.prcThen Create the Executable as Before and follow those steps

Jainullabuddin B Page 56

Page 57: XML Basics1

XML REPORTS

Now Define the Concurrent Program

Now, Find the Request Group Name

Jainullabuddin B Page 57

Page 58: XML Basics1

XML REPORTS

Now, Include it in the Corresponding Responsibility

Now Open MS Word and Create a template

Jainullabuddin B Page 58

Page 59: XML Basics1

XML REPORTS

It is saved as E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\proc_temp.rtf

Now, Open the XML Publisher Administrator and define the Data.

Now create the template

Jainullabuddin B Page 59

Page 60: XML Basics1

XML REPORTS

Give the New Template NameNow, Run the Program in Apps

Now, See the Output

Jainullabuddin B Page 60

Page 61: XML Basics1

XML REPORTS

Successfully Completed. An Important Thing to note here is – It is not necessary to have installed XML in Your system. Without Loading the data You can see the output

LINK BETWEEN RDF AND XML If You open the property Pallete in the Data Model of RDF, You can see the XML

SETTINGS Property. This will be helpful in the case of creation of XML Tags.

Jainullabuddin B Page 61

Page 62: XML Basics1

XML REPORTS

XML TagYou can change the name of the XMl Tag while generating the XML Tags.

Previously, the tag will be

Now Give the Name as Dates. Save it and Generate into XML File and Save it as

IN the Tag, You can see as Dates

XML TAG ATTRIBUTES

Jainullabuddin B Page 62

Page 63: XML Basics1

XML REPORTS Let us Give an Attribute

The XML Output will be

It will just add The Output is saved in E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xinv1.xml

EXCLUDE FROM XML OUTPUTAs the name indicates, it will exclude that item from the XML tag.

OUTPUT

Jainullabuddin B Page 63

Page 64: XML Basics1

XML REPORTS

You can see the absence of description here. The OUTPUT is saved in E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\xinv2.xml.

PLAY WITH INVOICESThis part is just a continuation from RTF templates. What we do here is more learning

about RTF templates using the in-build given examples from XML Publisher. For this purpose, we write a query to get some details about invoiceSELECT invoice_num, invoice_date, a.invoice_currency_code, a.gl_date, a.invoice_amount FROM ap_invoices_all a WHERE invoice_date < TO_DATE ('30-JAN-1996')

Write a Procedure and create the XML code using the procedureCREATE OR REPLACE PROCEDURE invoice_code (errbuf VARCHAR2, retcode NUMBER)IS myutlfile UTL_FILE.file_type;BEGIN myutlfile := UTL_FILE.fopen ('c:\temp', 'invoice.xml', 'W'); UTL_FILE.put_line (myutlfile, '<?xml version = "1.0"?>'); UTL_FILE.put_line (myutlfile, '<REC>');

FOR i IN (SELECT invoice_num, invoice_date, a.invoice_currency_code, a.gl_date, a.invoice_amount FROM ap_invoices_all a WHERE invoice_date < TO_DATE ('30-MAR-1996')) LOOP UTL_FILE.put_line (myutlfile, '<G_INVOICE_NUM>'); UTL_FILE.put_line (myutlfile, '<INVOICE_NUM>'||i.INVOICE_NUM||'</INVOICE_NUM>' ); UTL_FILE.put_line (myutlfile, '<INVOICE_DATE>'||i.INVOICE_DATE||'</INVOICE_DATE>' ); UTL_FILE.put_line (myutlfile, '<INVOICE_CURRENCY_CODE>'||i.INVOICE_CURRENCY_CODE||'</INVOICE_CURRENCY_CODE>' ); UTL_FILE.put_line (myutlfile, '<GL_DATE>'||i.GL_DATE||'</GL_DATE>'); UTL_FILE.put_line (myutlfile, '<INVOICE_AMOUNT>'||i.INVOICE_AMOUNT||'</INVOICE_AMOUNT>'

Jainullabuddin B Page 64

Page 65: XML Basics1

XML REPORTS ); UTL_FILE.put_line (myutlfile, '</G_INVOICE_NUM>'); END LOOP;

UTL_FILE.put_line (myutlfile, '</REC>'); UTL_FILE.fclose (myutlfile);END;

Execute the Procedure usingbegin

invoice_code('a',1); end;

The code will be generated in the C:\temp folder. Copy this and paste it in your area and load the data. Insert all those fields

Repeatable Row HeadersIf your invoices break across a page and you want to repeat the column header row this can be achieved using MSWord’s functionality.

1. Highlight the header row2. Table > Table Properties3. Under the Row tab select the ‘Repeat as Header row at the top of each page’

If the invoices table breaks across a page the header row will be repeated

Now You will get the rows repeated.

Jainullabuddin B Page 65

Page 66: XML Basics1

XML REPORTS

Splitting Rows across pagesYou can prevent rows splitting across a page break by using MSWord’s funtionality:

1. Highlight the data row2. Table > Table Properties3. Under the Row tab deselect the ‘Allow row to break across pages’

Rows that would normally be split across two pages will now be moved to the second page to preserve the row data

Using GroupsLet us use groups in the query for this we have created the RDF file . E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ invoice.rdfWe have included Vendor_id for this purpose and Group the Query using the vendor_id

Now design the template and save as

E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ invoice2.rtf

Jainullabuddin B Page 66

Page 67: XML Basics1

XML REPORTS Loaded data is from E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ invoice1.xml

Output is Like

The output is shown after grouping

TotalsAdding a total at the Vendor level is very straightforward. We add a new table with a single row after the invoices table

Write the Query in the template. E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ invoice3.rtfLoad the data from E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ invoice1.xml

Jainullabuddin B Page 67

Page 68: XML Basics1

XML REPORTS

This will give the sum for every Vendor

You can get the total in the report level also

Jainullabuddin B Page 68

Page 69: XML Basics1

XML REPORTS

Output is

Number Formatting

You can format the number in the following form field

Jainullabuddin B Page 69

Page 70: XML Basics1

XML REPORTS

(#,###.00) is used for negative values.

REGROUPINGIf You want to use Grouping By Currency Code inside the existing group, You can add this.For this ,we have created a template E:\Selvam\Selvam P.S\Materials\XML\XML Tutorial – Selvam\ invoice5.rtf

The Output will be

Jainullabuddin B Page 70

Page 71: XML Basics1

XML REPORTS

It was regrouped using the Currency Code also You have to add a tag, <?for-each-group:G_INVOICE_NUM;INVOICE_CURRENCY_CODE?>

ERRORS FACED1. If we are opting to see the output in Excel Format, the following error occurs,ERR 01403 : No Data Found

Jainullabuddin B Page 71

Page 72: XML Basics1

XML REPORTS

SOLUTION

SUMMARY1. Develop the report without layout.2. Register the report with Oracle applications in normal way. 3. While registering the report select the out put type as xml instead of text (in general

we will give as text).4. Assign to a request group.5. Once after running the report from the application we will get the out put in the form

of xml tags.6. Save the Out put xml tags in file (this out put file will be the in put for the template

generation).7. Develop the Template and save it in .rtf format8. Create Data Definition9. Create the Template in Apps10. Run the Report in the Apps

Jainullabuddin B Page 72