View previous topic :: View next topic
Author
Message
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
i have a input file(physical sequential) with records as mentioned below:
DR-APS
DOCTOR-XYZ
DOC-ABC
DOCT-BAC
I want to sort the above input file on the basis of a field mentioned after '-'
Please provide me the solution for this.
Back to top
Garry Carroll Senior Member Joined: 08 May 2006Posts: 1205 Location: Dublin, Ireland
You can run 2 steps, the first to use the PARSE function to prepend the records with the data following the '-'
OPTION COPY
INREC PARSE=(%01=(ABSPOS=1,ENDBEFR=C'-',FIXLEN=80),
%02=(ENDBEFR=C' ',FIXLEN=3)),
BUILD=(%02,1,80)
In this, an 80byte record is increased to 83 bytes, the first 3 bytes are then use in SORT.
run the SORT
SORT FIELDS=(1,3,CH,A)
OUTREC BUILD=(4,80)
This sorts on the 3 prepended bytes and drops them from the output records.
I've assumed 80 byte FB records with 3 bytes following the '-', delimited by a blank. The controls can be adjusted for VB or for longer sort fields.
Garry.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Abhay,
Here's a DFSORT job that will do what you asked for in one pass. I assumed your input file has RECFM=FB and LRECL=80 and your key is 3 bytes, but the job can be changed appropriately for other attributes and key lengths.
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB.80)
//SYSIN DD *
INREC PARSE=(%01=(STARTAFT=C'-',FIXLEN=3)),
OVERLAY=(81:%01)
SORT FIELDS=(81,3,CH,A)
OUTREC BUILD=(1,80)
/*
For your input example, SORTOUT will have:
Code:
DOC-ABC
DR-APS
DOCT-BAC
DOCTOR-XYZ
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Hi Frank,
I tried the code mentioned by you but it is giving abend U0016.
Below is the code i have used:
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=TCS.Y00057.TESTFIL,DISP=SHR
//SORTOUT DD DSN=TCS.Y00057.SORT101,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,10))
//SYSIN DD *
INREC PARSE=(%01=(STARTAFT=C'-',FIXLEN=3)),
OVERLAY=(81:%01)
SORT FIELDS=(81,3,CH,A)
OUTREC BUILD=(1,80)
/*
//SYSOUT DD SYSOUT=*
The message i am getting in spool in sysout is:
PRODUCT LICENSED FOR CPU SERIAL NUMBER 7C6FE, MODEL 2096 O02
SYSIN :
INREC PARSE=(%01=(STARTAFT=C'-',FIXLEN=3)),
*
OVERLAY=(81:%01)
SORT FIELDS=(81,3,CH,A)
OUTREC BUILD=(1,80)
*
WER268A INREC STATEMENT : SYNTAX ERROR
WER268A OUTREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
abhay,
You are using SYNCSORT and not DFSORT. You cannot use PARSE with SYNCSORT.
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Aaru wrote:
abhay,
You are using SYNCSORT and not DFSORT. You cannot use PARSE with SYNCSORT.
Hi Aaru/frank
Is there any method to solve the above problem through SYNCSORT or how i can use DFSORT in my JCL.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
abhay,
Quote:
Is there any method to solve the above problem through SYNCSORT .
You will not be able to use PARSE with SYncsort as this is not yet made available. Check this link.
http://ibmmainframes.com/viewtopic.php?t=24948&highlight=parse
Quote:
or how i can use DFSORT in my JCL
You will not be able to use DFSORT unless it is installed in your site.
Back to top
shankar.v Active User Joined: 25 Jun 2007Posts: 196 Location: Bangalore
abhay pratap singh,
Please check with the following code for your requirement.
Code:
// EXEC PGM=SORT
//SORTIN DD *
DR-APS
DOCTOR-XYZ
DOC-ABC
DOCT-BAC
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(00001,1,CH,EQ,C'-'),OVERLAY=(81:00002,3)),
IFTHEN=(WHEN=(00002,1,CH,EQ,C'-'),OVERLAY=(81:00003,3)),
IFTHEN=(WHEN=(00003,1,CH,EQ,C'-'),OVERLAY=(81:00004,3)),
IFTHEN=(WHEN=(00004,1,CH,EQ,C'-'),OVERLAY=(81:00005,3)),
IFTHEN=(WHEN=(00005,1,CH,EQ,C'-'),OVERLAY=(81:00006,3)),
IFTHEN=(WHEN=(00006,1,CH,EQ,C'-'),OVERLAY=(81:00007,3)),
IFTHEN=(WHEN=(00007,1,CH,EQ,C'-'),OVERLAY=(81:00008,3)),
IFTHEN=(WHEN=(00008,1,CH,EQ,C'-'),OVERLAY=(81:00009,3)),
IFTHEN=(WHEN=(00009,1,CH,EQ,C'-'),OVERLAY=(81:00010,3)),
IFTHEN=(WHEN=(00010,1,CH,EQ,C'-'),OVERLAY=(81:00011,3)),
IFTHEN=(WHEN=(00011,1,CH,EQ,C'-'),OVERLAY=(81:00012,3)),
IFTHEN=(WHEN=(00012,1,CH,EQ,C'-'),OVERLAY=(81:00013,3)),
IFTHEN=(WHEN=(00013,1,CH,EQ,C'-'),OVERLAY=(81:00014,3)),
IFTHEN=(WHEN=(00014,1,CH,EQ,C'-'),OVERLAY=(81:00015,3)),
IFTHEN=(WHEN=(00015,1,CH,EQ,C'-'),OVERLAY=(81:00016,3)),
IFTHEN=(WHEN=(00016,1,CH,EQ,C'-'),OVERLAY=(81:00017,3)),
IFTHEN=(WHEN=(00017,1,CH,EQ,C'-'),OVERLAY=(81:00018,3)),
IFTHEN=(WHEN=(00018,1,CH,EQ,C'-'),OVERLAY=(81:00019,3)),
IFTHEN=(WHEN=(00019,1,CH,EQ,C'-'),OVERLAY=(81:00020,3)),
IFTHEN=(WHEN=(00020,1,CH,EQ,C'-'),OVERLAY=(81:00021,3)),
IFTHEN=(WHEN=(00021,1,CH,EQ,C'-'),OVERLAY=(81:00022,3)),
IFTHEN=(WHEN=(00022,1,CH,EQ,C'-'),OVERLAY=(81:00023,3)),
IFTHEN=(WHEN=(00023,1,CH,EQ,C'-'),OVERLAY=(81:00024,3)),
IFTHEN=(WHEN=(00024,1,CH,EQ,C'-'),OVERLAY=(81:00025,3)),
IFTHEN=(WHEN=(00025,1,CH,EQ,C'-'),OVERLAY=(81:00026,3)),
IFTHEN=(WHEN=(00026,1,CH,EQ,C'-'),OVERLAY=(81:00027,3)),
IFTHEN=(WHEN=(00027,1,CH,EQ,C'-'),OVERLAY=(81:00028,3)),
IFTHEN=(WHEN=(00028,1,CH,EQ,C'-'),OVERLAY=(81:00029,3)),
IFTHEN=(WHEN=(00029,1,CH,EQ,C'-'),OVERLAY=(81:00030,3)),
IFTHEN=(WHEN=(00030,1,CH,EQ,C'-'),OVERLAY=(81:00031,3)),
IFTHEN=(WHEN=(00031,1,CH,EQ,C'-'),OVERLAY=(81:00032,3)),
IFTHEN=(WHEN=(00032,1,CH,EQ,C'-'),OVERLAY=(81:00033,3)),
IFTHEN=(WHEN=(00033,1,CH,EQ,C'-'),OVERLAY=(81:00034,3)),
IFTHEN=(WHEN=(00034,1,CH,EQ,C'-'),OVERLAY=(81:00035,3)),
IFTHEN=(WHEN=(00035,1,CH,EQ,C'-'),OVERLAY=(81:00036,3)),
IFTHEN=(WHEN=(00036,1,CH,EQ,C'-'),OVERLAY=(81:00037,3)),
IFTHEN=(WHEN=(00037,1,CH,EQ,C'-'),OVERLAY=(81:00038,3)),
IFTHEN=(WHEN=(00038,1,CH,EQ,C'-'),OVERLAY=(81:00039,3)),
IFTHEN=(WHEN=(00039,1,CH,EQ,C'-'),OVERLAY=(81:00040,3)),
IFTHEN=(WHEN=(00040,1,CH,EQ,C'-'),OVERLAY=(81:00041,3)),
IFTHEN=(WHEN=(00041,1,CH,EQ,C'-'),OVERLAY=(81:00042,3)),
IFTHEN=(WHEN=(00042,1,CH,EQ,C'-'),OVERLAY=(81:00043,3)),
IFTHEN=(WHEN=(00043,1,CH,EQ,C'-'),OVERLAY=(81:00044,3)),
IFTHEN=(WHEN=(00044,1,CH,EQ,C'-'),OVERLAY=(81:00045,3)),
IFTHEN=(WHEN=(00045,1,CH,EQ,C'-'),OVERLAY=(81:00046,3)),
IFTHEN=(WHEN=(00046,1,CH,EQ,C'-'),OVERLAY=(81:00047,3)),
IFTHEN=(WHEN=(00047,1,CH,EQ,C'-'),OVERLAY=(81:00048,3)),
IFTHEN=(WHEN=(00048,1,CH,EQ,C'-'),OVERLAY=(81:00049,3)),
IFTHEN=(WHEN=(00049,1,CH,EQ,C'-'),OVERLAY=(81:00050,3)),
IFTHEN=(WHEN=(00050,1,CH,EQ,C'-'),OVERLAY=(81:00051,3)),
IFTHEN=(WHEN=(00051,1,CH,EQ,C'-'),OVERLAY=(81:00052,3)),
IFTHEN=(WHEN=(00052,1,CH,EQ,C'-'),OVERLAY=(81:00053,3)),
IFTHEN=(WHEN=(00053,1,CH,EQ,C'-'),OVERLAY=(81:00054,3)),
IFTHEN=(WHEN=(00054,1,CH,EQ,C'-'),OVERLAY=(81:00055,3)),
IFTHEN=(WHEN=(00055,1,CH,EQ,C'-'),OVERLAY=(81:00056,3)),
IFTHEN=(WHEN=(00056,1,CH,EQ,C'-'),OVERLAY=(81:00057,3)),
IFTHEN=(WHEN=(00057,1,CH,EQ,C'-'),OVERLAY=(81:00058,3)),
IFTHEN=(WHEN=(00058,1,CH,EQ,C'-'),OVERLAY=(81:00059,3)),
IFTHEN=(WHEN=(00059,1,CH,EQ,C'-'),OVERLAY=(81:00060,3)),
IFTHEN=(WHEN=(00060,1,CH,EQ,C'-'),OVERLAY=(81:00061,3)),
IFTHEN=(WHEN=(00061,1,CH,EQ,C'-'),OVERLAY=(81:00062,3)),
IFTHEN=(WHEN=(00062,1,CH,EQ,C'-'),OVERLAY=(81:00063,3)),
IFTHEN=(WHEN=(00063,1,CH,EQ,C'-'),OVERLAY=(81:00064,3)),
IFTHEN=(WHEN=(00064,1,CH,EQ,C'-'),OVERLAY=(81:00065,3)),
IFTHEN=(WHEN=(00065,1,CH,EQ,C'-'),OVERLAY=(81:00066,3)),
IFTHEN=(WHEN=(00066,1,CH,EQ,C'-'),OVERLAY=(81:00067,3)),
IFTHEN=(WHEN=(00067,1,CH,EQ,C'-'),OVERLAY=(81:00068,3)),
IFTHEN=(WHEN=(00068,1,CH,EQ,C'-'),OVERLAY=(81:00069,3)),
IFTHEN=(WHEN=(00069,1,CH,EQ,C'-'),OVERLAY=(81:00070,3)),
IFTHEN=(WHEN=(00070,1,CH,EQ,C'-'),OVERLAY=(81:00071,3)),
IFTHEN=(WHEN=(00071,1,CH,EQ,C'-'),OVERLAY=(81:00072,3)),
IFTHEN=(WHEN=(00072,1,CH,EQ,C'-'),OVERLAY=(81:00073,3)),
IFTHEN=(WHEN=(00073,1,CH,EQ,C'-'),OVERLAY=(81:00074,3)),
IFTHEN=(WHEN=(00074,1,CH,EQ,C'-'),OVERLAY=(81:00075,3)),
IFTHEN=(WHEN=(00075,1,CH,EQ,C'-'),OVERLAY=(81:00076,3)),
IFTHEN=(WHEN=(00076,1,CH,EQ,C'-'),OVERLAY=(81:00077,3)),
IFTHEN=(WHEN=(00077,1,CH,EQ,C'-'),OVERLAY=(81:00078,3))
SORT FIELDS=(81,3,CH,A)
OUTREC FIELDS=(1,80)
/*
//
Output:
Code:
DOC-ABC
DR-APS
DOCT-BAC
DOCTOR-XYZ
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Hi shankar,
Is there any alternative to the solution provided by you in syncsort.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
abhay,
Quote:
Is there any alternative to the solution provided by you in syncsort.
You can try creating the SYSIN card dynamically to avoid manual work.
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Shankar/Aaru
I tried the code provided by shankar but it is giving adend U0016.Below is the part of code whch i have used
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=TCS.Y00057.TESTFIL,DISP=SHR
//SORTOUT DD DSN=TCS.Y00057.SORT101,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,10))
//SYSIN DD *
INREC IFTHEN=(WHEN=(00001,1,CH,EQ,C'-'),OVERLAY(81:00002,3)),
IFTHEN=(WHEN=(00002,1,CH,EQ,C'-'),OVERLAY(81:00003,3)),
IFTHEN=(WHEN=(00003,1,CH,EQ,C'-'),OVERLAY(81:00004,3)),
IFTHEN=(WHEN=(00004,1,CH,EQ,C'-'),OVERLAY(81:00005,3)),
IFTHEN=(WHEN=(00005,1,CH,EQ,C'-'),OVERLAY(81:00006,3)),
IFTHEN=(WHEN=(00006,1,CH,EQ,C'-'),OVERLAY(81:00007,3)),
IFTHEN=(WHEN=(00007,1,CH,EQ,C'-'),OVERLAY(81:00008,3))
SORT FIELDS=(81,3,CH,A)
OUTREC FIELDS=(1,80)
/*
//SYSOUT DD SYSOUT=*
O/P message i am getting in spool is:
SYSIN :
INREC IFTHEN=(WHEN=(00001,1,CH,EQ,C'-'),OVERLAY(81:00002,3)),
*
IFTHEN=(WHEN=(00002,1,CH,EQ,C'-'),OVERLAY(81:00003,3)),
IFTHEN=(WHEN=(00003,1,CH,EQ,C'-'),OVERLAY(81:00004,3)),
IFTHEN=(WHEN=(00004,1,CH,EQ,C'-'),OVERLAY(81:00005,3)),
IFTHEN=(WHEN=(00005,1,CH,EQ,C'-'),OVERLAY(81:00006,3)),
IFTHEN=(WHEN=(00006,1,CH,EQ,C'-'),OVERLAY(81:00007,3)),
IFTHEN=(WHEN=(00007,1,CH,EQ,C'-'),OVERLAY(81:00008,3))
SORT FIELDS=(81,3,CH,A)
OUTREC FIELDS=(1,80)
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
How i can pass SYSIN data dynamically.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
abhay,
Quote:
WER268A INREC STATEMENT : SYNTAX ERROR
You have coded the SYSIN statements from column 1. Code as shown below.
Code:
//SYSIN DD *
INREC IFTHEN=(WHEN=(00001,1,CH,EQ,C'-'),OVERLAY(81:00002,3)),
IFTHEN=(WHEN=(00002,1,CH,EQ,C'-'),OVERLAY(81:00003,3)),
IFTHEN=(WHEN=(00003,1,CH,EQ,C'-'),OVERLAY(81:00004,3)),
IFTHEN=(WHEN=(00004,1,CH,EQ,C'-'),OVERLAY(81:00005,3)),
IFTHEN=(WHEN=(00005,1,CH,EQ,C'-'),OVERLAY(81:00006,3)),
IFTHEN=(WHEN=(00006,1,CH,EQ,C'-'),OVERLAY(81:00007,3)),
IFTHEN=(WHEN=(00007,1,CH,EQ,C'-'),OVERLAY(81:00008,3))
SORT FIELDS=(81,3,CH,A)
OUTREC FIELDS=(1,80)
/*
This should work.
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
That is due to copy and paste otherwise code is written as it is mentioned by shankar.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
abhay,
Shankar's code is working fine in my shop. what syncsort version are you using?
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Aaru wrote:
abhay,
Shankar's code is working fine in my shop. what syncsort version are you using?
SYNCSORT FOR Z/OS 1.2.0.1N
Back to top
shankar.v Active User Joined: 25 Jun 2007Posts: 196 Location: Bangalore
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Shankar,
Can you provide me solution according to version 1.2.0
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hello,
If your system is currently licensed for Syncsort, i believe a better solution would be to install the current release of the product. . .
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
dick scherrer wrote:
Hello,
If your system is currently licensed for Syncsort, i believe a better solution would be to install the current release of the product. . .
Dick,
Is there any other utility in JCL or any other way in JCL through which i can perform the above mentioned operation.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
abhay,
Quote:
Is there any other utility in JCL or any other way in JCL through which i can perform the above mentioned operation.
The best possible thing is to get the latest version of the product installed in your site. Get in touch with the concerned for the same.
Please note that people have given 2 different sort cards(solns) for your reqt, One using SYNCSORT and other using DFSORT.
Back to top
abhay pratap singh New User Joined: 22 Nov 2007Posts: 77 Location: noida
Thanks to all for the response.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hello abhay,
You could always write program code to accomplish what you want. . .
You might also talk with the system support people to see if there is some other utility available on your system that would provide the functionality you want.
I still believe that your environment would be better served by installing the current release of your sort product.
Back to top
shankar.v Active User Joined: 25 Jun 2007Posts: 196 Location: Bangalore
abhay pratap singh,
Quote:
Can you provide me solution according to version 1.2.0
Please check with the following code for your requirement.
Code:
//S EXEC PGM=SORT
//SORTIN DD *
DR-APS
DOCTOR-XYZ
DOC-ABC
DOCT-BAC
/*
//O1 DD DSN=&&O1,DISP=(,PASS),SPACE=(CYL,(1,1))
//O2 DD DSN=&&O2,DISP=(,PASS),SPACE=(CYL,(1,1))
//O3 DD DSN=&&O3,DISP=(,PASS),SPACE=(CYL,(1,1))
//O4 DD DSN=&&O4,DISP=(,PASS),SPACE=(CYL,(1,1))
//O5 DD DSN=&&O5,DISP=(,PASS),SPACE=(CYL,(1,1))
//O6 DD DSN=&&O6,DISP=(,PASS),SPACE=(CYL,(1,1))
//O7 DD DSN=&&O7,DISP=(,PASS),SPACE=(CYL,(1,1))
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=O1,INCLUDE=(1,1,CH,EQ,C'-'),OUTREC=(1,80,2,3)
OUTFIL FNAMES=O2,INCLUDE=(2,1,CH,EQ,C'-'),OUTREC=(1,80,3,3)
OUTFIL FNAMES=O3,INCLUDE=(3,1,CH,EQ,C'-'),OUTREC=(1,80,4,3)
OUTFIL FNAMES=O4,INCLUDE=(4,1,CH,EQ,C'-'),OUTREC=(1,80,5,3)
OUTFIL FNAMES=O5,INCLUDE=(5,1,CH,EQ,C'-'),OUTREC=(1,80,6,3)
OUTFIL FNAMES=O6,INCLUDE=(6,1,CH,EQ,C'-'),OUTREC=(1,80,7,3)
OUTFIL FNAMES=O7,INCLUDE=(7,1,CH,EQ,C'-'),OUTREC=(1,80,8,3)
/*
// EXEC PGM=SORT
//SORTIN DD DSN=*.S.O1,DISP=(OLD,DELETE),VOL=REF=*.S.O1
// DD DSN=*.S.O2,DISP=(OLD,DELETE),VOL=REF=*.S.O2
// DD DSN=*.S.O3,DISP=(OLD,DELETE),VOL=REF=*.S.O3
// DD DSN=*.S.O4,DISP=(OLD,DELETE),VOL=REF=*.S.O4
// DD DSN=*.S.O5,DISP=(OLD,DELETE),VOL=REF=*.S.O5
// DD DSN=*.S.O6,DISP=(OLD,DELETE),VOL=REF=*.S.O6
// DD DSN=*.S.O7,DISP=(OLD,DELETE),VOL=REF=*.S.O7
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(81,3,CH,A)
OUTREC FIELDS=(1,80)
/*
//
Output:
Code:
DOC-ABC
DR-APS
DOCT-BAC
DOCTOR-XYZ
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Shankar,
Quote:
Please check with the following code for your requirement.
This should work perfectly with that version . But what if "-" is present somewhere between column 8 till 80 (assuming the LRECL to be 80) as you have taken into consideration only the first 7 bytes. Guess you will have to add few more DD steps.
abhay,
What is the LRECL?
Back to top
shankar.v Active User Joined: 25 Jun 2007Posts: 196 Location: Bangalore
Aaru,
Quote:
But what if "-" is present somewhere between column 8 till 80 (assuming the LRECL to be 80) as you have taken into consideration only the first 7 bytes.
As sorting is happening on field with length 3, the possibility of string "-" should be present somewhere between column 1 and 77 and not in column 78, 79 and 80. Please correct me if i am wrong.
Quote:
Guess you will have to add few more DD steps.
That's true for your point.
Back to top
Please enable JavaScript!