Tags
duplicate, easytrieve, eof, file comparison, firstdup, lastdup, mainframe, matched, SORT
EASYTRIEVE – SORT and FILE COMPARISION
FILE PERSNL FB(150 1800)
OLD-EMP# 9 5 N
*
FILE PERSUPD CARD
EMP# 1 5 N
RAISE-PERCENT 7 2 N
*
FILE SORTPER F 150 VIRTUAL
UPD-EMP# 9 5 N
NAME 17 8 A
PAY-GROSS 94 4 P 2
NEWSAL W 4 P 2
*
FILE NEWPERS FB(150 1800)
*
FILE ERRPRINT PRINTER
*
*
SORT PERSNL TO SORTPER USING OLD-EMP#
*
JOB INPUT (SORTPER KEY(UPD-EMP#) +
PERSUPD KEY(EMP#) )
*
IF MATCHED
PRINT NEW-RPT
END-IF
IF SORTPER
PUT NEWPERS FROM SORTPER
ELSE
DISPLAY ERRPRINT EMP# ‘RECORD NOT MATCHED’
END-IF
*
REPORT NEW-RPT LINESIZE 80 NOPAGE NODATE
SEQUENCE NAME
TITLE 1 ‘SALARY UPDATE REPORT’
HEADING UPD-EMP# (‘EMPL’ ‘NUMBER’)
LINE UPD-EMP# NAME PAY-GROSS NEWSAL RAISE-PERCENT
*
END
-
SORT statement sorts the input file PERSNL into the temporary file SORTPER in the ascending order of OLD-EMP#
SORT PERSNL TO SORTPER USING OLD-EMP#
-
JOB statement takes the INPUT as both the files to be compared. Ensure that the files are sorted based on the key specified. Number of keys and data type of each key should be same.
JOB INPUT (SORTPER KEY(UPD-EMP#) +
PERSUPD KEY(EMP#) )
-
[NOT] MATCHED – This specifies that the record with the same key is present in both the files.
IF MATCHED
PRINT NEW-RPT
END-IF
-
IF [NOT] EOF Filename – EOF specifies that the end of file is met. And only using the filename specifies that the record is present in that file.
IF SORTPER – specifies that record is available in the file SORTPER
IF EOF SORTPER – validates true when the End of file is reached for the file SORTPER
-
RECORD RELATIONAL CONDITION
- DUPLICATE – Current record is compared with previous and next record and if it is same as either of the two then the result is true.
- FIRST-DUP – The current record of the named file is compared to the previous and next records of the same file. The result is true if the current record’s key is different from the previous record’s key but the same as the next record’s key.
- LAST-DUP – The current record of the named file is compared to the previous and next records of the same file. The result is true if the current record’s key is the same as the previous record’s key but different from the next record’s key.
——————————————————————————————————–
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 - DUPLICATE – Current record is compared with previous and next record and if it is same as either of the two then the result is true.