MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syncsort - Make duplicate number to unique

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Mon Oct 29, 2007 3:45 pm    Post subject: Syncsort - Make duplicate number to unique Reply with quote

I have a account number as shown in the input. I want to add a two digit to the account number as 20 as shown in the output. If the account number is repeats then I need to increase it by one (21) and so on.



Input

----+----1
455521461
507461046
493182005
455521461
363161952
507461046
538101163
507461046
455521461

Output
----+----1-
53810116320
50746104620
50746104621
50746104622
49318200520
45552146120
45552146121
45552146122
36316195220
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
krisprems
Beginner


Joined: 13 Dec 2006
Posts: 101
Topics: 4
Location: india

PostPosted: Mon Oct 29, 2007 10:31 pm    Post subject: Reply with quote

hello chandra
in your i/p first record is
Quote:

455521461
, but in the o/p first record is
Quote:

538101163

So, on what basis are you sorting?
In your example where does the KEY start and what is its length?
_________________
cHEERs
krisprems
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Tue Oct 30, 2007 12:39 am    Post subject: Re: Syncsort - Make duplicate number to unique Reply with quote

Chandra,

The below code gives you the desired results.
Code:
//S1 EXEC PGM=ICEMAN                                           
//SYSOUT DD SYSOUT=*                                           
//SORTIN   DD  *                                               
455521461                                                       
507461046                                                       
493182005                                                       
455521461                                                       
363161952                                                       
507461046                                                       
538101163                                                       
507461046                                                       
455521461                                                       
/*                                                             
//SORTOUT DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SORTXSUM DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN DD *                                                   
  SORT FIELDS=(1,9,CH,A)                                       
  SUM FIELDS=NONE,XSUM                                         
/*                                                             
//S2    EXEC  PGM=ICETOOL                                       
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//IN DD DSN=&&T2,DISP=SHR                                       
//T3 DD DSN=T3.TEMP3,DISP=SHR       
//OUT DD SYSOUT=*                                               
//TOOLIN   DD    *                                               
SORT FROM(IN) TO(T3) USING(CTL1)                                 
SORT FROM(T3) TO(OUT) USING(CTL2)                               
/*                                                               
//CTL1CNTL DD *                                                 
  INREC OVERLAY=(10:SEQNUM,1,ZD)                                 
  SORT FIELDS=(1,9,CH,A)                                         
  OUTREC OVERLAY=(1:1,9,10:C'2',11:SEQNUM,1,FS,RESTART=(1,23))   
/*                                                               
//CTL2CNTL DD *                                                 
  SORT FIELDS=COPY                                               
/*                                                               
//S3      EXEC PGM=SORT                                         
//SORTIN   DD  DSN=&&T1,DISP=SHR                                 
//SORTOUT  DD  DSN=T4.TEMP4,DISP=SHR
//SYSOUT   DD  SYSOUT=*                                         
//SYSIN    DD  *                                                 
  SORT FIELDS=COPY                                               
  OUTREC FIELDS=(1:1,9,10:C'20')                                 
/*                                                               
//S4      EXEC PGM=SORT         
//SORTIN   DD  DSN=T3.TEMP3,DISP=SHR
//         DD  DSN=T4.TEMP4,DISP=SHR
//SORTOUT  DD  SYSOUT=*         
//SYSOUT   DD  SYSOUT=*         
//SYSIN    DD  *               
  SORT FIELDS=(1,11,CH,A)             
/*                             


SORTOUT of step S4 contains
Code:
36316195220
45552146120
45552146121
45552146122
49318200520
50746104620
50746104621
50746104622
53810116320
Back to top
View user's profile Send private message Send e-mail
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Tue Oct 30, 2007 1:44 am    Post subject: Reply with quote

If you don't want your output to be sorted i.e. if you want the output as is with just numbers (20,21,22) added at the end , then replace the sort card in the step S4 as below.
Code:
SORT FIELDS=COPY
Back to top
View user's profile Send private message Send e-mail
krisprems
Beginner


Joined: 13 Dec 2006
Posts: 101
Topics: 4
Location: india

PostPosted: Tue Oct 30, 2007 4:32 am    Post subject: Reply with quote

chandra
If it is OK to have the i/p field(1-9) sorted. Then this SORT JOB would be more enough.
Code:
//STEP1    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
455521461                                                               
507461046                                                               
493182005                                                               
455521461                                                               
363161952                                                               
507461046                                                               
538101163                                                               
507461046                                                               
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
455521461                                                               
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
           SORT FIELDS=(1,9,CH,A)                                       
           OUTREC OVERLAY=(10:SEQNUM,2,ZD,START=20,RESTART=(1,9))       
/*                                                                     


SORTOUT:
Code:
36316195220
45552146120
45552146121
45552146122
49318200520
50746104620
50746104621
50746104622
53810116320
Arrow Chandra, if this is not what you want please answer the questions from my previous post

vkphani, can't undestand as to why you have complicated so much Question
_________________
cHEERs
krisprems
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Tue Oct 30, 2007 4:45 am    Post subject: Reply with quote

krisprems,

good solution.
Back to top
View user's profile Send private message Send e-mail
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Tue Oct 30, 2007 5:06 am    Post subject: Reply with quote

chandra,

Change the sort order to descending in the sort card provided by Kris to get your desired output.

Code:


  SORT FIELDS=(1,9,CH,D)

 

_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
krisprems
Beginner


Joined: 13 Dec 2006
Posts: 101
Topics: 4
Location: india

PostPosted: Tue Oct 30, 2007 5:11 am    Post subject: Reply with quote

Quote:

krisprems,

good solution.
Thank you
Would like to hear the same from the person who started the topic Laughing
_________________
cHEERs
krisprems
Back to top
View user's profile Send private message
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Tue Oct 30, 2007 10:43 am    Post subject: Reply with quote

Hi all,

Thank you very much for the solution Krisprems and vkphani.

I want my output to be in sorted order which Krisprems shown.

Thanks once again
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group