TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Hi,
We have SYNCSORT v1.4.2
I have an input file as below:
Code: |
AA P 1990
AA P 1995
AA P 2003
AA C 2007
BB P 1985
BB C 2005 |
Byte 1-2 = KEY
Byte 4 = P=Previous, C=Current
Byte 6-10 = Year of commencement
I would like to append the start date (as an end date) of the next record after the start date of the each record grouped on common key.
For current records (position 4='C' should have end date as spaces.
Hence the output should be like
Code: |
AA P 1990 1995
AA P 1995 2003
AA P 2003 2007
AA C 2007
BB P 1985 2005
BB C 2005 |
|
|
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Hi Bill,
Thanks,
I could solve it
Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,2,A,15,5,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,2,A,15,5,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
SORT FIELDS=COPY
REFORMAT FIELDS=(F1:1,20,F2:1,20)
OUTFIL FILES=OUT,INCLUDE=(1,2,CH,NE,C' '),
BUILD=(1,9,X,26,4)
/*
//JNF1CNTL DD *
INREC OVERLAY=(15:SEQNUM,5,ZD,START=1,RESTART=(1,2))
/*
//JNF2CNTL DD *
INREC OVERLAY=(15:SEQNUM,5,ZD,START=0,RESTART=(1,2))
/*
|
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Looks almost there, so good work.
Thing you need to look at is this:
Code: |
JOIN UNPAIRED,F1,F2 |
You will get two unmatched records, the first of one file and the last of the other.
Code: |
XXX 0
1 <-> 1
2 <-> 2
3 <-> 3
4 <-> 4
5 <- |
The first record on F2 (the sequence-number zero record) you do not want. So:
|
|