32
Sort Utility – Programs Note: This tutorial is aimed at people who have some knowledge on SORT Utility. Provided the explanations wherever needed, input & output files, control cards, record layout for input & output files. Some other capabilities of sort are explained after the examples. Basic Information: Provides information about the field(s) that will be used for sorting options: FIELDS=(P,L,FF,O) - used to specify the key field(s) - Maximum of 64 P starting position of the key field L length of the key field FF data format of the control field CH EBCDIC alphanumeric ZD Zoned decimal PD Packed decimal FI Fixed point BI Binary O collating sequence A ascending order D descending order Mnemonic comparison type EQ equality NE not equal GT greater than GE greater than or equal to LT less than LE less than or equal to OMIT COND=(1,1,BI,EQ,X'FF',OR,8,5,PD,LT,+1) Any record containing X'FF' in the 1st byte OR a packed decimal value less than 1 in the 5 byte field starting in column 8 should be omitted from the output. Basic Program: VIEW USERID.SAMPLE.JCL(TPE2DSK) - 01.46 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ****************************** 000001 //TPE2DSK JOB (ACCT PARM),'DEVELP', 000002 // CLASS=3,NOTIFY=&SYSUID,MSGCLASS=T 000003 //* 000004 //SORT1 EXEC PGM=SYNCSORT 000005 //* 000006 //SORTIN DD DISP=SHR,DSN=USERID.TAPE.FILE 000007 //* 000008 //SORTOUT DD DISP=(NEW,CATLG,DELETE),UNIT=DISK, 1

Sort Utility Examples

Embed Size (px)

Citation preview

Page 1: Sort Utility Examples

Sort Utility – Programs

Note: This tutorial is aimed at people who have some knowledge on SORT Utility. Provided the explanations wherever needed, input & output files,

control cards, record layout for input & output files. Some other capabilities of sort are explained after the examples.

Basic Information:Provides information about the field(s) that will be used forsorting options: FIELDS=(P,L,FF,O) - used to specify the key field(s) - Maximum of 64 P starting position of the key field L length of the key field FF data format of the control field CH EBCDIC alphanumeric ZD Zoned decimal PD Packed decimal FI Fixed point BI Binary O collating sequence A ascending order D descending orderMnemonic comparison type EQ equality NE not equal GT greater than GE greater than or equal to LT less than LE less than or equal to

OMIT COND=(1,1,BI,EQ,X'FF',OR,8,5,PD,LT,+1)Any record containing X'FF' in the 1st byte OR a packed decimalvalue less than 1 in the 5 byte field starting in column 8 shouldbe omitted from the output. Basic Program:VIEW USERID.SAMPLE.JCL(TPE2DSK) - 01.46 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //TPE2DSK JOB (ACCT PARM),'DEVELP', 000002 // CLASS=3,NOTIFY=&SYSUID,MSGCLASS=T 000003 //* 000004 //SORT1 EXEC PGM=SYNCSORT 000005 //* 000006 //SORTIN DD DISP=SHR,DSN=USERID.TAPE.FILE000007 //* 000008 //SORTOUT DD DISP=(NEW,CATLG,DELETE),UNIT=DISK, 000009 // SPACE=(CYL,(100,100),RLSE), 000010 // DCB=(*.SORTIN), ==> Takes same attributes as input file. 000011 // DSN=USERID.SORTOUT.DASD.FILE 000012 //* 000013 //SYSOUT DD SYSOUT=* 000014 //* 000015 //SYSIN DD * 000016 SORT FIELDS=COPY 000017 /* ****** **************************** Bottom of Data ****************************

1

Page 2: Sort Utility Examples

Example 1:EDIT USERID.PAVAN.SORT.EXAMPLE(NEWJCL) - 01.54 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORTOT01 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,MSGLEVEL=(1,1),NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.PAVAN.SORT.INPUT.NEW,DISP=SHR 000008 //* 000009 //SORTWK01 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000010 //SORTWK02 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000011 //SORTWK03 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000012 //* 000013 //* SORTOUT : SORTOF**: STEPS SHOULD NOT HAVE 000014 //* DCB PARAMETERS. IT TAKES THE ATTRIBUTES FROM THE INPUT FILE. 000015 //* IF MENTIONED, IT SHOULD BE SAME AS INPUT FILE, OTHERWISE IT ABENDS, 000016 //* IRRESPECTIVE OF WHETHER OUTPUT RECL > OR < THAN THE INPUT RECL. 000017 //* 000018 //SORTOUT DD DSN=USERID.SORT.SORTOUT.OUTNEWP, 000019 //* DISP=(NEW,CATLG,DELETE), 000020 // DISP=(NEW,CATLG,CATLG), 000021 //* DCB=(RECFM=FB,LRECL=40,BLKSIZE=0), 000022 // RECFM=FB,LRECL=20,BLKSIZE=200, 000023 // UNIT=DISK,SPACE=(CYL,(1,2),RLSE) 000024 //* 000025 //****************************************************************** 000026 //*$ORTPARM : IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000027 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000028 //****************************************************************** 000029 //*$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000030 //SYSIN DD DSN=USERID.PAVAN.SORT.EXAMPLE(NEWCTL),DISP=SHR 000031 //* ****** **************************** Bottom of Data ****************************

EDIT USERID.PAVAN.SORT.EXAMPLE(NEWCTL) - 01.41 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,4,CH,A) 000002 SUM FIELDS=(16,5,ZD) ****** **************************** Bottom of Data ****************************

Input:File-AID - Edit - USERID.PAVAN.SORT.INPUT.NEW ----------- COLUMNS 000001 000020COMMAND ===> SCROLL ===> CSR NAME MARKS 15/AN 5/NUM (1-15) (16-20) Column numbers 1-------------- 2------- ****** ***************************** TOP OF DATA ******************-CAPS ON-** 000001 PAVAN REDDY 111 111 + 120 + 800 + 610 = 1641 000002 PAVAN KUMAR 120 000003 PRAVEEN KUMAR 230 -> 230 000004 PAVANI SHARMA 800 000005 PAVAN KUMA 610 000006 DHANANJAY 550 -> 550 000007 SOUJANYA 600 -> 600 000008 SOUHAN 150 -> 150 000009 ROHINI KUMAR 665 -> 1565 000010 ROHITH SHARMA 900

2

Page 3: Sort Utility Examples

****** **************************** BOTTOM OF DATA ****************-CAPS ON-**

Output:File-AID - Edit - USERID.SORT.SORTOUT.OUTNEWP ----------- COLUMNS 000001 000020COMMAND ===> SCROLL ===> CSR NAME MARKS 15/AN 5/NUM (1-15) (16-20) 1-------------- 2------- ****** ***************************** TOP OF DATA ******************-CAPS ON-** 000001 DHANANJAY 550 000002 PAVAN REDDY 1641 000003 PRAVEEN KUMAR 230 000004 ROHINI KUMAR 1565 000005 SOUHAN 150 000006 SOUJANYA 600 ****** **************************** BOTTOM OF DATA ****************-CAPS ON-**

This control card is used as layout for the file shown above.EDIT USERID.PAVAN.SORT.EXAMPLE(NEWCPY) - 01.06 Member NEWCPY saved Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 01 STUDENT-REC. 000002 05 NAME PIC X(15). 000003 05 MARKS PIC 9(05). ****** **************************** Bottom of Data ****************************

