Previous Topic: Writing a Program (CA Datacom/DB Tables)Next Topic: Writing a Program (Multiple CA Datacom/DB Tables)


Writing a Program (Standard Files)

If you use the Reporting Facility to access standard files, practice writing a program that accesses a standard file. This section presents the requirements of a report and then provides the program that generated it. The report generated by the program you write has the following format:

                                XYZ COMPANY, INC.    01    NOV   08               EARNINGS REPORT                  PAGE   1    DEPT    EMPLOYEE  EMPLOYEE                         REGULAR    OVERTIME    NUMBER  NUMBER    NAME                             EARNINGS   EARNINGS    XXX     XXXX      XXXXXXXXXXXXXXXXXXXX               XXX.XX     XXX.XX    .       .         .                                       .          .    .       .         .                                       .          .    .       .         .                                       .          .    XXX     XXXX      XXXXXXXXXXXXXXXXXXXX               XXX.XX     XXX.XX                                                                   _______    GRAND TOTAL                                                   XXXXX.XX                                                                  ________

This format indicates that the program will generate a report that includes:

The following are the position and contents of the input record fields:

1-3

Department number

4-7

Employee number

8-27

Employee name

28-29

Hours

30-33

Current rate (9.999)

34-38

Regular earnings (999.99)

39-43

Overtime earnings (999.99)

In writing the program, make the following assumptions:

Note: You may also assume that all of the fields defined with a DEFINE statement are alphanumeric, except the regular earnings and overtime earnings fields, which are numeric with two implied decimal places.

Remember that you would provide the requirements (as shown previously) in a real situation. Study the command formats and note which parameters are commands or reserved words and which parameters you must supply.

There are three significant differences between the earnings report program in this section and the earnings report program in the previous section.

  1. The program in this section requires a standard file definition.
  2. There is no Communications Area in this program because the file is standard.
  3. The program in this section requires a grand total for the overtime earnings field. The grand total is specified with the PRINT command.

After you have written the program, check the following solution to find the correct input statements and their explanations. .

Solution

 USER 'XYZ COMPANY, INC.'  PAYFILE:  INPUT  DISK  BLOCK EQ 2150  FIXED RECORD EQ 43  DEFINE PAYFILE-DEPTNUM        001-003  X ' DEPT ' 'NUMBER'  DEFINE PAYFILE-EMPNUM         004-007  X 'EMPLOYEE' 'NUMBER' 'NUMBER'  DEFINE PAYFILE-NAME           008-027  X 'EMPLOYEE' '  NAME  '  DEFINE PAYFILE-REGEARN        034-038 N2 'REGULAR' 'EARNINGS'  DEFINE PAYFILE-OVTEARN        039-043 N2 'OVERTIME' 'EARNINGS'  GET PAYFILE  GOTO EOJ WHEN PAYFILE EQ 'E'  REPORT 'EARNINGS REPORT'  SELECT ALL  CONTROL PAYFILE-DEPTNUM  PRINT PAYFILE-DEPTNUM PAYFILE-EMPNUM PAYFILE-NAME       PAYFILE-REGEARN (PAYFILE-OVTEARN)  END

Following is a line-by-line explanation of the earnings report program.