12. Report-Writer Statements : Print Statements : .Print and .Println Statements—Print Text of Report : Examples
 
Share this page                  
Examples
1. Assume a report specification with the following literals:
.print 'Text may'
    ' span several lines.'
It would print the following output:
Text may span several lines.
Because there was no specification statement such as a .tab or a .newline to separate the fields, the two text strings printed immediately adjacent to each other on the same line of the output.
2. In this example, assume that page_numberis equal to 3.
.pr 'Page number:', page_number(zz)
Report-Writer would print the following text:
Page number: 3
3. The following example shows the specifications you need to print a data value (represented by a delimited identifier for the column name) and an aggregate, using a numeric template for the aggregate where the value of millions_fmt is 'nnn,nnn,nnn.nn':
.print "acct bal", sum("acct bal")($millions_fmt)
4. A complex .print statement that displays a large number of data items can look like the following:
.print 'Values of the data are: ', var1,
                 var2(e20.4) cvar1(c40), ' and finally',
                 lastvar (' $$$,$$$,$$$.nnCR')
Note that in the previous example, the field, var1, was listed without a format. Report-Writer prints the value with the default format for the data type, according to the table in Default Formats, in the chapter "Report-Writer Expressions and Formats." It is acceptable to mix the default data formats with extremely complex templates. Using an acceptable default format saves you the time and effort of specifying every format in detail.