Example 2:EDIT USERID.PAVAN.SORT.EXAMPLE(MAY19JCL) - 01.34 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORTEX01 JOB (CDCGBIAC,SOR,TEST),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.PAVAN.SORT.INPUT,DISP=SHR 000008 //SORTOUT DD DSN=USERID.SORT.OUTPUT, 000009 // DISP=(NEW,CATLG,DELETE), 000010 // RECFM=FB,LRECL=60,BLKSIZE=0, 000011 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000012 //* 000013 //****************************************************************** 000014 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000015 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000016 //****************************************************************** 000017 //$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000018 //SYSIN DD * 000019 SORT FIELDS=(1,2,PD,D) 000020 /* 000021 //* ****** **************************** Bottom of Data ****************************

EDIT USERID.PAVAN.SORT.EXAMPLE(OUTCOPY) - 01.05 Member OUTCOPY saved Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 01 SORT-COPY. 000002 05 EMP-ID PIC S9(5) COMP-3. 000003 05 DEPT PIC X(10). 000004 05 EMP-NAME PIC X(22). 000005 05 SALARY PIC 9(5). 000006 05 FILLER PIC X(20).

3

Page 4: Sort Utility Examples

****** **************************** Bottom of Data ****************************

LAYOUT: USERID.PAVAN.SORT.EXAMPLE(INCOPY) FIELD --------- FIELD LEVEL/NAME ---------- -PICTURE- -NUMBER START END LENGTH SORT-COPY 1 40 40 5 EMP-ID S9(5) 1 1 3 3 5 DEPT X(10) 2 4 13 10 5 EMP-NAME X(22) 3 14 35 22 5 SALARY 9(5) 4 36 40 5 ******************************* Bottom of data ********************************

VIEW USERID.TESTCTLCDLIB(KCTESORT) - 01.00 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND ****** **************************** Bottom of Data ****************************

Input:File-AID - Edit - USERID.PAVAN.SORT.INPUT --------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 000002 10101 GTS VENKAT RANGA 300 000003 10002 GIS SIVA SANKAR NAIR 200 000004 10103 CSC ROHINI 10 000005 10100 CSC ROHINI 10 000006 19900 KEAN RAVI KATIPALLY 999 000007 20000 FSG HARISH CHANDRA 123 000008 19900 GTS PAVAN KUMAR REDDY 678 000009 9911 SMG DHANSHREE 11111 000010 9911 SMG DHANSHREE 11111 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output:File-AID - Edit - USERID.SORT.OUTPUT -------------------- COLUMNS 000001 000060COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY FILLER 3/PS 10/AN 22/AN 5/NUM 20/AN (1-3) (4-13) (14-35) (36-40) (41-60) 1------- 2--------- 3--------------------- 4------- 5-------------------****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 20000 FSG HARISH CHANDRA 123 INVALID 000002 19900 KEAN RAVI KATIPALLY 999 INVALID 000003 19900 GTS PAVAN KUMAR REDDY 678 INVALID 000004 10100 AMDO RAMA KRISHNA 1000 INVALID 000005 10101 GTS VENKAT RANGA 300 INVALID 000006 10103 CSC ROHINI 10 INVALID 000007 10100 CSC ROHINI 10 INVALID 000008 10002 GIS SIVA SANKAR NAIR 200 INVALID 000009 9911 SMG DHANSHREE 11111 INVALID 000010 9911 SMG DHANSHREE 11111 INVALID ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

4

Page 5: Sort Utility Examples

Example 3.0: SKIPREC=1,STOPAFT=3 EDIT USERID.PAVAN.SORT.EXAMPLE(JCL) - 01.36 Command name is invalid Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORTEX01 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.PAVAN.SORT.INPUT,DISP=SHR 000008 //SORTOUT DD DSN=USERID.SORT.OUTPUT3, 000009 // DISP=(NEW,CATLG,DELETE), 000010 // RECFM=FB,LRECL=60,BLKSIZE=0, 000011 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000012 //SORTWK01 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000013 //SORTWK02 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000014 //SORTWK03 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000015 //****************************************************************** 000016 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000017 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000018 //****************************************************************** 000019 //$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000020 //SYSIN DD DSN=USERID.PAVAN.SORT.EXAMPLE(CTLCARD),DISP=SHR 000021 //* ****** **************************** Bottom of Data ****************************

EDIT USERID.PAVAN.SORT.EXAMPLE(CTLCARD) - 01.27 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,2,PD,A),SKIPREC=1,STOPAFT=3 000002 SUM FIELDS=NONE ****** **************************** Bottom of Data ****************************

Input:File-AID - Edit - USERID.PAVAN.SORT.INPUT --------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 - Skipped 000002 10101 GTS VENKAT RANGA 300 - processed 000003 10002 GIS SIVA SANKAR NAIR 200 - processed 000004 10103 CSC ROHINI 10 - duplicate as rec2 000005 10100 CSC ROHINI 10 == stopped after 3 records 000006 19900 KEAN RAVI KATIPALLY 999 000007 20000 FSG HARISH CHANDRA 123 000008 19900 GTS PAVAN KUMAR REDDY 678 000009 9911 SMG DHANSHREE 11111 000010 9911 SMG DHANSHREE 11111 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output:File-AID - Edit - USERID.SORT.OUTPUT3 ------------------- COLUMNS 000001 000060COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY FILLER 3/PS 10/AN 22/AN 5/NUM 20/AN (1-3) (4-13) (14-35) (36-40) (41-60) 1------- 2--------- 3--------------------- 4------- 5-------------------****** ***************************** TOP OF DATA ******************-CAPS OFF-*

5

Page 6: Sort Utility Examples

000001 10002 GIS SIVA SANKAR NAIR 200 INVALID 000002 10101 GTS VENKAT RANGA 300 INVALID ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Example 3.1 SKIPREC=1,STOPAFT=6 Control card used for this is USERID.PAVAN.SORT.EXAMPLE(CTLCARD) File-AID - Edit - USERID.PAVAN.SORT.INPUT --------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 - Skipped 000002 10101 GTS VENKAT RANGA 300 - processed 000003 10002 GIS SIVA SANKAR NAIR 200 - processed 000004 10103 CSC ROHINI 10 - duplicate as rec2 000005 10100 CSC ROHINI 10 - duplicate as rec2 000006 19900 KEAN RAVI KATIPALLY 999 - processed 000007 20000 FSG HARISH CHANDRA 123 – processed and stopped 000008 19900 GTS PAVAN KUMAR REDDY 678 000009 9911 SMG DHANSHREE 11111 000010 9911 SMG DHANSHREE 11111 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

EDIT USERID.PAVAN.SORT.EXAMPLE(CTLCARD) - 01.28 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,2,PD,A),SKIPREC=1,STOPAFT=6 000002 SUM FIELDS=NONE ****** **************************** Bottom of Data ****************************

File-AID - Edit - USERID.SORT.OUTPUT3 ------------------- COLUMNS 000001 000060COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY FILLER 3/PS 10/AN 22/AN 5/NUM 20/AN (1-3) (4-13) (14-35) (36-40) (41-60) 1------- 2--------- 3--------------------- 4------- 5-------------------****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10002 GIS SIVA SANKAR NAIR 200 INVALID 000002 10101 GTS VENKAT RANGA 300 INVALID 000003 19900 KEAN RAVI KATIPALLY 999 INVALID 000004 20000 FSG HARISH CHANDRA 123 INVALID ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Example 4: EDIT USERID.PAVAN.SORT.EXAMPLE(JCL) - 01.47 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORTEX01 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,MSGLEVEL=(1,1),NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.PAVAN.SORT.INPUT,DISP=SHR 000008 //*

