Previous Topic: Coding a Second HeadingNext Topic: Controlling Printing Sequence


Selecting Records for Processing

 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 SELECT statement specifies which records you are selecting for processing.

Code the general SELECT command in the following format:

►►─ SELECT ─ logical expression ──────────────────────────────────────────────►◄

The SELECT statement for the sample program looks like this:

 SELECT PERSONEL-STATE EQ 'TX'

The word SELECT is coded as shown, followed by the logical expression PERSONEL-STATE EQ 'TX'. The logical expression specifies the logical constraint which must be satisfied before you select the record for processing.

PERSONEL-STATE EQ 'TX' conforms to the format of an elementary condition as previously discussed in the GOTO command. PERSONEL-STATE is the defined field name and 'TX' is the alphanumeric literal.

The SELECT statement tells the Reporting Facility to select for processing only records for the state of Texas. The purpose of this statement is to present the state field for screening.