View previous topic :: View next topic
|
Author |
Message |
Prosenjit001
New User
Joined: 02 Nov 2011 Posts: 14 Location: India
|
|
|
|
Hi ,
I have one file as below -
Code: |
abc 123
def 123
dfg 4566
dgh 4510
xyz 541
dafa 8956
dfff 122
|
I want to copy the records till xyz ( position is fixed 1 to 3) , but i dont know record number of xyz , it can be record number 5 or can be record number 10 , can be anything .
How it is possible using SORT . please suggest .
O/P should be -
Code: |
abc 123
def 123
dfg 4566
dgh 4510
xyz 541 |
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
something like this should work
Code: |
000004 //S1 EXEC PGM=SORT
000005 //SYSPRINT DD SYSOUT=*
000006 //SYSOUT DD SYSOUT=*
000007 //SORTIN DD *
000008 AAA
000009 BBB
000010 CCC
000011 XYZ
000012 EEE
000013 FFF
000014 GGG
000015 XYZ
000016 HHH
000017 //SORTOUT DD SYSOUT=*,
000018 // DCB=(RECFM=FB,LRECL=80)
000019 //SYSIN DD *
000020 SORT FIELDS=COPY
000021 INREC IFTHEN=(WHEN=GROUP,END=(1,3,CH,EQ,C'XYZ'),
000022 PUSH=(81:ID=4))
000023 OUTFIL INCLUDE=(81,4,ZD,EQ,1),BUILD=(1,80) |
to get
Code: |
********************************* TOP OF DATA **********************************
AAA
BBB
CCC
XYZ
******************************** BOTTOM OF DATA ******************************** |
if You are sure that there are no more than 9 XYZ occurrences
than You can be stingy and instead of a 4 chars group id use a 1 char group id
in other words use a group id with enough digits to take care of the maximum number of occurrences of XYZ
This technique is described in the "Include or omit groups of records" Smart DFSORT Trick at:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
but Frank, as usual, might come up with a better solution |
|
Back to top |
|
|
Prosenjit001
New User
Joined: 02 Nov 2011 Posts: 14 Location: India
|
|
|
|
Hi Enrico ,
Thank you verymuch for sort card you have provided , it is working fine : |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Thank you verymuch for sort card you have provided , it is working fine |
glad that it helped,
but I still strongly suggest that You meditate a bit or better ( given the trend ) 64 bits
on the document pointed by the link posted |
|
Back to top |
|
|
|