6

Page 7: Sort Utility Examples

000009 //SORTWK01 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000010 //SORTWK02 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000011 //SORTWK03 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000012 //* 000013 //* SORTOF**: STEPS SHOULD NOT HAVE DCB PARAMETERS. IT TAKES 000014 //* THE ATTRIBUTES FROM THE INPUT FILE. 000015 //* IF MENTIONED, IT SHOULD BE SAME AS INPUT FILE, OTHERWISE IT ABENDS, 000016 //* IRRESPECTIVE OF WHETHER OUTPUT RECL > OR < THAN THE INPUT RECL. 000017 //* 000018 //*FIND THE EXAMPLE MENTIONED IN SORTOF01. 000019 //*APPLICABLE FOR OTHERS ALSO SORTOF0* 000020 //* 000021 //SORTOF01 DD DSN=USERID.SORT.OF01, 000022 // DISP=(NEW,CATLG,DELETE), 000023 //* DCB=(RECFM=FB,LRECL=40,BLKSIZE=0), 000024 //* RECFM=FB,LRECL=40,BLKSIZE=0, 000025 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000026 //SORTOF02 DD DSN=USERID.SORT.OF02, 000027 // DISP=(NEW,CATLG,DELETE), 000028 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000029 //SORTOF03 DD DSN=USERID.SORT.OF03, 000030 // DISP=(NEW,CATLG,DELETE), 000031 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000032 //SORTOF04 DD DSN=USERID.SORT.OF04, 000033 // DISP=(NEW,CATLG,DELETE), 000034 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000035 //SORTOF05 DD DSN=USERID.SORT.OF05, 000036 // DISP=(NEW,CATLG,DELETE), 000037 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000038 //* 000039 //****************************************************************** 000040 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000041 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000042 //****************************************************************** 000043 //$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000044 //* OUTFIL FILES=01,INCLUDE=(1,2,PD,EQ,1010') => NO RECORDS PICKED UP 000045 //* OUTFIL FILES=02,INCLUDE=(1,2,PD,EQ,1000') => NO RECORDS PICKED UP 000046 //* OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,0991') => NO RECORDS PICKED UP 000047 //* NO RECORDS PICKED UP AS 1/2 BYTE IS USED FOR SIGN. 000048 //* 000049 //* INCLUDE=(1,2,PD,EQ,X'0991')--> X'0991' IS INCORRECT SYNTACTICALLY 000050 //* 000051 //* OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,'9) -> '9 IS INVALID 000052 //* EVEN THOUGH ' IS SHOWN,IN HEX ON FORMAT WHEN THE I/P FILE IS VIEWED'000053 //* 79 = ' IN HEXA FORMAT 000054 //* 000055 //SYSIN DD DSN=USERID.PAVAN.SORT.EXAMPLE(CARD),DISP=SHR 000056 //* ****** **************************** Bottom of Data ****************************

VIEW USERID.PAVAN.SORT.EXAMPLE(CARD) - 01.35 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,2,PD,A) 000002 OUTFIL FILES=01,INCLUDE=(1,2,PD,EQ,101) 000003 OUTFIL FILES=02,INCLUDE=(1,2,PD,EQ,610) 000004 OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,788) 000005 OUTFIL FILES=04,INCLUDE=(1,2,PD,EQ,810) 000006 OUTFIL FILES=05,INCLUDE=(1,2,PD,EQ,100) ****** **************************** Bottom of Data ****************************

EDIT USERID.PAVAN.SORT.EXAMPLE(OF01SRT) - 01.36 Columns 00001 00072 Command ===> Scroll ===> CSR

7

Page 8: Sort Utility Examples

****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,2,PD,A) 000002 OUTFIL FILES=01,INCLUDE=(1,2,PD,EQ,101) 000003 OUTFIL FILES=02,INCLUDE=(1,2,PD,EQ,+610) => Whether you add plus (+) 000004 OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,+788) => sign or not it doesn’t make difference. Above card and this doesn’t have any difference.000005 OUTFIL FILES=04,INCLUDE=(1,2,PD,EQ,810) 000006 OUTFIL FILES=05,INCLUDE=(1,2,PD,EQ,100) ****** **************************** Bottom of Data ****************************

LAYOUT: USERID.PAVAN.SORT.EXAMPLE(INCOPY) FIELD --------- FIELD LEVEL/NAME ---------- -PICTURE- -NUMBER START END LENGTH SORT-COPY 1 40 40 5 EMP-ID S9(5) 1 1 3 3 5 DEPT X(10) 2 4 13 10 5 EMP-NAME X(22) 3 14 35 22 5 SALARY 9(5) 4 36 40 5 ******************************* Bottom of data ********************************

Input file:File-AID - Edit - USERID.PAVAN.SORT.INPUT --------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 000002 10101 GTS VENKAT RANGA 300 000003 10002 GIS SIVA SANKAR NAIR 200 000004 10103 CSC ROHINI 10 000005 10100 CSC ROHINI 10 000006 69900 KEAN RAVI KATIPALLY 999 000007 61000 FSG HARISH CHANDRA 123 000008 79900 GTS PAVAN KUMAR REDDY 678 000009 81000 SMG DHANSHREE 11111 000010 78800 GTS KISHORE KUMAR 678 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output files [5 output files are generated as shown below]:Output file 1:File-AID - Edit - USERID.SORT.OF01 ---------------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 000002 10101 GTS VENKAT RANGA 300 000003 10103 CSC ROHINI 10 000004 10100 CSC ROHINI 10 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file 2:File-AID - Edit - USERID.SORT.OF02 ---------------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40)

8

Page 9: Sort Utility Examples

1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 61000 FSG HARISH CHANDRA 123 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file 3:File-AID - Edit - USERID.SORT.OF03 ---------------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 78800 GTS KISHORE KUMAR 678 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file 4:File-AID - Edit - USERID.SORT.OF04 ---------------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 81000 SMG DHANSHREE 11111 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file 5:File-AID - Edit - USERID.SORT.OF05 ---------------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10002 GIS SIVA SANKAR NAIR 200 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Spool Information:Errors I faced:Ran with duplicate outfil names i.e. FILES=03 specified thrice.Hence, got the error SORTOF03 DUPLICATE OUTFIL SPECIFICATION OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,799)OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,809)OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,798)

BROWSE -- SORTEX01.J10895.SORT#04.SYSOUT ----------- Line 00000000 Col 001 080 Command ===> Scroll ===> CSR ********************************* Top of Data ********************************** SYNCSORT FOR Z/OS 1.2.2.3R U.S. PATENTS: 4210961, 5117495 (C) 2005 SYNCSO z/OS 1.8.0 PRODUCT LICENSED FOR CPU SERIAL NUMBER 53B6C, MODEL 2086 460 LICEN $ORTPARM : RC16=ABE SYSIN : SORT FIELDS=(1,2,PD,A) OUTFIL FILES=01,INCLUDE=(1,2,PD,EQ,101) OUTFIL FILES=02,INCLUDE=(1,2,PD,EQ,610) OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,799) OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,809)

9

Page 10: Sort Utility Examples

OUTFIL FILES=03,INCLUDE=(1,2,PD,EQ,798) WER190A SORTOF03 DUPLICATE OUTFIL SPECIFICATION WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000 ******************************* Bottom of Data ********************************

