The PRINT Statement

The PRINT Statement 1

Statement Format 1

Statement OPTIONS.. 1

DATA.. 1

Data Item Options. 1

HEADING.. 1

HEADING Configuration Options. 1

PIC.. 1

SUM.. 1

COL or RCOL. 1

BREAK[(Field name)] |  ALL. 1

MSG768. 1

REPORT(nbr) 1

FIELDTABLEn. 1

FIELDTABLE with HEX.. 1

Limiting Printing. 1

PAGE | SPACE(nbr) 1

SUMMARY.. 1

Report Layouts. 1

Default Report Layout 1

Default Line Layout 1

Control Break Identification. 1

Label Printing. 1

LINE.. 1

Eastrieve Conversion Option. 1

EZT. 1

 

PRINT formats data for a report and prints one or more lines. It is usually used within a PROCESS block.  For example,

PROCESS Customer WHERE Customer.Balance > 1000; [Not interested in small creditors

     PRINT (Customer.Name, Customer.Address, Customer.Balance);

END PROCESS Customer;

 

PRINT is not valid within a program that uses PROGRAM xxx REPORT; Instead, use PLINE, which is a version of the PRINT statement designed to be written within $R-xxxx routines.

Statement Format

PRINT DATA(data list) [REPORT(nbr)] [FIELDTABLE] | [SUMMARY]; 

 

SUMMARY may not be used with FIELDTABLE

Statement OPTIONS

DATA

DATA is the most important option of the PRINT statement as it defines which fields are to be printed.  You will normally omit the keyword DATA, writing

            PRINT (Item1, Item2, item3) Other-options;

rather than writing

            PRINT DATA(Item1, Item2, item3) Other-options;

 

If DATA is written explicitly, then it does not have to be the first option of the PRINT statement.

 

The data list consists of one or several items separated by commas. Items may be

·         Field references, e.g. Customer.Name

·         Generic references, e.g. Customer.*.  This is equivalent to naming all the fields of the record or group individually.

·         String constants, e.g. 'xxxx'.

·         Numbers and decimal numbers

Data Item Options

Items can have options: -

·         HEADING ‘field heading’

·         PIC 'picture'

·         SUM, NOSUM, AVG,

·         COL | RCOL

·         BREAK field | ALL

·         MSG768

HEADING

Fields are printed in columns, normally using the field name as the column heading. For example, the field “Customer.Balance” will be printed under a column heading of “Balance” if the field requires 7 or fewer characters. If it requires more characters then the field name is extended with hyphens, and an asterisk marks the field boundaries. For example Customer.Name, requiring 30 characters, will use a column heading of

*------------Name------------*.

 

With Heading you explicitly specify the heading that you want. Headings are specified as one or several character strings, e.g.

            Customer.Address HEADING 'Main Mailing Address'

and

            FR.NameHEADING 'Region' 'Name',

As with default headings, if necessary this is expanded with *--- and ---*.

HEADING Configuration Options

You can configure MANASYS Jazz to omit the hyphens and asterisks.  Refer to Configure/COBOL for details. 

PIC

You can specify an explicit layout for data if you do not want to use the defaults provided by Jazz.  For example,

Customer.Balance PIC '$,$$$,$$9.99 CR'

 

The PIC values follow the rules defined for defining data.  Click here for these rules, and look at PIC and DPIC in particular.

 

For numeric fields the value that you provide should be a valid COBOL PICTURE clause, and should be appropriate for the data.  Jazz provides only limited checking: whereas the default pictures will accommodate the maximum values that the field can hold and won’t put an alphabetic picture with numeric data or vice versa, Jazz does not check for these possible errors with explicit PIC clauses. If the field uses the SUM option then the same picture will be used for the totals as for the details, so you should ensure that the PIC value is large enough.

 

For DATE fields the PIC value should define a date format, e.g.

Customer.Commenced PIC 'dd MMM yyyy'

 

BOOLEAN fields and fields with CODES will print as their value, for example

DEPTMGR BOOLEAN,

This defines a single-character field with value 'Y' or something else, but its value will be printed as 'True' or 'False'.   Similarly

SEX CHAR(1) CAPS CODES(M:Male, F:Female),

will print as 'Male' or 'Female'

SUM

The field will be summed, with totals being reported at the end of the report and subtotals being reported on control break.

NOSUM

When an Easytrieve program is being converted to Jazz, SUM is added to eligible fields (numeric, not a BREAK field).  If SUM has been added a field that you do not want summed, change its SUM to NOSUM.

AVG

The field will be summed, with averages being reported at the end of the report and on control break. The PROCESS statement must include the TALLY option.

COL or RCOL

Use these to specify the starting (leftmost) or finishing (rightmost) column of the data item.   If necessary COL and RCOL will cause the line to be split into two.   Use COL for CHAR and VARCHAR items, which are left-aligned, and RCOL for numeric items.

BREAK[(Field name)] |  ALL

BREAK specifies that the field is only printed on control break, and the first line of a new page.  For example, here is a program printing data from IN1.  The PROCESS statement specifies the input sequence, and which of the control fields cause control breaks: -

PROCESS IN1 [WHERE (IN1.Region = 1 | IN1.Region = 6) ]

        ORDER (IN1.Region BREAK, IN1.District BREAK, IN1.Name);

    GET FR WHERE (FR.Region = IN1.Region);

    PRINT (IN1.Region BREAK,FR.Name BREAK (IN1.Region), IN1.District BREAK,

        IN1.Name, IN1.SalesThisMonth SUM);

END PROCESS IN1;       

 

BREAK is optional when applied to an item that is a control break field, and also the field name can be omitted.  Thus
           
IN1.Region,

            IN1.Region BREAK,

and
           
IN1.Region BREAK(IN1.Region),

are all equivalent in the PRINT statement above, as BREAK(IN1.Region) is inherited from the PROCESS statement.

 

BREAK (field name), e.g. BREAK (IN1.Region), must be given for fields like FR.Name if you want PRINT to handle them as if they were control break fields.

 

With the above PRINT statement the report is like this, with subtotals on every change of in1.Region,and  IN1.District and grand totals at the end

1Printed at 01 Feb 2021, 15:29:49                             RepNbr1                             Page   1                            

 

Region *--------Region Name---------* District *-----------------Name-----------------* *SalesThisMonth-*                           

 

     1 New Zealand                           1 REEDE, Phillip                                   $468.55                             

     1                                       1 District Subtotal                                $468.55                             

 

                                             3 CAMPBELL, Dennis                               $5,662.44                             

                                               CORLETT, Norton Hesse                          $9,197.76                             

                                               ROBERTS, Adelaide                              $4,138.56                             

                                               ROBERTS, Margaret Annie                        $8,138.51                             

                                               WILLIAMSON, Catherine                          $5,554.20                             

     1                                       3 District Subtotal                             $32,691.47                             

                                             7 POLAND, Lorna Aroha                            $7,103.77                             

     1                                       7 District Subtotal                              $7,103.77                             

     1                                         Region Subtotal                               $83,215.58                             

 

     2 Australia                             1 CAMPBELL, Lindsay Kenneth                      $9,055.81                             

 

BREAK is the default for control break fields, so we will get the same results if we omit BREAK with IN1.Region and IN1.District.

 

Notice that although the Region and District are printed on the subtotal lines, on the detail lines District is only printed on the first detail line for that district, and Region and Region Name is only printed on the first detail line for the region.   What if we wanted Region fields to also be printed at the start of each district? We would use BREAK options like this: -

PROCESS IN1 [WHERE (IN1.Region = 1 | IN1.Region = 6) ]

        ORDER (IN1.Region BREAK, IN1.District BREAK, IN1.Name);

    GET FR WHERE (FR.Region = IN1.Region);

    PRINT (IN1.Region BREAK(IN1.District),FR.Name BREAK (IN1.District), IN1.District BREAK,

        IN1.Name, IN1.SalesThisMonth SUM);

END PROCESS IN1;  

Now the Region Number and Name are printed on the first record of each district: -   

1Printed at 01 Feb 2021, 15:43:31                             RepNbr1                             Page   1                            

0Region *--------Region Name---------* District *-----------------Name-----------------* *SalesThisMonth-*                           

0     1 New Zealand                           1 REEDE, Phillip                                   $468.55                             

      1                                       1 District Subtotal                                $468.55                             

0     1 New Zealand                           2 PYM, Freda Mary                                $8,642.65                             

                                                PYM, Samuel Arnott                             $2,304.87                             

      1                                       2 District Subtotal                             $10,947.52                             

0     1 New Zealand                           3 CAMPBELL, Dennis                               $5,662.44                             

                                                CORLETT, Norton Hesse                          $9,197.76                             

                                                ROBERTS, Adelaide                              $4,138.56                             

                                                ROBERTS, Margaret Annie                        $8,138.51                             

                                                WILLIAMSON, Catherine                          $5,554.20                             

      1                                       3 District Subtotal                             $32,691.47                             

0     1 New Zealand                           4 SARTEN, Leslie Robert                          $3,824.97                             

                                                VOLZKE, Mary                                   $8,275.54                             

                                                WELLARD, Alfred Champion                       $7,611.58                             

      1                                       4 District Subtotal                             $19,712.09                             

0     1 New Zealand                           5 BARNES, Caroline                               $1,121.76                             

                                                CUDD, Joseph                                   $9,084.29                             

                                                TREBILCOCK, Anne Matilda                       $2,086.13                             

      1                                       5 District Subtotal                             $12,292.18                             

0     1 New Zealand                           7 POLAND, Lorna Aroha                            $7,103.77                             

      1                                       7 District Subtotal                              $7,103.77                             

                                                Region Subtotal                               $83,215.58                             

0     2 Australia                             1 CAMPBELL, Lindsay Kenneth                      $9,055.81                             

 

Use ALL to have the control break fields printed on every line.  For example, with

    PRINT (IN1.Region All,FR.Name, IN1.District ALL,

        IN1.Name, IN1.SalesThisMonth SUM);

the report looks like this: -

Printed at 01 Feb 2021, 16:41:30                             RepNbr1                             Page   1

 

Region *--------Region Name---------* District *-----------------Name-----------------* *SalesThisMonth-*

 

     1 New Zealand                           1 REEDE, Phillip                                   $468.55 

     1 District Subtotal                     1                                                  $468.55 

 

     1 New Zealand                           2 PYM, Freda Mary                                $8,642.65 

     1 New Zealand                           2 PYM, Samuel Arnott                             $2,304.87 

     1 District Subtotal                     2                                               $10,947.52 

 

     1 New Zealand                           3 CAMPBELL, Dennis                               $5,662.44 

     1 New Zealand                           3 CORLETT, Norton Hesse                          $9,197.76 

     1 New Zealand                           3 ROBERTS, Adelaide                              $4,138.56 

     1 New Zealand                           3 ROBERTS, Margaret Annie                        $8,138.51 

     1 New Zealand                           3 WILLIAMSON, Catherine                          $5,554.20 

     1 District Subtotal                     3                                               $32,691.47 

 

Control breaks are only effective if the PRINT statement is written directly within PROCESSEND PROCESS, or if it is written within a ROUTINE that is linked to the PROCESS statement through LINKID.  For example, here the PRINT statement handles control breaks normally for IN1.Region and IN1.District. 

PROCESS IN1 WHERE (IN1.Region = 1 | IN1.Region = 6)

        ORDER (IN1.Region BREAK, IN1.District BREAK, IN1.Name) INDEX JZ.JZ-INDEX SID(18);

    GET FR WHERE (FR.Region = IN1.Region);

    PERFORM PrintLine LINKID(18);

END PROCESS IN1;  

ROUTINE Printline LINKID(18);

    PRINT (IN1.Region,FR.Name, IN1.District, IN1.Name, IN1.BillingCycle,

        IN1.SalesThisMonth SUM, IN1.SalesYTD SUM);

END ROUTINE Printline;  

 

However if LINKID(18) is omitted from the ROUTINE statement the report looks like this, with no subtotals on change of Region or District: -

Region *--------Region Name---------* District *----Name-----* BillingCycle *SalesThisMonth *--SalesYTD---*                        

 

     1 New Zealand                           1 BLEE,ElliottLin    November           206.02        4,640.25                        

     1 New Zealand                           1 HANNAH,Honour      December           206.02        4,640.25                        

     1 New Zealand                           1 JAMES,Elizabeth    October            206.02        4,640.25                        

     1 New Zealand                           2 HARRINGTON,Laur    February           206.02        4,640.25                        

     1 New Zealand                           2 HAY,Gordon         May                206.02        4,640.25                        

     1 New Zealand                           4 GREGORY,Nancy      November           206.02        4,640.25                        

     6 France                               11 EPTHORPE,SARAHE    February           206.02        4,640.25                        

     6 France                               11 GREGORY,Isabel     July               206.02        4,640.25                        

 Grand Total                                                                       8,858.86      199,530.75 

MSG768

This option will sometimes be added to items printed by your PRINT statement when an item is neither from the PROCESS file, nor a SUMS field.  For example,

PROCESS INP TALLY REOPEN SID(24) ORDER(INP.GROUP2.E-RB BREAK,INP.GROUP1.E-TS);

    PERFORM REPORT2 LINKID(24);

END PROCESS INP;

ROUTINE REPORT2 [Report] LINKID(24);

   

    PRINT (INP.E-RB, MSG768 SUM,Sums18.TALLY(1)) LINE(1) REPORT(2);

    #768 E Check that EZT-MISC3058-Data.GROUP1.W-PRCS is correctly set

END ROUTINE REPORT2;

Field EZT-MISC3058-Data.W-PRCS is not set by the PROCESS loop, so MSG768 is inserted and the message produced.  Here the error needs to be fixed by copying the assignment from the PROCESS loop controlling REPORT1

PROCESS INP TALLY REOPEN SID(24) ORDER(INP.GROUP2.E-RB BREAK,INP.GROUP1.E-TS);

    EZT-MISC3058-Data.W-PRCS = INP.E-PRCS;

    PERFORM REPORT2 LINKID(24);

END PROCESS INP;

           

    PRINT (INP.E-RB, SUM,Sums18.TALLY(1)) LINE(1) REPORT(2);

 

Remove MSG768 from the PRINT statement so that the message does not keep appearing.

REPORT(nbr)

A single program can produce several reports. Use REPORT to distinguish which report the PRINT statement refers to. If the PRINT statement has no REPORT option then REPORT(1) is assumed.

 

It is possible to define overall report characteristics with a REPORT statement: -

REPORT(1) PAGE(50) WIDTH(120) HEADING('Large Customer Report');

 

If there is no REPORT statement, then a report with PAGE(60) WIDTH(132) HEADING('RepnbrN') is assumed.

FIELDTABLEn

FIELDTABLE is designed for debugging, and for some special situations such as validating a file definition and printing conversion statistics (nbr of records in, out, sums of key values).  You would not use this option for printing every record of a file as it prints a separate line for every field, including every occurrence of every field.  You will probably limit printing to only 1 or a few records.

 

With this option, instead of arranging fields across the page PRINT causes each field to be printed on its own line, with format

            Field name/Heading               Length *Value*

for example, from PRINT (in1.*) FIELDTABLE; with In1 defined

DEFINE IN1 VB DATA(

    RDKey GROUP,

        Region DECIMAL(3),

        District DECIMAL(3),

        END GROUP,

    Name (3) CHAR(5),

    SalesThisMonth DECIMAL(7,2),

    SalesYTD DECIMAL(7,2),

    BillingCycle LIKE Types.month,

    DateCommenced CHAR(10))

this printout results: -

*   Field Name   *  LENGTH  VALUE    

IN1.Region        :      4*   9      

IN1.District      :      4*   3      

IN1.Name(1)       :      5*Custo*    

IN1.Name(2)       :      5*merNa*    

IN1.Name(3)       :      5*me2  *    

IN1.SalesThisMonth:     10*    329.82

IN1.SalesYTD      :     10*  1,092.63

IN1.BillingCycle  :     13*001/January

IN1.DateCommenced :     10*2012-10-17*

 

Length is the print length.  CHAR and VARCHAR fields may print over several lines (continuation lines will be labelled   Contd”), and an asterisk is printed following their last character unless this would cause another line.

 

You may not use FIELDTABLE with BREAK, PAGE, SPACE or ORDER or any field options (HEADING, SUM, etc) except HEX.  

FIELDTABLE with HEX

HEX may be specified for GROUP or Record references, and for references to CHAR and VARCHAR fields. 

    PRINT(CustF.* HEX, CustF HEX) FIELDTABLE;

    #652 E HEX invalid with CustF.*

Here HEX is invalid, and will be ignored, for the generic reference CustF.*.  It is valid for the record (= GROUP) reference CustF, so that this statement is equivalent to: -

    PRINT(CustF.*, CustF HEX) FIELDTABLE;

 

This produces printing like this: -

*    Field Name    *  PR-LTH  VALUE                                               

CustF.Account       :      6:000001                                               

CustF.Region        :      4:   5                                                 

CustF.District      :      4:   6                                                 

CustF.Name          :     30:BANFIELD, Nora Joyce Annie    *                      

CustF.SalesThisMonth:     12: $5,817.53                                           

CustF.SalesYTD      :     12:$52,357.77                                           

CustF.Billingcycle  :     13:009/September                                        

CustF.DateCommenced :      9:28 Feb 18                                            

CustF               :     53:0...4...8...C...10..14..18..1C..20..24..28..2C..30..3

CustF               :     53:000001.\.lBANFIELD, Nora Joyce Annie    .u<R5w|..3í.

CustF               :     53:333333050644444444224676246766246666222208735377003E0

CustF               :     53:0000010C0C21E695C4C0EF210AF93501EE950000515C257C913D4

 

For each HEX item the data will be printed in blocks of four lines.   64 bytes will be printed in each block: if the item is longer then more 4-line blocks will be printed. Each 4-line block contains: -

1.    Ruler line, giving the offset of the character (counting in Hex)

2.    Character line, printing the field.  CHAR and PIC values are printed as normal, but other values may not be printable.  Values less than X20 (decimal 32), and greater than AD (decimal 173) are printed as ‘.’.

3.    First half-byte

4.    Second half-byte

 

The Hex encoding in lines 3 and 4 will be Ascii or EBCDIC depend on the system hosting the compiled COBOL program.  Here the program has been compiled locally (Micro Focus Enterprise Developer, running on a Windows laptop), so the encoding is Ascii. Here is the definition of CustF

DEFINE CustF VSAM DATA( 

    Account PIC '999999' HEADING 'Account Number' KEY,   

    Region DECIMAL(3),       

    District DECIMAL(3) RANGE(1:10),

    Name CHAR(30)  CAPS DKEY 'jazzuser.vsam.custf1',       

    SalesThisMonth MONEY(7,2),   

    SalesYTD MONEY(7,2),        

    Billingcycle LIKE Types.Month,

    DateCommenced DATE)

You can see from this how the data is represented in the Custf record.  Account takes 6 bytes, and has content X’303030303031’ = ‘000001,  Region and District are 2 byte packed numbers, and so on.

Limiting Printing

Here the PROCESS loop has been limited so that only the first three records are printed

PROCESS Custf COUNT JZ.IX1 UNTIL JZ.IX1 > 2;

    #199 W Reference to a field in the current file expected

    PRINT (CustF.*, CustF HEX) FIELDTABLE ;

END PROCESS Custf;

 

PAGE | SPACE(nbr)

With PAGE the PRINT statement will cause a new page.  SPACE(nbr) will cause the next line to be printed after spacing nbr lines, i.e. there will be (nbr – 1) blank lines.  PAGE and SPACE statement options will be ignored if there is a change in any BREAK fields: in this case line spacing is controlled by the control-break logic.

 

These options are usually used with program logic like this: -

            IF CUSTOMER.Code = 1234 THEN;
                       
PRINT (‘Specified Customer’) PAGE;

 

Note that this rule is different to the rule for a PLINE statement: -

            PRINT statement: on change of page or control break any PAGE or SPACE option is ignored.

            PLINE statement: PAGE/SPACE options are not ignored, but override automatic control break spacing.

SUMMARY

Summary causes a PRINT statement to print only the Subtotal and Total lines.  Detail lines are omitted.

Report Layouts

A PRINT statement such as

PRINT (Customer.Name, Customer.Address, Customer.Balance);

attempts to arrange data to produce a layout that looks good and is clear.

Default Report Layout

The layout rules are: -

 

1.            At the top of every page a page heading is printed. This has

a.    At the left, “Printed at dd mmm yyyy, hh.mm.ss”.   This is the value of $Today, i.e. the date and time at which this program starts. It will be the same on every page, no matter how long the report takes to print, and it is the date/time at which the program runs, not the date/time at which the printer actually prints the report.

b.    At the right, “Page nbr”. A page number of up to 9999. If the report has more than 9999 pages numbering will restart from 0.

c.     Centred in the space between the date/time and page number, the report heading, which is “Report 1” by default.

2.            A blank line

3.            One or more lines of column headings. From the PRINT statement above this would contain “Name”, “Address” and “Balance” arranged so that they appear above the corresponding data. If the column heading is shorter than the data area required, the extra space is filled with “*---” and “---*” so that it is clear where the columns begin and end.

4.            Another blank line

5.            Several lines of data from the PRINT statement, giving the values from up to 54* records

6.            Another blank line

7.            The heading is repeated as a footing.

 *          Assuming a page size of 60 lines per page for this example and a single line of column headings.

 

Note that there are a minimum of 6 lines per page required for page heading, column heading, and footer.  More may be needed if the PRINT statement produces more than one line, or if control breaks are involved (see below).

Default Line Layout

When you write something like

PRINT (Customer.Name, Customer.Address, Customer.Balance);

Jazz calculates the print layout as follows: -

1.            Fields require enough space for their maximum value.

a.    for CHAR and VARCHAR fields this is simply their number of characters, i.e. a field defined

            Name VARCHAR(30)

would require 30 characters.

b.    For numbers (other than FLOAT and LONG), there must be enough space to print the maximum value that the number can hold, plus

                                          i.    a decimal point if relevant

                                         ii.    commas at thousands, millions, etc. if relevant

                                        iii.    a leading minus sign if the number is negative,

                                       iv.    a currency symbol for MONEY fields.

Thus if Customer.Balance were defined as

Balance MONEY(9,2)

then 14 character spaces would be needed to cope with “-$1,234,567.89”

2.            Column headings are given by HEADING options, or are the field names, i.e. Name, Address, and Balance.

a.    If the column heading is shorter than the space required by the data, the heading is extended with “*---” and “---*”. For example

                Name VARCHAR(30),

will have a heading “*------------Name------------*”.

b.    If the heading is longer than the space required by the data, then filler is inserted

                                          i.    To the left of numeric fields

                                         ii.    To the right of character fields

c.     Constants (strings and numbers) have no headings.

3.            A column’s position can be explicitly specified with COL or RCOL: -

a.    COL specifies the left-most position of the column, and is more suitable for CHAR and VARCHAR fields and string constants. COL + column-width must be less than or equal to the report’s WIDTH.

b.    RCOL specifies the left-most position of the column, and is more suitable for numeric fields and constants. RCOL must be less than or equal to the report’s WIDTH, and must be greater than the field’s width.

4.            In the absence of COL or RCOL item options, one character of filler will be inserted between two fields. No space is inserted between a field and a constant.

5.            If there is insufficient room on the line to fit the next column, then a second line will be produced. This can happen because the line is already full, or because a COL or RCOL value is to the left of the end of the previous column.

Control Break Identification

PRINT  with SUM will produce subtotal lines for every control break, and a grand total line at the end.  For example: -

PROCESS in1 WHERE in1.Region >= 3 & in1.Region < 6

        ORDER(in1.Region, IN1.District BREAK, in1.Name);

    PRINT (IN1.Region,IN1.District,IN1.Name,IN1.SalesThisMonth SUM) ;

    #521 W BREAK assumed for Region

END PROCESS in1;

This produces a report like this, with subtotals on every change of in1.Region,and  IN1.District and grand totals at the end

     5       10 INALL,EttieEmil          206.02                 

     5       10                        1,442.14 District Subtotal

 

     5       11 HIPTHORP,Thomas          206.02                 

     5       11                          206.02 District Subtotal

     5                                 7,211.93 Region Subtotal 

                                      19,491.79 Grand Total     

Identification text like District Subtotal” is formed from the heading of the control break field and “ Subtotal”.  The field’s heading can be given in its definition with a HEADING property, or else will be formed from its name with hyphens replaced with blanks.  Jazz places this identification text as far to the left as it can.  In this case the longest of the three identification texts is “ District Subtotal” but there is insufficient room to place this under the IN1.Name column (although it looks as if there is plenty of room, IN1.Name is only 15 characters, and the blanks to the left of the total fields might actually have a numeric space.  However if we add three blanks after IN1.Name: -

PRINT (IN1.Region,IN1.District,IN1.Name,'   ',IN1.SalesThisMonth SUM) ;

the identifying text drops in under IN1.Name:-

     5       11 HIPTHORP,Thomas            206.02

     5       11 District Subtotal          206.02

     5          Region Subtotal          7,211.93

                Grand Total             19,491.79

 

We can use COL (or RCOL) to create space where we want this text to go: -

PRINT (IN1.Region COL(20),IN1.District,IN1.Name,IN1.SalesThisMonth SUM) ;

                        5      11 HIPTHORP,Thomas          206.02

 District Subtotal      5      11                          206.02

 Region Subtotal        5                                7,211.93

 Grand Total                                            19,491.79

Label Printing

If a REPORT is defined with label options, for example

REPORT LABEL ACROSS(2)  DOWN(15)  SIZE(65)  NEWPAGE;

then PRINT produces “labels”, i.e. columns of printing, without headings.   In this case there are two columns, each of 65 characters.  If the page WIDTH was less than ACROSS * SIZE, 130 in this case, then it is increased.

 

With label printing you should use separate PRINT statements for each line. For example

PROGRAM TLBL2 BATCH DATABASE sample DB2 EZT;

COPY EMPLOYEE;

COPY JZSMth;

REPORT ACROSS(3) DOWN(4);

PROCESS EMPLOYEE ORDER(EMPLOYEE.WORKDEPT BREAK,EMPLOYEE.EMPNO);

    GET Department WHERE DEPARTMENT.DEPTNO = employee.workdept;

    PRINT(DEPARTMENT.DEPTNAME) PAGE;

    PRINT (EMPLOYEE.EMPNO,EMPLOYEE.WORKDEPT);

    PRINT (EMPLOYEE.FIRSTNME, EMPLOYEE.LASTNAME);

    PRINT (EMPLOYEE.PHONENO,EMPLOYEE.HIREDATE);

END PROCESS EMPLOYEE;

 

This program produces a report like this: -

1SPIFFY COMPUTER SERVICE DIVISISPIFFY COMPUTER SERVICE DIVISISPIFFY COMPUTER SERVICE DIVISI

 000010                        000110                        000120                       

 CHRISTINE    HAAS             VINCENT      LUCCHESSI        SEAN         O'CONNELLY      

 3978    01 Jan 95             3490    16 May 88             2167    05 Dec 93            

 SPIFFY COMPUTER SERVICE DIVISISPIFFY COMPUTER SERVICE DIVISISPIFFY COMPUTER SERVICE DIVISI

 100321                        100331                        100346                       

 MICHAEL      THOMPSON         SALLY        KWAN             IRVING       STERN           

 3476    10 Oct 03             4738    05 Apr 05             2618    14 Sep 05            

LINE

You may find it convenient to use the LINE option for line spacing, and to put the printing into a ROUTINE.  For example

PROGRAM TLBL2 BATCH DATABASE sample DB2 EZT;

COPY EMPLOYEE;

COPY JZSMth;

REPORT NAME 'LBLS' LABEL ACROSS(2)  DOWN(15)  SIZE(65)  NEWPAGE SPACE(1) ;

PROCESS EMPLOYEE ORDER(EMPLOYEE.WORKDEPT BREAK,EMPLOYEE.EMPNO);

    GET Department WHERE DEPARTMENT.DEPTNO = EMPLOYEE.WORKDEPT;

    PERFORM lbls;

END PROCESS EMPLOYEE;

ROUTINE LBLS;

    PRINT ('YOUR COMPANY NAME' COL(7),'903' COL(33),'12-3456789' COL(39)) LINE(01);

    PRINT ('YOUR COMPANY STREET' COL(7)) LINE(2);

    PRINT ('YOUR COMPANY CITY STATE ZIP' COL(7)) LINE(03);

    PRINT (EMPLOYEE.EMPNO COL(7), EMPLOYEE.WORKDEPT COL(23)) LINE(10);

    PRINT (EMPLOYEE.FIRSTNME COL(7),EMPLOYEE.LASTNAME COL(39)) LINE(12);

    PRINT (EMPLOYEE.HIREDATE COL(7)) LINE(14);

    PRINT (EMPLOYEE.PHONENO COL(7), EMPLOYEE.SALARY,EMPLOYEE.BONUS) LINE(15);

END ROUTINE LBLS;

If you use LINE, then it must be used on all PRINT statements, and the values must be in order. 

 

This prints labels like this, with control characters: -

1      YOUR COMPANY NAME         903   12-3456789                       YOUR COMPANY NAME         903   12-3456789                   

       YOUR COMPANY STREET                                              YOUR COMPANY STREET                                          

       YOUR COMPANY CITY STATE ZIP                                      YOUR COMPANY CITY STATE ZIP                                  

-                                                                                                                                    

-                                                                                                                                    

       000010          A00                                              000110          A00                                          

0      CHRISTINE                       HAAS                             VINCENT                         LUCCHESSI                    

0      01 Jan 95                                                        16 May 88                                                    

       3978     $160,387.00       $1,000.00                             3490      $66,500.00         $900.00                         

Or, with the control characters resolved

      YOUR COMPANY NAME         903   12-3456789                       YOUR COMPANY NAME         903   12-3456789                   

      YOUR COMPANY STREET                                              YOUR COMPANY STREET                                          

      YOUR COMPANY CITY STATE ZIP                                      YOUR COMPANY CITY STATE ZIP                                  

                                                                                                                                    

                                                                                                                                    

                                                                                                                                    

                                                                                                                                    

                                                                                                                                    

                                                                                                                                    

      000010                                                           000110                                                       

                                                                                                                                    

      CHRISTINE                       HAAS                             VINCENT                         LUCCHESSI                    

                                                                                                                                    

      01 Jan 95                                                        16 May 88                                                    

      3978     $160,387.00       $1,000.00                             3490      $66,500.00         $900.00  

Eastrieve Conversion

When a program is converted from Easytrieve, the PROGRAM statement will include an EZT option: -

            PROGRAM MX600A06 BATCH EZT;

 

EZT applies SUM options to all numeric fields except control fields in a PRINT statement.  For example, when

            PRINT (Branch, Job-Cat, Old-Sal, Old-Sal, Total-Sal, Raise-Dol);

is checked by MANASYS this becomes

PRINT (MYFILE.BRANCH,MYFILE.JOB-CAT,EZT-ABatch-Data.OLD-SAL SUM,

        EZT-ABatch-Data.TOTAL-SAL SUM,EZT-ABatch-Data.RAISE-DOL SUM);

Easytrieve and Jazz have different ways of handling totalling.  In Jazz, fields are accumulated and totals are printed only if SUM is written. Easytrieve however will print totals for all numeric fields in a LINE statement like

LINE 01 BRANCH JOB-CAT OLD-SAL TOTAL-SAL RAISE-DOL   

unless its default rules are overridden with a SUM statement.  When converting Easytrieve to Jazz with the Easytrieve Conversion Notepad, a LINE statement as above becomes a PRINT statement as above. 

If a SUM has been applied to a field that you don’t want summed, change SUM to NOSUM.

SUM and field width

When a field is summed, extra space is allowed in case the summed value would exceed the space allowed for individual values.  This can cause problems if the EZT uses COL and hasn’t allowed enough room for the summed field: -

    PRINT (JZWK1.W-BODYANT COL(05),JZWK1.W-CON-ANT COL(13),JZWK1.W-DIVISANT COL(28),JZWK1.W-DC COL(41),JZWK1.W-DEB SUM COL(49),JZWK1.W-CRED SUM COL(74),JZWK1.W-DESCRICAO COL(99)) LINE(1);

    #183 E Line overflow caused by item JZWK1.W-CRED

    #183 E Line overflow caused by item JZWK1.W-DESCRICAO

 

This is easily fixed by removing the COL options and letting MANASYS determine where the data should start. If left uncorrected, this PRINT statement would produce several lines.