Previous Topic: Ending a ProgramNext Topic: Writing a Program (Standard Files)


Writing a Program (CA Datacom/DB Tables)

You have now thoroughly examined the sample program and may test your skills by writing a simple CA Datacom/DB Reporting Facility program. This section presents the requirements for a program to test your understanding of the Reporting Facility concepts.

Before writing the program, become familiar with these guidelines for coding input statements.

Write the program to produce a report in the following format:

                          XYZ COMPANY, INC.     01  NOV  08            PAYROLL 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

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

You will need the following information to write the program:

After you have written the program, look at the following solution for the correct input statements and an explanation of those statements.

Solution

 USER 'XYZ COMPANY, INC.'
 PAYROLL:  INPUT DATACOM  RECORD EQ 337  NAME EQ PAY DBID EQ 001
 DEFINE PAYROLL-COMMAND  001-005   X
 DEFINE PAYROLL-KEY      006-010   X
 DEFINE PAYROLL-ELMLIST  191-201   X
 DEFINE PAYROLL-DEPTNUM  301-303   X ' DEPT ' 'NUMBER'
 DEFINE PAYROLL-EMPNUM   304-307   X  'EMPLOYEE' 'NUMBER'
 DEFINE PAYROLL-NAME     308-327   X  'NAME'
 DEFINE PAYROLL-REGEARN  328-332  N2 'REGULAR' 'EARNINGS'
 DEFINE PAYROLL-OVTEARN  333-337  N2 'OVERTIME' 'EARNINGS'
 MOVE 'GETIT' TO PAYROLL-COMMAND
 MOVE 'IDNUM' TO PAYROLL-KEY
 MOVE 'PAYRC' TO PAYROLL-ELMLIST
 GET PAYROLL
 GOTO EOJ WHEN PAYROLL EQ 'E'
 REPORT 'PAYROLL REPORT'
 SELECT ALL
 CONTROL PAYROLL-DEPTNUM
 PRINT PAYROLL-DEPTNUM PAYROLL-EMPNUM PAYROLL-NAME
      PAYROLL-REGEARN PAYROLL-OVTEARN
 END

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

USER Statement

In the first statement, the USER command provides the first line of heading on each page of the report.

 USER 'XYZ COMPANY, INC.'

INPUT Statement

In the second statement, the INPUT command defines the table to the Reporting Facility.

 PAYROLL:  INPUT DATACOM RECORD EQ 337 NAME EQ PAY DBID EQ 001

Communications Area

The next three DEFINE statements make up the Communications Area.

Data Area

The next five DEFINE statements make up the Data Area.

Move Statements

GET Statement

The GET statement tells the Reporting Facility to return a record from the table named PAYROLL.

 GET PAYROLL

GOTO Statement

The GOTO statement specifies a branch to the end-of-job procedure when the Reporting Facility determines the end of the table.

 GOTO EOJ PAYROLL EQ 'E'

REPORT Statement

The REPORT command specifies that the second heading line on each page of the report is to be PAYROLL REPORT.

 REPORT 'PAYROLL REPORT'

SELECT Statement

The SELECT statement specifies that all the records in the table are to be selected for processing.

 SELECT ALL

CONTROL Statement

The CONTROL statement specifies that the report is to be sorted by department number.

 CONTROL PAYROLL-DEPTNUM

PRINT Statement

The PRINT statement specifies which fields are to be printed and the order in which they are to be printed.

 PRINT PAYROLL-DEPTNUM PAYROLL-EMPNUM PAYROLL-NAME
	PAYROLL-REGEARN PAYROLL-OVTEARN

END Command

The END command signals the Reporting Facility that the last statement has been processed.