Example 2 -- Average Salaries by Job Title Report

This program reads an input file containing employee salary and job information. The output lists the employees that share the same job title, the salary of each employee, and the average salary for each type of job. The program performs the following functions:
idmscu
This program reads an input file containing employee salary and job information. The output lists the employees that share the same job title, the salary of each employee, and the average salary for each type of job. The program performs the following functions:
  • Sorts input records by employee last name for each job title
  • Executes a control break each time the job title changes and at the end of the output phase
  • Totals employee salaries at every control break
  • Counts the number of employees at every control break
  • Calculates an average salary at every control break
  • Prints title, header, detail, and total lines
CA Culprit parameters used in this report are shown in the table under Sequential Parameter Listing for Average Salaries by Job Title. The report output is illustrated in the table under Output for Average Salaries by Job Title.
Parameters coded for this report are described below:
Input Definition Parameters
The Input File Layout for the Employee Compensation Status Report shows the input file for this CA Culprit run. The input file contains fixed-length 80-byte records; by default, the DD statement labeled SYS010 in z/OS execution JCL defines the input file. The CA Culprit run uses four input fields; all of the fields are alphanumeric except the SALARY field, which is defined as a 10-byte packed decimal value with two implied decimal positions.
Output Definition Parameters
Report 01 is a printed report with 70 characters per line and 55 lines per page. The detail lines sort in alphabetical order by the last name of each employee that shares the same job title. The control break code on the SORT parameter specifies two blank output lines each time the job title changes.
The type 5 edit parameters coded for this report define one detail line. The detail line contains three printed output fields in relative column positions 10, 20, and 30, and a nonprinted output field that acts as counter. An output field size and format edit code is specified for SALARY.
The type 6 edit parameters coded for this report specify two total lines. The first total line specifies a literal work field value in relative column 10 and the total salary for the current control break in relative column 30. The accumulated value of SALARY prints because SALARY is a numeric field that is referenced on a type 5 edit parameter. A blank line prints between the last detail line and the first total line at each control break because this edit line specifies a spacing code in column 10.
The second total line specifies a literal work field value and the average salary for the current control break. CA Culprit calculates the value of AVG-SAL in type 8 procedure logic.
Work Field Parameters
Report 01 defines two numeric work fields and one multiply-occurring alphanumeric work field, as follows:
  • COUNT is a numeric work field that is initialized to 1. It is referenced both as a nonprinted numeric work field on a type 5 edit parameter and as an operand in an arithmetic process operation in type 8 procedure logic.
  • LABEL is a multiply-occurring alphanumeric work field that occurs two times. The initial value of each occurrence is a 20-blank literal. Explicit occurrences of LABEL are referenced on type 6 edit parameters and in MOVE operations on type 8 procedure logic.
  • AVG-SAL is a numeric work field that is initialized to 0.00. It is referenced as a result field in an arithmetic calculation and is output on a type 6 edit parameter.
Process Parameters
Type 8 procedure logic executes at every control break. The procedure logic for this report determines whether the number of employee records for the current control break exceeds 1; that is, whether the value for COUNT is greater than 1. If the value of COUNT is 1, processing for the control break stops and no total lines print. If the value of COUNT is greater than 1, CA Culprit calculates the average salary for the current control break.
If the level of the control break is 1 (that is, the control break occurs on a title name), the procedure logic branches to sequence number 600. The logic starting at sequence number 600 instructs CA Culprit to move literals to the first and second occurrences of LABEL. An implicit TAKE after sequence number 650 outputs both total lines.
In this example, a control break level not equal to 1 implies that the control break level is 2; a level-2 control break generates the grand total lines for Report 01. At the end of the output phase, CA Culprit moves 'COMPANY SALARY' to LABEL.1. The procedure logic branches to sequence number 650, where CA Culprit moves a literal value to LABEL.2 and outputs the grand total lines for the report.
Sequential Parameter Listing for Average Salaries by Job Title:
 mm/dd/yy                   SEQUENTIAL PARAMETER LISTING                    Vnn.n  PAGE   1  00 ** SYSIN **                            IN 80    INSTALLATION SECURITY OPTION IS NO                                            REC EMP-NAME       1   25          'EMPLOYEE' 'NAME'                                            REC EMP-LNAME     11   10                                            REC DEPARTMENT    30   20                                            REC TITLE         50   20                                            REC SALARY        70   10   3  DP=2                                            01OUT  75                                            01SORT TITLE,-,EMP-LNAME                                            013AVERAGE SALARIES BY JOB TITLE                                            01410001  ' '                                            0151*000  COUNT                                            0151*010  TITLE                                            0151*020  EMP-NAME                                            0151*030  SALARY  SZ=10 F$                                            0161*0100 LABEL.1                                            0161*030  SALARY  SZ=10 F$                                            0162*010  LABEL.2                                            0162*030  AVG-SAL SZ=10 F$                                            010 COUNT 1  LABEL.2 '                    ' AVG-SAL DP=2                                            018    COUNT EQ 1 DROP                                            018    SALARY DIVIDE COUNT AVG-SAL                                            018    LEVL EQ 1 600                                            018    MOVE 'COMPANY SALARY      ' TO LABEL.1                                            018    B 650                                            018600 MOVE 'TOTAL SALARY        ' TO LABEL.1                                            018650 MOVE 'AVERAGE SALARY      ' TO LABEL.2
Output for Average Salaries by Job Title:
 REPORT NO. 01         AVERAGE SALARIES BY JOB TITLE    mm/dd/yy PAGE     3     PROGRAMMER/ANALYST      JANE      DOUGH                  $33,000.00     PROGRAMMER/ANALYST      JAMES     GALLWAY                $33,000.00     PROGRAMMER/ANALYST      PERCY     GRANGER                $34,500.00     PROGRAMMER/ANALYST      VLADIMIR  HEAROWITZ              $33,000.00     PROGRAMMER/ANALYST      JULIE     JENSEN                 $37,000.00     PROGRAMMER/ANALYST      KATHERINE O'HEARN                $42,500.00     TOTAL SALARY                                            $213,000.00     AVERAGE SALARY                                           $35,500.00     RAINDANCE CONSULTANT    CAROLYN   CROW                   $37,500.00     RAINMAKER               BURT      LANCHESTER             $54,500.00     RECRUITER/INTERVWR      MADELINE  ORGRATZI               $39,000.00     SNOWBLOWER              ROY       ANDALE                 $33,500.00     SNOWBLOWER              RICHARD   MUNYON                 $36,000.00     TOTAL SALARY                                             $69,500.00     AVERAGE SALARY                                           $34,750.00     SPORTS CONSULTANT       JOCK      JACKSON                $34,000.00     STURM/DRANG ADMIN       HARRY     ARM                    $46,000.00     STURM/DRANG ADMIN       RICHARD   WAGNER                 $47,000.00     TOTAL SALARY                                             $93,000.00     AVERAGE SALARY                                           $46,500.00     SUNSHINE SUPERVISOR     ALAN      DONOVAN                $33,500.00     SYSTEMS PROGRAMMER      TERENCE   KLWELLEN               $43,000.00     WINTERIZER              JOE       KASPAR                 $31,000.00     WINTERIZER              MARK      TIME                   $33,000.00     TOTAL SALARY                                             $64,000.00     AVERAGE SALARY                                           $32,000.00     COMPANY SALARY                                        $2,522,500.00     AVERAGE SALARY                                           $45,044.64    RECORDS WRITTEN FOR REPORT 01 --        118
The last page of output is shown.