IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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: 7309
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: 7309
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Duplicate data in PUT CONTAINER using... CICS 4
No new posts I want to append a record in an exist... CLIST & REXX 17
No new posts How to append Previous date into a S... JCL & VSAM 2
Search our Forums:

Back to Top