Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SORT -SEQNUM

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SORT -SEQNUM
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    Post subject:
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    Post subject: Reply to: SORT -SEQNUM
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    Post subject: Re: Reply to: SORT -SEQNUM
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 Moderator


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

PostPosted: Thu Mar 04, 2010 11:41 pm    Post subject:
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    Post subject: Reply to: SORT -SEQNUM
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 Moderator


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

PostPosted: Fri Mar 05, 2010 11:04 pm    Post subject:
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:

http://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    Post subject: Reply to: SORT -SEQNUM
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us