Copy records before and after
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: Copy records before and after Author: Martin PostPosted: Sun Oct 14, 2007 1:06 pm
    —
Hi All,

Here's a brief description of the problem. I have a input file which has a header( group of records) , records and a trailer( group of records).

I need to copy the header , selective records and the trailer.

Ex:

Code:


Input file

1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
.
.
.
.
2007sort1234454545
set of records
.
.
.
.
.
2005sort1234454545
2006sort1234454545
2008sort1234454545
2008sort1234454545
2007sort888999898
set of records
.
.
.
.
.
.
.
.
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
.
.
.
.
End of file.

Output file :

1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
.
.
.
.
2007sort1234454545
set of records
.
.
.
.
.
2007sort888999898
set of records
.
.
.
.
.
.
.
.
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
.
.
.
.
End of file.




Output file should contain:

- All the header records.
- All 2007 records.( Here all the set of records under 2007 should be copied over)
- All the trailer record.

In other words I need to exclude all the records which does not belong to 2007 year.

Any solutions?

-Mt

#2:  Author: CICS Guy PostPosted: Sun Oct 14, 2007 4:10 pm
    —
Have you looked at INCLUDE/OMIT in the sort manual?
This sounds like a very simple task for even a beginner....

#3:  Author: Martin PostPosted: Mon Oct 15, 2007 12:40 am
    —
CICS Guy,

The problem that am facing here is how do I exclude the set of records which come under the 2005,2006,2008 records. There is no unique identifier for these records.

-Mt

#4:  Author: CICS Guy PostPosted: Mon Oct 15, 2007 6:59 am
    —
Well, you either have to have something unique in the headers and trailers or something unique in the details - one or the other.......

#5:  Author: krispremsLocation: india PostPosted: Mon Oct 15, 2007 8:16 am
    —
Martin
Quote:

1xxxxxxxxxxxxxxxx -- > Header record
2xxxxxxxxxxxxxxxx -- > Header record
3xxxxxxxxxxxxxxxx -- > Header record

The headers or the trailers that you have shown, is there any way to identify these records(any uniqueness), and also are these 1st three and last three records of your input file?

#6:  Author: vivek1983 PostPosted: Mon Oct 15, 2007 8:40 am
    —
Martin,

I am assuming that the no of header records and the trailer records = 3 and that there are any only one set of header and trailer records.

Try my below suggestion:

1. Extract the first 3 records to a temporary dataset t1.
2. Extract the last 3 records to a temporary dataset t2.
3. Extract the inbetween records with INCLUDE COND=(1,4,CH,EQ,C'2007') to a temporary dataset t3.
4. Concatenate the datasets T1 + T3 + T2 and place it in the output file.

As I am at home cannot provide u with the JCL now.

#7:  Author: Frank YaegerLocation: San Jose PostPosted: Mon Oct 15, 2007 1:05 pm
    —
Martin,

You haven't given much detail about what your input records actually look like. But I'll make some assumptions so I can show you how to do this kind of thing with DFSORT/ICETOOL. I'll assume that:
- the first header record and the first trailer record have '1' in position 1 and none of the other input records do
- the year records have '20' in positions 1-2 and none of the other input records do
- the input file has RECFM=FB and LRECL=80

Given those assumptions, here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
2007sort1234454545
Record 01 A
Record 02 B
2005sort1234454545
2006sort1234454545
2008sort1234454545
Record 01 X
2008sort1234454545
2007sort888999898
Record 01 C
Record 02 D
Record 03 3
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
/*
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
SPLICE FROM(IN) TO(OUT) ON(85,8,ZD) KEEPNODUPS KEEPBASE -
  WITHALL WITH(1,80) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,4,85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(81,2,CH,EQ,C'20',OR,81,1,CH,EQ,C'1'),
                OVERLAY=(85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(93:SEQNUM,8,ZD,
                         85:85,8,ZD,SUB,93,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,
    INCLUDE=(81,4,CH,EQ,C'2007',OR,81,1,CH,EQ,C'1'),
    BUILD=(1,80)
/*


OUT would have:

Code:

1xxxxxxxxxxxxxxxx  -- > Header record         
2xxxxxxxxxxxxxxxx  -- > Header record         
3xxxxxxxxxxxxxxxx  -- > Header record         
2007sort1234454545                             
Record 01 A                                   
Record 02 B                                   
2007sort888999898                             
Record 01 C                                   
Record 02 D                                   
Record 03 3                                   
1xxxxxxxxxxxxxxxx  -- > Trailer record         
2xxxxxxxxxxxxxxxx  -- > Trailer record         
3xxxxxxxxxxxxxxxx  -- > Trailer record         

#8:  Author: Frank YaegerLocation: San Jose PostPosted: Tue Jul 29, 2008 4:25 pm
    —
Here's an easier and more efficient way to do this using the new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008):

Code:

//S1  EXEC  PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
2007sort1234454545
Record 01 A
Record 02 B
2005sort1234454545
2006sort1234454545
2008sort1234454545
Record 01 X
2008sort1234454545
2007sort888999898
Record 01 C
Record 02 D
Record 03 3
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
/*
//OUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,
          BEGIN=(1,2,CH,EQ,C'20',OR,1,1,CH,EQ,C'1'),
          PUSH=(81:1,4))
  OUTFIL INCLUDE=(81,4,CH,EQ,C'2007',OR,81,1,CH,EQ,C'1'),
    BUILD=(1,80)
/*


For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group