Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

inserting sequence numbers using syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: inserting sequence numbers using syncsort
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: 1439
Location: Bangalore,India

PostPosted: Mon Jan 07, 2008 4:22 pm    Post subject:
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    Post subject:
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: 1187
Location: Bangalore,India

PostPosted: Mon Jan 07, 2008 5:13 pm    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Mon Jan 07, 2008 5:26 pm    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us