MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
chandra Beginner Joined: 26 Sep 2003 Posts: 130 Topics: 36
Posted: Wed Sep 14, 2005 9:44 am Post subject: Sort multiple records using Syncsort
Hi,
I have a input file with LRECL=2652 and RECFM=FB. I want to sort my file depending on field postion in 52 and length 3 (it will be present in only B01 records [postion 14 to 19]) the output should be grouped depending on the field postion 5 length 10.The input records should be as fallows
Code:
----+----1----+----2----+----3----+----4----+----5----+-
101 A0034805 B0220050120001PYMT
101 A0034805 B0320041001 4.05..........
101 A0034805 B01200410012005100120050913DAKOTA 201
101 A0037955 B0220041013001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041113001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041213001PYMT
101 A0037955 B0120041001 4.05.......... 401
101 A0039662 B0220050901001PYMT
101 A0039662 B0320050701 4.05........
101 A0039662 B01200410012005100120050913DONALD 101
101 A0039669 B0220050701001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050801001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050901001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B01200410012005100120050913ELIZABETH 301
I need output like this
Code:
101 A0039662 B0220050901001PYMT
101 A0039662 B0320050701 4.05........
101 A0039662 B01200410012005100120050913DONALD 101
101 A0034805 B0220050120001PYMT
101 A0034805 B0320041001 4.05..........
101 A0034805 B01200410012005100120050913DAKOTA 201
101 A0039669 B0220050701001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050801001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050901001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B01200410012005100120050913ELIZABETH 301
101 A0037955 B0220041013001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041113001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041213001PYMT
101 A0037955 B0120041001 4.05.......... 401
_________________ Regards,
Chandra
Back to top
bprasanna Beginner Joined: 05 Sep 2003 Posts: 119 Topics: 33 Location: Hyderabad
Posted: Wed Sep 14, 2005 12:50 pm Post subject:
Chandra,
Please try with the the below logic.I think it shold work.
1)create a character '1' at the end of the file in a fixed postion for all non blank records at positoon 52 of length 3 and create a charecter '0' for blank records .(say this position is at the end of the record)
2)then sort the creted files with key as the position 5 of length 3 in ascending then 52 position of length 3 in ascending and then the newly created character in DECENDING order(end of the record).
I am not able to conneact to mainfreams and test this logic now,So I am just posting my though.
Thanks
Bprasanna
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Sep 14, 2005 1:16 pm Post subject:
Quote:
1)create a character '1' at the end of the file in a fixed postion for all non blank records at positoon 52 of length 3 and create a charecter '0' for blank records .(say this position is at the end of the record)
2)then sort the creted files with key as the position 5 of length 3 in ascending then 52 position of length 3 in ascending and then the newly created character in DECENDING order(end of the record).
bprasanna ,
Nope will not work. Look at chandra's output. Once you sort with the field at pos 5 then A0034805 will be at the top.
You will need splice or Join to reformat the file and get the desired output.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Sep 14, 2005 1:19 pm Post subject:
Chandra,
The following JCl will give you desired results. You will need syncsort z/0S 1.2 version for this to work.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR.TEST.INPUT,
// DISP=SHR
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=T1
OUTFIL FNAMES=T2,INCLUDE=(52,3,CH,NE,C' '),
OUTREC=(5,10,52,3)
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=&T1,DISP=OLD
//SORTJNF2 DD DSN=&T2,DISP=OLD
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(5,10,A)
JOINKEYS FILES=F2,FIELDS=(1,10,A)
REFORMAT FIELDS=(F1:01,2652,
F2:11,03)
SORT FIELDS=(2653,3,CH,A,5,10,CH,A)
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
lal Beginner Joined: 21 Oct 2003 Posts: 70 Topics: 25
Posted: Wed Sep 14, 2005 5:51 pm Post subject:
Hi Kolusu,
I tried to solve the Chandra's problem with the splice operator. I assumed the lrecl to be 80.
Code:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
101 A0034805 B0220050120001PYMT
101 A0034805 B0320041001 4.05..........
101 A0034805 B01200410012005100120050913DAKOTA 201
101 A0037955 B0220041013001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041113001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041213001PYMT
101 A0037955 B0120041001 4.05.......... 401
101 A0039662 B0220050901001PYMT
101 A0039662 B0320050701 4.05........
101 A0039662 B01200410012005100120050913DONALD 101
101 A0039669 B0220050701001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050801001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050901001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B01200410012005100120050913ELIZABETH 301
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON DD DSN=&T2,DISP=OLD,VOL=REF=*.T2
// DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//T3 DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON1 DD DSN=&T3,DISP=OLD,VOL=REF=*.T3
//COMBINE DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(5,9,ZD) WITH(1,4) WITH(14,66) WITHALL
COPY FROM(CON1) USING(CTL2)
//CTL1CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=T1,OUTREC(1,80,83:X)
OUTFIL FNAMES=T2,INCLUDE=(52,3,CH,NE,C' '),
OUTREC=(5:5,9,81:52,3)
//CTL2CNTL DD *
SORT FIELDS=(81,3,CH,A,5,9,CH,A)
OUTFIL FNAMES=COMBINE,OUTREC=(1,80)
/*
But I get the ouput which is same as input without any changes. Untill the creation of T3 it seems to be working fine, but second copy statement doesn't seems to be working. I am not able to figure it. Could you please help.
Regards,
Lal
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Sep 14, 2005 7:54 pm Post subject:
lal,
The reason your job is failing is due to a couple of errors.
1.on the last copy operator you are assiging T3 output to Con1 once again. You don't have to do that.
2. You actually need a SORT operator instead of COPY operator on the last pass. If the Toolin statement has a COPY operator , You ONLY can COPY the data , you cannot Sort the data even though your specified sort fields=(...) in the Ctl2. Toolin overrides the CTl2 control cards.
You also don't need SORT FIELDS=COPY when you are using COPY operator in the toolin. i.e the first pass.
Here is the Working JCl for your data.
Code:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
101 A0034805 B0220050120001PYMT
101 A0034805 B0320041001 4.05..........
101 A0034805 B01200410012005100120050913DAKOTA 201
101 A0037955 B0220041013001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041113001PYMT
101 A0037955 B0320041001 4.05..........
101 A0037955 B0220041213001PYMT
101 A0037955 B0120041001 4.05.......... 401
101 A0039662 B0220050901001PYMT
101 A0039662 B0320050701 4.05........
101 A0039662 B01200410012005100120050913DONALD 101
101 A0039669 B0220050701001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050801001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B0220050901001PYMT
101 A0039669 B0320050701 3.05.............
101 A0039669 B01200410012005100120050913ELIZABETH 301
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON DD DSN=&T2,DISP=OLD,VOL=REF=*.T2
// DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//T3 DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(5,9,ZD) WITH(1,4) WITH(14,66) WITHALL
SORT FROM(T3) USING(CTL2)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OUTREC(1,80,83:X)
OUTFIL FNAMES=T2,INCLUDE=(52,3,CH,NE,C' '),
OUTREC=(5:5,9,81:52,3)
//CTL2CNTL DD *
SORT FIELDS=(81,3,CH,A,5,9,CH,A)
OUTFIL FNAMES=OUT,OUTREC=(1,80)
/*
Hope this helps....
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Sep 14, 2005 7:59 pm Post subject:
Chandra,
Here is a JCL which is coded for your Input file attributes.
Code:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=YOUR INPUT DATASET,
// DISP=SHR
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON DD DSN=&T2,DISP=OLD,VOL=REF=*.T2
// DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//T3 DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT DD DSN=YOUR OUTPUT DATASET,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(5,9,ZD) WITH(1,4) WITH(14,2639) WITHALL
SORT FROM(T3) USING(CTL2)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OUTREC(1,2652,3X)
OUTFIL FNAMES=T2,INCLUDE=(52,3,CH,NE,C' '),
OUTREC=(5:5,9,2653:52,3)
//CTL2CNTL DD *
SORT FIELDS=(2653,3,CH,A,5,9,CH,A)
OUTFIL FNAMES=OUT,OUTREC=(1,2652)
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
chandra Beginner Joined: 26 Sep 2003 Posts: 130 Topics: 36
Posted: Thu Sep 15, 2005 4:27 am Post subject:
Hi Kolusu,
Thanks for you reply.
I think we don't have Syncsort Z/OS 1.2 version we have RELEASE 1.1D BATCH 0420 TPF LEVEL 3
I have used your last JCL but I got the output as it is in input. _________________ Regards,
Chandra
Back to top
Phantom Data Mgmt Moderator Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 15, 2005 4:45 am Post subject:
Chandra,
Show us your JCL and Sysout messages so that we can see what has gone wrong.
Thanks,
Phantom
Back to top
chandra Beginner Joined: 26 Sep 2003 Posts: 130 Topics: 36
Posted: Thu Sep 15, 2005 5:47 am Post subject:
Phantom,
In my first post I have mentioned the sorting field in position 52 to show input but actualy it will be in postion 547. LRECl=2731,RECFB=FB.
Quote:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=TS09347.ANNUAL.STATE.FIXED,
// DISP=SHR
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(10,10),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(10,10),RLSE)
//CON DD DSN=&T2,DISP=OLD,VOL=REF=*.T2
// DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//T3 DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(10,10),RLSE)
//OUT DD DSN=TS09347.ANNUAL.STATE.FIXED.SORTED,DISP=OLD
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(4,10,ZD) WITH(1,3) WITH(14,2718) WITHALL
SORT FROM(T3) USING(CTL2)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OUTREC(1,2731,3X)
OUTFIL FNAMES=T2,INCLUDE=(547,3,CH,NE,X'00'),
OUTREC=(4:4,10,2732:547,3)
//CTL2CNTL DD *
SORT FIELDS=(2653,3,CH,A,4,10,CH,A)
OUTFIL FNAMES=OUT,OUTREC=(1,2731)
/*
TOOLIN messages
Quote:
SYT000I SYNCTOOL RELEASE 1.4D - COPYRIGHT 2003 SYNCSORT INC.
SYT001I INITIAL PROCESSING MODE IS "STOP"
SYT002I "TOOLIN" INTERFACE BEING USED
COPY FROM(IN) USING(CTL1)
SYT020I SYNCSORT CALLED WITH IDENTIFIER "0001"
SYT030I OPERATION COMPLETED WITH RETURN CODE 0
SPLICE FROM(CON) TO(T3) ON(4,10,ZD) WITH(1,3) WITH(14,2718) WITHALL
SYT020I SYNCSORT CALLED WITH IDENTIFIER "0002"
SYT031I NUMBER OF RECORDS PROCESSED: 000000000000753
SYT026I NUMBER OF SELECTED RECORDS: 000000000000728
SYT030I OPERATION COMPLETED WITH RETURN CODE 0
SORT FROM(T3) USING(CTL2)
SYT020I SYNCSORT CALLED WITH IDENTIFIER "0003"
SYT030I OPERATION COMPLETED WITH RETURN CODE 0
SYT004I SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 0
_________________ Regards,
Chandra
Back to top
Phantom Data Mgmt Moderator Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 15, 2005 6:28 am Post subject:
Chandra,
In you earlier post, you said
Quote:
I have used your last JCL but I got the output as it is in input.
But your sysout clearly says that number of records processed < no. of records in input.
Code:
SYT031I NUMBER OF RECORDS PROCESSED: 000000000000753
SYT026I NUMBER OF SELECTED RECORDS: 000000000000728
I am not quite clear on what problem you are facing.
Thanks,
Phantom
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Sep 15, 2005 7:34 am Post subject:
Quote:
In my first post I have mentioned the sorting field in position 52 to show input but actualy it will be in postion 547. LRECl=2731,RECFB=FB.
Chandra,
You are just wasting time. You need to be clear with your requirements. I wrote 3 different versions for the same job based on the requirements. And you simply came back with "The JCL does not work for me". You don't even post the error/sysout messages to back up what exactly does not work for you.
Now you are telling me that the File attributes are different and even positions of the data is different.
I am not going to spend any of my time on this as I already have. Good luck.
Thanks
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
lal Beginner Joined: 21 Oct 2003 Posts: 70 Topics: 25
Posted: Thu Sep 15, 2005 9:03 am Post subject:
Hi Kolusu,
Thanx for your reply for my problem.
Thanx,
Lal
Back to top
chandra Beginner Joined: 26 Sep 2003 Posts: 130 Topics: 36
Posted: Sat Sep 17, 2005 5:45 am Post subject:
Hi All,
My JCL is here
Quote:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=* LIB
//DFSMSG DD SYSOUT=*
//IN1 DD *
101 A0039667 B01200410012005100120050917JOHN 201
101 A0039668 B0220041028001PAYMENT
101 A0039668 B0320041001 3.05
101 A0039668 B0220041128001PAYMENT
101 A0039668 B0320041001 3.05
101 A0039668 B0220041228001PAYMENT
101 A0039668 B0320041001 3.05
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON DD DSN=&T2,DISP=OLD,VOL=REF=*.T2
// DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//T3 DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(5,9,ZD) WITH(1,4) WITH(14,66) WITHALL
SORT FROM(T3) USING(CTL2)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OUTREC(1,80,83:X)
OUTFIL FNAMES=T2,INCLUDE=(52,3,CH,NE,C' '),
OUTREC=(5:5,9,81:52,3)
//CTL2CNTL DD *
SORT FIELDS=(81,3,CH,A,5,9,CH,A)
OUTFIL FNAMES=OUT,OUTREC=(1,80)
/*
Output
Quote: 101 A0039668 B0320041001 3.05
101 A0039668 B0220041128001PAYMENT
101 A0039668 B0320041001 3.05
101 A0039668 B0220041228001PAYMENT
101 A0039668 B0320041001 3.05
101 A0039667 B01200410012005100120050917JOHN 201
DFS messages is
Quote:
CTL1CNTL :
OUTFIL FNAMES=T1,OUTREC(1,80,83:X)
OUTFIL FNAMES=T2,INCLUDE=(52,3,CH,NE,C' '),
OUTREC=(5:5,9,81:52,3)
PARMLIST :
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=IN1,SORTDD=CTL1,COPY
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER108I IN1 : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I T1 : RECFM=FB ; LRECL= 83; BLKSIZE= 27971
WER110I T2 : RECFM=FB ; LRECL= 83; BLKSIZE= 27971
WER405I T1 : DATA RECORDS OUT 7; TOTAL RECORDS OUT
WER405I T2 : DATA RECORDS OUT 1; TOTAL RECORDS OUT
WER054I RCD IN 7, OUT 7
WER169I RELEASE 1.1D BATCH 0420 TPF LEVEL 3
PARMLIST :
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=CON,SORTOUT=T3,DYNALLOC,CMP=CLC,
OVLSHRT,EQUALS
SORT FIELDS=(00005,0009,ZD,A)
MODS E35=(SYNCT#35,4096,,N)
WER428I CALLER-PROVIDED IDENTIFIER IS "0002"
WER108I CON : RECFM=FB ; LRECL= 83; BLKSIZE= 27971
WER110I T3 : RECFM=FB ; LRECL= 83; BLKSIZE= 27971
WER045C END SORT PHASE
WER055I INSERT 6, DELETE 8
WER418I DATASPACE(S) AND/OR HIPERSPACE(S) USED
WER246I FILESIZE 664 BYTES
WER054I RCD IN 8, OUT 6
WER169I RELEASE 1.1D BATCH 0420 TPF LEVEL 3
CTL2CNTL :
SORT FIELDS=(81,3,CH,A,5,9,CH,A)
OUTFIL FNAMES=OUT,OUTREC=(1,80)
PARMLIST :
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=T3,SORTDD=CTL2,DYNALLOC
WER428I CALLER-PROVIDED IDENTIFIER IS "0003"
WER108I T3 : RECFM=FB ; LRECL= 83; BLKSIZE= 27971
WER110I OUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER045C END SORT PHASE
WER418I DATASPACE(S) AND/OR HIPERSPACE(S) USED
WER405I OUT : DATA RECORDS OUT 6; TOTAL RECORDS OUT 6
WER246I FILESIZE 498 BYTES
WER054I RCD IN 6, OUT 6
WER169I RELEASE 1.1D BATCH 0420 TPF LEVEL 3
WER052I END SYNCSORT - TS09347Z,STEP0100,,DIAG=8B00,C84D,A2B2,A06E,C24E,6CC3,2
I am getting one contract less in my output. Please let me know where I am doing wrong. _________________ Regards,
Chandra
Back to top
lal Beginner Joined: 21 Oct 2003 Posts: 70 Topics: 25
Posted: Tue Sep 27, 2005 3:22 pm Post subject:
Hi Chandra,
In order to get complete set of records in the order you wish, you should have 'B01' record for the A0039668.
Thanx,
Lal
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum