IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

inserting sequence numbers using syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Mon Jan 07, 2008 3:55 pm
Reply with quote

Hi,

i have the following file.

23456
asdf
asd
asdfg
.2345
bhgh
ghjgfj
jfgj
jjgf
.4567
nbnhdf
mgmgf
mhmhk

i want an output like below.

0123456
02asdf
03asd
04asdfg
01.2345
02bhgh
03ghjgfj
04jfgj
05jjgf
01.4567
02nbnhdf
03mgmgf
04mhmhk

whenever the first byte is x'.', the sequence number should be re-initialized and start from 1....
how can this be done using syncsort. Please clarify
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Jan 07, 2008 4:22 pm
Reply with quote

Priya,

Quote:
23456


Quote:
whenever the first byte is x'.', the sequence number should be re-initialized


Quote:
0123456

Show correct i/p and o/p?
Back to top
View user's profile Send private message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Mon Jan 07, 2008 4:28 pm
Reply with quote

reinitialized means again start from 01, 02, 03...in the example i have taken a 2 byte sequence number..
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon Jan 07, 2008 5:13 pm
Reply with quote

Hi There,

You can use following sort card

Code:
OPTION COPY                         
OUTREC FIELDS=(1:SEQNUM,2,ZD,3:1,80)


Here I assume ur input record length as 80 U can change change it as per ur requirement.

Please let me know if you have any query regarding this.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Jan 07, 2008 5:19 pm
Reply with quote

Code:
//*****************************************************
//STEP1    EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
23456                                                 
ASDF                                                   
ASD                                                   
ASDFG                                                 
.2345                                                 
BHGH                                                   
GHJGFJ                                                 
JFGJ                                                   
JJGF                                                   
.4567                                                 
NBNHDF                                                 
MGMGF                                                 
MHMHK                                                 
/*                                                     
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD)),   
        IFTHEN=(WHEN=(1,1,CH,EQ,C'.'),                                 
                OVERLAY=(81:SEQNUM,2,ZD)),                             
        IFTHEN=(WHEN=(1,1,CH,NE,C'.'),                                 
                OVERLAY=(89:SEQNUM,2,ZD,                               
                         81:81,2,ZD,SUB,89,2,ZD,M11,LENGTH=2))         
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1:SEQNUM,2,ZD,RESTART=(81,2),3:1,78))
/*                                                                     
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Jan 07, 2008 5:26 pm
Reply with quote

Hello,

Murali is saying that one of the record (23456) from you input shown does not have any dot ( "." ), what sequence no. should be there for this in output.
Back to top
View user's profile Send private message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Mon Jan 07, 2008 5:28 pm
Reply with quote

Thanks Krisprems.
can u explain the 3rd and 4th sysin card?


Thanks.
Gpriya
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Jan 07, 2008 5:36 pm
Reply with quote

the trick i have used is variation of "how to handle records in groups"
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts Inserting variable length into output... JCL & VSAM 2
Search our Forums:

Back to Top