SORT in Easytrieve

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

being updated..

3 thoughts on “SORT in Easytrieve”

  1. Can we use Value clause in occurs statement in Easytrieve?
    If we use, will the initialized value applies for all occurences?

    Ex:
    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.

  2. Hi Karhik,

    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.
    554:201,4,DT1,EDIT=(TTTT-TT-TT)
    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

  3. I think, in mainframes, Julian date is only 5 digits; so your input should be 11002 to get output as 2011-01-02

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.