Joined: 26 Nov 2002 Posts: 12404 Topics: 75 Location: San Jose
Posted: Tue Nov 09, 2004 11:55 am Post subject:
nguyenh,
Let me put your requirement in simple terms.
Code:
col 1- 38 col 39-44 col 77 - 78
****************header rec1*****************
detail rec 3 key400 cc
detail rec 2 key100 aa
....
****************header rec2*****************
detail rec 1 key300 cc
detail rec 5 key200 aa
....
Now
1. you just want 1 header record
2. sort all the detail records on col 39 -44 and col 77- 78
3. you want to append the columns 39 thru at the end of each record
sample output
Code:
****************one header*****************
detail rec 2 key100 aa key100
detail rec 5 key200 aa key200
detail rec 1 key300 cc key300
detail rec 3 key400 cc key400
col 1- 38 39-44 77 - 78
****************header key001********
detail rec 3 cc
detail rec 2 aa
....
****************header key002********
detail rec 1 cc
detail rec 5 aa
....
Quote:
1. you just want 1 header record (Yes! the first one only)
2. sort all the detail records on col 39 -44 and col 77- 78 (Yes!)
3. you want to append the columns 39 thru 44 at the end of each record (Yes!)
Here is sample output:
Code:
col 1- 38 39-44 77-78 81-82
****************header key001*****************
detail rec 2 aa key001
detail rec 3 cc key001
....
detail rec 5 aa key002
detail rec 1 cc key002
...
col 1- 38 39-44 77-78
****************key001*************
detail rec 3 cc
detail rec 2 aa
....
****************key002*************
detail rec 1 cc
detail rec 5 aa
...
Code:
col 1- 38 39-44 77-78 81-82
****************key001*****************
detail rec 2 aa key001
detail rec 3 cc key001
....
detail rec 5 aa key002
detail rec 1 cc key002
Joined: 26 Nov 2002 Posts: 12404 Topics: 75 Location: San Jose
Posted: Tue Nov 09, 2004 3:29 pm Post subject:
nguyenh,
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. However you need the latest version of syncsort to run this jcl which supports the splice parameter.
A brief explanation of the job. I assumed that your header record is identified by * in the 1st byte. I also assumed that your detail record is key the first 12 bytes.
The first copy operator splits the file into 2 files, namely HDR and detail. we first a seqnum of 8 bytes of ZD format to records using INREC fields.
Using OUTFIL we split the records into 2 HDR and DET files. On the header record we zero out the seqnum and start new seqnum of 8 bytes of ZD format from 89th byte. We also add an indicator 'H' and copy the contents from 39 thru 44.
All the detail records are copied into DET file. we add an indicator of "z" to all the detail records.
The next SORT operator concatenates the above created HDR & DET files and using INREC we perform the tagging the record no: to all the detail records.
We now sort on the tagno and the indicator and the detail records key( 1 thru 12)
By doing so the detail records are sorted within each header.
We take the output from the sort step and use splice operator to splice the header name at the end of every detail record.
Kolusu,
Thank you so much for your helps. The code works perfect for current requirements, however there are more functionalities that I want it to do. but
at the moment I am still trying to understand what the code is doing.
I will come back with more questions. I hope you dont mind. I really appreciate for your helps!
Posted: Thu Nov 11, 2004 1:51 pm Post subject: help me understand this code
Kolusu,
Could you please help me understand what each of these parameters in this code does, and what the output records will look like after execute it ?
Joined: 26 Nov 2002 Posts: 12404 Topics: 75 Location: San Jose
Posted: Thu Nov 11, 2004 2:12 pm Post subject:
nguyenh,
Code:
OUTREC=(1,80, $ Copy 80 bytes from pos1 of input
8C'0', $ pad 8 zeroes
SEQNUM,8,ZD, $ seqnum( record #)
C'H', $ char of 'h'
39,6) $ Copy 6 bytes from pos 39 of input
OUTFIL FNAMES=DET,SAVE,
OUTREC=(1,88, $ Copy 88 bytes from pos 1 of inrec
SEQNUM,8,ZD, $ seqnum( record #)
C'Z', $ char of 'z'
6X) $ pad 6 spaces.
option SAVE operates in a global fashion over all of the other OUTFIL statements for which SAVE is not specified, enabling you to keep any OUTFIL input records that would not be kept otherwise. SAVE will include the same records for each group for which it is specified.
In simple terms it is acts like the ELSE part of IF condition.
Code:
IF COND = 'A' OR 'B' OR 'C'
PUT OUTPUT1
ELSE
PUT OUTPUT2
END-IF
Joined: 26 Nov 2002 Posts: 12404 Topics: 75 Location: San Jose
Posted: Tue Dec 07, 2004 4:21 pm Post subject:
nguyenh,
OPTION EQUALS| NOEQUALS : Determines whether or not the sort will preserve the order of records with identical sort fields. NOEQUALS is the default, and causes equal-keyed records to be written in a random order,not in the order they were encountered.
1,96 means copy the contents from byte 1 for a length of 96
(81,8,ZD,SUB,89,8,ZD),M11,LENGTH=8 means subtract the contents at 81 for 8 bytes from contents at 89 for 8 bytes and write out the result in the format TTTTTTTT ( no zero suppression as 9(08 ) in cobol)
97,7 means means copy the contents from byte 97 for a length of 7
Code:
Sort fields=(97,8,ZD,A, $ sort on 8 bytes starting at 97
105,1,CH,A, $ sort on 1 byte starting at 105
1,12,CH,A) $ sort on 12 bytes starting at 1
Code:
OUTFIL FNAMES=T3, $ output file DD name
OUTREC=(1,80, $ copy 80 bytes from pos 1
106,6, $ copy 6 bytes from pos 106
97,8) $ copy 8 bytes from pos 97
Code:
//CTL3CNTL DD *
OUTFIL FNAMES=OUT, $ output file DD name
OUTREC=(1,86) $ copy 86 bytes from pos 1
If your shop has DFSORT then you can access the DFSORT manual from here.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Dec 07, 2004 4:29 pm Post subject:
This a portion of a DFSORT/ICETOOL job Kolusu showed earlier. The CTL2CNTL DD supplies DFSORT statements for the SORT operator with USING(CTL2) and the CTL3CNTL DD supplies DFSORT statements for the SPLICE operator with USING(CTL3).
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "DFSORT: Getting Started". It's an excellent tutorial that will teach you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online at:
Here's a brief explanation of the DFSORT control statements in CTL2CNTL and CTL3CNTL.
CTL2CNTL statements:
EQUALS tells DFSORT to keep the original order of duplicate records.
INREC reformats the records before they are sorted using the following fields: 1-96; the ZD value in positions 81-88 minus the ZD value in positions 89-96, and 97-103. M11,LENGTH=8 edits the result of the subtraction.
SORT sorts the records ascending on the following fields in the reformatted INREC record: the ZD field in positions 97-104, the CH field in position 105 and the CH field in positions 1-12.
OUTFIL writes records to the T3 DD data set after they are sorted. OUTREC reformats the records for output using the following fields: positions 1-80, positions 106-111 and positions 97-104.
CTL3CNTL statements:
OUTFIL writes records to the OUT DD data set after they are spliced. OUTREC reformats the records using positions 1-86. _________________ 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
Frank Yaeger,
Thank you very much. I actually read your mini ICETOOLS Userguide D/N: Fc27-1997-00 that is very impressive work of you, I even have a copy of it on my desk. But since I am a mainframe and DFSORT beginner so I need something more for dummy . I will read DFSORT links that you suggested.
Kolusu,
Thank you for your helps. Now I understand that part,
This is the part that I am still confused on, I tried to catalog all the temporary datasets, so that I can see the actual data being put in them, but couldn't get it to work (I am very bad in mainframe), so I have to ask you this one more time:
Based on your explaination of the following code:
Code:
OUTREC=(1,80, $ Copy 80 bytes from pos1 of input
8C'0', $ pad 8 zeroes
SEQNUM,8,ZD, $ seqnum( record #)
C'H', $ char of 'h'
39,6) $ Copy 6 bytes from pos 39 of input
so after the above lines has been executed: am I correct that the output records will have the following format?
Code:
[80 bytes from byte 1][8 zeros][8 bytes sequence number][H][6 bytes from byte 39]
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Tue Dec 07, 2004 11:20 pm Post subject:
nguyenh,
Code:
I tried to catalog all the temporary datasets, so that I can see the actual data being put in them, but couldn't get it to work (I am very bad in mainframe), so I have to ask you this one more time:
You can do that easily. All you need to do is to create & catalog the datasets before the sort step. use IEFBR14 to create an empty file (& catalog it). Then use the datasets in the SYNCTOOL/ICETOOL with DISP as SHR.
All times are GMT - 5 Hours Goto page Previous1, 2, 3, 4Next
Page 2 of 4
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