Example 5:VIEW USERID.PAVAN.SORT.EXAMPLE(JCL2) - 01.48 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORTEX01 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,MSGLEVEL=(1,1),NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.SORTXSUM.INPUT,DISP=SHR 000008 //* 000009 //SORTWK01 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000010 //SORTWK02 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000011 //SORTWK03 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000012 //* 000013 //* SORTOF**: STEPS SHOULD NOT HAVE DCB PARAMETERS. IT TAKES 000014 //* THE ATTRIBUTES FROM THE INPUT FILE. 000015 //* IF MENTIONED, IT SHOULD BE SAME AS INPUT FILE, OTHERWISE IT ABENDS, 000016 //* IRRESPECTIVE OF WHETHER OUTPUT RECL > OR < THAN THE INPUT RECL. 000017 //* 000018 //SORTOUT DD DSN=USERID.SORT.SORTOUT, 000019 // DISP=(NEW,CATLG,DELETE), 000020 //* DCB=(RECFM=FB,LRECL=40,BLKSIZE=0), 000021 //* RECFM=FB,LRECL=40,BLKSIZE=0, 000022 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000023 //SORTXSUM DD DSN=USERID.SORT.SORTXSUM, 000024 // DISP=(NEW,CATLG,DELETE), 000025 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000026 //****************************************************************** 000027 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000028 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000029 //****************************************************************** 000030 //$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000031 //* 000032 //SYSIN DD DSN=USERID.PAVAN.SORT.EXAMPLE(CARD),DISP=SHR 000033 //* ****** **************************** Bottom of Data ****************************

EDIT USERID.PAVAN.SORT.EXAMPLE(CARD) - 01.29 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,2,PD,A) 000002 SUM FIELDS=NONE,XSUM ****** **************************** Bottom of Data ****************************Note: Only first 2 bytes i.e. 4 numbers are compared.

Input file:File-AID - Edit - USERID.SORTXSUM.INPUT ----------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 000002 10101 GTS VENKAT RANGA 300 000003 10002 GIS SIVA SANKAR NAIR 200

10

Page 11: Sort Utility Examples

000004 10103 CSC ROHINI 10 000005 69900 CSC ROHINI 10 000006 69900 KEAN RAVI KATIPALLY 999 000007 79900 GTS PAVAN KUMAR REDDY 678 000008 78800 GTS KISHORE KUMAR 678 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output files :2 are generated.SORTOUT:File-AID - Edit - USERID.SORT.SORTOUT ------------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10002 GIS SIVA SANKAR NAIR 200 000002 10100 AMDO RAMA KRISHNA 1000 000003 69900 CSC ROHINI 10 000004 78800 GTS KISHORE KUMAR 678 000005 79900 GTS PAVAN KUMAR REDDY 678 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

SORTXSUM:File-AID - Edit - USERID.SORT.SORTXSUM ------------------ COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10101 GTS VENKAT RANGA 300 000002 10103 CSC ROHINI 10 000003 69900 KEAN RAVI KATIPALLY 999 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Example 6EDIT USERID.PAVAN.SORT.EXAMPLE(JCL3) - 01.48 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORTOF01 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,MSGLEVEL=(1,1),NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.PAVAN.SORT.INPUT,DISP=SHR 000008 //* 000009 //SORTWK01 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000010 //SORTWK02 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000011 //SORTWK03 DD UNIT=DISK,SPACE=(472,(888,176),RLSE),AVGREC=K 000012 //* 000013 //* SORTOF**: STEPS SHOULD NOT HAVE DCB PARAMETERS. IT TAKES 000014 //* THE ATTRIBUTES FROM THE INPUT FILE. 000015 //* IF MENTIONED, IT SHOULD BE SAME AS INPUT FILE, OTHERWISE IT ABENDS, 000016 //* IRRESPECTIVE OF WHETHER OUTPUT RECL > OR < THAN THE INPUT RECL. 000017 //* 000018 //*FIND THE EXAMPLE MENTIONED IN SORTOF01. 000019 //*APPLICABLE FOR OTHERS ALSO SORTOF0* 000020 //* 000021 //SORTOF01 DD DSN=USERID.SORT.START.OF01,

11

Page 12: Sort Utility Examples

000022 // DISP=(NEW,CATLG,DELETE), 000023 //* DCB=(RECFM=FB,LRECL=40,BLKSIZE=0), 000024 //* RECFM=FB,LRECL=40,BLKSIZE=0, 000025 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000026 //SORTOF02 DD DSN=USERID.SORT.START.OF02, 000027 // DISP=(NEW,CATLG,DELETE), 000028 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000029 //SORTOF03 DD DSN=USERID.SORT.START.OF03, 000030 // DISP=(NEW,CATLG,DELETE), 000031 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000032 //* 000033 //****************************************************************** 000034 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000035 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND000036 //******************************************************************000037 //$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000038 //SYSIN DD DSN=USERID.PAVAN.SORT.EXAMPLE(CARD3),DISP=SHR 000039 //* ****** **************************** Bottom of Data ****************************

VIEW USERID.PAVAN.SORT.EXAMPLE(CARD3) - 01.30 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=(1,2,PD,A) 000002 OUTFIL FILES=01,ENDREC=10 000003 OUTFIL FILES=02,STARTREC=5,ENDREC=8 000004 OUTFIL FILES=03,STARTREC=5 ****** **************************** Bottom of Data ****************************

Input file:File-AID - Edit - USERID.PAVAN.SORT.INPUT --------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 AMDO RAMA KRISHNA 1000 000002 10101 GTS VENKAT RANGA 300 000003 10002 GIS SIVA SANKAR NAIR 200 000004 10103 CSC ROHINI 10 000005 10100 CSC ROHINI 10 000006 69900 KEAN RAVI KATIPALLY 999 000007 61000 FSG HARISH CHANDRA 123 000008 79900 GTS PAVAN KUMAR REDDY 678 000009 81000 SMG DHANSHREE 11111 000010 78800 GTS KISHORE KUMAR 678 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output files – 3 output files are generated:Output file 1:File-AID - Edit - USERID.SORT.START.OF01 ---------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10002 GIS SIVA SANKAR NAIR 200 000002 10100 AMDO RAMA KRISHNA 1000 000003 10101 GTS VENKAT RANGA 300 000004 10103 CSC ROHINI 10 000005 10100 CSC ROHINI 10

12

Page 13: Sort Utility Examples

000006 61000 FSG HARISH CHANDRA 123 000007 69900 KEAN RAVI KATIPALLY 999 000008 78800 GTS KISHORE KUMAR 678 000009 79900 GTS PAVAN KUMAR REDDY 678 000010 81000 SMG DHANSHREE 11111 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file 2:File-AID - Edit - USERID.SORT.START.OF02 ---------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 CSC ROHINI 10 000002 61000 FSG HARISH CHANDRA 123 000003 69900 KEAN RAVI KATIPALLY 999 000004 78800 GTS KISHORE KUMAR 678 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file 3:File-AID - Edit - USERID.SORT.START.OF03 ---------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR EMP-ID DEPT EMP-NAME SALARY 3/PS 10/AN 22/AN 5/NUM (1-3) (4-13) (14-35) (36-40) 1------- 2--------- 3--------------------- 4------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 10100 CSC ROHINI 10 000002 61000 FSG HARISH CHANDRA 123 000003 69900 KEAN RAVI KATIPALLY 999 000004 78800 GTS KISHORE KUMAR 678 000005 79900 GTS PAVAN KUMAR REDDY 678 000006 81000 SMG DHANSHREE 11111 ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Spool informationBROWSE -- SORTOF01.J11516.SORT#04.SYSOUT ----------- Line 00000021 Col 001 080 Command ===> Scroll ===> CSR WER036B G=100,B=1330 WER045C END SORT PHASE WER418I DATASPACE(S) AND/OR HIPERSPACE(S) USED WER405I SORTOF01 : DATA RECORDS OUT 10; TOTAL RECORDS OUT 10 WER405I SORTOF02 : DATA RECORDS OUT 4; TOTAL RECORDS OUT 4 WER405I SORTOF03 : DATA RECORDS OUT 6; TOTAL RECORDS OUT 6 WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000 WER416B SORTIN : EXCP'S=1,UNIT=3390,DEV=5F17,CHP=(F8F9FAFDFEFF,1),VOL=CSO015WER416B OUTFIL WAS USED FOR SORTOUT WER246I FILESIZE 400 BYTES WER054I RCD IN 10, OUT 10 WER072I EQUALS IN EFFECT WER169I RELEASE 1.2 BATCH 0454 TPF LEVEL 2.3 WER052I END SYNCSORT - SORTOF01,SORT#04,,DIAG=9B00,4003,A219,EC7F,D2E6,6C8B,22

Example 7: INREC and OUTRECEDIT USERID.PAVAN.TEST(CJCLOUT) - 01.23 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORT001 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,NOTIFY=&SYSUID 000003 //*

13

Page 14: Sort Utility Examples

000004 //SORT#04 EXEC PGM=SYNCSORT,COND=(0,NE) 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.INOUTREC.INPUT,DISP=SHR 000008 //SORTOUT DD DSN=USERID.INOUTREC.OUTPUT.MAY16, 000009 // DISP=(NEW,CATLG,DELETE), 000010 // RECFM=FB,LRECL=80,BLKSIZE=0, 000011 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000012 //****************************************************************** 000013 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000014 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000015 //****************************************************************** 000016 //*$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000017 //SYSIN DD DSN=USERID.PAVAN.TEST(CTRLCARD),DISP=SHR 000018 //* ****** **************************** Bottom of Data ****************************

VIEW USERID.PAVAN.TEST(CTRLCARD) - 01.15 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=COPY 000002 INCLUDE COND=(21,1,CH,EQ,X'11',OR,25,2,CH,EQ,C'22') 000003 OUTREC FIELDS=(5:10,10,3C'*',34,6,C' $ ',28,4,35:6Z) ****** **************************** Bottom of Data ****************************

Third record is skipped as it doesn’t get through the include condition.

OUTREC FIELDS=(5:10,10,3C'*',34,6,C' $ ',28,4,35:6Z)

5:10,10 => Position 10 to next 10 positions in input file is copied to output file from 5th position to next 10 positions in output file.AR REDDY.K AYAL SHARMAE SUKTHANK A RAO ANNA

3C'*' : Then next three * symbols are placed.***

34,6, : Then from 34 to next 6 positions i.e. 34,35,36,37,38,39 are copied immediately from the next position to the output file.

ELF HEATE NOR FRNDIST DO

C' $ ': Then a space followed by $ symbol, then a space.$

28,4 : Then the data from 28,29,30,31 from input file copied to successive positions in the output file.417M263R431D177M

Copybook used for input file:VIEW USERID.PAVAN.TEST(COPYBOOK) - 01.02 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 01 COPY-BOOK.

14

Page 15: Sort Utility Examples

000002 05 NAME PIC X(20). 000003 05 MONEY PIC S9(5)V9(2) COMP-3. 000004 05 COUNT PIC 9(6). 000005 05 RELATION PIC X(10). ****** **************************** Bottom of Data ****************************

Input file:File-AID - Edit - USERID.INOUTREC.INPUT ----------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR NAME MONEY COUNT RELATION 20/AN 4/PS 6/NUM 10/AN (1-20) (21-24) (25-30) (31-40) 1------------------- 2-------- 3------- 4--------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 PAVAN KUMAR REDDY.K 11001.00 223417 MYSELF HEY 000002 SHANKAR DAYAL SHARMA 11000.00 232263 RELATE NOP 000003 DHANASHREE SUKTHANK -10058.34 187431 DEAR FRNDS 000004 SAMBA SIVA RAO ANNA 100.00 225177 MAOIST DON ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file:VIEW USERID.INOUTREC.OUTPUT.MAY16 Columns 00001 00072 Command ===> Scroll ===> CSR =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--****** ***************************** Top of Data ******************************000001 AR REDDY.K***ELF HE $ 417M 000002 AYAL SHARM***ATE NO $ 263R 000003 A RAO ANNA***IST DO $ 177M ****** **************************** Bottom of Data ****************************

Example 8: EDIT USERID.PAVAN.TEST(CJCLOUT) - 01.24 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 //SORT001 JOB (ACCT PARM),'TEST', 000002 // TIME=5,CLASS=3,MSGCLASS=T,NOTIFY=&SYSUID 000003 //* 000004 //SORT#04 EXEC PGM=SYNCSORT,COND=(0,NE) 000005 //SYSOUT DD SYSOUT=* 000006 //SYSPRINT DD SYSOUT=* 000007 //SORTIN DD DSN=USERID.INOUTREC.INPUT,DISP=SHR 000008 //SORTOUT DD DSN=USERID.INOUTREC.OUTPUTX, 000009 // DISP=(NEW,CATLG,DELETE), 000010 // RECFM=FB,LRECL=80,BLKSIZE=0, 000011 // UNIT=DISK,SPACE=(CYL,(50,20),RLSE) 000012 //****************************************************************** 000013 //*IT CONVERTS SYSTEM RETURN CODE TO USER ABEND CODE. 000014 //*RC16=ABE GENERIC K.C. CNTL CARD TO CONVERT RC16 TO A U0016 ABEND 000015 //****************************************************************** 000016 //*$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR 000017 //SYSIN DD DSN=USERID.PAVAN.TEST(INRECDUP),DISP=SHR 000018 //* ****** **************************** Bottom of Data ****************************

VIEW USERID.PAVAN.TEST(INRECDUP) - 01.30 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 SORT FIELDS=COPY 000002 OUTREC FIELDS=(5:10,10,3C'*',21:2X,34,6,C' $ ', 000003 60:3,1,CHANGE=(8,C'V',C'CHANGED', 000004 C'A',C'DELETE '),

15

Page 16: Sort Utility Examples

000005 NOMATCH=(C'NOMATCH')) ****** **************************** Bottom of Data ****************************

Copybook used for input file:VIEW USERID.PAVAN.TEST(COPYBOOK) - 01.02 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ******************************000001 01 COPY-BOOK. 000002 05 NAME PIC X(20). 000003 05 MONEY PIC S9(5)V9(2) COMP-3. 000004 05 COUNT PIC 9(6). 000005 05 RELATION PIC X(10). ****** **************************** Bottom of Data ****************************

Input file:File-AID - Edit - USERID.INOUTREC.INPUT ----------------- COLUMNS 000001 000040COMMAND ===> SCROLL ===> CSR NAME MONEY COUNT RELATION 20/AN 4/PS 6/NUM 10/AN (1-20) (21-24) (25-30) (31-40) 1------------------- 2-------- 3------- 4--------- ****** ***************************** TOP OF DATA ******************-CAPS OFF-* 000001 PAVAN KUMAR REDDY.K 11001.00 223417 MYSELF HEY 000002 SHANKAR DAYAL SHARMA 11000.00 232263 RELATE NOP 000003 DHANASHREE SUKTHANK -10058.34 187431 DEAR FRNDS 000004 SAMBA SIVA RAO ANNA 100.00 225177 MAOIST DON ****** **************************** BOTTOM OF DATA ****************-CAPS OFF-*

