Add Sequence no for records under a group



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Add Sequence no for records under a group

Postby Falcon » Sat Apr 14, 2012 12:00 am

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
Regards,
Ian Padayachi
Falcon
 
Posts: 7
Joined: Fri Jul 09, 2010 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Add Sequence no for records under a group

Postby dick scherrer » Sat Apr 14, 2012 12:19 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Add Sequence no for records under a group

Postby Thampy » Sat Apr 14, 2012 2:34 am

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
Thampy
 
Posts: 36
Joined: Sat Sep 26, 2009 2:27 pm
Has thanked: 0 time
Been thanked: 3 times

Re: Add Sequence no for records under a group

Postby Falcon » Sat Apr 14, 2012 10:54 pm

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 ********************
Regards,
Ian Padayachi
Falcon
 
Posts: 7
Joined: Fri Jul 09, 2010 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Add Sequence no for records under a group

Postby BillyBoyo » Sun Apr 15, 2012 12:37 am

BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Add Sequence no for records under a group

Postby Akatsukami » Sun Apr 15, 2012 2:51 am

Is not the keyword BEGIN rather than KEYBEGIN?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Add Sequence no for records under a group

Postby BillyBoyo » Sun Apr 15, 2012 3:40 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Add Sequence no for records under a group

Postby dick scherrer » Sun Apr 15, 2012 5:01 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post