Thomas, As others have explained it is quite simple to get the desired results. I am showing examples for both FB and VB files using symbols. With symbols you have the flexibility of changing it and then not worry about changing the control cards.
A brief explanation of the job. 1. The first IFTHEN with WHEN=INIT, we will number all records in the file with a 8 byte sequence number. 2. The next 2 IFTHEN statements will validate that sequence number and build the record. If you have more ranges then you can add IFTHEN statements before the last IFTHEN with WHEN=NONE statement //STEP0100 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYMNOUT DD SYSOUT=* //SYMNAMES DD * FILE-REC-LENGTH,1,80,CH RECORD-SEQ-NUMBER,*,8,ZD REQD-DATA1,1,3,CH REQD-DATA2,31,10,CH REQD-DATA3,71,10,CH RECD-SELECT-NUM1,5 RECD-SELECT-NUM2,7 RECD-SELECT-NUM3,9 //SORTIN DD DISP=SHR,DSN=Your Input FB file //SORTOUT DD SYSOUT=* //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=INIT,OVERLAY=(RECORD-SEQ-NUMBER:SEQNUM,8,ZD)), IFTHEN=(WHEN=(RECORD-SEQ-NUMBER,GT,RECD-SELECT-NUM1,AND, RECORD-SEQ-NUMBER,LE,RECD-SELECT-NUM2), BUILD=(REQD-DATA1,REQD-DATA2)), IFTHEN=(WHEN=(RECORD-SEQ-NUMBER,GT,RECD-SELECT-NUM2,AND, RECORD-SEQ-NUMBER,LE,RECD-SELECT-NUM3), BUILD=(REQD-DATA1,REQD-DATA2,REQD-DATA3)), IFTHEN=(WHEN=NONE,BUILD=(REQD-DATA2)) //* The above control cards will be translated as the following //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)), IFTHEN=(WHEN=(81,8,ZD,GT,5,AND,81,8,ZD,LE,7), BUILD=(1,3,31,10)), IFTHEN=(WHEN=(81,8,ZD,GT,7,AND,81,8,ZD,LE,9), BUILD=(1,3,31,10,71,10)), IFTHEN=(WHEN=NONE,BUILD=(31,10)) //* If you have VB input files then you need to use sequencing of the records right after the RDW. //STEP0200 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYMNOUT DD SYSOUT=* //SYMNAMES DD * FILE-RDW,1,4,BI RECORD-SEQ-NUMBER,*,8,ZD VBDATA-SPOS,= REQD-DATA1,*,3,CH SKIP,27 REQD-DATA2,*,10,CH SKIP,30 REQD-DATA3,*,10,CH RECD-SELECT-NUM1,5 RECD-SELECT-NUM2,7 RECD-SELECT-NUM3,9 //SORTIN DD DISP=SHR,DSN=Your Input VB File //SORTOUT DD SYSOUT=* //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=INIT, BUILD=(FILE-RDW,RECORD-SEQ-NUMBER:SEQNUM,8,ZD,VBDATA-SPOS)), IFTHEN=(WHEN=(RECORD-SEQ-NUMBER,GT,RECD-SELECT-NUM1,AND, RECORD-SEQ-NUMBER,LE,RECD-SELECT-NUM2), BUILD=(FILE-RDW,REQD-DATA1,REQD-DATA2)), IFTHEN=(WHEN=(RECORD-SEQ-NUMBER,GT,RECD-SELECT-NUM2,AND, RECORD-SEQ-NUMBER,LE,RECD-SELECT-NUM3), BUILD=(FILE-RDW,REQD-DATA1,REQD-DATA2,REQD-DATA3)), IFTHEN=(WHEN=NONE,BUILD=(FILE-RDW,REQD-DATA2)) //* Further if you have any questions, please let me know Thanks, Kolusu DFSORT Development IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> wrote on 10/23/2014 06:43:44 AM: > From: Thomas Berg <thomas.b...@swedbank.se> > To: IBM-MAIN@LISTSERV.UA.EDU > Date: 10/23/2014 06:44 AM > Subject: Re: DFSORT/ICETOOL pondering > Sent by: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> > > > -----Original Message----- > > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] > > On Behalf Of Elardus Engelbrecht > > Sent: Wednesday, October 22, 2014 3:52 PM > > To: IBM-MAIN@LISTSERV.UA.EDU > > Subject: Re: DFSORT/ICETOOL pondering > > > > Thomas Berg wrote: > > > > >Sometimes I have a need to do a selective copy of a dataset where the > > selection is both record sequence and record position/part dependent. > > >And by that I mean the record part/position is varying depending on which > > record it's about. > > >An example (yes, it looks silly): > > > > Who ever gave you homework is silly... ;-D > > ...it's me... :) > > > >I want to copy position 31 to 40 of all records but from record > 8 and 9 I want > > to copy also (concatenate) position 71 to 80 and from record 6 to 8 I also > > (concatenate in "front") want to copy position 1 to 3. > > > > Hmmm. Hard requirement if you want all of this in ONE pass. Could > you be kind > > to post an example of your input and output? > > An hypotethical example (monospace font recommended): > > Input: > ----+----1----+----2----+----3----+----4----+----5----+----6---- > +----7----+----8 > 001aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb01ccccccccccccccccccccccccccccccdddddddd01 > 002aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb02ccccccccccccccccccccccccccccccdddddddd02 > 003aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb03ccccccccccccccccccccccccccccccdddddddd03 > 004aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb04ccccccccccccccccccccccccccccccdddddddd04 > 005aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb05ccccccccccccccccccccccccccccccdddddddd05 > 006aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb06ccccccccccccccccccccccccccccccdddddddd06 > 007aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb07ccccccccccccccccccccccccccccccdddddddd07 > 008aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb08ccccccccccccccccccccccccccccccdddddddd08 > 009aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb09ccccccccccccccccccccccccccccccdddddddd09 > 010aaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb10ccccccccccccccccccccccccccccccdddddddd10 > > > Output: > ----+----1----+----2----+----3 > bbbbbbbb01 > bbbbbbbb02 > bbbbbbbb03 > bbbbbbbb04 > bbbbbbbb05 > 006bbbbbbbb06 > 007bbbbbbbb07 > 008bbbbbbbb08dddddddd08 > bbbbbbbb09dddddddd09 > bbbbbbbb10 > > > > What about the rest of input? Should they stay the same during > copy or left out > > of the output? > > The rest is discarded. > > > >I can see the use of the SUBSET (ICETOOL) for record selection > but how do you > > user DFSORT/ICETOOL to solve the combining record and varying position needs > > ? > > > > What about SPLICE and JOIN? > > I haven't looked more closely at these. Thought they required a > matching file etc. > > > >I now use a homegrown program for this but it's lacking > efficiency to say the > > least and I'm looking at DFSORTs efficiency and speed. > > > > How so? Could you post that program or some snippets? I believe I > could do that > > with REXX. > > That program IS coded in REXX. It works but it's a problem with > (very) large files. > (This program is sort of a Swiss Army Knife with lot of other > functions, this copy problem is a minor subfunction in it. > I use it e g as a line command at ISPF 3.4 etc.) > > > > Best Regards, > Thomas Berg > ___________________________________________________________________ > Thomas Berg Specialist zOS/RQM/IT Delivery Swedbank AB (Publ) > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN