Search This Blog

Tuesday, 22 January 2013

Brought Forward/Carried Forward Totals In XML


Brought Forward/Carried Forward Totals

Many reports require that a page total be maintained throughout the report output and be displayed at the beginning and end of each page. These totals are known as "brought forward/carried forward" totals.
Note: The totaling for the brought forward and carried forward fields is performed in the PDF-formatting layer. Therefore this feature is not available for other outputs types: HTML, RTF, Excel.
An example is displayed in the following figure:
At the end of the first page, the page total for the Amount element is displayed as the Carried Forward total. At the top of the second page, this value is displayed as the Brought Forward total from the previous page. At the bottom of the second page, the brought forward value plus the total for that page is calculated and displayed as the new Carried Forward value, and this continues throughout the report.

Assume you have the following XML:
The following sample template creates the invoice table and declares a placeholder that will hold your page total:







To display the brought forward total at the top of each page (except the first), use the following syntax:
The following table describes the elements comprising the brought forward syntax:
Insert the brought forward object at the top of the template where you want the brought forward total to display. If you place it in the body of the template, you can insert the syntax in a form field.
Place the carried forward object at the bottom of your template where you want the total to display. The carried forward object for our example is as follows:


Note the following differences with the brought-forward object:
·         The display-condition is set to exceptlast so that the carried forward total will display on every page except the last page.
·         The display string is "Carried Forward".
·         The show-carry-forward element is used to show the carried forward value. It has the same properties as brought-carried-forward, described above.

You are not limited to a single value in your template, you can create multiple brought forward/carried forward objects in your template pointing to various numeric elements in your data.

Number Formatting In XML


Number Formatting

Number Formatting

XML Publisher supports two methods for specifying the number format:
·         Microsoft Word’s Native number format mask.
Oracle’s format-number function.
·         Native XSL format-number function
Use only one of these methods. If the number format mask is specified using both methods, the data will be formatted twice, causing unexpected behavior. The group separator and the number separator will be set at runtime based on the template locale. This is applicable for both the Oracle format mask and the MS format mask.
To use the Oracle format mask or the Microsoft format mask, the numbers in your data source must be in a raw format, with no formatting applied (for example: 1000.00).

Using the Microsoft Number Format Mask

To format numeric values, use Microsoft Word’s field formatting features available from the Text Form Field Options dialog box. The following graphic displays an example:
To apply a number format to a form field:
1.    Open the Form Field Options dialog box for the placeholder field.
2.    Set the Type to Number.
3.    Select the appropriate Number format from the list of options.
The following table lists the supported Microsoft format mask definitions:
Symbol
Location
Meaning
0
Number
Digit. Each explicitly set 0 will appear, if no other number occupies the position.
Example:
Format mask: 00.0000
Data: 1.234
Display: 01.2340
#
Number
Digit. When set to #, only the incoming data is displayed.
Example:
Format mask: ##.####
Data: 1.234
Display: 1.234
.
Number
Determines the position of the decimal separator. The decimal separator symbol used will be determined at runtime based on template locale.
For example:
Format mask: #,##0.00
Data: 1234.56
Display for English locale: 1,234.56
Display for German locale: 1.234,56
,
Number
Determines the placement of the grouping separator. The grouping separator symbol used will be determined at runtime based on template locale.
For example:
Format mask: #,##0.00
Data: 1234.56
Display for English locale: 1,234.56
Display for German locale: 1.234,56
-
Number
Determines placement of minus sign for negative numbers.
E
Number
Separates mantissa and exponent in a scientific notation.
Example:
0.###E+0 plus sign always shown for positive numbers
0.###E-0 plus sign not shown for positive numbers
;
Subpattern boundary
Separates positive and negative subpatterns. See Note below.
%
Prefix or Suffix
Multiply by 100 and show as percentage
Prefix or Suffix
Used to quote special characters in a prefix or suffix.
Note: Sub pattern boundary: A pattern contains a positive and negative sub pattern, for example, "#,##0.00;(#,##0.00)". Each sub pattern has a prefix, numeric part, and suffix. The negative sub pattern is optional. If absent, the positive sub pattern prefixed with the localized minus sign ("-" in most locales) is used as the negative sub pattern. That is, "0.00" alone is equivalent to "0.00;-0.00". If there is an explicit negative sub pattern, it serves only to specify the negative prefix and suffix. The number of digits, minimal digits, and other characteristics are all the same as the positive pattern. That means that "#,##0.0#;(#)" produces precisely the same behavior as "#,##0.0#;(#,##0.0#)".
Example: -
Here we are using same RTF which we had used in IF STATEMENT.
RTF looks

Now we are going to format the number of Inv_Amt using the Microsoft Number format Mask which is shown below

for that give double click on Inv_Amt then we can see below window

In the above picture we can see there is one option as Type change it to Number which is show below



From the above picture we can see there is one option as Number format which has some number formats which is shown below

Here we have to give default number also which is shown below.
Select one of the above formats according to our requirement. Here we are selecting third option which is shown below

Click on ‘OK’

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output

From the above picture we can see the Number format of the Invoice_Amount what ever we had given in the Number format option.


Using the Oracle Format Mask:

To apply the Oracle format mask to a form field:
1.    Open the Form Field Options dialog box for the placeholder field.
2.    Set the Type to "Regular text".
3.    In the Form Field Help Text field, enter the mask definition according to the following example:
<?format-number:fieldname;’999G999D99’?>
where fieldname is the XML tag name of the data element you are formatting and 999G999D99 is the mask definition.
The following graphic shows an example Form Field Help Text dialog entry for the data element "empno":

Example: -
Here also we are going to take same RTF which we had taken in the IF STATEMENT which is shown below
Just give double click on Inv Amt then click on Add Help Text there we have to give XML format which is shown below

Click on ‘OK’

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output
From the above output we can see that Invoice_Amount is formatted into a specified format which we had mentioned in XML format.





The following table lists the supported Oracle number format mask symbols and their definitions:
Symbol
Meanings
0
Digit. Each explicitly set 0 will appear, if no other number occupies the position. Example: Format mask: 00.0000 Data: 1.234 Display: 01.2340
9
Digit. When set to 9, only the incoming data is displayed. Example: Format mask: 99.9999 Data: 1.234 Display: 1.234
C
Returns the ISO currency symbol in the specified position.
D
Determines the placement of the decimal separator. The decimal separator symbol used will be determined at runtime based on template locale. For example: Format mask: 9G999D99 Data: 1234.56 Display for English locale: 1,234.56 Display for German locale: 1.234,56
EEEE
Returns a value in scientific notation.
G
Determines the placement of the grouping (thousands) separator. The grouping separator symbol used will be determined at runtime based on template locale. For example: Format mask: 9G999D99 Data: 1234.56 Display for English locale: 1,234.56 Display for German locale: 1.234,56
L
Returns the local currency symbol in the specified position.
MI
Displays negative value with a trailing "-".
PR
Displays negative value enclosed by <>
PT
Displays negative value enclosed by ()
S (before number)
Displays positive value with a leading "+" and negative values with a leading "-"
S (after number)
Displays positive value with a trailing "+" and negative value with a trailing "-"

Date Formatting in XML


Date Formatting

Date Formatting

XML Publisher supports three methods for specifying the date format:
·         Specify an explicit date format mask using Microsoft Word’s native date format mask.
·         Specify an explicit date format mask using Oracle’s format-date function.
·         Specify an abstract date format mask using Oracle’s abstract date format masks. (Recommended for multilingual templates.)
Only one method should be used. If both the Oracle and MS format masks are specified, the data will be formatted twice causing unexpected behavior.

Data Source Requirements

To use the Microsoft format mask or the Oracle format mask, the date from the XML data source must be in canonical format. This format is:
YYY-MM-DDThh:mm:ss+HH:MM
where
·         YYYY is the year
·         MM is the month
·         DD is the day
·         T is the separator between the date and time component
·         hh is the hour in 24-hour format
·         mm is the minutes
·         ss is the seconds
·         +HH:MM is the time zone offset from Universal Time (UTC), or Greenwich Mean Time
An example of this construction is:
2005-01-01T09:30:10-07:00
The data after the "T" is optional, therefore the following date: 2005-01-01 can be formatted using either date formatting option. Note that if you do not include the time zone offset, the time will be formatted to the UTC time.

Using the Microsoft Date Format Mask

Use the same procedure as number formatting.
Following table lists the supported Microsoft date format mask components:



Refer LOGO location from XML


Refer LOGO location from XML

Follow the below steps for ‘Refer LOGO location from XML’
  1. Insert a dummy image in our template.
  2. In the format picture dialog box select the web tab. Enter the following syntax in the Alternative text region to reference the image URL:
url: {IMAGE_LOCATION}.
Where IMAGE_LOCATION is an element from our XML file that holds the full URL to the image .
 We can also build a URL based on multiple elements at runtime. Just use the Concat function to build the URL string. For example:
url: {concat(SERVER,’ / ‘,IMAGE_DIR,’ / ‘,IMAGE_FILE)}
This method can also be used with the OA_MEDIA reference as follows
url: {concat{‘${OA_MEDIA}’ , ‘ / ‘,IMAGE_FILE)}




Inserting a static LOGO in Header In XML


Inserting a static LOGO in Header


In the previous lesson we had learnt how to add header and footer. Now we are going to insert a static image to that template itself.

Previous lesson (template shown below)


Now we are going to add static image.
For that just click on empty where we have to insert image.
For example we are going to place image at the left side of the page. For that just give click or place cursor at some place in the left side of the page which is shown below

Now go to Isert=>picture=>from file which is shown below


When ever we click on ‘From file’ a pop window will appear with images which is shown below



Select one of the pictures and select Insert

Now our RTF looks like

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
 We get the below output


Next page


It is the way how to print static logo