how to get sequence number like this?

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

how to get sequence number like this?

Post by rangab » Mon Feb 09, 2009 8:35 pm

Hi,

My input dataset (LRECL=80, RECFM=FB):

Code: Select all

12345600000ZX
12345600000ZY
12345700000ZX
12345700000ZY
12345800000ZX
12345800000ZY
12345600000ZX
12345600000ZY
Expected output: LRECL=90, RECFM=FB

Code: Select all

12345600000ZX    0001
12345600000ZY    0002
12345600000ZX    0001
12345600000ZY    0002
Input dataset contains duplicates and output should contain duplicates but with sequence number assigned to them.

Thanks.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

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

Post by Frank Yaeger » Mon Feb 09, 2009 9:17 pm

I wish you would make more of an effort to match your examples to your descriptions and explain the "rules" for your examples.

What is the starting position and length of the key field you want to check for duplicates on? Why do you have the first two records in the output and the last two records in the output, but not the other four records? I don't see any difference between the 4 pairs of records.

Assuming your input records are already in order by the key (as shown in your example) and you want to restart the sequence numbers each time the key in positions 1-11 changes (just a guess on the key positions), you can do it with a DFSORT job like this:

Code: Select all

//S1    EXEC  PGM=SORT                                  
//SYSOUT    DD  SYSOUT=*                                
//SORTIN DD *                                           
12345600000ZX                                           
12345600000ZY                                           
12345700000ZX                                           
12345700000ZY                                           
12345800000ZX                                           
12345800000ZY                                           
12345600000ZX                                           
12345600000ZY                                           
/*
//SORTOUT DD SYSOUT=*                                   
//SYSIN    DD    *                                      
  OPTION COPY                                           
  INREC OVERLAY=(18:SEQNUM,4,ZD,RESTART=(1,11),90:X)    
/*
SORTOUT would be RECFM=FB/LRECL=90 with these records:

Code: Select all

12345600000ZX    0001     
12345600000ZY    0002     
12345700000ZX    0001     
12345700000ZY    0002     
12345800000ZX    0001     
12345800000ZY    0002     
12345600000ZX    0001     
12345600000ZY    0002     
If that's not what you want, then you need to do a better job of explaining what you do want.
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

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

Post by rangab » Tue Feb 10, 2009 2:04 pm

Frank, thanks for the reply. I will try to improve :oops:

The key here starts in 1st column and of 6 bytes length. I want this sequence number technique to be applied on certain key value only (ex. 123456). However, the code you have given here should work for me.

Thanks a lot.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

Post by rangab » Tue Feb 10, 2009 2:27 pm

Frank, thank you again. It has worked.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

how to apply this technique?

Post by rangab » Tue Feb 10, 2009 2:59 pm

Hi, Frank.

How to apply the sequence number technique on below data? This dataset's LRECL=80 & RECFM=FB. The key field starts in 19th column and of 6 bytes. I want to apply 5 digit sequence number only for key value '161009' and it's next record (01 & 02) at column position 30.

Input:

Code: Select all

----+----1----+----2----+
0000012121800000VA161009
0000012121800000VB11+C1U
0000012121800000VA131009
0000012121800000VB11+P1U
0000012121800000VA161009
0000012121800000VB08+B1U
0000012121800000VA141009
0000012121800000VB11+X1U
0000012121800000VA161009
0000012121800000VB08+J1U
0000012121800000VA161009
0000012121800000VB08+H1U
Output:

Code: Select all

0000012121800000VA161009     00001
0000012121800000VB11+C1U     00002
0000012121800000VA161009     00001
0000012121800000VB08+B1U     00002
0000012121800000VA161009     00001
0000012121800000VB08+J1U     00002
0000012121800000VA161009     00001
0000012121800000VB08+H1U     00002
I hope, have explained it better this time. :)
TIA.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

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

Post by Frank Yaeger » Tue Feb 10, 2009 9:07 pm

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

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(19,6,CH,EQ,C'161009'),
    RECORDS=2,PUSH=(30:SEQ=5))
  OUTFIL OMIT=(30,1,CH,EQ,C' ')
/*
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

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

Post by rangab » Wed Feb 11, 2009 4:51 pm

wow....thanks a lot.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 10:34 pm

<< Content deleted By Admin >>

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