Understanding the Printable Documents Framework

This section discusses:

  • The Printable Documents Framework.

  • The Printable Document Object.

  • The Printable Document Object methods and properties.

The Printable Documents Framework enables the creation of a real-time, printable document within the context of any online transaction. This printable version functionality is a common web feature that removes non-printable content from a web page (such as images, frames, buttons) for ease of printing. This framework removes the need to schedule a job to produce simple, straightforward transactional reports for printing. This printable version functionality supports these transactions:

  • Counter sale goods receipt.

  • Counter sale pick plan.

  • Deposit refund.

  • Cash drawer receipt.

If you want to add printable version functionality to any other online transaction in the system, you can leverage the Printable Document Object to assist you with this type of configuration.

Note: To view the goods receipt, pick plan, deposit receipts, and cash drawer receipts, you will need to grant full security access to the Web Libraries on your permission list for the iscripts located in the web library WEBLIB_SCM_UTIL. These iscripts are HTMLAREA.FieldFormula.IScript_isPrintReady and HTMLAREA.FieldFormula.IScript_PrintDoc.

See Understanding BI Publisher Picking Plan and Goods Receipts Reports.

The Style Repository within the Printable Document Framework provides the ability to define the stylesheet to use with the Printable Document Framework reports. In addition, this repository allows you to customize the stylesheets and override a given stylesheet for reports at the business-unit level so that a different look and feel can be created for reports for each business unit.

Note: The Printable Document Style component is shipped as system data and should be updated by the developers adding reports to the Printable Document Framework. You populate the Printable Document Style By Business Unit component if you want to change the default stylesheet by business unit for a report within the Printable Document Framework.

If you want to add printable version functionality to any other online transaction in the system, then you can leverage the Printable Document Object to assist you with this type of configuration.

To leverage the Printable Document Object within PeopleTools:

  1. Add a translate value to the SCM_REP_TYPE field for your report.

    This field is a CHAR(4) that contains the list of the valid SCM Reports for use with the SCM Printable Document Framework. These values are shipped for this field:

    • BICR (Billing Cash Receipt)

    • BIDR (Billing Deposit Receipt)

    • OMGR (Order Management Goods Receipt)

    • OMPK (Order Management Pick Plan)

  2. Once you have added the translate value, you have these two options:

    • Add the SAC_RPT_SUB subpage to your page at Level0.

      This subpage contains an HTMLArea (DERIVED_HTML.HTMLAREA) that does not display any information to the user. Instead, this HTMLArea is used to pop up or print your printable document in the background by the Printable Document Framework.

    • If you already have a HTMLArea on your page, you can omit the delivered subpage and simply assign the values returned by the PrintableDocument object properties showHTML or printHTML to the HTMLArea on your page.

  3. Add PeopleCode to the page to create and display (or directly print) the printable document.

    Note: This PeopleCode can be behind FieldChange on a pushbutton or link, behind RowInit, or anywhere that you can to initiate the Printable Document logic. This code is used for either launching a pop-up window that displays your printable document (showHTML) or for sending your printable document directly to a print dialog (printHTML).

Your PeopleCode must instantiate the PrintableDocument object (SCM_UTILITES:PrintableDocument) to generate a report. This PrintableDocument object accepts a rowset, an XML document, or a HTML string as valid data sources in order to generate a report. If you choose the rowset or XML document data source, then you must populate the XSLDocument property in order to translate the data into HTML for display. This XSLDocument can be populated directly or you can use the Print Document Framework Style Repository using the SetStyle() method to retrieve the report stylesheet. If the report data is already in HTML format, then no translation is needed and the XSLDocument property does not need to be set.

This figure illustrates the Printable Document Object Class:

Image: Printable Document Object Class

This example illustrates the fields and controls on the Printable Document Object Class. You can find definitions for the fields and controls later on this page.

Printable Document Object Class

A sample PeopleCode instantiation of the Printable Document Object class might be:

