Page 1 of 1

Delete duplicate headers and keep group records

PostPosted: Tue Feb 17, 2009 10:58 pm
by Irene Ioujanina
Hi, I really appreciate if you can help with the following... There are groups of records, each group starts with one record of the header. Need to keep the sequence of all records, and just delete the same headers ... Can recognize the header record by the constant 'Header' in 1thru 6 positions.
Input:
---------
Header A1
data1
data2
data3
header A2
data4
data5
header A2
data6
data7
header A2
data8
header A3
data9

Output:
----------
Header A1
data1
data2
data3
header A2
data4
data5
data6
data7
data8
header A3
data9

Thanking in advance.

Re: Delete duplicate headers and keep group records

PostPosted: Wed Feb 18, 2009 12:24 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for. I changed 'header' to 'Header' in your records per your statement:

Can recognize the header record by the constant 'Header' in 1thru 6 positions


If the identifier is really 'header' instead of 'Header', change the job accordingly.

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
Header A1
data1
data2
data3
Header A2
data4
data5
Header A2
data6
data7
Header A2
data8
Header A3
data9
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,6,CH,EQ,C'Header'),
    OVERLAY=(81:SEQNUM,8,ZD,RESTART=(8,2)))
  OUTFIL OMIT=(81,8,ZD,GT,1),BUILD=(1,80)
/*

Re: Delete duplicate headers and keep group records

PostPosted: Wed Feb 18, 2009 12:44 am
by Irene Ioujanina
Brilliant . well....as usual :) .
Thanks a lot.