View previous topic :: View next topic
|
Author |
Message |
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
Thank you it worked |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
|