/*Import the Printable Document*/
import SCM_Utilities:PrintableDocument;

/*Instantiate the PrintableDocument Object*/
Local SCM_UTILITIES:PrintableDocument &pDoc;

/*Add code to create a local rowset withthe data needed for printing*/
Local Rowset &rs;
...
&pDoc.RowsetData=&rs;

/*Set the stylesheet*/
&pDoc.SetStyle("OM", "US001", "OMGR");

/*Show the Printable Document*/
&pDoc.Show();

This section provides an overview of the methods and properties available for use with the Printable Document Object.

Methods

The Printable Document object has these methods that you can call:

Method

Use

Additional Information

Show ()

Use this method to display your report as a pop-up document.

Just before launching the pop-up window, you can set various display properties on the PrintableDocument object to control the size and placement of the pop-up menu. You can also control what additional elements appear in the pop-up menu. For example, you can turn the toolbar, menu, and scroll bars on or off. Any attributes that are not set are provided by default from the client's browser environment.

Print ()

Use this method to send your report to a print dialog.

While the Show() method may be used to display pure XML in a pop-up window for the user to then manually print, the Print() method throws an exception if there is no XSL document to transform the XML. This occurs because JavaScript can only invoke its print() and close() methods on a window that contains HTML. Attempts to print or close a window with only XML fail, and thus the user is presented with a small, confusing, orphaned window.

SetStyle(&BU_Type, &BU, &Report_Type)

Use this method to set the XSLDocument property based on the Printable Document Framework Repository.

&BU_Type: OM for Order Management or AR for Accounts Receivable.

&BU: an OM or" AR Business Unit

&Report_Type: a valid translate value on the SCM_REP_TYPE field

includeXSLTemplate(&templateName as string)

Use this method to include XSL templates stored in HTML objects into an existing XSLDocument.

Several templates are shipped with the product.

Include these templates by passing to the includeXSLTemplate() method any PrintableDocument properties having names beginning with "pdXSLTmplt." It is not recommended that you directly pass in the HTML object names of these standard templates, as some require the inclusion of other templates to work properly. Using the pdXSLTmplt properties ensures that any other required templates are included as well.

Properties

This table lists the properties available for use with the Printable Document Object:

Property

Use

Examples, Additional Parameters

rowsetData

Use this property to set the datasource for your report using a rowset.

Example for setting the pop-up window attributes:

&pDoc.Height=400;
&pDoc.Width=600;
&pDoc.MenuBar=False;
&pDoc.StatusBar=True;
&pDoc.Resizeable=True;

XMLDocument

Use this property to set the datasource for a report using a XMLDoc or fetch the XMLDoc result from your rowsetData (convert a rowset to XML)

XSLDocument

Use this property to set the XSL Stylesheet or to fetch the XSL Stylesheet generated by the SetStyle() method.

HTMLString

Use this property to set the HTMLString for display or fetch the HTMLString generated from the XMLDocument and XSLDocument.

printHTML

Use this property if you already have an HTMLArea on the page, and can use it instead of including the delivered sub-page.

showHTML

Use this property if you already have an HTMLArea on the page, and can use it instead of including the delivered subpage.

pdXSLTmpltHeader

This is a delivered template for document headers. It puts the company logo in the upper left corner of the page, company address in the upper right, and document title centered and below the other two.

Parameters (any parameters omitted will not appear in the address block):

name — Piece of the address block

address1 — Piece of the address block

address2 — Piece of the address block

address3 — Piece of the address block

city — Piece of the address block

state — Piece of the address block

postal — Piece of the address block

reportTitle — The title for the report

pdXSLTmpltAddress

This is a delivered template for address blocks.

Parameters (any parameters omitted will not appear in the address block):

msgStr — A label for the address block

name — Piece of the address block

address1 — Piece of the address block

address2 — Piece of the address block

address3 — Piece of the address block

city — Piece of the address block

state — Piece of the address block

postal — Piece of the address block