Page 1 of 1

Add Sequence no for records under a group

PostPosted: Sat Apr 14, 2012 12:00 am
by Falcon
Hi,
I need to add sequence number to each record grouped by key field. First 7 bytes are key fields and input file is FB. The expected output is given below.
Please let me know how to accomplish it and i use SYNCSORT 1.3.2.2R.

Input file:
4529123AAB         
4529123ABB         
4529123ACC         
1293940ABB         
1293940ACC         
1929303AAB         
1929303ABB         
1929303ACC         
1929303ADD         


Output:
4529123AAB00001     
4529123ABB00002     
4529123ACC00003     
1293940ABB00001     
1293940ACC00002     
1929303AAB00001     
1929303ABB00002     
1929303ACC00003     
1929303ADD00004     


Note: WHEN=GROUP does not work in this version of SYNCSORT.

Thanks

Re: Add Sequence no for records under a group

PostPosted: Sat Apr 14, 2012 12:19 am
by dick scherrer
Hello,

i use SYNCSORT 1.3.2.2R.

WHEN=GROUP does not work in this version of SYNCSORT.

According to my 1.3 manual, WHEN=GROUP is supported.

It may help if you post your diagnostic output as well as the jcl and sort control submitted.

Re: Add Sequence no for records under a group

PostPosted: Sat Apr 14, 2012 2:34 am
by Thampy
Try the below Syncsort JCL. RESTART subparameter specifies that the sequence numbering is restarted when the value in the RESTART field changes

//STEP010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
4529123AAB
4529123ABB
4529123ACC
1293940ABB
1293940ACC
1929303AAB
1929303ABB
1929303ACC
1929303ADD
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,10,SEQNUM,5,ZD,RESTART=(1,7))
//*

Output

4529123AAB00001
4529123ABB00002
4529123ACC00003
1293940ABB00001
1293940ACC00002
1929303AAB00001
1929303ABB00002
1929303ACC00003
1929303ADD00004

Re: Add Sequence no for records under a group

PostPosted: Sat Apr 14, 2012 10:54 pm
by Falcon
Thampy,
Thanks a lot. It works.

Dick,
I tried to use WHEN=GROUP and it gave me the below messages.

********************************* TOP OF DATA **********************
 SYNCSORT FOR Z/OS  1.3.2.2R    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                                          XXXXXXXXXXXXXXXX   z/OS
 SYNCSORT LICENSED FOR CPU SERIAL NUMBER XXXXXXXXXXXXXXXXXXXXXX     
 SYSIN :                                                           
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(11:SEQ=5))           
                          *                                         
 WER268A  INREC STATEMENT   : SYNTAX ERROR                         
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                     
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                     
******************************** BOTTOM OF DATA ********************

Re: Add Sequence no for records under a group

PostPosted: Sun Apr 15, 2012 12:37 am
by BillyBoyo

Re: Add Sequence no for records under a group

PostPosted: Sun Apr 15, 2012 2:51 am
by Akatsukami
Is not the keyword BEGIN rather than KEYBEGIN?

Re: Add Sequence no for records under a group

PostPosted: Sun Apr 15, 2012 3:40 am
by BillyBoyo
BEGIN and KEYBEGIN exist in DFSORT.

For Syncsort, I don't know, as documentation is only available to those with the product.

EDIT: Having searched this forum for KEYBEGIN and only found four references, all in this topic (five now, I guess) I'd think it not valid in TS/OP's Syncsort.

Re: Add Sequence no for records under a group

PostPosted: Sun Apr 15, 2012 5:01 am
by dick scherrer
Hello,

From something i posted elsewhere:
The syntax provided will not work with Syncsort. Syncsort does however support WHEN=GROUP.

Suggest you read about BEGIN instead of KEYBEGIN (i've never done this, but this is in the manual).

and from someone else
This will work with Syncsort:
//STEP0001 EXEC PGM=SYNCSORT                                       
//SORTIN   DD   *                                                   
ABC ID1 2001-08-25 XXXXX                                           
ABC ID1 2005-04-30 YYYYYY                                           
ABC ID2 1987-08-25 123456                                           
ABC ID2 2011-09-21 123789                                           
ABC ID2 2003-04-25 123456                                           
ABC ID3 2005-04-30 FFFFFFF                                         
DEF ID3 2005-04-30 FFF333                                           
/*                                                                 
//SORTOUT  DD   SYSOUT=*                                           
//SYSOUT   DD   SYSOUT=*                                           
//SYSIN    DD   *                                                   
  SORT FIELDS=(1,7,CH,A,9,10,CH,D)                                 
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7))) 
  OUTFIL INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)                       
/*


I don't have the 1.3 documentation available this weekend, but will check the specifics on Monday if you remind me.