Previous Topic: Writing a Program (Standard Files)Next Topic: Reporting Facility Modes of Operation


Writing a Program (Multiple CA Datacom/DB Tables)

In this section, you have the opportunity to further expand your Reporting Facility programming skills by writing a program that accesses more than one table.

The tables to be accessed are the sample CA Datacom/DB PERSONEL table and PAYROLL table. As with previous sample programs, all the information needed to write the program is provided.

Write the program to generate a report with this format:

                               XYZ COMPANY, INC.  09   JAN   08                 PAYROLL REPORT                     PAGE  1 EMPLOYEE                                       CURRENT      YEAR-TO-DATE NUMBER    NAME                      STATUS     PAY RATE             WAGES XXXXX     XXXXXXXXXXXXXXXXXXXXXX     X         99999.99        $$$,$$9.99  .        .                          .              .                 .  .        .                          .              .                 .  .        .                          .              .                 . XXXXX     XXXXXXXXXXXXXXXXXXXXXX     X         99999.99        $$$,$$9.99                                                                __________ GRAND TOTAL                                                  $$$$$,$$9.99

The previous example indicates that the program will generate a report that includes:

Note: Assume that the status field in the record contains either S (salaried) or H (hourly).

You can make the following assumptions in writing this program:

Keep in mind that you would supply the above requirements in a real situation. Study the command formats and note which parameters are commands or reserved words and which parameters are user-supplied.

Note: This should be the general structure of the program:

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

Solution

 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-EMPLOYEENUM 301-305 X 'EMPLOYEE' ' NUMBER '  DEFINE PERSONEL-NAME        306-329 X 'NAME'  PAYROLL:  INPUT DATACOM  RECORD EQ 339  NAME EQ PAY DBID EQ 001  DEFINE PAYROLL-COMMAND      001-005 X  DEFINE PAYROLL-KEY          006-010 X  DEFINE PAYROLL-VALUE        011-015 X  DEFINE PAYROLL-ELMLIST      191-201 X  DEFINE PAYROLL-CODE             306 X  DEFINE PAYROLL-STATUS           307 X  DEFINE PAYROLL-CURRENTRATE  308-315 N3 'CURRENT' ' PAY RATE '  DEFINE PAYROLL-YTDWAGES     316-323 N2         'YEAR-TO-DATE' '    WAGES' PIC '$$$,$$9.99'  MOVE 'GETIT' TO PERSONEL-COMMAND  MOVE 'EMPNO' TO PERSONEL-KEY  MOVE 'IDEMP' TO PERSONEL-ELMLIST  GET PERSONEL  GOTO EOJ WHEN PERSONEL EQ 'E'  MOVE 'REDKG' TO PAYROLL-COMMAND  MOVE 'EMPNO' TO PAYROLL-KEY  MOVE PERSONEL-EMPLOYEENUM TO PAYROLL-VALUE  MOVE 'PAYRC' TO PAYROLL-ELMLIST  GET PAYROLL  GOTO START WHEN PAYROLL EQ 'N'  REPORT 'PAYROLL REPORT'  SELECT PAYROLL-CODE EQ 'A'  CONTROL PERSONEL-EMPLOYEENUM  PRINT PERSONEL-EMPLOYEENUM PERSONEL-NAME PAYROLL-STATUS     PAYROLL-CURRENTRATE (PAYROLL-YTDWAGES)  END

The following is a line-by-line explanation of the above report.

Following the DEFINE statements for the second table are the MOVE statements for the first table.

After the GOTO statement for the first table, the MOVE statements for the second table (PAYROLL) are coded.

The next line of coding is the GOTO statement for the second table. Remember that you were instructed to code the program so that if there were no match of employee numbers in the PERSONEL record and the PAYROLL record, neither record would be selected for printing.