MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deleting consecutive records using Sort/Fileaid

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
newuser
Beginner


Joined: 12 Jun 2003
Posts: 16
Topics: 8

PostPosted: Wed Jun 22, 2005 11:07 am    Post subject: Deleting consecutive records using Sort/Fileaid Reply with quote

Hello,

Just trying my luck in this forum for a sort/fileaid solution.

I have Syncsort, Fileaid. Unfortunately I dont have DFSORT. I prefer not to use SAS, EZtrieve,rexx etc.

I have a dataset (VBM format) with some records. I want to delete a record satisfying a particular condition (say value of ABC in position n). Apart from deleting that record it must delete the next record also. This scenario happens when there are two records as header in the file (always in pairs).

The first header record can be identified by a condition, but there is no identifier for the second header record except that it will be the next
record to the first header record. I want to delete the headers satisfying particular condition.

Eg:
File is like this

Code:

Heading1ABC
heading2 AAA
aaaaaaaaaaaaa
Heading1XYZ
heading2 BBB
sometext
sometext
Heading1ABC
heading2 CCC
Heading1DEF
heading2 DDD
Heading1ABC
heading2 EEE

The output should be
Code:

aaaaaaaaaaaaa
Heading1XYZ
heading2 BBB
sometext
sometext
Heading1DEF
heading2 DDD

That is, record satisfying condition ABC must be deleted along with the
subsequent record.

Thanks
Kumar
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jun 22, 2005 11:20 am    Post subject: Reply with quote

Newuser,

The following JCL will give you the desired results. A brief explanation of the job.

The first steps takes in the input file and adds a constant of '1' or '0' to all the records depending on the search string. If string ABC is found on the record then the indicator will be '1' else it would be 0. we also will add seqnum which serves as a record no.

using outrec fields we add the constant to the record-no , so that the header records to be deleted will have the same record-no. Now doing sumsort on the record-no , we can eliminate the dups(same record-no is a dup) and use an omit cond to eliminate the first header record.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=YOUR INPUT VBM FILE,
//            DISP=SHR                           
//SORTOUT  DD DSN=&T1,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC FIELDS=(1,5,                                         
                6:14,3,CHANGE=(1,C'ABC',C'1'),NOMATCH=(C'0'),
                SEQNUM,8,ZD,6)                               
  OUTREC FIELDS=(1,5,                                       
                 6,1,ZD,ADD,7,8,ZD,EDIT=(TTTTTTTT),15)       
/*                                                           
//STEP0200 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=&T1,
//            DISP=SHR                           
//SORTOUT  DD DSN=YOUR OUTPUT VBM FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                                 
  OPTION EQUALS                                                 
  SORT FIELDS=(6,8,CH,A)                                         
  SUM FIELDS=NONE                                               
  OUTFIL OMIT=(22,3,CH,EQ,C'ABC'),                               
  OUTREC=(1,5,14)                                               
/*                           


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
newuser
Beginner


Joined: 12 Jun 2003
Posts: 16
Topics: 8

PostPosted: Wed Jun 22, 2005 12:28 pm    Post subject: Reply with quote

This is simply great, Kolusu ! Exactly the solution I was looking for...I tried in a similar site for the solution, but didnot have luck there.

I tried your 2 simple steps and it works like a charm and that too, I received the solution in no time.

This site is great and I will definitely recommend this site to others. And, Kolusu you are simply great!

Thanks & Best Regards
Kumar
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group