Output file:VIEW USERID.INOUTREC.OUTPUTX Columns 00001 00072 Command ===> Scroll ===> CSR =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--****** ***************************** Top of Data ******************************000001 AR REDDY.K*** ELF HE $ CHANGED 000002 AYAL SHARM*** ATE NO $ DELETE 000003 E SUKTHANK*** R FRND $ DELETE 000004 A RAO ANNA*** IST DO $ NOMATCH ****** **************************** Bottom of Data ****************************

Third record is skipped as it doesn’t get through the include condition.

OUTREC FIELDS=(5:10,10,3C'*',21:2X,34,6,C' $ ', 60:3,1,CHANGE=(8,C'V',C'CHANGED', C'A',C'DELETE '), NOMATCH=(C'NOMATCH'))

5:10,10 => Position 10 to next 10 positions in input file is copied to output file from 5th position to next 10 positions in output file.AR REDDY.K 5-14 = 10 positionsAYAL SHARMAE SUKTHANK A RAO ANNA

3C'*' : 15,16,17 = 3 positionsThen next three * symbols are placed.***

21:2X : 18,19,20 = No data, then we get 2 spaces i.e. 21,22 positions.

34,6, : Then from 34 to next 6 positions i.e. 34,35,36,37,38,39 are copied Immediately, the next position the cursor is pointing to columns i.e. from 23-28

16

Page 17: Sort Utility Examples

to the output file.

2----+---********* ELF HE ATE NO R FRND IST DO

C' $ ': Then a space followed by $ symbol, then a space.

60:3,1,CHANGE=(8,C'V',C'CHANGED', Here 8 specifies the length of variable 'CHANGED'. C'A',C'DELETE '), NOMATCH=(C'NOMATCH')) 6----+-*******CHANGEDDELETE DELETE NOMATCH

If in input file from position 3 to 1 position(60:3,1), 1.has the character ‘V’ then write at 60 position, characters CHANGED2.has the character ‘A’ then write at 60 position, characters DELETE3.has the characters other than ‘V’ & A then write at 60 position, characters NOMATCH

Other capabilities of SORT:

1. ALTSEQ , CODE. //EXAMP JOB A400,PROGRAMMER 01 //S1 EXEC PGM=SORT 02 //SYSOUT DD SYSOUT=A 03 //SORTIN DD DSN=A123456.IN5,DISP=SHR 04 //SORTOUT DD DSN=OUT1,UNIT=3490,DISP=(,KEEP),VOL=SER=VOL001 05 //SORTWK01 DD UNIT=3390,SPACE=(CYL,(10,10)) 06 //SORTWK02 DD UNIT=3390,SPACE=(CYL,(10,10)) 07 //SYSIN DD * 08 * COLLATE $, # and @ AFTER Z 09 SORT FIELDS=(7,5,AQ,A) 10 ALTSEQ CODE=(5BEA,7BEB,7CEC) ALTSEQ statement. CODE specifies that the three characters $, # and @ are to collate in that order after Z.

2. Converting Lower case to Upper CaseIf you have a file with a set of records, few in uppercase and few in lower case. To translate them to uppercase completely. Use the sort card below.Sample sort card is shown below://SORTOUT DD SYSOUT=* //SYSIN DD * INREC OVERLAY=(1:1, 2,TRAN=LTOU) SORT FIELDS=(1,2, CH,A) SUM FIELDS=NONE /*

3. The CHANGE operand of the OUTREC statement is a feature of SyncSort which allows the programmer to recode records. Consider the following dataset containing pet information with the Pet name in positions 1-8, Gender (M or F) in position 9 &

17

Page 18: Sort Utility Examples

Species (D = dog, C = cat, R = rabbit) in position 10:

1------8910 column positionBUFFY FDWAFFLES MCOREO MRHERSHEYSFC

Let's assume I desire the following output with the name remaining in positions 1-8, a blank in position 9, the gender (recoded as 1 if male & as 2, if female) in position 10, a blank in position 11, and the species (spelled out as DOG, CAT, or OTHER) in positions 12-16:

BUFFY 2 DOGWAFFLES 1 CATOREO 1 OTHERHERSHEYS 2 CAT

My SyncSort control cards would appear as follows:

//SYSIN DD * SORT FIELDS=COPY OUTREC FIELDS=(1:1,8, NAME 9:1X, BLANK 10:9,1,CHANGE=(1,C'M',C'1', RECODE GENDER C'F',C'2'), 11:1X, BLANK 12:10,1,CHANGE=(5,C'D',C'DOG ', RECODE SPECIES C'C',C'CAT '), NOMATCH=(C'OTHER'))

Let's quickly explain the last field: 12 is the position in the output record, 10 is the position in the input record, 1 is the length in the input record, 5 is the length in the output record, C'D' and C'C' are the change-from values, and C'DOG ' and C'CAT ' are the change-to values. Note the NOMATCH operand is optional (it wasn't used with gender), but if it is omitted and an unmatched condition is encountered, SyncSort will ABEND with U0016 return code. As always, be careful of misplaced blanks, commas and parentheses. Proper alignment is not required by SyncSort, but may be required by your peers!

4. SORT options: FILSZ, - provides information about the field(s) that will be used for sorting options: FIELDS=(P,L,FF,O) - used to specify the key field(s) - Maximum of 64 P starting position of the key field L length of the key field FF data format of the control field CH EBCDIC alphanumeric ZD Zoned decimal PD Packed decimal FI Fixed point BI Binary O collating sequence A ascending order D descending orderMnemonic comparison type EQ equality NE not equal GT greater than

18

Page 19: Sort Utility Examples

GE greater than or equal to LT less than LE less than or equal to

OMIT COND=(1,1,BI,EQ,X'FF',OR,8,5,PD,LT,+1)Any record containing X'FF' in the 1st byte OR a packed decimalvalue less than 1 in the 5 byte field starting in column 8 shouldbe omitted from the output.

//SORTSTEP EXEC PGM=SYNCSORT //SORTIN DD DSN=Z123456.INPUT,DISP=SHR //SORTOUT DD DSN=Z123456.SORTED,DISP=(NEW,PASS,DELETE), // UNIT=DISK,VOL=SER=ACA301,SPACE=(TRK,(1,1)) //SYSOUT DD SYSOUT=* //SORTWK01 DD DSN=&&SORTWK01,UNIT=PUB,DISP=(NEW,DELETE), // SPACE=(TRK,(1,1)) //SYSIN DD * SORT FIELDS=(2,4,CH,A,8,5,PD,D), SKIPREC=1 FILSZ=E400 It means there are estimated records of 400. Using this and LRECL, sort program will calculate the amount of work storage required. /*

The above step will: 1. Skip the first record 2. Sort the remaining records in Ascending order based on the Characters in the 4 byte field starting in position 2.3. If there is a match, sort in Descending order based on the Packed Decimal number in the 5 byte field starting in position 8.4. The file will contain an estimated 400 records

5. Why to use $ORTPARM in the sort programs. 1. This is the message when $ORTPARM is commented as //*$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR Messages:JOB SORT001(JOB55379) SUBMITTED*** 11.01.20 JOB55379 $HASP165 SORT001 ENDED AT KCYNJE1 MAXCC=16 CN(INTERNAL)***

2. This is the message when $ORTPARM is uncommented and executed as //$ORTPARM DD DSN=USERID.TESTCTLCDLIB(KCTESORT),DISP=SHR

