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 

Remove Duplicate Headers and Trailers

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


Joined: 12 Oct 2004
Posts: 13
Topics: 6

PostPosted: Mon Sep 17, 2007 8:13 am    Post subject: Remove Duplicate Headers and Trailers Reply with quote

I have an Input File of LRECL=80 with multiple header,detailed and trailer record

The First three Bytes=
HDR represents header Record
DET represents Detailed Records
TRL Represents the Trailer record

I need to extract the first header record, the detailed records and the last trailer record.The intermediate header and trailer records has to be deleted
NOTE:The first header record value and the intermediate header record value need not be same only the first three bytes will be same
Similarly the last trailer record value and the intermediate trailer record value need not be same only the first three bytes will be same
Is it possible to solve the problem using PGM=SORT in one step (one pass)

INPUT
Code:

HDR     ----- 1st Header
DET2001
DET2006
DET2002
TRL
HDR
DET2003
DET2000
TRL
HDR
DET2000
DET2009
TRL      ----- Last header

OUTPUT
Code:

HDR     ----- 1st Header
DET2001
DET2006
DET2002
DET2003
DET2000
DET2000
DET2009
TRL      ----- Last header

_________________
Thanks & Rgds
Dinesh
Back to top
View user's profile Send private message Yahoo Messenger
Dinesh Kumar
Beginner


Joined: 12 Oct 2004
Posts: 13
Topics: 6

PostPosted: Mon Sep 17, 2007 8:16 am    Post subject: Reply with quote

The data content is as stated below
INPUT
Code:

HDR ----- 1st Header
DET2001
DET2006
DET2002
TRL
HDR
DET2003
DET2000
TRL
HDR
DET2000
DET2009
TRL ----- Last Trailer

OUTPUT
Code:
 
HDR ----- 1st Header
DET2001
DET2006
DET2002
DET2003
DET2000
DET2000
DET2009
TRL ----- Last Trailer

_________________
Thanks & Rgds
Dinesh
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Sep 17, 2007 9:54 am    Post subject: Reply with quote

Quote:

Is it possible to solve the problem using PGM=SORT in one step (one pass)

Dinesh Kumar,

AFAIK Getting the last trailer record within 1 one pass is kinda difficult. I can get the 1st header and details without any problem. If 2 passes of the data is okay then let me know

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


Joined: 04 Sep 2007
Posts: 4
Topics: 0

PostPosted: Mon Sep 17, 2007 10:36 am    Post subject: Reply with quote

Dinesh Kumar,

Please check with the following code for your requirement.

Code:
// EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD DSN=INFILE,DISP=SHR
//T DD DSN=&&T,DISP=(,PASS)
//OUT DD DSN=OUTFILE,.....
//TOOLIN DD *
 SORT FROM(IN) TO(T) USING(CTL1)
 SORT FROM(T) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
 INREC  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD)),
        IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),OVERLAY=(90:SEQNUM,9,ZD)),
        IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),OVERLAY=(90:SEQNUM,9,ZD))
 SORT FIELDS=(90,9,ZD,D),EQUALS
 OUTFIL IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),OVERLAY=(99:SEQNUM,9,ZD)),
        IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),OVERLAY=(99:SEQNUM,9,ZD))
/*
//CTL2CNTL DD *
 INCLUDE COND=((90,9,ZD,EQ,1,AND,1,3,CH,EQ,C'HDR'),OR,
               (99,9,ZD,EQ,1,AND,1,3,CH,EQ,C'TRL'),OR,
               (1,3,CH,EQ,C'DET'))
 SORT FIELDS=(81,9,ZD,A)
 OUTFIL OUTREC=(1,80)
/*
//
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: Mon Sep 17, 2007 11:57 am    Post subject: Reply with quote

shankar.v,

OP wanted a 1 pass solution.

If 2 pass solution is fine then here is a simpler version with just 1 copy and 1 sort.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*                                   
//SORTIN    DD *                                         
HDR     ----- 1ST HEADER                                 
DET2001                                                   
DET2006                                                   
DET2002                                                   
TRL                                                       
HDR                                                       
DET2003                                                   
DET2000                                                   
TRL                                                       
HDR                                                       
DET2000                                                   
DET2009                                                   
TRL     ----- LAST HEADER                                 
//T1        DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2        DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN     DD *                                         
  SORT FIELDS=COPY                                       
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                     
  INCLUDE=(1,3,SS,EQ,C'HDR,TRL'),                         
  HEADER1=(01,80),                                       
  TRAILER1=(01,80)                                       
  OUTFIL FNAMES=T2,                                       
  INCLUDE=(1,3,CH,EQ,C'DET')                             
/*                     
//STEP0200 EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*                 
//SORTIN    DD DSN=&T1,DISP=SHR         
//          DD DSN=&T2,DISP=SHR         
//SORTOUT   DD SYSOUT=*                 
//SYSIN     DD *                       
  OPTION EQUALS                         
  SORT FIELDS=(81,1,CH,A)               
  INREC IFTHEN=(WHEN=INIT,             
        OVERLAY=(81:C'1')),             
        IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),
        OVERLAY=(81:C'0')),             
        IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
        OVERLAY=(81:C'2'))             
                                       
  OUTREC BUILD=(01,80)                 
/*                     


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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