Customer Balance Report Tutorial

advertisement
Oracle BI Publisher
RTF Template Development Tutorial
Page 2 of 25
Contents
Oracle BI Publisher .................................................................................................................................. 1
RTF Template Development Tutorial................................................................................................... 1
Contents ........................................................................................................................................... 2
Customer Balance Report Tutorial.......................................................................................................... 3
Step 1: Load Sample XML Data ............................................................................................................ 3
Step 2: Insert address block and report level dates and totals ........................................................... 3
Step 3: Preview Template .................................................................................................................... 4
Step 4: Insert a table of Invoices ......................................................................................................... 4
Step 5: Number & Date Formatting..................................................................................................... 7
Number formatting .......................................................................................................................... 7
Date formatting ................................................................................................................................ 8
Step 6: Dressing Up.............................................................................................................................. 8
Headers and Footers ........................................................................................................................ 8
Images .............................................................................................................................................. 9
Page Numbering ............................................................................................................................... 9
Step 7: Adding Total........................................................................................................................... 10
Adding Total ................................................................................................................................... 10
Step 8: Adding Page/Brought Forward/Carried Forward Total ......................................................... 11
Step 9: Adding Running Total ............................................................................................................ 13
Step 10: For loop................................................................................................................................ 14
Step 11: Page/Section Break ............................................................................................................. 15
Step 12: Conditional formatting ........................................................................................................ 16
Step 13: Adding a barcode ................................................................................................................. 16
Step 14: Sorting ................................................................................................................................. 17
Step 15: Different Last Page .............................................................................................................. 18
Step 16: Chart .................................................................................................................................... 19
Step 17: Add Table of Contents or Bookmark! .................................................................................. 21
Table of Contents ........................................................................................................................... 21
Bookmark ....................................................................................................................................... 22
Conclusion.......................................................................................................................................... 24
Page 3 of 25
Customer Balance Report Tutorial
This tutorial describes how you would typically create a layout template for the Receivables
Customer Balance Report. It will use the following two sample data XML files
-
AR_SAMPLE_DATA.xml
Crosstab_Sample_Data.xml
AR_Sample_Data.xml is required for most of the training steps in this tutorial.
Crosstab_Sample_Data.xml is required only for Crosstab training.
Before you start the following set of training steps, make sure that you have installed BI Publisher
Desktop Add-in.
Step 1: Load Sample XML Data
From the Data menu select Load XML Data to load a sample XML document that contains the data
fields you may want to insert into your RTF layout template. Select the XML data file called
AR_SAMPLE_DATA.xml.
Step 2: Insert address block and report level dates and totals
You may want to select single data fields, such as the customer name and address at the header of
the letter. Position the cursor in the Word document where you want to insert the Address. From
the Insert menu select Field… to open the dialog window shown below.
Select the field Customer Name and click Insert to insert a form field for the customer name into the
document. You may also insert the remaining address fields (such as Address Line1, City, State and
Zip). You can also just drag the Customer Name field from the dialog and drop it into the Word
document.
Page 4 of 25
Note: As a beginner, you should use Insert Fields only for data fields that are unique (not repeating)
in your document. Refer to the “Insert Table” section for additional information on how to insert
repetitive fields
Step 3: Preview Template
After adding fields to the document, you may want to test your template. Oracle BI Publisher
Template Builder allows you to preview your template with your sample XML data. You can preview
the output in Adobe Acrobat Reader (PDF), Microsoft Word file (RTF), Microsoft EXCEL (EXCEL) or a
browser (HTML).
From the Preview menu select HTML to preview your template in a browser. From the Preview
menu select PDF to preview your document in Acrobat Reader. You must have Adobe Acrobat
Reader version 5.0 or higher installed to preview documents in PDF format. You can download
Acrobat Reader for free at http://www.adobe.com/products/acrobat/readstep2.html.
The preview should show Vision Corporation instead of the field Customer Name.
Step 4: Insert a table of Invoices
You can build a table or a repeating section by inserting the elements and then adding additional
form fields with processing instructions (for-each). Instead, the Template Builder offers an additional
function that generates a table for you.
The document should include a table of all invoices that are not or only partially paid. On the Insert
menu select Table/Form > Advanced to open the Table/Form Dialog The following dialog will be
displayed:
Scroll in the left Data Source view pane until you see the G Invoices element. Push the left mouse
button and drag the G Invoices element over to the center Template tree view. When you drop an
element with children (other elements below the element), the following pop-up dialog appears:
Page 5 of 25
Note: A Node is a term used in tree views for an element in the tree view. For example,
Customer Name, G Currency and G Invoices are all nodes. Transaction Date is also called a
child node of G Invoices, and G Invoices is referred to as a parent node of Transaction Date.
To add multiple nodes, click Drop All Nodes with the left mouse button. When you select the "G
Invoices" node, the dialog box should now look like this:
We only want to show the fields Trx Number, Trans Type, Transaction Date, Trans Amount, and
Trans Amount Remaining. Select the field Receipt Amount in the center view and press the Delete
button on your keyboard. Repeat the procedure for the other fields that you do not want to be
included in the table (as shown in the screenshot below).
You should now click again on the G Invoices element in the center view. The Properties region on
the right shows how the data fields will be formatted. You should see the following information:
Page 6 of 25
For each group you can set the following properties that describe how a group (such as G Invoices)
should be rendered by the template builder:
Style: Select Table to create a table around the data fields.
Grouping: Grouping is an advanced operation that allows you to re-group the data – for
example by transaction date instead of currency. You can select the element that the data
should be grouped by for this property. Please refer to the Oracle BI Publisher User’s Guide
for additional information on grouping.
Show Grouping Value: This property will only be shown if you have selected a node created
by the Grouping functionality. You can choose for a group if the Data Field node used as a
grouping criterion is shown in the table or form.
Sort By: You can select an element by which the data groups are sorted.
Sort Order: If you have selected an element for Sort By you can select, if the data should be
sorted either ascending or descending.
Sort Data Type: If you have selected an element for Sort By the data is by default sorted as
Text. That means that 12 will be shown after 111. If you need to sort numbers you should
select Number as the sort data type
Break: This property allows you to insert a page break or a section break between every data
group. If nothing is select, then the data groups will be shown continuously with no break. If
you select New Page per Element, then a page break will be inserted between each element.
If you select New Section per Element, a section break will be created for each data group. A
section break allows changing the header/footer and resets the page number. You will
typically use this option, if you want to print multiple documents (for example invoices or
purchase orders) to a single PDF file.
Page 7 of 25
The order in which the data elements are shown reflects the order of the columns in the table. If you
want to reorder the columns you need to change the Insert Position box from Child to Same Level.
Then drag the elements into the correct order.
Click the OK button to create the table. The inserted table should look like this:
Trx Number
for-each
G_INVOICES
TRX_NUMBER
Trans Type
TRANS_TYP
E
Transaction Date
TRANSACTION_DATE
Trans Amount
Trans Amount Remaining
TRANS_AMOUNT TRANS_AMOUNT_REMAINI
NG end G_INVOICES
The Template Builder creates two kinds of form fields:


