IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SORT -SEQNUM


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Thu Mar 04, 2010 7:04 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Mar 04, 2010 7:29 pm
Reply with quote

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
View user's profile Send private message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Thu Mar 04, 2010 8:52 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Mar 04, 2010 10:12 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 04, 2010 11:41 pm
Reply with quote

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
View user's profile Send private message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Fri Mar 05, 2010 1:29 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 05, 2010 11:04 pm
Reply with quote

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
View user's profile Send private message
rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Mon Mar 08, 2010 2:24 pm
Reply with quote

Thanks Frank!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top