View previous topic :: View next topic
|
Author |
Message |
rakesh1155
New User
Joined: 21 Jan 2009 Posts: 84 Location: India
|
|
|
|
Hi,
I have a requirement. I have a flat file. The key for the data in the file is 6 bytes. The file can contain duplicates.
I need to insert sequence number for the file. For each duplicate record, the sequence number should not change.
Sample Input:
AAA111
AAA111
AAA111
AAA123
AAA123
AAA456
BBB111
BBB111
BBB111
Sample Output:
AAA111 1
AAA111 1
AAA111 1
AAA123 2
AAA123 2
AAA456 3
BBB111 4
BBB111 4
BBB111 4
Can you help ?
-Thanks,
Rakesh. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Any chance that you could reveal the LRECL, RECFM, Position, and length of the key for the input file; the LRECL, RECFM, position, length, and format of the sequence for the output file? A one digit sequence as you have shown would not allow for a very big file. What sort product and version are using? |
|
Back to top |
|
|
rakesh1155
New User
Joined: 21 Jan 2009 Posts: 84 Location: India
|
|
|
|
Right... a one digit sequence wont help me much.
I had just put a sample input and output in my post.
Input LRECL = 70 (key portion - first 30 bytes) RECFM = FB.
I would need a 7-byte sequence in the bytes 71-74,
Output LRECL = 74.
I am using DFSORT and not sure of the version.
Is it possible to put a condition on the INCR attribute of the SEQNUM? |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rakesh1155 wrote: |
I would need a 7-byte sequence in the bytes 71-74,
Output LRECL = 74.
I am using DFSORT and not sure of the version.
Is it possible to put a condition on the INCR attribute of the SEQNUM? |
Do you want the seqnum in Packed decimal format? If you want a 7 byte readable sequence number then your output lrecl needs to be incremented to 77. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Assuming you want a 4-byte PD value in 71-74, you can use a DFSORT job like the following:
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/70)
//SORTOUT DD DSN=... output file (FB/74)
//SYSIN DD *
SORT FIELDS=(1,30,CH,A),EQUALS
INREC IFOUTLEN=74,
IFTHEN=(WHEN=INIT,
OVERLAY=(71:SEQNUM,7,ZD,RESTART=(1,30))),
IFTHEN=(WHEN=GROUP,BEGIN=(71,7,ZD,EQ,1),
PUSH=(71:ID=7)),
IFTHEN=(WHEN=INIT,BUILD=(1,70,71:71,7,ZD,TO=PD,LENGTH=4))
/*
|
|
|
Back to top |
|
|
rakesh1155
New User
Joined: 21 Jan 2009 Posts: 84 Location: India
|
|
|
|
Thanks. It is working as I wanted.
Yes, I wanted it in packed decimal format.
But, Can you please explain the SORT-CARD ?
-Thanks,
Rakesh. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The first IFTHEN clause adds a ZD sequence number in positions 71-77. The sequence number restarts at 1 each time the key (1-30) changes. So the first record with each key will have sequence number 1.
The second IFTHEN clause starts a new group each time the sequence number is 1 and puts an ID value in positions 71-77 of each record in the group. The ID number starts at 1 and is incremented by 1 for each group. So the records of the first group will have an ID of 1, the records of the second group will have an ID of 2, etc.
The third IFTHEN clause just converts the 7-byte ZD ID to a 4-byte PD ID.
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080 |
|
Back to top |
|
|
rakesh1155
New User
Joined: 21 Jan 2009 Posts: 84 Location: India
|
|
|
|
Thanks Frank! |
|
Back to top |
|
|
|