Previous Topic: Moving DataNext Topic: Transferring Control


Retrieving a Record

 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

Code the GET statement after the MOVE statements. When the GET statement is processed during program execution for a CA Datacom/DB table, the system constructs a CA Datacom/DB request area in the previously set up command area. This request area is used to access the next record.

The CA Datacom/DB command you moved to PERSONEL-COMMAND prior to the GET determines the type of read that is performed. GETIT indicates sequential processing and REDKG indicates a random read using a key value previously provided in the command area. When a standard file is read, the GET statement always returns the next sequential record. Code the general GET command in the following format:

►►─ GET ─ filename ───────────────────────────────────────────────────────────►◄

The GET statement for the sample program looks like this:

 GET PERSONEL

The word GET is coded as shown. The file name should be the name of the previously defined input file in the INPUT statement.

The GET statement tells the Reporting Facility to get a record in the table named PERSONEL.