If I wanted to extract all the records having '1111' as the first four bytes, into a dataset, those with '2222' to another, '3333' to yet another, and the remaining records to a fourth dataset(here is where the WHEN OTHER is required).
OUTFIL with the SAVE parameter will capture any records which weren't included/were excluded from any of the other output datasets, if that is a requirement of your process.
Here is an example :
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DSN=... input data set
//KEY1111 DD DSN=...
//KEY2222 DD DSN=...
//KEY3333 DD DSN=...
//KEYOTHER DD DSN=...
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=KEY1111,INCLUDE=(1,4,CH,EQ,C'1111')
OUTFIL FNAMES=KEY2222,INCLUDE=(1,4,CH,EQ,C'2222')
OUTFIL FNAMES=KEY3333,INCLUDE=(1,4,CH,EQ,C'3333')
OUTFIL FNAMES=KEYOTHER,SAVE
/*
Here the file mentioned with DDname KEYOTHER will have all the records that were not included in the first three output files.
OUTFIL with the SAVE parameter will capture any records which weren't included/were excluded from any of the other output datasets, if that is a requirement of your process.
Here is an example :
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DSN=... input data set
//KEY1111 DD DSN=...
//KEY2222 DD DSN=...
//KEY3333 DD DSN=...
//KEYOTHER DD DSN=...
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=KEY1111,INCLUDE=(1,4,CH,EQ,C'1111')
OUTFIL FNAMES=KEY2222,INCLUDE=(1,4,CH,EQ,C'2222')
OUTFIL FNAMES=KEY3333,INCLUDE=(1,4,CH,EQ,C'3333')
OUTFIL FNAMES=KEYOTHER,SAVE
/*
Here the file mentioned with DDname KEYOTHER will have all the records that were not included in the first three output files.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.