Form fields representing data elements
Form fields with processing instructions for repeating table rows or document section
Form fields representing data elements are replaced with the data when the template is processed.
The for-each G_INVOICES and end G_INVOICES form fields indicate a repeating section. The section
of the document encapsulated by these two form fields is repeated, if the associated data element
G_INVOICE is found repetitively in the data. Please refer to the Oracle BI Publisher User’s Guide for
additional information on form fields.
You can now format these elements in Microsoft Word and add additional text. You can also move
fields around as long as you keep them in the surrounding for-each G_INVOICES and end
G_INVOICES processing instruction. If you remove one of these processing instructions your
template may not work anymore with BI Publisher. You now can preview the template again to
review your current template, this time try PDF as an output.
Step 5: Number & Date Formatting
You probably would like to change the alignment of the table columns or change the data type and
format for the amounts and dates.
Number formatting
Select the TRANS_AMOUNT field, right-click and select Properties to see the Text Form Field
Options dialog.
Page 8 of 25
You may select the Number in the Type field, #,##0.00 for Number format and enter 1000 as the
Default Number to achieve a more desirable format for currencies in US Dollar.
Date formatting
To format the date, open the form field dialog for the TRANSACTION_DATE and specify that it is a
Date field. Then select the date format you want to use. It should be noted here that BI Publisher is
expecting the date data as an XSD format date (Canonical Date Format) e.g. 2006-09-01 00:00:00.0.
If the date is not in this format then BI Publisher will be unable to format it further.
Formatting options defined in this dialog box are understood by Oracle BI Publisher and used to
format your fields. Now preview your template again to see the date and number formatting in
action.
Step 6: Dressing Up
Headers and Footers
You will have noticed by now that you can use the MSWord header and footer functionalities. You
can place a company logo, report title, and page numbering, etc, in the header and in the footer, and
also you can place a BI Publisher’s boilerplates to display data in the header and footer in the
generated reports. Only one problem is that MS Word doesn’t let you place text form fields nor auto
shapes in the area, so if you have such requirements that you need to, for example, display auto
shapes or have conditions that you want to write by using the text form, then you can use BI
Publisher’s tag, <?start:body?> and <?end body?>.
Anything before <?start:body?> tag would be considered as header area and after <?end body?>
would be as footer area, and the between the two tags would be body content area. We will use the
BI Publisher’s header/footer tags for this exercise.
Also it’s a best practice to use a table component to control the layout, so we’ll use a table in the
header section and another table in the footer section.
Page 9 of 25
1. Type <?start:body?> before CUSTOMER_NAME text form. and type <?end body?> after the
table. (You can use a text form to have this tag as well.)
2. Insert a table in the header before the <?start:body?> tag and another table after the <?end
body?> tag. Choose 3 columns and 1 row for the each table.
3. From the right click menu choose ‘Borders and Shading’ and make all the grid and table
frame lines not to be displayed.
4. Type ‘Customer Balance Report’ in the central column of the header table. Make that to be
bold and center alignment.
5. Type ‘Draft’ in the central column of the footer table. Make that to be bold and center
alignment.
Now your template should look like this.
Customer Balance Report
<?start:body?>
CUSTOMER_NAME
ADDRESS_LINE1
CITY, STATE, ZIP
Trx Number
F
TRX_NUMBE
R
TranADDRE
SS_LINE1s
Type
TRANS_TYP
E
Transaction Date
Trans Amount
Trans Amount
Remaining
TRANSACTION_DA
TE
TRANS_AMOU
NT
TRANS_AMOUNT_
REMAININGF
<?end body?>
Draft
Images
It’s a simple case of using the Insert>Picture> From File to insert an image into the header/footer or
main region of the report. Let’s insert Oracle company logo in the header region. You should have
downloaded the file called company_logo.png onto your local machine by now, otherwise download
it from the files online folder.
Page Numbering
You can use the MSWord autotext ‘Page X of Y’ and other auto text objects if you use MSWord’s
native header and footer functionalities. But this time we’re not using that, instead we’re using BI
Publisher’s tags to support the header and footer. But we still can display such page number.
1. Place a cursor into the most right cell and choose ‘Field’ from ‘Insert’ tool bar menu and
select ‘Page’.
2. Type ‘of’ after the ‘Page’ field.
Page 10 of 25
3. Choose ‘Field’ from ‘Insert’ tool bar menu and select ‘NumPages’ and place it right after the
‘of’.
4. Make the cell to be right alignment
Now your template should look like this.
Customer Balance Report
10 of 25
<?start:body?>
CUSTOMER_NAME
ADDRESS_LINE1
CITY, STATE, ZIP
Trx Number
Trans Type
Transaction Date
Trans Amount
F
TRX_NUMBE
R
TRANS_TYP
E
TRANSACTION_DA
TE
TRANS_AMOU
NT
Trans Amount
Remaining
TRANS_AMOUNT_
REMAININGF
<?end body?>
Draft
BI Publisher supports many of the MSWord native functions so spend some time changing the look
and feel of your report using the MSWord dialogs. For example, font size, font color, table color,
table lines, etc, etc…
Step 7: Adding Total
Adding Total
Now you want to see the total amount of the whole transactions amount. This would be very simple.
1. Click Insert from Template Builder tool bar menu and choose Field
2. Select TRANS_AMOUNT element and choose ‘SUM’ as a calculation
3. Click Insert button
Page 11 of 25
You can add another SUM Total for TRANS_AMOUNT_REMAINING, too. In this tutorial, you’ll add
another row at the last row of the table so that you can display total amount of the whole
transaction at the last row of the table. So it would look like this.
Trx Number
Trans Type
Transaction Date
Trans Amount
F
TRANS_TYPE TRANSACTION_DATE TRANS_AMOUNT
TRX_NUMBER
Total: sum
TRANS_AMOUNT
Trans Amount Remaining
TRANS_AMOUNT_REMAINING
E
sum
TRANS_AMOUNT_REMAINING
Step 8: Adding Page/Brought Forward/Carried Forward Total
In this exercise we also want to display page total, brought forward total and carried forward total of
the transaction amount in each page. The brought forward total is a total amount of the previous
page that is forwarded to the current page while the carried forward total is a total amount of the
current page that is carried to the next page. Since we want to display these total values in every
page, we will put the brought forward total in header area and the carried forward total in footer
area.
Set Page Total
1. Insert another text form into TRANS_AMOUNT_REMAINING column’s cell of the main table,
place it right before the TRANS_AMOUNT_REMAINING text form.
2. Double click on the text form and type ‘PT’ as a default value.
3. click ‘Add Help Text’ and type the following in the box.
<?add-page-total:pt;'TRANS_AMOUNT_REMAINING'?>
4. Click OK.
Page 12 of 25
Trx Number
F
TRX_NUMBE
R
Trans Type
TRANS_TYPE
Transaction Date
TRANSACTION_DA
TE
Trans Amount
TRANS_AMOUNT
Total: sum
TRANS_AMOUNT
Trans Amount Remaining
PTTRANS_AMOUNT_REM
AINING E
sum
TRANS_AMOUNT_REMAIN
ING
Display Page Total in Footer
1. Insert a row above the existing row in the Footer.
2. Type ‘Page Total:’ and select right alignment in the central cell of the footer table.
3. Place mouse cursor at the right cell of the table and click ‘Text Form Field’ icon from the tool
bar to insert a Text Form.
4. Double click on the text form and click ‘Add Help Text’ and type the following in the box.
<xdofo:show-page-total name="pt" format="99G999G999D00"/>
5. Type ‘Page Total’ in Default Text field and click OK.
Note that you need to specify a number format in the xdofo tag and MS Word number formatting
functionality can not be used.
Page Total: Page Total
Draft
Display Brought Forward Total in Header
1.
2.
3.
4.
Insert a row below the existing one in a header table
Select the entire row and select ‘Boarders and Shading’ from right click menu
Under Boarder tag, set a boarder line for the bottom and click OK.
Type ‘Brought Forward Total:’ and select right alignment in the central cell of the header
bottom line.
5. Place mouse cursor at the right cell of the table and click ‘Text Form Field’ icon from the tool
bar to insert a Text Form.
6. Double click on the text form and click ‘Add Help Text’ and type the following in the box.
<xdofo:show-brought-forward name="pt" format="99G999G999D00"/>
7. Type ‘Forward Total’ in Default Text field and click OK.
Customer Balance Report
12 of 25
Brought Forward Total: Forward Total
Display Carried Forward Total in Footer
1. Insert an additional row under Page Total row in the Footer table
2. Type ‘Carried Forward Total:’ and select right alignment in the central cell of the footer table.
Page 13 of 25
3. Place mouse cursor at the right cell of the table and click ‘Text Form Field’ icon from the tool
bar to insert a Text Form.
4. Double click on the text form and click ‘Add Help Text’ and type the following in the box.
<xdofo:show-carry-forward name="pt" format="99G999G999D00"/>
5. Type ‘Carried Total’ in Default Text field and click OK.
Page Total: Page Total
Carried Forward Total: Carried Total
Draft
And now you should have something like this.
Customer Balance Report
13 of 25
Brought Forward Total: Forward Total
<?start:body?>
Trx Number
Trans Type
Transaction Date
Trans Amount
Trans Amount Remaining
F
TRANS_TYPE TRANSACTION_DATE TRANS_AMOUNT PT;
TRX_NUMBER
TRANS_AMOUNT_REMAINING
E
sum TRANS_AMOUNT_REMAINING
<?end body?>
Page Total: Page Total
Carried Forward Total: Carried Total
Draft
Step 9: Adding Running Total
Ok, we’re almost done for this total stuff! Just one more, it’s very exciting one! It’s a running total
that will keep adding the previous value to the current value when it goes down the cells so the very
last value should be the same as a total value. This requires a little trick, so it might sound a bit
complicated, but once you understand it, it’s pretty straight forward! Basically what you need to do
is to define a variable, and add the current value to whatever the value has been added at the
previous cell.
1. Insert a Text Form at the beginning of the body space.
2. Double click on the text form and type ‘RT’ as the default text.
3. Click ‘Add Help Text’ and type the following.
<?xdoxslt:set_variable($_XDOCTX,'RT', 0)?>
4. Click OK.
5. Add a column to the right of Trans Amount Remaining and name the column header as
Running Total.
Page 14 of 25
6. Cut and past <?end for-each?> tag from the Trans Amount Remaining cell to the added cell
so that it will be the last tag in the row of the table.
7. Insert a Text Form in the Running Total’s cell.
8. Double click the text form and type ‘Set’ as the default text.
9. Click ‘Add Help Text’ and type the following. (this part gets the last value and add the current
value to it, and set the accumulated value to the RT variable.)
<?xdoxslt:set_variable($_XDOCTX,'RT',
xdoxslt:get_variable($_XDOCTX,'RT')+TRANS_AMOUNT_REMAINING)?>
10. Click OK.
11. Insert a Text Form right after the ‘Set’ text form.
12. Double click the text form and change Type to ‘Number’ and type ’999.00’ as the default text,
and select ‘#,##0.00’ as the number format.
13. Click ‘Add Help Text’ and type the following. (this part just displays the current accumulated
value, which has been set by the functions that are set in ‘Set’ text form.)
<?xdoxslt:get_variable($_XDOCTX,'RT')?>
14. Click OK.
Ok, so hope you can make all the above steps set right, so by this point your report should look like
this.
Customer Balance Report
14 of 25
Brought Forward Total: Forward Total
<?start:body?>
Trx Number
Trans Type
F
TRX_NUMBE
R
TRANS_TYP
E
Transaction
Date
TRANSACTI
ON_DATE
Trans Amount
TRANS_AMOU
NT
Trans Amount
Running Total
Remaining
PT;
Set999.00E
TRANS_AMOUNT
_REMAINING
sum TRANS_AMOUNT_REMAINING
<?end body?>
Page Total: Page Total
Carried Forward Total: Carried Total
Draft
Step 10: For loop
Now you might have already noticed that your report displays invoice information only for one
customer but when you look into the XML data file there is much more customers information! This
is because now you have only one ‘for loop’ that is used for G_INVOICE node. In order to display
multiple customer information you need to have another for-loop at G_CUSTOMER level.
Page 15 of 25
You can simply insert a text form field by clicking text form field button into right before
CUSTOMER_NAME filed, and double click the filed to open a dialog and click on ‘Add Help Text…’
button. And you can input the following.
<?for-each:G_CUSTOMER?>
As any other programming would do the same, you need to close the for-loop, so you need to insert
another text form field to input the following.
<?end for-each?>
And at this point, having the brought forward and carried forward doesn’t really make sense
anymore, so let’s remove them just to make it simple. So now it should look like the below.
Customer Balance Report
15 of 25
<?start:body?>
FCUSTOMER_NAME
ADDRESS_LINE1
CITY, STATE, ZIP
Trx Number
Trans Type
Transaction Date
Trans Amount
F
TRX_NUMBE
R
TRANS_TYP
E
TRANSACTION_DA
TE
TRANS_AMOU
NT
Trans Amount
Remaining
PT;
TRANS_AMOUNT_
REMAINING
Running Total
Set999.00E
sum TRANS_AMOUNT_REMAINING
EF
<?end body?>
Draft
Step 11: Page/Section Break
Now your report displays all the customer’s transaction data as one document, some of the
customers information is displayed across the pages and starts at the middle of the page. But you
might want to create it as multiple documents in one report book, which means that you want to
have each customer data started at the top of the page so that you can separate each customer’s
data into different documents and send them to each customer, for example.
The easiest way to achieve this is to insert a page break.
1. Place your mouse cursor between sum TRANS_AMOUNT_REMAINING and EF
2. Select Insert from Word tool bar and select ‘Break…’ menu, choose ‘Page Break’ and click OK.
However, as you might notice it the page number is still continuous across pages so when you
separate each customer’s document the page number wouldn’t make sense. In order to have
different set of page number for each customer’s document you can use a section break.
Page 16 of 25
1. Double click on the first ‘for-each’ for Customer Name text form.
2. Change the ‘for-each’ loop to ‘for-each@section’
Example:
Before
<?for-each:G_CUSTOMER?>
After
<?for-each@section:G_CUSTOMER?>
3. Click OK.
Try Preview and make sure that your report displays customer data per customer and each customer
section always starts from the top page. Also the page number starts with each customer and the
total number of the pages are the number of pages for each customer’s.
Step 12: Conditional formatting
You can highlight certain values in your invoice table. Let’s assume we want to use a red background
on any amount remaining that is greater than $10000. To achieve this we need to add some XSL
code to check the value and set the background color to be red if the value is greater than 10000.
The XSL code you need is:
<?if:TRANS_AMOUNT_REMAINING >10000?>
<xsl:attribute xdofo:ctx="block" name="background-color">red</xsl:attribute>
<?end if?>
Step:
1.
2.
3.
4.
5.
Insert a text form right before TRANS_AMOUNT_REMAINING
Double click on the text form
Type ‘Red’ as a default text
Click ‘Add Help Text..’
Insert the following tags.
<?if:TRANS_AMOUNT_REMAINING >100000?>
<xsl:attribute xdofo:ctx="block" name="background-color">red</xsl:attribute>
<?end if?>
This tests the amount remaining value. If it’s over 1,000,000 then the background color attribute is
set to red. This will override any other background color that may have been set.
Step 13: Adding a barcode
To add a barcode you’ll first need one. Install the Customer Balance Template/FREE3OF9.ttf font into
your WINDOWS_HOME/fonts directory. Now restart MSWord, the font will now be available from
the font drop down list.
Highlight the fields or text you want and select the barcode font. Now you need to define a mapping
by creating a custom document property.
Page 17 of 25
1. Select File  Properties  Custom Tab
2. In the Name field enter: xdo-font.Free 3 of 9.normal.normal – notice the name of the font
must match the name of the font in the MSWord font drop down
3. In the Value field enter: truetype.c:\windows\fonts\FREE3OF9.ttf
4. Now test your template using the Preview function and you should see the barcode rendered
based on the data.
This works fine as long as you generate the report on your local machine, but note that it means it
wouldn’t work when you try to generate the report at a different machine unless the barcode font
has been installed and the appropriate font mapping has already been defined. If you need to run
the report at a different machine, for example at a server, which probably would be most of the
cases, then you need to set such font configuration information. We don’t go through that for this
training but you can find the detail information how to set the font information in User’s guide.
Step 14: Sorting
Now you want to display the transaction data from the lowest to the highest based on the
transaction amount. BI Publisher supports a sorting function in the both ways, ascending and
descending.
1. Double Click on the text form for ‘G_INVOICES’ for-each loop, which is right before
TRX_NUMBER
2. Add the following
<?sort:TRANS_AMOUNT;'ascending';data-type='text'?>
Trx Number
Trans Type
F
TRANS_TYP
Transaction
Date
TRANSACTI
Trans Amount
TRANS_AMOU
Trans Amount
Remaining
PT;
Running Total
Set999.00E
Page 18 of 25
Trx Number
Trans Type
TRX_NUMBE
R
E
Transaction
Date
ON_DATE
Trans Amount
NT
Trans Amount
Remaining
REDTRANS_AMO
UNT_REMAININ
G
Running Total
(Double click on ‘F’ text form right before the TRX_NUMBER, you can find the sorting tag.
First, you need to specify on which data you want to sort and select whether ascending or
descending. When you preview at this point you’ll notice that the data is sorted based on the
TRANS_AMOUNT value but it’s not quite right. For example, 120,653.20 is displayed before
12,375.00 although the sorting order should be ascending, which means from the lowest to the
highest. This is because now the sorting is done based on the text value base sorting, not the
number value base. You can change the ‘data-type=’text’ to ‘data-type=’number’, then you’ll see
the data is now sorted by TRANS_AMOUNT number value.
Step 15: Different Last Page
BI Publisher supports different last page header/footer or content. This is useful for documents such
as checks, invoices, or purchase orders on which you may want certain content, such as check or
summary, only in the last page. BI Publisher provides this ability. To utilize this feature, you must
create a section break in your template to ensure the content of the final page is separated from the
rest of the report and Insert the following syntax on the final page:
<?start@last-page:body?>
<?end body?>
Any content above or below these two tags will appear only on the last page of the report. Also,
note that because this command explicitly specifies the content of the final page, any desired
headers or footers previously defined for the report must be reinserted on the last page.
1.
2.
3.
4.
Add another row in a table in the footer.
Type ‘Trans Amount Remaining Total’ in the right cell.
Set the mouse cursor at the end of the first page.
Click Insert from tool bar and choose Break, and select ‘Next Page’ under ‘Section Break
Type’
5. Now you see another one page has been added. Move to the page.
6. Insert the following tags.
<?start@last-page:body?>
<?end body?>
7. Copy the header and footer content from the first page and paste them to each of the
header and footer area in the second page.
8. Click ‘Insert’ from Template Builder menu and select ‘Field’.
9. Select ‘Trans Amount Remaining’ from the tree and choose ‘SUM’ from the calculation LOV,
and click ‘Insert’ button, so that you have the sum of Trans Amount Remaining in the right
cell right after ‘Remaining Transaction Amount Total:’
10. Try Preview to see the result
Page 19 of 25
You will notice that all the pages show total amount of Trans Amount Remaining in the footer area
except for the first page for the customer that goes across more than one page. For example, look at
a customer, Computer Service and Rentals, which has 2 pages of the report. You’ll see that there is
no Trans Amount Remaining total displayed in the footer area in the first page and only the second
page has the Trans Amount Remaining total displayed in the footer. That’s what we are talking
about! ;-)
The second page should look similar to this.
Customer Balance Report
19 of 25
Brought Forward Total: Forward Total
<?start@last-page:body?>
<?end body?>
Trans Amount Remaining: TRANS_AMOUNT_REMAINING
Page Total: Page Total
Carried Forward Total: Carried Total
Draft
Step 16: Chart
To add a chart basically you need to do these 2 steps, the first is to insert a dummy image and the
second is to define BI Beans Graph XML in Alternative Text area under Web tab of Format Picture
dialog. But it’s not easy to understand this BI Beans Graph XML. Especially if you’re just starting,
(well, even you’re experienced but still!) you might get overwhelmed by this. But don’t worry! there
is a Chart creation tool that can be accessed by the template builder tool menu. The following is the
steps to insert a chart that shows customer’s transaction amount per customer in vertical bar graph.
Before you start the following steps, you need to take the section break out from the ‘foreach@section’, which you have done it at Step 11.
1.
2.
3.
4.
5.
6.
7.
8.
Click Chart under Insert menu of Template Builder
Drag and Drop ‘CUSTOMER_NAME’ element from the left tree pane to Labels.
And check Grouping
Drag and Drop ‘TRANS_AMOUNT from the left pane to main area or Value.
Select ‘Bar Graph – Vertical’ as Type
Select ‘Comet’ as Style
Select ‘SUM’ as Measure and choose
Click OK.
Page 20 of 25
After you click ‘OK’ you’ll see a dummy image inserted in your report. At this point, the image
doesn’t show the data in the Graph plot area though Customer names are displayed correctly. This is
because inside the chart XSL definition the XPATH for TRANS_AMOUNT element is not set
appropriately. Follow the following steps to modify the XSL definition.
1. Double click on the Chart image
2. Click Web tab
3. Find the following tags
<Cell>
<xsl:value-of select="sum(current-group()/TRANS_AMOUNT)"/>
</Cell>
4. Change it to
<Cell>
<xsl:value-of select="sum(current-group()//TRANS_AMOUNT)"/>
</Cell>
Notice the extra ‘/’ between ‘current-group() and ‘TRANS_AMOUNT’.
Try preview you’ll see the bar graph will be displayed with actual values.
Example:
Page 21 of 25
You can also try different type of charts by using the Chart Creation Tool of the template builder.
There are whole a lot of different types of graphs are supported as long as BI Beans supports, but
you need to understand the Graph XML and Data XML definition, you can find more information on
BI Beans web site.
Ok, we’re almost done, all the contents are presented. But at the last thing, let’s master this very
cool technique that would attracts a lot of people! It’s Table of Contents and Bookmark!
Step 17: Add Table of Contents or Bookmark!
Table of Contents
This is pretty easy and very straightforward. What you need to do is just to use MS Word native
function.
1. Type <?CUSTOMER_NAME?> and remove CUSTOMER_NAME text form, this is because the
Table of Content function can not handle the text form.
2. Change the font setting for the <?CUSTOMER_NAME?> to be ‘Heading 1’.
3. Insert a section break before the first page header so that you will have a blank page as the
first page. You can use MS Word’s section break for this. (Insert->Break->Section Break->Next
Page)
4. Move to the inserted first page and place your mouse cursor into the first page.
5. Click Insert from the tool menu and select Reference-> Index and Tables
6. Click Table of Content tab and choose how you want to display your Table of Contents
7. Click OK.
8. Make sure that the table of contents has <?CUSTOMER_NAME?> tag inserted.
So, you should see something like the following in the first page.
Page 22 of 25
Step 17: Add Table of Contents or Bookmark!
As one of new features that have been introduced with 10.1.3.2 is a Crosstab support through
Template Builder. Before, you still could create a crosstab, but you need to develop some logic to
support dynamically generating columns and cells. Yes, if you have been there you know what I’m
talking about… It was a lot of pain! But now, you can just insert the crosstab from the Template
Builder tool bar and map required element in the UI, and you have the crosstab in your template!
It’s nothing!
In order to play with the crosstab, let’s start with a new data and new template.
1. Create a new RTF template
2. Import
Bookmark
So the one last step! Now you have a table of contents displayed in the first page and sometimes
that is what users want. But if you’re familiar with PDF document you might want to make it as a
bookmark that is displayed at left pane and makes so easy to move around the document you
generate. Only you need to do is to add BI Publisher’s tag before and after the table of contents that
has been added at the previous step.
Page 23 of 25
1. Remove the section break that has been used to create the first page for the table of
contents because the table of contents is not going to be displayed, it will be converted to a
bookmark, so you don’t want to have one blank page at the first page.
2. Add the following tag before the table of contents.
<?convert-to-bookmark:?>
3. Add the following tag after the table of contents.
<?end convert-to-bookmark:?>
Now, try preview the document, you will see a bookmark that has links to each customer’s report.
Pretty cool, huh?!
<The following section is added with the release of 10.1.3.2.>
Step 17: Crosstab
One of the new features that have been introduced since R10.1.3.2 is a Crosstab UI development
support through the Template Builder. Before, you could still develop the crosstab layout by
manually developing some logic to generate dynamic columns and cells based on the data. If you
have been there, you know what I’m talking about… Yes, it was such a pain to insert such logic based
on your data. But now things got much better, you can just insert the crosstab object from the
toolbar and drag and drop the data element in the new UI to generate the crosstab!
Before this exercise let’s create a new template and load a new data for crosstab layout.
Page 24 of 25
1.
2.
3.
4.
5.
6.
7.
8.
Create a new RTF template
Load Crosstab_Sample_Data.xml
Go to File->Page Setup and choose Landscape as Orientation
Select Crosstab from the Template Builder tool bar. (Insert->Crosstab)
Drag and Drop ‘Flows’to data area
Drag and Drop ‘Bus Grp’ to Row Header area
Drag and Drop ‘Type’ to Column Header area
Click OK.
Now when you try preview it, you’ll get a crosstab layout report!
As you notice there are many text forms inserted along with the creation of crosstab.
Basically, the first row is displaying column header by having for-each-group loop with ‘Type’
element. And then the row header of the second row is taking care of repeating Business Groups in
vertical order with for-each-group loop logic. And inside the for-each-group logic there is a for-eachgroup loop logic, which you can find it in the second cell from the left in the second row. And the last
cell in the second row is talking care of sub-total, which is a total for the Business Group in the row.
Lastly, the last row is similar to the first row, but the difference is to display total for each Type
column. So now you know what I was talking about! Yes, you had to do this by yourself before, old
days….. But now you don’t really need to think about the logic, you can create the crosstab in just a
matter of 5 seconds!
Conclusion
Now you have finished all the steps and should have this fancy customer balance report that has
implemented many techniques of BI Publisher and MS Word. With all the steps done with this
tutorial you should be able to develop many different varieties of BI Publisher reports and also
Page 25 of 25
should be able to demonstrate its strong capability and flexibility to satisfy many different business
requirements on business report. Also with this tutorial and materials along with this training you
should be confident enough to provide a training of RTF template development to somebody else.
There are more RTF template development techniques, so keep play around with BI Publisher and
you will find more fun and excitement! Have fun!
Download