Discussion:
Should be easy with SORT :) I thought (:
(too old to reply)
Gibney, Dave
2018-05-15 21:50:34 UTC
Permalink
I have a file with say 4 records:
FDRABR.VZ21RS2.C1000n00 D05809
FDRABR.VZ21RSC.C1000n00 D05547
FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VFNTCAT.C1000n00 D06244

I want a file that is
Record1||Record3
Record2||Record4
That is:
FDRABR.VZ21RS2.C1000n00 D05809 FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VZ21RSC.C1000n00 D05547 FDRABR.VFNTCAT.C1000n00 D06244

I can't seem to come up with a working SORT incantation to accomplish this, I'd also be happy with using another always available IEBxxx, etc. utility. I'd rather not Rexx or any other actual programming language.

Syncsort (MFX) FWIW, but DFSORT control should work also.

Dave Gibney
Information Technology Services
Washington State University


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Gibney, Dave
2018-05-15 22:45:52 UTC
Permalink
And of course, the standard make a fool of myself in public and immediately find a solution involving adding a sequence number field is working for me.
-----Original Message-----
On Behalf Of Gibney, Dave
Sent: Tuesday, May 15, 2018 2:52 PM
FDRABR.VZ21RS2.C1000n00 D05809
FDRABR.VZ21RSC.C1000n00 D05547
FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VFNTCAT.C1000n00 D06244
I want a file that is
Record1||Record3
Record2||Record4
FDRABR.VZ21RS2.C1000n00 D05809 FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VZ21RSC.C1000n00 D05547 FDRABR.VFNTCAT.C1000n00 D06244
I can't seem to come up with a working SORT incantation to accomplish this,
I'd also be happy with using another always available IEBxxx, etc. utility. I'd
rather not Rexx or any other actual programming language.
Syncsort (MFX) FWIW, but DFSORT control should work also.
Dave Gibney
Information Technology Services
Washington State University
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Sri h Kolusu
2018-05-15 23:35:18 UTC
Permalink
Dave,

Not sure what solution you came up, but here is a job that will manage any
number of records and put the odd numbered records as a pair and even
numbered records as a pair

We use joinkeys trick of matching the file to itself. we treat a group of 4
records as one group and then merge them as single record.

//****************************************************************
//* CREATE AN INPUT FILE WITH 100 RECORDS WITH A RECORD NUMBER **
//****************************************************************
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD DSN=&&IN,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION COPY
OUTFIL REPEAT=100,
BUILD=(SEQNUM,8,ZD,80:X)
/*
//****************************************************************
//* MERGE THE ODD NUMBERED RECORDS AS A SINGLE RECORD AND EVEN **
//* NUMBERED RECORDS AS A SINGLE RECORD. EX: 1-3,2-4,5-7,6-8... **
//****************************************************************
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=&&IN,DISP=(OLD,PASS),VOL=REF=*.STEP0100.SORTOUT
//INB DD DSN=&&IN,DISP=(OLD,PASS),VOL=REF=*.STEP0100.SORTOUT
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,9,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,9,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,80,F2:1,80)
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(81:ID=8,SEQ=1))
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(81:ID=8,SEQ=1)),
IFTHEN=(WHEN=(89,1,ZD,LE,2),
OVERLAY=(89:C'0')),
IFTHEN=(WHEN=(89,1,ZD,GT,2),
OVERLAY=(89:89,1,ZD,SUB,+2,EDIT=(T)))
/*


The output from this job is

00000001
00000003
00000002
00000004
00000005
00000007
00000006
00000008
00000009
00000011
00000010
00000012
00000013
00000015


Further if you have any questions please let me know

Thanks,
Kolusu
DFSORT Development
IBM Corporation
Date: 05/15/2018 03:48 PM
And of course, the standard make a fool of myself in public and
immediately find a solution involving adding a sequence number field
is working for me.
-----Original Message-----
On Behalf Of Gibney, Dave
Sent: Tuesday, May 15, 2018 2:52 PM
FDRABR.VZ21RS2.C1000n00 D05809
FDRABR.VZ21RSC.C1000n00 D05547
FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VFNTCAT.C1000n00 D06244
I want a file that is
Record1||Record3
Record2||Record4
FDRABR.VZ21RS2.C1000n00 D05809 FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VZ21RSC.C1000n00 D05547 FDRABR.VFNTCAT.C1000n00 D06244
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Gibney, Dave
2018-05-15 23:44:07 UTC
Permalink
I am sure there's room to improve, and several assumptions on my part, but I did:

//SORTS EXEC PGM=SORT,REGION=0M,TIME=NOLIMIT,PARM='VLTESTI=1'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&FDRTSEL,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SORTOF01 DD DISP=(NEW,PASS),DSN=&&SOF01A
//SORTOF02 DD DISP=(NEW,PASS),DSN=&&SOF02A
//SORTOF03 DD DISP=(NEW,PASS),DSN=&&SOF03A
//SORTOF04 DD DISP=(NEW,PASS),DSN=&&SOF04A
//SYSIN DD *
INCLUDE COND=(2,7,CH,EQ,C'FDR692')
INREC FIELDS=(40,24,82,6)
SORT FIELDS=COPY
OUTFIL FILES=(01,02,03,04),SPLIT
OUTREC FIELDS=(SEQNUM,1,ZD,RESTART=(9,1),C' ',1,30)
//SORTJ EXEC PGM=SORT,REGION=0M,TIME=NOLIMIT,PARM='VLTESTI=1'
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTJNF1 DD DISP=(OLD,PASS),DSN=&&SOF01A
// DD DISP=(OLD,PASS),DSN=&&SOF02A
//SORTJNF2 DD DISP=(OLD,PASS),DSN=&&SOF03A
// DD DISP=(OLD,PASS),DSN=&&SOF04A
//SORTOF2 DD SYSOUT=*
//SORTOF3 DD SYSOUT=*
//SYSIN DD *
JOIN UNPAIRED
JOINKEYS FILE=F1,FIELDS=(1,1,CH,A)
JOINKEYS FILE=F2,FIELDS=(1,1,CH,A)
REFORMAT FIELDS=(F1:3,30,26,1,F2:3,30)
SORT FIELDS=COPY
-----Original Message-----
On Behalf Of Sri h Kolusu
Sent: Tuesday, May 15, 2018 4:37 PM
Dave,
Not sure what solution you came up, but here is a job that will manage any
number of records and put the odd numbered records as a pair and even
numbered records as a pair
We use joinkeys trick of matching the file to itself. we treat a group of 4
records as one group and then merge them as single record.
//**********************************************************
******
//* CREATE AN INPUT FILE WITH 100 RECORDS WITH A RECORD NUMBER **
//**********************************************************
******
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD DSN=&&IN,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION COPY
OUTFIL REPEAT=100,
BUILD=(SEQNUM,8,ZD,80:X)
/*
//**********************************************************
******
//* MERGE THE ODD NUMBERED RECORDS AS A SINGLE RECORD AND EVEN
**
//* NUMBERED RECORDS AS A SINGLE RECORD. EX: 1-3,2-4,5-7,6-8... **
//**********************************************************
******
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=&&IN,DISP=(OLD,PASS),VOL=REF=*.STEP0100.SORTOUT
//INB DD DSN=&&IN,DISP=(OLD,PASS),VOL=REF=*.STEP0100.SORTOUT
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,9,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,9,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,80,F2:1,80)
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(81:ID=8,SEQ=1))
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(81:ID=8,SEQ=1)),
IFTHEN=(WHEN=(89,1,ZD,LE,2),
OVERLAY=(89:C'0')),
IFTHEN=(WHEN=(89,1,ZD,GT,2),
OVERLAY=(89:89,1,ZD,SUB,+2,EDIT=(T)))
/*
The output from this job is
00000001
00000003
00000002
00000004
00000005
00000007
00000006
00000008
00000009
00000011
00000010
00000012
00000013
00000015
Further if you have any questions please let me know
Thanks,
Kolusu
DFSORT Development
IBM Corporation
Date: 05/15/2018 03:48 PM
And of course, the standard make a fool of myself in public and
immediately find a solution involving adding a sequence number field
is working for me.
-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-
On Behalf Of Gibney, Dave
Sent: Tuesday, May 15, 2018 2:52 PM
FDRABR.VZ21RS2.C1000n00 D05809
FDRABR.VZ21RSC.C1000n00 D05547
FDRABR.VFNTCA2.C1000n00 D06255
FDRABR.VFNTCAT.C1000n00 D06244
I want a file that is
Record1||Record3
Record2||Record4
FDRABR.VZ21RS2.C1000n00 D05809 FDRABR.VFNTCA2.C1000n00
D06255
FDRABR.VZ21RSC.C1000n00 D05547 FDRABR.VFNTCAT.C1000n00
D06244
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Sri h Kolusu
2018-05-16 00:39:24 UTC
Permalink
Dave,

You can replace your 2 step solution with this single step which will give
you the desired results. You don't need a COPY and SORT step, you can
simply get it done using a COPY operation.

//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=&&FDRTSEL,DISP=(OLD,PASS),VOL=REF=*.FDRTSTEP.ddname
//INB DD DSN=&&FDRTSEL,DISP=(OLD,PASS),VOL=REF=*.FDRTSTEP.ddname
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(31,9,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(31,9,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,30,F2:1,30)
INREC BUILD=(1,30,C'|',31,30)
/*
//JNF1CNTL DD *
INCLUDE COND=(2,7,CH,EQ,C'FDR692')
INREC IFTHEN=(WHEN=INIT,BUILD=(40,24,82,6)),
IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(31:ID=8,SEQ=1))
/*
//JNF2CNTL DD *
INCLUDE COND=(2,7,CH,EQ,C'FDR692')
INREC IFTHEN=(WHEN=INIT,BUILD=(40,24,82,6)),
IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(31:ID=8,SEQ=1)),
IFTHEN=(WHEN=(39,1,ZD,LE,2),
OVERLAY=(39:C'0')),
IFTHEN=(WHEN=(39,1,ZD,GT,2),
OVERLAY=(39:39,1,ZD,SUB,+2,EDIT=(T)))
/*

Further if you have any questions please let me know

Thanks,
Kolusu
DFSORT Development
IBM Corporation
Date: 05/15/2018 04:46 PM
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Sri h Kolusu
2018-05-16 15:39:43 UTC
Permalink
Dave,

If your input record count is NOT a multiple of 4, then you may want to see
the unpaired records too. My earlier job will only consider the paired
records. So in order to account for the unpaired records , change the main
task SYSIN to the following

//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(31,9,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(31,9,A),SORTED,NOSEQCK
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,39,F2:1,39,?)
INCLUDE COND=(79,1,CH,EQ,C'B',OR,
(79,1,CH,EQ,C'1',AND,39,1,ZD,LE,2))

INREC BUILD=(1,30,C'|',40,30)
/*

Thanks,
Kolusu
DFSORT Development
IBM Corporation

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