EASYTRIEVE – Sample Program – Display Totals and Summary
The Input file contains the data of all the employees as shown below
=COLS> —-+—-1—-+—-2—-+—-3—-+—-4—-+—-5
****** ***************************** Top of Data ********
000100 RAJESH SURNAME1 23125478 MECH 100 10
000110 MADURI SURNAMEA 23125378 MECH 200 09
000200 SUNI SURNAME2 22351875 CHEM 300 10
000210 SIVA SURNAMEB 22351345 CHEM 400 08
000300 RAMS SURNAMEC 21357987 MCA 500 07
000310 HARI SURNAME3 21352287 MCA 600 05
000400 PAVAN SURNAME4 22574821 MTEC 700 03
****** **************************** Bottom of Data ******
The output report Looks like below.
********************************* Top of Data **********************************
3/21/12 EMPLOYEES DETAIL SALARY REPORT PAGE 1
DETAIL BY BRANCH – DESC BY NEW SAL
BRANCH FIRST
NAME NAME OLD-SAL RAISE-DOL RAISE-PCT TOTAL-SAL
CHEM SIVA 400.00 36.00 9.00 436.00
SUNI 300.00 21.00 7.00 321.00
CHEM 700.00 57.00 8.00 757.00
MCA HARI 600.00 54.00 9.00 654.00
RAMS 500.00 45.00 9.00 545.00
MCA 1100.00 99.00 9.00 1,199.00
MECH MADURI 200.00 18.00 9.00 218.00
RAJESH 100.00 7.00 7.00 107.00
MECH 300.00 25.00 8.00 325.00
MTEC PAVAN 700.00 63.00 9.00 763.00
MTEC 700.00 63.00 9.00 763.00
2800.00 244.00 8.42 3,044.00
3/21/12 EMPLOYEES SUMMARY SALARY REPORT PAGE 1
BRANCH
NAME JOB-CAT OLD-SAL TOTAL-SAL RAISE-DOL
CHEM 08 400.00 436.00 36.00
CHEM 10 300.00 321.00 21.00
CHEM 700.00 757.00 57.00
MCA 05 600.00 654.00 54.00
MCA 07 500.00 545.00 45.00
MCA 1100.00 1,199.00 99.00
MECH 09 200.00 218.00 18.00
MECH 10 100.00 107.00 7.00
MECH 300.00 325.00 25.00
MTEC 03 700.00 763.00 63.00
MTEC 700.00 763.00 63.00
2800.00 3,044.00 244.00
******************************** Bottom of Data ********************************
The Code for this is provided Below:
//STEP01 EXEC PGM=EZTPA00
//INPUT DD DSN=HLQ1.INPUT01,DISP=SHR
//OUTPUT1 DD DSN=HLQ1.OUTPUT01,
// DISP=(,CATLG,DELETE),
// UNIT=SYSALLDA,SPACE=(CYL,(1,1),RLSE),
// DCB=(RECFM=FB,LRECL=100,BLKSIZE=0)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
FILE INPUT
INREC 1 80 A
FIRST-NAME 1 6 A HEADING (‘FIRST’ ‘NAME’)
SECOND-NAME 8 8 A HEADING (‘SECOND’ ‘NAME’)
EMPLOYEE-NUM 17 8 N HEADING (‘EMPLOYEE’ ‘NUM’)
BRANCH 26 4 A HEADING (‘BRANCH’ ‘NAME’)
SALARY 31 3 N
JOB-CAT 35 2 N
*
OLD-SAL W 3 P 2
RAISE-PCT W 3 P 2
RAISE-DOL W 3 P 2
TOTAL-SAL W 4 P 2
FILE OUTPUT1 PRINTER
*
JOB INPUT (INPUT)
*
OLD-SAL = SALARY
IF JOB-CAT = 10
RAISE-PCT = 7.00
ELSE
RAISE-PCT = 9.00
END-IF
RAISE-DOL = OLD-SAL * RAISE-PCT / 100
TOTAL-SAL = OLD-SAL + RAISE-DOL
PRINT DETAIL-REPORT
PRINT SUMM-REPORT
REPORT DETAIL-REPORT PRINTER OUTPUT1 LINESIZE 80
SEQUENCE BRANCH TOTAL-SAL D
CONTROL BRANCH
TITLE 01 ‘EMPLOYEES DETAIL SALARY REPORT ‘
TITLE 02 ‘DETAIL BY BRANCH – DESC BY NEW SAL’
LINE 01 BRANCH FIRST-NAME OLD-SAL RAISE-DOL RAISE-PCT TOTAL-SAL
BEFORE-BREAK. PROC
RAISE-PCT = RAISE-PCT / TALLY
END-PROC
REPORT SUMM-REPORT PRINTER OUTPUT1 SUMMARY LINESIZE 80
SEQUENCE BRANCH JOB-CAT
CONTROL BRANCH JOB-CAT
TITLE 01 ‘EMPLOYEES SUMMARY SALARY REPORT ‘
LINE 01 BRANCH JOB-CAT OLD-SAL TOTAL-SAL RAISE-DOL
/*
Explaining concepts used in this program:
- HEADING – When used, we get the header as mentioned here in the final Report. This is used at the field declaration process. This can also be done in REPORT section. Here we gave the statement as HEADING (‘FIRST’ ‘NAME’) as we have space between FIRST and NAME, we got the HEADER in two rows.
- Here when we provide the option of PRINTER for output file, the default length of output file is taken as 133 and RECFM as FA (printer file). But LINESIZE provided in the REPORT section, defines the length the report to be displayed in the output file.
-
We have declared the working storage variables as shown below
OLD-SAL W 3 P 2
RAISE-PCT W 3 P 2
RAISE-DOL W 3 P 2
TOTAL-SAL W 4 P 2
- In this program, we have one DETAIL RPT and one SUMMARY report. So we have to give report names in the PRINT statement.
-
SEQUENCE BRANCH TOTAL-SAL D
SEQUENCE tells that the report needs to be sorted first by branch in ascending order and then the TOTAL-SAL in descending order.
- CONTROL BRANCH – tells that the totals needs to be done whenever the branch changes. This can be seen in the output detail report.
- To provide 2 titles, the format is as TITLE 01 for the first title and TITLE 02 for the second title. Avoid giving TITLE statement to not get any title in your output.
-
BEFORE-BREAK is a report procedure that is used to modify totals before total line printing. (Here the total is printed whenever there is change in BRANCH as specified in the statement CONTROL BRANCH)
——————————————————————————————————–
In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
——————————————————————————————————–
You may also like to look at:
Working on Mainframes – Is Change to a different technology necessary |