SORT Usage1 - COPY
//SORT01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=TOUGH.B01.RATE,DISP=SHR
//SORTOUT DD DSN=TOUGH.B01.RATE.SORT,DISP=SHR
//SYSIN DD *
SORT FIELDS=COPY
//
1. Simple COPY
SORT FIELDS=COPY
SORT FIELDS=(1,50,CH,A)
2. Selecting COPY
SORT FIELDS=COPY
OUTREC FIELDS=(1,23,48,3)
3. Selecting, Adding COPY
SORT FIELDS=COPY
OUTREC FIELDS=(1,23,48,3,X'C3D5E8',49,1)
OUTREC FIELDS=(1,23,48,3,C'CNY',49,1)
CH - Character
ZD - Zoned Decimal
PD - Packed Decimal
BI - Binary
Select the 1-23 digits, 48-50 digits, inserting 'CNY', 49 digit from original file. => New File
4. Selecting, Condition COPY
SORT FIELDS=COPY
OUTREC FIELDS=(1,23,48,3) -> Column
INCLUDE COND=(45,3,CH,EQ,C'CNY') -> Selecting
INCLUDE COND=(5,5,CH,GT,X'000171909C',AND,5,5,CH,LE,X'000300000C') ->GT/LE
OMIT COND=(45,4,CH,EQ,C'0464')
SORT Usage1 - SPLIT
//SORT01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=TOUGH.B01.RATE
//SORTOUT1 DD DISP=SHR,DSN=TOUGH.B01.RATE1
//SORTOUT2 DD DISP=SHR,DSN=TOUGH.B01.RATE2
//SORTOUT3 DD DISP=SHR,DSN=TOUGH.B01.RATE3
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT1,INCLUDE=(45,4,CH,EQ,C'1307')
OUTFIL FNAMES=SORTOUT2,INCLUDE=(45,4,CH,GT,C'1307')
OUTFIL FNAMES=SORTOUT3,SAVE
/*
SAVE: 把没有被前面文件接受的记录输出到文件SORT3中。
SORT Usage3 - MERGE
//SORT01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN01 DD DISP=SHR,DSN=TOUGH.B01.RATE01
//SORTIN02 DD DISP=SHR,DSN=TOUGH.B01.RATE02
//SORTOUT DD DISP=SHR,DSN=TOUGH.B01.RATE.NEW
//SYSIN DD *
MERGE FIELDS(1,19,CH,A)
/*
1. Omit MERGE
MERGE FIELDS=(1,19,CH,A)
OMIT COND=(45,4,CH,EQ,C'3273')
2. Selecting MERGE
MERGE FIELDS=(1,19,CH,A)
INCLUDE COND=(45,4,CH,EQ,C'3273',AND,2,3,CH,LE,C'0000C')
SORT Usage3 - Other
1. Top Selecting
SORT FIELDS=COPY,STOPAFT=15
OUTREC FIELDS=(1,23,48,3)
INCLUDE COND=(45,3,CH,EQ,C'CNY') -> GT/LE
2. Start from Nth record, then output
SORT FIELDS=COPY,SKIPREC=20,STOPAFT=15
INCLUDE COND=(45,3,CH,EQ,C'CNY') -> GT/LE
3. CHANGE
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,OUTREC=(1,18,19,3,CHANGE=(3,C'123',C'456'),NOMATCH=(19,3),22,100)
If the value of 19-21th record is 123, then replace with 456. Otherwise keep it is.
=========================================================================
INCLUDE COND=(
106,5,CH,EQ,C'BIOL',OR,
106,5,CH,EQ,C'HIST',OR,
106,5,CH,EQ,C'BUSIN',OR,
106,5,CH,EQ,C'PSYCH')
INCLUDE COND=(106,5,SS,EQ,C'BIOL ,HIST ,BUSIN,PSYCH')
With substring search (SS format), you only write the field once and write the character constant so it includes all of the strings you want to search for. If the value in the field matches any of the strings (for example, "BUSIN"), the record is included. If the value in the field does not match any of the strings, the record is omitted.
INCLUDE COND=(1,75,SS,EQ,C'INTRODUCTION')