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

copy until a particular string


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

New User


Joined: 02 Nov 2011
Posts: 14
Location: India

PostPosted: Fri Jan 27, 2012 1:01 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Jan 27, 2012 2:01 pm
Reply with quote

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
View user's profile Send private message
Prosenjit001

New User


Joined: 02 Nov 2011
Posts: 14
Location: India

PostPosted: Fri Jan 27, 2012 2:12 pm
Reply with quote

Hi Enrico ,

Thank you verymuch for sort card you have provided , it is working fine : icon_biggrin.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Jan 27, 2012 2:23 pm
Reply with quote

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 icon_biggrin.gif
on the document pointed by the link posted
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Need COBOL COPY Help in MVS Environment COBOL Programming 4
Search our Forums:

Back to Top