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:
Department number
Employee number
Employee name
Hours
Current rate (9.999)
Regular earnings (999.99)
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.
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.
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 ' DEFINE PAYFILE-NAME 008-027 X 'EMPLOYEE' ' NAME '
DEFINE PAYFILE-REGEARN 034-038 N2 'REGULAR' 'EARNINGS' DEFINE PAYFILE-OVTEARN 039-043 N2 'OVERTIME' 'EARNINGS'
Notice the N2 parameter in both of the above statements. N indicates the fields named PAYFILE-REGEARN and PAYFILE-OVTEARN contain zoned decimal data. The number of implied decimal places is indicated by the integer 2.
GET PAYFILE
The GET statement following the DEFINE statement is a significant deviation from the previous programs in this guide and requires some explanation.
As previously discussed, the general order of entry for individual statements is as follows:
COMPUTE MULTIPLY DECODE DIVIDE SET MOVE ADD INCREMENT SUBTRACT DECREMENT
REPORT CONTROL SELECT PRINT
Note: Since this program accesses a standard file and not a CA Datacom/DB file, no MOVE statements are required.
In this earnings report program, the GET and GOTO statements were not really necessary because the Reporting Facility would have automatically provided those two statements after the DEFINE statements. The system automatically provides GET and GOTO statements for the first file defined. See GET Command for more information about the GET command.
In the two previous programs in this guide, you specified the GET and GOTO statements. If they had not been specified, the Reporting Facility would have automatically generated them following the last DEFINE statement. This would produce undesirable results.
When a GET statement is found that specifies the name of the first file defined, the automatic GET and GOTO statements are not generated.
GOTO EOJ PAYFILE EQ 'E'
REPORT 'EARNINGS REPORT'
SELECT ALL
CONTROL PAYFILE-DEPTNUM
PRINT PAYFILE-DEPTNUM PAYFILE-EMPNUM PAYFILE-NAME
PAYFILE-REGEARN (PAYFILE-OVTEARN)
PAYFILE-OVTEARN is enclosed in parentheses. This indicates that the values in the PAYFILE-OVTEARN field are to be accumulated and printed as a final total at the end of the report.
|
Copyright © 2014 CA.
All rights reserved.
|
|