Previous Topic: Selecting Records for ProcessingNext Topic: Printing Report Fields


Controlling Printing Sequence

 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 CONTROL statement specifies the hierarchical sequence in which the data is presented or specifies the control-break fields. The sample program is concerned only with specifying the sequence in which the report is printed.

The following is the general CONTROL command format relevant to coding the CONTROL statement:

►►─ CONTROL ─ fieldname ──────────────────────────────────────────────────────►◄

The CONTROL statement for the sample program looks like this:

 CONTROL PERSONEL-CITY

The word CONTROL is coded as shown, followed by the name of the field (PERSONEL-CITY) that will be the sort sequence field.

The CONTROL statement in this example tells the Reporting Facility to sort the report in ascending sequence by city.