sort command

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
Priya_mano_c
Member
Posts: 3
Joined: Wed Nov 15, 2006 3:08 pm

sort command

Post by Priya_mano_c » Wed Nov 15, 2006 3:12 pm

Is there any option in SORT to generate sequence numbers
For example,
If there is a file with values like
S1
S1
S2
S2
S2



I need to generate



1 for s1

2 for s1

1 for s2

2 for s2

3 for s2

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Nov 15, 2006 11:19 pm

Here's a DFSORT job that will do what you asked for:

Code: Select all

//S1    EXEC  PGM=ICEMAN                    
//SYSOUT    DD  SYSOUT=*                    
//SORTIN DD *                               
S1                                          
S1                                          
S2                                          
S2                                          
S2                                          
//SORTOUT DD SYSOUT=*                       
//SYSIN    DD    *                          
  OPTION COPY                               
  INREC BUILD=(SEQNUM,1,ZD,RESTART=(1,2),   
   C' for ',1,2)                            
/*
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/servers/storage/support/sof ... tmpub.html
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others