Posted: Sun Oct 14, 2007 1:06 pm Post subject: Copy records before and after
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.
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.
Joined: 13 Dec 2006 Posts: 101 Topics: 4 Location: india
Posted: Mon Oct 15, 2007 8:16 am Post subject:
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? _________________ cHEERs
krisprems
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. _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Oct 15, 2007 1:05 pm Post subject:
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
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Jul 29, 2008 4:25 pm Post subject:
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:
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