One advantage by uncomment is, output file will not get created if the job abend. But in previous step where $ortparm is commented, we have to delete for each unsuccessful execution to rerun the same job

RC16=ABE -> converts system abend to user abend.JOB SORT001(JOB55397) SUBMITTED *** 11.04.22 JOB55397 $HASP165 SORT001 ENDED AT KCYNJE1 - ABENDED S000 U0016 CN(INTERNAL) *** ************************************************************************

6. DFSORT, SYNCSORT Table 50. Summary Field Formats and Lengths

19

Page 20: Sort Utility Examples

Format Code Length Description

BI BI 2, 4, or 8 bytes Unsigned binary

FI 2, 4, or 8 bytes Signed fixed-point

| FL

|

4, 8, or 16 bytes

| Signed hexadecimal

| floating-point

PD 1 to 16 bytes Signed packed decimal

ZD 1 to 31 bytes Signed zoned decimal

7. INREC & OUTRECINREC is processed before the records are sorted, copied or merged. OUTREC is processed after the records are sorted, copied or merged.

8. PACKOFF – JCL AND SORT CARDAn important thing to remember is, when you get the following error. Give a pack off. You can never come to the conclusion what is the error. Error is the PDS is pack on format

If you come across such errors which can be general shown in red below.Give a pack off and try submitting the same job.BROWSE -- SORTEX01.J09821.SORT#04.SYSOUT ----------- Line 00000000 Col 001 080 Command ===> Scroll ===> CSR ******************************** Top of Data **********************************SYNCSORT FOR Z/OS 1.2.2.3R U.S. PATENTS: 4210961, 5117495 (C) 2005 SYNCSO z/OS 1.8.0 PRODUCT LICENSED FOR CPU SERIAL NUMBER 53B6C, MODEL 2086 460 LICEN$ORTPARM : RC16=ABE SYSIN : .. F...&.oSORT FIELDS=(1,2,PD,A),..þSUM FIELDS=NONE.. * WER161B ALTERNATE PARM USED WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000 WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE ******************************* Bottom of Data ********************************

9. ELIMINATE DUPLICATES //SYSIN DD * SORT FIELDS=(1,3,CH,A) SUM FIELDS=NONE /* Input file has following data and structure

INPUT FILE

MOHANK 23423423434534344 KIRAN MOHANK 13342345345345345 RAJEEV ARAMES 34535345325354324 SURESH SURESH 98347385385933987 PULI RAMESH 67575789769876785 MADHU KRISHN 50830948530859340 OIIED KRISHN 30495849572938495 MADHU SURESH 98347385385933987 PULI

OUTFILE

ARAMES 34535345325354324 SURESHKRISHN 50830948530859340 OIIED MOHANK 23423423434534344 KIRAN

20

Page 21: Sort Utility Examples

RAMESH 67575789769876785 MADHU SURESH 98347385385933987 PULI

EXPLANATIONIf we give SUM FIELDS=NONE it will eliminate duplicates

9 .SPLIT FILE INTO TWO OR THREE FILES DEPENDS ON CONDITIONS..//SORTOF01 DD DSN=dataset1, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,// SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) //SORTOF02 DD DSN=dataset2, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,// SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) //SORTOF03 DD DSN=dataset3, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,// SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)..//SYSIN DD * SORT FIELDS=COPY OUTFIL FILES=01,INCLUDE=(1,6,CH,EQ,C'MOHANK') OUTFIL FILES=02,INCLUDE=(1,6,CH,EQ,C'SURESH') OUTFIL FILES=03,INCLUDE=(1,6,CH,EQ,C'KRISHN')/* Input file has following data and structure

Input file:

INPUT FILE

MOHANK 23423423434534344 KIRAN MOHANK 13342345345345345 RAJEEV ARAMES 34535345325354324 SURESH SURESH 98347385385933987 PULI RAMESH 67575789769876785 MADHU KRISHN 50830948530859340 OIIED KRISHN 30495849572938495 MADHU SURESH 98347385385933987 PULI

Output files:

SORTOF01

MOHANK 23423423434534344 KIRAN MOHANK 13342345345345345 RAJEEV

SORTOF02

SURESH 98347385385933987 PULI SURESH 98347385385933987 PULI

SORTOF03

KRISHN 50830948530859340 OIIED

21

Page 22: Sort Utility Examples

KRISHN 30495849572938495 MADHU

EXPLANATION1. SORT FIELDS=COPY - indicate, it for copy of records, not for sort2. OUTFIL FILES=01,INCLUDE=(1,6,CH,EQ,C'MOHANK') OUTFIL FILES=02,INCLUDE=(1,6,CH,EQ,C'SURESH') OUTFIL FILES=03,INCLUDE=(1,6,CH,EQ,C'KRISHN')- SYNCSORT will take data from 1st position to 6th position of input file and it will compare that data with MOHANK or SURESH or KRISHN- If data equals to MOHANK then that record will copies to dataset defined in SORTOF01 step. ( because we defined FILES=01 in second condition )- If data equals to SURESH then that record will pass to dataset defined in SORTOF02 step. ( because we defined FILES=02 in second condition )

- If data equals to KRISHN then that record will copied to dataset defined in SORTOF03 step. ( because we defined FILES=03 in third condition )

10. COPY ELIMINATED DUPLICATES INTO ANOTHER FILE - SAMPLE JCL..//SORTXSUM DD DSN=dataset-name, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,// SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)..//SYSIN DD * SORT FIELDS=(1,3,CH,A) Is the matching done for the entire record or just the field numbers mentioned here??

Answer is just for fields mentioned in SORT FIELDS= RESPECTIVE COLUMN NAMES.

