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
 

 

copy until a particular string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: copy until a particular string
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Fri Jan 27, 2012 2:01 pm    Post subject: Reply to: copy until a particular string
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:

http://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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Fri Jan 27, 2012 2:23 pm    Post subject: Reply to: copy until a particular string
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts copy SEQ to PDS and create stats steve-myers JCL & VSAM 7 Thu Apr 27, 2017 1:15 am
No new posts Copy load modules and alias vasanthz IBM Tools 5 Thu Apr 20, 2017 6:31 am
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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