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

How to get the records when sequnce number is reset


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed Jun 16, 2010 2:50 pm
Reply with quote

hi ,
I have some data like in the sample blow , i want the output to display
only those records where the dequence number is reset.
here the last 3 digits are the sequence number , its FB , ReclLen 80 bytes

Input :

AHB N 81 001
AHB N 81 002
AHB N 81 003
AHB N 81 004
AHB P 41 001
AHB P 41 002
AHB P 41 003
AHB P 41 004
AHB P 41 005
AHB P 45 001
AHB P 45 002
HB0 E 45 001
HB0 E 45 002
HB0 E 45 003

Output :
AHB N 81 004
AHB P 41 005
AHB P 45 002
HB0 E 45 003
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Jun 16, 2010 3:31 pm
Reply with quote

Hi,

here is a possible way
Code:
//STEP0100 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD *                         
AHB N 81 001                             
AHB N 81 002                             
AHB N 81 003                             
AHB N 81 004                             
AHB P 41 001                             
AHB P 41 002                             
AHB P 41 003                             
AHB P 41 004                             
AHB P 41 005                             
AHB P 45 001                             
AHB P 45 002                             
HB0 E 45 001                             
HB0 E 45 002                             
HB0 E 45 003   
/*                         
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                     
  SORT FIELDS=COPY                   
  OUTFIL REMOVECC,NODETAIL,         
  SECTIONS=(1,08,TRAILER3=(1,80))   
/*                                   
           


Gerry
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed Jun 16, 2010 7:43 pm
Reply with quote

Thank you it worked
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jun 16, 2010 7:48 pm
Reply with quote

Nice one Gerry. Only one comment though
Would it not be better to use
Code:
//SYSIN    DD *                   
  SORT FIELDS=(1,12,CH,A)         
  OUTFIL REMOVECC,NODETAIL,       
  SECTIONS=(1,08,TRAILER3=(1,80))
Which would also cater for the records not already being in sort order.

I was going to suggest using a SELECT statement in ICETOOL but then I would have had to perform a sort beforehand to ensure that the records were in the correct order. Using your method, amended to sort the data, it's only one pass of the data whether the records are correctly sorted or not.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jun 16, 2010 10:55 pm
Reply with quote

Assuming the records are already in the correct order by 1-8, SELECT can do it using COPY like this:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
AHB N 81 001
AHB N 81 002
AHB N 81 003
AHB N 81 004
AHB P 41 001
AHB P 41 002
AHB P 41 003
AHB P 41 004
AHB P 41 005
AHB P 45 001
AHB P 45 002
HB0 E 45 001
HB0 E 45 002
HB0 E 45 003
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,8,CH) LAST USING(CTL1)
/*
//CTL1CNTL DD *
  OPTION COPY
/*


If the records are NOT in the correct order, then you'd just have to remove OPTION COPY and let SELECT do a SORT.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Jun 17, 2010 11:33 am
Reply with quote

Thanks Frank,

As a rather infrequent user of DFSORT and hence not frequently nose diving into the manuals, I have now learnt that I can use USING with a SELECT. Another one to stick into the archive.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top