Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Append ENDDATE using STARTDATE from next rec with same key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
TS70363

New User


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

PostPosted: Mon Jun 08, 2015 4:44 pm    Post subject: Append ENDDATE using STARTDATE from next rec with same key
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Jun 09, 2015 4:14 am    Post subject: Reply to: Append ENDDATE using STARTDATE from next rec with same key
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: 93
Location: Bangalore, India

PostPosted: Tue Jun 09, 2015 3:27 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Jun 09, 2015 5:43 pm    Post subject: Reply to: Append ENDDATE using STARTDATE from next rec with same key
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Append to file, but also remove old r... Garry Carroll JCL & VSAM 3 Mon Jan 25, 2016 8:05 pm
No new posts Append data from another file Abdul Lateef DFSORT/ICETOOL 4 Mon Apr 13, 2015 3:49 pm
No new posts APPEND in PUT CONTAINER sambap CICS 3 Tue Aug 12, 2014 5:36 pm
No new posts Append a 6 byte string after the each... Chanchal Majumder JCL & VSAM 10 Tue Jun 04, 2013 1:34 pm
No new posts How to append leading zeros using SORT senthilnathanj JCL & VSAM 5 Wed Oct 24, 2012 11:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us