Page 1 of 1

how to get sequence number like this?

Posted: Mon Feb 09, 2009 8:35 pm
by rangab
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.

Posted: Mon Feb 09, 2009 9:17 pm
by Frank Yaeger
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.

Posted: Tue Feb 10, 2009 2:04 pm
by rangab
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.

Posted: Tue Feb 10, 2009 2:27 pm
by rangab
Frank, thank you again. It has worked.

how to apply this technique?

Posted: Tue Feb 10, 2009 2:59 pm
by rangab
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.

Posted: Tue Feb 10, 2009 9:07 pm
by Frank Yaeger
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' ')
/*

Posted: Wed Feb 11, 2009 4:51 pm
by rangab
wow....thanks a lot.

Topic deleted by Admin

Posted: Mon Jan 25, 2016 10:34 pm
by academyindia4
<< Content deleted By Admin >>