Back in the mists of time - so I can say it now :-) - Frank Yaeger and I 
were discussing how we might add some things to the first offering of 
OUTFIL in DFSORT that weren't then in Syncsort. We came up with SAVE and 
"Card Dealer".

SAVE has, to my mind, been most invaluable. Prior to this you had to 
figure out the boolean complement of the INCLUDE= clause. With more than 
one INCLUDE= clause in a sort it became hairier, requiring De Morgan's 
Law*. :-)  SAVE made this a lot simpler and less error prone.

"Card Dealer" not so much.

I would expect both implementations - DFSORT and Syncsort - to have had 
these functions since the 1990s and both have gone much further.

On the "tagging" that Sri Hari mentioned:

1) You needn't tag unless you want to - and there will be some occasions 
where you don't want to. One example might be if you've been counting with 
SUM FIELDS= and a binary "ONE" field. You might throw away records where 
the count is less than, say, 100.

2) One other thing you might want to do is to throw away, say, 90% of the 
records on the way in with INCLUDE/OMIT and then divide up the surviving 
records on the way out, using OUTFIL INCLUDE=/OMIT= and SAVE.

Just some thoughts from someone who's loved playing with what DFSORT can 
do but has never actually been a DFSORT developer.

* Augustus De Morgan founded the Maths Department at UCL, where I learnt a 
trick or two. :-)

Cheers, Martin

Martin Packer

Systems Investigator & Performance Troubleshooter, IBM

+44-7802-245-584

email: martin_pac...@uk.ibm.com

Twitter / Facebook IDs: MartinPacker

Blog: https://mainframeperformancetopics.com

Mainframe, Performance, Topics Podcast Series (With Marna Walle): 
https://anchor.fm/marna-walle

Youtube channel: https://www.youtube.com/channel/UCu_65HaYgksbF6Q8SQ4oOvA



From:   Sri h Kolusu <skol...@us.ibm.com>
To:     IBM-MAIN@LISTSERV.UA.EDU
Date:   22/09/2020 19:24
Subject:        [EXTERNAL] Re: SORT question: How to both remove records 
from a file AND write removed records to a 2nd output?
Sent by:        IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU>



> In one pass of an input file is there a way to use SORT to both
> remove identified records from an input file AND write those removed
> records to a second output file?


Peter,

You don't need 2 passes of data, you can tag the records that match your
identification and then use that tag to filter the records on OUTFIL. Some
thing like this

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC  - DROP THIS RECORD
DEF  - PICK THIS RECORD
EFG  - PICK THIS RECORD
XYZ  - DROP THIS RECORD
ZZZ  - DROP THIS RECORD
//PICKREC  DD SYSOUT=*
//DROPREC  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,3,SS,EQ,C'DEF,EFG'),
       OVERLAY=(81:C'A'))

  OUTFIL FNAMES=PICKREC,
  INCLUDE=(81,1,CH,EQ,C'A'),
  BUILD=(1,80)

  OUTFIL FNAMES=DROPREC,SAVE,
  BUILD=(1,80)
/*


The PICKREC file will have the following records

DEF  - PICK THIS RECORD
EFG  - PICK THIS RECORD

The DROPREC file will have the following records

ABC  - DROP THIS RECORD
XYZ  - DROP THIS RECORD
ZZZ  - DROP THIS RECORD


For VB files, make sure that you have the Indicator right after the RDW so
that you retain the variable length records as is

Something like this

//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
         BUILD=(1,4,            $ RDW
                X,              $ ID TAG
                5)),            $ DATA AS-IS

        IFTHEN=(WHEN=(6,3,SS,EQ,C'DEF,EFG'),
       OVERLAY=(05:C'A'))

  OUTFIL FNAMES=PICKREC,
  INCLUDE=(05,1,CH,EQ,C'A'),
    BUILD=(1,04,                $ RDW
           6)                   $ DATA AS-IS

  OUTFIL FNAMES=DROPREC,SAVE,
    BUILD=(1,04,                $ RDW
           6)                   $ DATA AS-IS
/*


Fruther if you have any questions please let me know

Thanks,
 Kolusu
DFSORT Development
IBM Corporation

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN




Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to