Kristie Boaler
New User
Joined: 27 Nov 2006 Posts: 3 Location: Australia
|
|
|
|
Hi,
I need to merge 2 files which have 2 types of records - header records which start with X'80' and detail records which start with X'A8'. The records are to be merged based on a timestamp in the header record, while keeping the header and detail records grouped as they were in the original file eg.
File1
-----
X'80134310'
X'A8D4D5E2E4'
X'A8C6D5D9C3E25B'
X'80134550'
X'A8C6D5D5C65B5B'
File2
-----
X'80134420'
X'A8D5D5C3E3'
Merged File
-------------
X'80134310'
X'A8D4D5E2E4'
X'A8C6D5D9C3E25B'
X'80134420'
X'A8D5D5C3E3'
X'80134550'
X'A8C6D5D5C65B5B'
All the records are variable length, and there's 2-4 detail records for each header. I think I need to use IFTHEN and OVERLAY statements to keep the records grouped together. Any suggestions would be much appreciated.
Thanks,
Kristie |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT/ICETOOL job that will do what you asked for. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use INREC with SPLICE. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
Use [URL] BBCode for External Links
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file1 (VB/10244)
// DD DSN=... input file2 (VB/10244)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (VB/10244)
//TOOLIN DD *
SPLICE FROM(CON) TO(T1) ON(8,8,ZD) KEEPBASE -
WITHALL WITH(24,10240) VLENOVLY USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8:SEQNUM,8,ZD,24:5)),
IFTHEN=(WHEN=(24,1,BI,EQ,X'80'),
OVERLAY=(5:25,3,8:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,
OVERLAY=(16:SEQNUM,8,ZD,
8:8,8,ZD,SUB,16,8,ZD,M11,LENGTH=8))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(5,3,BI,A)
OUTREC BUILD=(1,4,5:24)
/*
|
|
|