Previous Topic: Controlling Printing SequenceNext Topic: Ending a Program


Printing Report Fields

 USER 'XYZ COMPANY, INC.'
 PERSONEL:  INPUT DATACOM  RECORD EQ 375  NAME EQ PMF DBID EQ 001
 DEFINE PERSONEL-COMMAND      001-005   X
 DEFINE PERSONEL-KEY          006-010   X
 DEFINE PERSONEL-ELMLIST      191-201   X
 DEFINE PERSONEL-NUMBER       301-305   X '  ID  ' 'NUMBER'
 DEFINE PERSONEL-NAME         306-329   X 'EMPLOYEE NAME'
 DEFINE PERSONEL-CITY         354-368   X 'CITY'
 DEFINE PERSONEL-STATE        369-370   X
 DEFINE PERSONEL-ZIP-CODE     371-375   X 'ZIP'   'CODE'
 MOVE 'GETIT' TO PERSONEL-COMMAND
 MOVE 'EMPNO' TO PERSONEL-KEY
 MOVE 'ADEMP' TO PERSONEL-ELMLIST
 GET PERSONEL
 GOTO EOJ WHEN PERSONEL EQ 'E'
 REPORT 'EMPLOYEE SUMMARY - TEXAS'
 SELECT PERSONEL-STATE EQ 'TX'
 CONTROL PERSONEL-CITY
 PRINT PERSONEL-NAME PERSONEL-NUMBER PERSONEL-CITY
      PERSONEL-ZIP-CODE
 END

The PRINT statement specifies which fields will be printed on the report and their format. You may also use the PRINT statement to specify the location of each field within a detail line. (The sample program does not demonstrate this.)

Code the general PRINT command in the following format:

           ┌─────────────┐
►►─ PRINT ─▼─ fieldname ─┴────────────────────────────────────────────────────►◄

The PRINT statement for the sample program looks like this:

 PRINT PERSONEL-NAME PERSONEL-NUMBER PERSONEL-CITY
      PERSONEL-ZIP-CODE

The word PRINT is coded as shown, followed by the names of the fields to appear on the report.

Notice in the following report that the contents of the fields named in the PRINT statement are printed on the report under the appropriate column headings and that the fields are properly spaced across the page automatically.

                                XYZ COMPANY, INC.     01  NOV  08             EMPLOYEE SUMMARY - TEXAS              PAGE  1                                   ID                                ZIP    EMPLOYEE NAME                NUMBER             CITY             CODE    LUTHER GARY                  00009              DALLAS           75243    WALKER FRANK                 00016              DALLAS           75243    PATTERSON AL                 00018              DALLAS           75243    EVERS DANNY                  00030              DALLAS           75243         .                         .                   .               .         .                         .                   .               .         .                         .                   .               .    CHURCH PHILLIP               00105              HOUSTON          77506    ABEL PHILIP                  00115              HOUSTON          77506    NEELY ROY                    00123              HOUSTON          77506    DIETER RODNEY                00130              HOUSTON          77506    END OF REPORT

As previously discussed, the Reporting Facility uses the name of the field specified in the PRINT statement for the column heading if no heading was specified by a DEFINE statement in the Data Area.

The order in which the column headings and field contents appear is determined by the order in which you enter the names of the fields in the PRINT statement. Therefore, the contents of the field named PERSONEL-NAME are printed first under the column heading EMPLOYEE NAME, followed by the contents of the field named PERSONEL-NUMBER under the column heading ID NUMBER, and so on.

The PRINT statement tells the Reporting Facility: