XML Reports With Screen Shots Jainullabuddin B
XML Reports With Screen Shots Jainullabuddin B
XML Reports With Screen Shots Jainullabuddin B
XML REPORTS
With Screen shots
Jainullabuddin B
Jainullabuddin B Page 1
XML REPORTS
INDEX
TITLE
INTRODUCTION
VERSION OF XML
CREATING AN ORDINARY XML
REPORT
INSERTING INDIVIDUAL FIELDS
GETTING TWO KIND OF OUTPUT
AT A TIME
RTF TEMPLATE
CREATING XML REPORT USING
PROCEDURES
ERRORS FACED
SUMMARY
Jainullabuddin B Page 2
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
• Flexible
• High Quality
• Template-Based Reports
The main feature of XML Publisher is that it separates the Data Source from the
presentation/Layout
Data
Logic
Layout
XML
Report
Translation Publisher
output
n
• XML Publisher enables user to design the check layout using Microsoft word or
Adobe Acrobat
HTML
XML Publisher
EXCEL
RTF
Jainullabuddin B Page 3
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 XML
Version 5.6 Build 45
Jainullabuddin B Page 4
XML REPORTS
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@prod
Create 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
XML REPORTS
This is saved as
D:\oracle\prodappl\inv\11.5.0\reports\US\xinv.RDF
Jainullabuddin B Page 6
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
Jainullabuddin B Page 7
XML REPORTS
Jainullabuddin B Page 8
XML REPORTS
Here, we are inserting all those fields. So, Select All Fields.
You will get the layout as Follows
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 9
XML REPORTS
Jainullabuddin B Page 10
XML REPORTS
Jainullabuddin B Page 11
XML REPORTS
Save it.
Now, we have to find the Request Group Name.
Jainullabuddin B Page 12
XML REPORTS
Query for Your Request group and Add the New Program.
Jainullabuddin B Page 13
XML REPORTS
Save It.
Go to Inventory Responsibility.
Jainullabuddin B Page 14
XML REPORTS
But this is not the format, we require. This was generated, because, we have not attached the
template (Which we created) anywhere.
Jainullabuddin B Page 15
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
Jainullabuddin B Page 16
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
Jainullabuddin B Page 17
XML REPORTS
After the template definition is created, the following fields are not updateable: Application,
Code, and Type
Jainullabuddin B Page 18
XML REPORTS
If You see the output, it will come in the Format we have give. Here we have given as PDF
POINTS TO REMEMBER
Jainullabuddin B Page 19
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.
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.
After drawing table, Type the Following things and keep ready the template.
Jainullabuddin B Page 20
XML REPORTS
Jainullabuddin B Page 21
XML REPORTS
After inserting all those, Save the File in rtf format. E:\Selvam\Selvam P.S\Materials\XML\XML
Tutorial – Selvam\xtemplate2.rtf
You 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 22
XML REPORTS
Jainullabuddin B Page 23
XML REPORTS
Jainullabuddin B Page 24
XML REPORTS
For this You have to make changes in the XML Publisher Templates only. You can create a new
template also.
Jainullabuddin B Page 25
XML REPORTS
You can see that the Old template was added here. If, You need to change this one,
Jainullabuddin B Page 26
XML REPORTS
Jainullabuddin B Page 27
XML REPORTS
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 28
XML REPORTS
Add Your New template and Save. You can’t see any Save Option here. So, Just Press CTRL+S.
Jainullabuddin B Page 29
XML REPORTS
POINTS TO REMEMBER
Jainullabuddin B Page 30
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 31
XML REPORTS
It will take the second template. You can check this in VIEW DETAILS
Jainullabuddin B Page 32
XML REPORTS
Creating Placeholders
The 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.
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 33
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 it
• Create a table having two columns in it. Give the column Headings.
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 steps
By 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?>
Jainullabuddin B Page 34
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.
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 F
For this, we have to enable the following
Jainullabuddin B Page 35
XML REPORTS
Jainullabuddin B Page 36
XML REPORTS
Double click in it. You will get like this.
Jainullabuddin B Page 37
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.
Jainullabuddin B Page 38
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 39
XML REPORTS
If You see the output, both will appear.
Jainullabuddin B Page 40
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,
Jainullabuddin B Page 41
XML REPORTS
SORTING
Let 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.
Jainullabuddin B Page 42
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.
Jainullabuddin B Page 43
XML REPORTS
Jainullabuddin B Page 44
XML REPORTS
Conditional Formatting
Conditional 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
Jainullabuddin B Page 45
XML REPORTS
IF-THEN-ELSE
XML 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?>
Choose Statements
Use 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 46
XML REPORTS
Use the following syntax for these elements:
<?choose:?>
<?when:expression?>
<?otherwise?>
What our requirement is, If the Inventory_item_id = 11816, then, the contents to be highlighted
in Blue color. Output is
Jainullabuddin B Page 47
XML REPORTS
The Output is
Jainullabuddin B Page 48
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 49
XML REPORTS
Output
Jainullabuddin B Page 50
XML REPORTS
In the Same Way, You can add two columns also
Row Striping
If 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=1
The 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
The output is
Jainullabuddin B Page 51
XML REPORTS
Auto Formatting
You 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
Jainullabuddin B Page 52
XML REPORTS
FROM all_directories
The Output is
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.
CODING
CREATE 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 ('01JAN2008')
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;
Jainullabuddin B Page 53
XML REPORTS
UTL_FILE.put_line (myutlfile, '</REC>');
UTL_FILE.fclose (myutlfile);
END;
This was saved as
Now Compile the Program.
BEGIN
xmlproc ('a', 1);
END;
Jainullabuddin B Page 54
XML REPORTS
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.
CODING
CREATE OR REPLACE PROCEDURE xmloutproc (errbuf VARCHAR2, retcode NUMBER)
IS
BEGIN
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 ('01JAN2008')
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 Procedure
BEGIN
xmloutproc ('a', 1);
END;
Jainullabuddin B Page 55
XML REPORTS
Jainullabuddin B Page 56
XML REPORTS
Jainullabuddin B Page 57
XML REPORTS
Now, Open the XML Publisher Administrator and define the Data.
Jainullabuddin B Page 58
XML REPORTS
Jainullabuddin B Page 59
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
Jainullabuddin B Page 60
XML REPORTS
XML Tag
You 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
Jainullabuddin B Page 61
XML REPORTS
Let us Give an Attribute
OUTPUT
Jainullabuddin B Page 62
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.
Write a Procedure and create the XML code using the procedure
CREATE 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 ('30MAR1996'))
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
Jainullabuddin B Page 63
XML REPORTS
(myutlfile,
'<INVOICE_AMOUNT>'||
i.INVOICE_AMOUNT||'</INVOICE_AMOUNT>'
);
UTL_FILE.put_line (myutlfile, '</G_INVOICE_NUM>');
END LOOP;
UTL_FILE.put_line (myutlfile, '</REC>');
UTL_FILE.fclose (myutlfile);
END;
Execute the Procedure using
begin
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
Jainullabuddin B Page 64
XML REPORTS
Jainullabuddin B Page 65
XML REPORTS
Using Groups
Let 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.rdf
We have included Vendor_id for this purpose and Group the Query using the vendor_id
Output is Like
Jainullabuddin B Page 66
XML REPORTS
Totals
Adding a total at the Vendor level is very straightforward. We add a new table with a single row after the
invoices table
Jainullabuddin B Page 67
XML REPORTS
This will give the sum for every Vendor
Output is
Jainullabuddin B Page 68
XML REPORTS
Number Formatting
REGROUPING
If 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
Jainullabuddin B Page 69
XML REPORTS
Jainullabuddin B Page 70
XML REPORTS
<?for-each-group:G_INVOICE_NUM;INVOICE_CURRENCY_CODE?>
ERRORS FACED
1. If we are opting to see the output in Excel Format, the following error occurs,
ERR 01403 : No Data Found
SOLUTION
SUMMARY
1. 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 format
8. Create Data Definition
9. Create the Template in Apps
10. Run the Report in the Apps
Jainullabuddin B Page 71