IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Append ENDDATE using STARTDATE from next rec with same key


 
IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: :: View next topic  
Author Message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Jun 08, 2015 4:44 pm
Reply with quote

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
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Tue Jun 09, 2015 4:14 am
Reply with quote

Have a look at this one to try to get you going.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Tue Jun 09, 2015 3:27 pm
Reply with quote

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))         
/*                                                           
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Tue Jun 09, 2015 5:43 pm
Reply with quote

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:

Code:
 JOIN UNPAIRED,F1
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> SYNCSORT
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts How to append data from PARM in OUTFIL DFSORT/ICETOOL 17
No new posts Append the milliseconds to the data s... DFSORT/ICETOOL 1
No new posts Append data from two files into a sin... DFSORT/ICETOOL 5
No new posts SORT to append Month and YEAR in MMYY... DFSORT/ICETOOL 1
No new posts Append to file, but also remove old r... JCL & VSAM 3

Back to Top