You can Sort a file into another file in Easytrieve. The Syntax is
SORT file-name-1 + TO file-name-2 + USING (field-name [D]...) + [BEFORE proc-name]
- file-name-1 is the input file DD Name
- file-name-2 is the Sorted output file
- field-name is the field defined in file-name-1, based on which the file has to be sorted
- If you want the sort to be on Descending order, pass the parameter ‘D’ after the field name (by Default, it will be Ascending)
- If you have any select criteria to filter what records to be written in the output file, have it in a Proc and give the proc name with BEFORE parameter (optional)
Let us see a couple of sample programs to explain.
Simple Sort on a key
The below program will simply
FILE INFILE FB(80 960) ACCOUNT-NO 1 8 N * FILE OUTFILE * SORT INFILE TO OUTFILE USING ACCOUNT-NO
3 thoughts on “SORT in Easytrieve”
Can we use Value clause in occurs statement in Easytrieve?
If we use, will the initialized value applies for all occurences?
F1 W 101 A OCCURS 100 TIMES
F2 F1 100 A
F3 F1 +100 1 A VALUE ‘,’
In the above example, the comma is getting populated in only occurence. How to get the same in all occurences.
This post is regarding the julian to gregarion date conversion of packed decimal field.
input file–date is starting at 201 and length of 4 bytes
i have used the outrec as below.
for example:input date:2011002
output should be dispalyed as:2011-01-02 however with the above code year is getting dispalyed as 3911…can you please look into the issue.
I have used the centwin parameter as 80
I think, in mainframes, Julian date is only 5 digits; so your input should be 11002 to get output as 2011-01-02