Category Archives: SORT

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 [...]

Sort-card to split a file into multiple files (OUTFIL,FNAMES,SAVE)

Let’s say we have a file with first byte having 2 different values ‘A’ or ‘B’ or any other character. We are going to create a file with all records starting with A (DD name SORTXXA), a second file with all records starting with B (DD name SORTXXB), a third file (DD name SORTXXX) with [...]

SYMNAMES in SORT

SYMNAMES is a means of defining variables in SORT. When you have a complex sortcard, it becomes hard to have your sort control card ‘readable / understandable’. It is a good practice to always use SYSNAMES DD to define variables and then use the logical variable names in Sort card. Below is an example with [...]

IBM SORT – Add a trailer record with Record Count

//STEP010 EXEC PGM=SORT //SORTIN DD DISP=SHR,DSN=my.file //SORTOUT DD DISP=(,CATLG,DELETE), //DSN=new.file, //LIKE=my.file //SYSIN DD * SORT FIELDS=COPY OUTFIL REMOVECC, TRAILER1=(C’COUNT:’,COUNT-1=(EDIT=(TTTTTTTT))) /*

ICETOOL Count

Below step will get the number of records present in IN1 and IN2 files. The counts will be displayed in TOOLMSG DD. This will come handy, when you need to get count of big files and you have so many files to check the count. //STEP01 EXEC PGM=ICETOOL //DFSMSG DD SYSOUT=* //TOOLMSG DD SYSOUT=* //SYSOUT [...]

Sort Card examples (IBM Mainframes)

Avoid duplicates in a particular field (say first 8 characters) SORT FIELDS=(1,8,CH,A) SUM FIELDS=NONE Sort first 8 characters, and omit few values SORT FIELDS=(1,8,CH,A) OMIT COND=(1,8,CH,EQ,C’AAAAAAAA’) Sort first 8 characters, and include only few values SORT FIELDS=(1,8,CH,A) INCLUDE COND=(1,8,CH,EQ,C’AAAAAAAA’,OR, 1,8,CH,EQ,C’BBBBBBBB’) Sort card to select only 15 characters from 36th position of my input file. //SORTSTEP [...]