I want to sort my records only omiting all the header part. The problem is that the header repeats for every 17 records. I have to retain the position of these headers while i am sorting. I want to do it by sorting and cannot use any other methods like ezytrieve and quickjob. I can use either syncsort or dfsort. Can anyone give a clue on how it can be done.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Sep 10, 2004 9:54 am Post subject:
It's not clear to me what you want to do. You say you want to "sort my records only omiting all the header part". Does that mean you want to remove the header records? If so, you can do that with OMIT before you sort the records. But then you say "I have to retain the position of these headers while i am sorting." so it sounds like you don't want to remove the headers. Confusing.
Are you trying to sort the detail records within each group of headers and details records independently of the other groups? It would help if you showed an example of what the input records look like with the keys out of order, and what the output records look like with the keys in order.
What is the RECFM and LRECL of your input file? What is the starting position, length and format of the key?
Do the headers have some kind of identifier (e.g. 'HDR' in positions 1-3)?
Do your groups always consist of 5 header records and 7 detail records?
What's the approximate maximum number of records in the input file? _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Hi Frank,
Sorry for the late reply. I didnt come to office for last two days. Now for the description, first of all let me clarify that i want to retain the headers.
Code:
*************************************************************
sample input
*************************************************************
--------------------------------------------------------------------------------------
SUMMARY REPORT FOR AUGUST
field1 field2 field3 field4 field5
--------------------------------------------------------------------------------------
4
2
1
5
5
2
3
--------------------------------------------------------------------------------------
SUMMARY REPORT FOR AUGUST
field1 field2 field3 field4 field5
--------------------------------------------------------------------------------------
8
5
2
3
1
9
1
*************************************************************
sample output for the above input
*************************************************************
--------------------------------------------------------------------------------------
SUMMARY REPORT FOR AUGUST
field1 field2 field3 field4 field5
--------------------------------------------------------------------------------------
1
1
1
2
2
2
3
--------------------------------------------------------------------------------------
SUMMARY REPORT FOR AUGUST
field1 field2 field3 field4 field5
--------------------------------------------------------------------------------------
3
4
5
5
5
8
9
*************************************************************
*************************************************************
The sortable field is field1 alone. Thats why i didnt fill in values for other fields.
The headers should repeat after every 7 records in the output file. Sorting shouldnt be inbetween headers. it should consider all records together.
Please let me know if there is any way to insert headers after every 7 output records.
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Wed Sep 15, 2004 10:39 am Post subject:
bade_miya,
The following DFSORT/ICETOOL JCL will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool .I assumed that your input file is 80 bytes in lrecl and is of FB recfm.
A brief explanation of the job.
The first copy operator splits the input file into 2 files. T1 will have all the headers records and file T2 will have all the detail records. Since you wanted the header records to appear after every 7 records, we add a seqnum to the header file with increments of 7.
The sort operator then takes the detail file (T2) and sorts it on FIELD1 and writes out to T3. We also add a seqnum to this file so that sneak in the header records in between.
The last sort operator takes in files T1 & T3 concatenated together and sorts on the seqnum, to acheive the desired results. While writting out , we remove the sequence number.
If you want the headers to be generated, instead of retaining the orginals headers from the input file, then we can avoid a couple of passes. Let me know if you are interested in that solution.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Sep 15, 2004 11:40 am Post subject:
Bade,
Here's another way to do this with DFSORT. I assumed that your input file has RECFM=FB and LRECL=86. The approach here is to set up DFSORT symbols for the headers from the input record headers, and then use them to create the headers in the report where needed. Since each input line is 86 bytes, we have to break each header line into two DFSORT symbols (a DFSORT symbol string can be a maximum of 50 bytes).
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... FB/86 input file
//SORTOUT DD DSN=&&S,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
* Create two DFSORT symbols as follows from each of the four
* header lines:
* HDAn,'bytes 1-43'
* HDBn,'bytes 44-86'
OPTION COPY,STOPAFT=4
OUTFIL OUTREC=(C'HDA',SEQNUM,1,ZD,C',''',1,43,C'''',80:X,/,
C'HDB',SEQNUM,1,ZD,C',''',44,43,C'''')
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S,DISP=(OLD,PASS)
//SORTIN DD DSN=... FB/86 input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
* Collate equal keys in original order
OPTION EQUALS
* Remove the original header lines
OMIT COND=(1,1,CH,LT,C'1',OR,1,1,CH,GT,C'9')
* Sort on the key
SORT FIELDS=(1,1,CH,A)
* Use the HDAn-HDBn symbols to create the 4 header lines
* before each 7 sorted data lines.
OUTFIL HEADER2=(HDA1,HDB1,/,HDA2,HDB2,/,HDA3,HDB3,/,HDA4,HDB4),
LINES=11
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Last edited by Frank Yaeger on Thu Sep 16, 2004 10:08 am; edited 1 time in total
Hi Frank&Kolusu,
First of all i appologize for not providing the details that Frank asked for in the previous post. I missed that part while posting my reply.
Q)What is the RECFM and LRECL of your input file? What is the starting position, length and format of the key?
A) RECFM=FB LRECL=135, position=1,length=31,format=ch
Q)Do the headers have some kind of identifier (e.g. 'HDR' in positions 1-3)?
A) NO they dont have. The headers are
--------------------------------------------------------------------------------------
SUMMARY REPORT FOR AUGUST
field1 field2 field3 field4 field5
--------------------------------------------------------------------------------------
The first two headers are excatly the same and the third header will be names of various fiedls.
Q)Do your groups always consist of 5 header records and 7 detail records?
A) yes it does. but it is 4 headers .
Q)What's the approximate maximum number of records in the input file?
A) dont know for sure. lets say 1-1000.
*************************************************************
Now for the replies, Kolusu is considering only one header i guess. If we take that way, the job is working perfect. i am trying to apply it in case of more than one header. I would also like to know about how to generate the headers as you mentioned in your previous post as it would perfectly suit my need. Can we generate the same kind of headers as i have shown in the previous post? Should i provide any other info for that?
Frank,
I didnt get what this statement in your job ment.
'SORTIN DD DSN=&&IN,DISP=(OLD,PASS)'
as we havent used &&IN anywhere else in the jcl.
It also gave me a JCL error. so i try giving it disp=(,pass) and modified the outfil statement to
OUTFIL OUTREC=(C'HDA',SEQNUM,1,ZD,C',''',1,43,C'''',129:X,/,
C'HDB',SEQNUM,1,ZD,C',''',44,43,C'''')
as my infile lrecl=135. (please correct me if i am wrong in changing this.)
When i submitted the job, it gave me MAX CC=S013 REASON CODE =20 for SYSIN statement for S2 STEP. I couldnt resolve it. Please help me with this.
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Thu Sep 16, 2004 5:28 am Post subject:
Bade_miya,
Quote:
Now for the replies, Kolusu is considering only one header i guess. If we take that way, the job is working perfect. i am trying to apply it in case of more than one header.
I am not considering that you have only a single header. My job works for 'N' of headers.
Quote:
I would also like to know about how to generate the headers as you mentioned in your previous post as it would perfectly suit my need.
you want a header like that after every 7 sorted records?
Code:
SUMMARY REPORT FOR AUGUST
field1 field2 field3 field4 field5
Quote:
When i submitted the job, it gave me MAX CC=S013 REASON CODE =20 for SYSIN statement for S2 STEP. I couldnt resolve it. Please help me with this.
It would help us if you can provide us the TOOLIN and DFSMSG DD's sysout
Hi guys,
This is the message i in JESYSMSG which i got while running Franks solution.
********************************************************************
Code:
IEF237I JES2 ALLOCATED TO SYSIN
IEF237I JES2 ALLOCATED TO SYSIN
IEC141I 013-20,IGG0191A,MFID12AA,S2,SYMNAMES,5127,PUBL03,SYS04260.T073936.RA000.
IEA995I SYMPTOM DUMP OUTPUT
SYSTEM COMPLETION CODE=013 REASON CODE=00000020
'It would help us if you can provide us the TOOLIN and DFSMSG DD's sysout '
But it was not for TOOLIN which i got the error message and Franks solution dosent contain any TOOLIN. And i have provided the error message i have got for the step S2 and also the step itself.
I am not considering that you have only a single header. My job works for 'N' of headers
But in your sample input there is only one kind of header ie 'SUMMARY REPORT FOR AUGUST'. There are two other kind of headers also, as shown in my sample input. They are.
1) -------------------------------------------------------------------------------------------
2) field1 field2 field3 field4 field5
If you want the headers to be generated, instead of retaining the orginals headers from the input file, then we can avoid a couple of passes. Let me know if you are interested in that solution.
Please tell me how we can do this. Can i generate these three kind of headers after every 7 records?
SYSOUT FOR S1
-------------------
*************************************************************
Code:
SYSIN :
* CREATE TWO DFSORT SYMBOLS AS FOLLOWS FROM EACH OF THE FOUR
* HEADER LINES:
* HDAN,'BYTES 1-43'
* HDBN,'BYTES 44-86'
OPTION COPY,STOPAFT=4
OUTFIL OUTREC=(C'HDA',SEQNUM,1,ZD,C',''',1,43,C'''',129:X,/,
C'HDB',SEQNUM,1,ZD,C',''',44,43,C'''')
WER164B 6,896K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 64K BYTES RESERVE REQUESTED, 1,027,808 BYTES USED
WER146B 20K BYTES OF EMERGENCY SPACE ALLOCATED
WER108I SORTIN : RECFM=FB ; LRECL= 100; BLKSIZE= 100
WER110I SORTOUT : RECFM=FB ; LRECL= 129; BLKSIZE= 27993
WER405I SORTOUT : DATA RECORDS OUT 4; TOTAL RECORDS OUT 8
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
WER416B SORTIN: EXCP'S=1,UNIT=3390,DEV=5183,CHP=(BBCCBDBFC6C8CA,1),VOL=DVLP7
WER416B OUTFIL WAS USED FOR SORTOUT
WER054I RCD IN 4, OUT 4
WER169I RELEASE 1.1C BATCH 0405 TPF LEVEL 2B
WER052I END SYNCSORT - MFID12AA,S1,,DIAG=E800,7BCE,C0AA,20CC,A056,4CC2,82E8,0C6
SYSOUT FOR S2
-------------------
Its a SNAP and it is very large. i will paste the begining lines of the same
*************************************************************
Code:
PSW AT ENTRY TO SNAP 078D1000 80008B1E ILC 02 INTC 0033
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Sep 16, 2004 10:07 am Post subject:
Bade,
The SORTIN DD statement was supposed to be:
//SORTIN DD DSN=... FB/86 input file
&&IN was the input data set I generated and used for my test. I changed the //SORTIN DD in the first step, but forgot to change it in the second step.
The WER messages indicate you're using Syncsort, not DFSORT, so there's no point in my showing you how to do this with DFSORT. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
But i used the same job as shown. I havent mentioned syncsort anywhere. In my step S1 and S2 i have used PGM=ICEMAN. Then how come i am using syncsort? Please explain.
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