SUM FIELDS=NONE,XSUM /* Input file:

INPUT FILE

MOHANK 23423423434534344 KIRAN MOHANK 13342345345345345 RAJEEV ARAMES 34535345325354324 SURESH SURESH 98347385385933987 PULI RAMESH 67575789769876785 MADHU KRISHN 50830948530859340 OIIED KRISHN 30495849572938495 MADHU SURESH 98347385385933987 PULI

SORTOUT

ARAMES 34535345325354324 SURESH KRISHN 50830948530859340 OIIED MOHANK 23423423434534344 KIRAN RAMESH 67575789769876785 MADHU SURESH 98347385385933987 PULI

SORTXSUM

KRISHN 30495849572938495 MADHU MOHANK 13342345345345345 RAJEEVSURESH 98347385385933987 PULI

22

Page 23: Sort Utility Examples

EXPLANATION1. SORT FIELDS=(1,3,CH,A) Input file will be sorted depending up on the key specified above 1,3,CH,A - key starting position is 1 and length 3, comparing type character, sorting is don in ascending order

2. SUM FIELDS=NONE,XSUM SUM FIELDS=NONE means it will eliminate duplicates XSUM options will copy all records eliminated in sort process will copy to another data set defined in SORTXSUM step.

11. FORMATING A FILE (USING INREC)Input file has following data and structure

INPUT FILE

MOHANK 43423423434534344 KIRAN MOHANK 13342345345345345 RAJEEV ARAMES 34535345325354324 SURESH SURESH 98347385385933987 PULI RAMESH 67575789769876785 MADHU KRISHN 50830948530859340 OIIED KRISHN 30495849572938495 MADHU SURESH 98347385385933987 PULI

//SYSIN DD * SORT FIELDS=COPY INREC FIELDS=(7:2,5,20:8,3) /*

INREC FIELDS=(7:2,5,20:8,3)- Output position: 7,8,9,10,11, Input – from 2 to 5- Output position: 20,21,22,23,24,25, Input – from 8,9,10

OUTPUT FILE

OHANK 342 OHANK 334 RAMES 453 URESH 834 AMESH 757 RISHN 083 RISHN 049 URESH 834

EXPLANATION1. SORT FIELDS=COPY It is for copy records to output file2. INREC FIELDS=(7:2,5,20:10,3) (for formatting) Here we have two formatting, 1. 7:2,5 - data at 2nd position of input file with length 5 copied to 7th position of output file 2. 20:8,3 - data at 8th position of input file with length 3 copied to 20th position of output file

In above example, we can use OUTREC instead of INREC,INREC adds, deletes, or reformats fields before the

23

Page 24: Sort Utility Examples

records are sorted or merged. so that performance willbe improved

OUTREC adds, deletes, or reformats fields after the records are sorted or merged.

12. SORT options: - provides information about the field(s) that will be used for sorting options: FIELDS=(P,L,FF,O) - used to specify the key field(s) - Maximum of 64 P starting position of the key field L length of the key field FF data format of the control field CH EBCDIC alphanumeric ZD Zoned decimal PD Packed decimal FI Fixed point BI Binary O collating sequence A ascending order D descending orderMnemonic comparison type EQ equality NE not equal GT greater than GE greater than or equal to LT less than LE less than or equal to

OMIT COND=(1,1,BI,EQ,X'FF',OR,8,5,PD,LT,+1)Any record containing X'FF' in the 1st byte OR a packed decimalvalue less than 1 in the 5 byte field starting in column 8 shouldbe omitted from the output.

13. FILSZ//SORTSTEP EXEC PGM=SYNCSORT//SORTIN DD DSN=Z123456.INPUT,DISP=SHR//SORTOUT DD DSN=Z123456.SORTED,DISP=(NEW,PASS,DELETE),// UNIT=DISK,VOL=SER=ACA301,SPACE=(TRK,(1,1))//SYSOUT DD SYSOUT=*//SORTWK01 DD DSN=&&SORTWK01,UNIT=PUB,DISP=(NEW,DELETE),// SPACE=(TRK,(1,1))//SYSIN DD * SORT FIELDS=(2,4,CH,A,8,5,PD,D), SKIPREC=1 FILSZ=E400 It means there are estimated records of 400. Using this and LRECL, sort program will calculate the amount of work storage required. /*The above step will: 1. Skip the first record 2. Sort the remaining records in Ascending order based on the Characters in the 4 byte field starting in position 2.3. If there is a match, sort in Descending order based on the Packed Decimal number in the 5 byte field starting in position 8.4. The file will contain an estimated 400 records

24

Page 25: Sort Utility Examples

14. To sort and shift fields, CORE=MAX, PARM='DYNALLOC', //* To sort and shift fields//SORTIT EXEC PGM=SORT,PARM=’ABEND’//SYSOUT DD SYSOUT=*//SORTIN DD * number in column 1, name in 10, state in 199283873 JOAN CT7023232 JANE CN8432343 MARIO MA5549023 JILL CT/*//SORTOUT DD SYSOUT=*//SYSIN DD ** sort by name SORT FIELDS=(10,09,CH,A),DYNALLOC=(SYSDA,6),FILSZ=E2000 Described below. OUTREC FIELDS=(01:10,09, move name from 10 to 1 10:01,07) move number from 1 to 10* OutREC moves data after sorting ends./*//* END OF JOB

DYNALLOC Specifies that the host sort utility supports dynamic allocation of any necessary work files.

What do the parameters PARM='CORE=MAX' and PARM='DYNALLOC' in a sort job mean?CORE=MAX is an alias for SIZE=MAX which tells DFSORT to determine how much storage to use based on the TMAXLIM and DSA values in effect.

DYNALLOC tells DFSORT to use dynamic allocation of work data sets.

One of the reasons for getting SORT INTERNAL ERROR - RECOVERY ATTEMPT IN PROGRESS from Sync sort is due to assigning the incorrect value (very less file size value) to FILSZ parm in SORT card. The value assigned to FILSZ parm should be greater than number of records in the input file (or nearer to input file record count). For example:If we assign 1500000 to FILSZ and if we process 10539694 records. And this is leading to the infinite loop in getting the extra storage. FILSZ=E1500000 E stands for estimated. If you know the exact count, just mention the count of records ignoring the beginning character ‘E’.

To determine the input file size for a sort application. DFSORT performs calculations based on the user supplied record count and other parameters (such as AVGRLEN) to estimate the total number of bytes to be sorted. This value is important for sort applications, since it is used for several internal optimizations as well as for dynamic work data set allocation (see OPTION DYNALLOC). If no input record count (or only an estimate) is supplied for the sort application, DFSORT attempts to automatically compute the file size to be used for the optimizations and allocations.

U can give more sortwork areas too if you still have a problem. This will create temporary sort areas and are used while sorting large files. The syntax is specified below.

//SORTWKnn DD UNIT=SYSDA,SPACE=(CYL,(1,1) However the SORTWK should not be specified for copy or merge utitlity if the DYNALLOC parm is used

15. Find the records with the matching criteria.

25

Page 26: Sort Utility Examples

SORT FIELDS=COPYINCLUDE COND= (1, 80, SS, EQ, C'FIND STRING')

Here,SS - Sub string,1 - Starting position of the range80 - Width of the search rangeEQ - Comparison operatorsThe Sort card for this will need information like range of columns within which you want the search to be performed. To search in the whole file you can give the start position as 1 and LRECL of the file as the width of the search range as done above. We can also replace the 'EQ' parameter by 'NE' which will fetch us all the records which don'thave the specified string. Only EQ & NE can be used for comparison. We can even use OMIT COND instead of INCLUDE.This can also be used to find the records with string that match one of the strings in the COND.For exampleSORT FIELDS=COPYINCLUDE COND= (1, 80, SS, EQ, C'HDR,TRL')The above sort card returns all records with the substring ' HDR' or'TRL' occurring within the search range(1-80) of the record in theinput file.

16. Duplicate SORTIN DDnamesIf you specify a particular DDname (such as SORTIN) more than once within the same step, DFSORT uses the first DDname and ignores subsequent duplicates. Processing continues normally. In addition, SORTIN0, SORTIN1...SORTIN9 can be specified instead of SORTIN00, SORTIN01...SORTIN09, respectively. If you specify both SORTINn and SORTIN0n in the same job step, DFSORT treats them as duplicates, and ignores each usage after the first. For example, SORTIN2 and SORTIN02 are treated as duplicates and only SORTIN2 is used. Note: For a Conventional merge, SORTINn will not be recognized because of the existing restriction which allows only SORTIN01, SORTIN02...SORTIN16. Duplicates of these accepted ddnames will be ignored.

17. what is the purpose of using PARM=’RC16=ABE’ parameter in SORT program?. Code:

//SORT EXEC  PGM=SORT,COND=(4,LT),PARM='RC16=ABE' ... //SYSIN DD *   DEBUG ABEND                                            SORT FIELDS=COPY                                        OUTFIL FNAMES=OUTFIL1,                                    OMIT=(685,11,CH,EQ,C' ',AND,681,01,CH,EQ,C'I')                     

  OUTFIL FNAMES=OUTFIL2,     INCLUDE=685,11,CH,EQ,C' ',AND,681,01,CH,EQ,C'I') /*

R16=ABE ==> Step will ABEND if return code is 16, ignoring this would mean return code will be 16 but no abend will happen.

26