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

Retain latest record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Thu Dec 22, 2011 5:55 pm
Reply with quote

I have an input file which has data for add, change or delete transactions. The fields are Action Type (pos 1-3), Key (pos 5-8) and Maintenance Timestamp.
Code:
ADD KEY1 2011-12-22-07.01.05.000000
CHG KEY2 2011-12-22-07.01.07.000000
DEL KEY3 2011-12-22-07.01.08.000000
ADD KEY4 2011-12-22-07.01.09.000000
CHG KEY4 2011-12-22-07.01.19.000000
CHG KEY4 2011-12-22-07.01.29.000000
DEL KEY4 2011-12-22-07.01.31.000000
ADD KEY5 2011-12-22-07.00.35.000000
CHG KEY5 2011-12-22-07.01.38.000000
CHG KEY6 2011-12-22-07.00.32.000000
CHG KEY6 2011-12-22-07.02.43.000000
CHG KEY7 2011-12-22-07.03.31.000000
DEL KEY7 2011-12-22-07.04.30.000000
DEL KEY8 2011-12-22-07.01.33.000000
ADD KEY8 2011-12-22-07.07.55.000000
CHG KEY8 2011-12-22-07.09.13.000000


In case multiple occurences of the key is present, the one with the latest timestamp needs to be retained. But if we have ADD as the first occurence for a particular key and DEL as the last occurence, then all the records for the key needs to be removed. Currently we are doing this using 8 SORT steps. The final output looks like this.

Code:
ADD KEY1 2011-12-22-07.01.05.000000
CHG KEY2 2011-12-22-07.01.07.000000
DEL KEY3 2011-12-22-07.01.08.000000
CHG KEY5 2011-12-22-07.01.38.000000
CHG KEY6 2011-12-22-07.02.43.000000
CHG KEY8 2011-12-22-07.09.13.000000


Is it possible to do this in a better way? Our installation has function level corresponding to z/OS DFSORT V1R5 PTF UK90007.

Thanks for your inputs.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Dec 22, 2011 9:44 pm
Reply with quote

remoonline,

Why is Key7 Eliminated from your output? It doesn't start with ADD as 1st record.

What is the LRECL and RECFM of the Input dataset
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Thu Dec 22, 2011 9:58 pm
Reply with quote

My apologies. Key7 should be part of the output.

Code:
ADD KEY1 2011-12-22-07.01.05.000000
CHG KEY2 2011-12-22-07.01.07.000000
DEL KEY3 2011-12-22-07.01.08.000000
CHG KEY5 2011-12-22-07.01.38.000000
CHG KEY6 2011-12-22-07.02.43.000000
DEL KEY7 2011-12-22-07.04.30.000000
CHG KEY8 2011-12-22-07.09.13.000000


RECFM is FB and LRECL 80
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Dec 22, 2011 10:20 pm
Reply with quote

remoonline,

It would take less than 8 passes of data if you have the latest PTF installed. You are behind on DFSORT functional PTFs. Ask your System Programmer to install z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026.

I will work something to work on your DFSORT level , but what do you do in this scenario? It doesn't start with ADD , but ends with DEL.

CHG KEY9 2011-12-22-07.01.09.000000
DEL KEY9 2011-12-22-07.01.19.000000
ADD KEY9 2011-12-22-07.01.29.000000
DEL KEY9 2011-12-22-07.01.31.000000


Can a single key have more than 1 ADD/DEL record?
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Thu Dec 22, 2011 10:38 pm
Reply with quote

For the example
Code:
CHG KEY9 2011-12-22-07.01.09.000000
DEL KEY9 2011-12-22-07.01.19.000000
ADD KEY9 2011-12-22-07.01.29.000000
DEL KEY9 2011-12-22-07.01.31.000000


the output will be
Code:
DEL KEY9 2011-12-22-07.01.31.000000


It is possible to have a ADD, then DEL and then again an ADD. The final file is a delta file used to keep other downstream systems in sync. So we don't need to keep recs which were created and deleted on same day.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Dec 23, 2011 9:59 pm
Reply with quote

remoonline,

use the following DFSORT/ICETOOL JCL which will give you the desired results.
Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN       DD *                                                   
----+----1----+----2----+----3----+----4----+----5----+----6----+-
ADD KEY1 2011-12-22-07.01.05.000000                               
CHG KEY2 2011-12-22-07.01.07.000000                               
DEL KEY3 2011-12-22-07.01.08.000000                               
ADD KEY4 2011-12-22-07.01.09.000000                               
CHG KEY4 2011-12-22-07.01.19.000000                               
CHG KEY4 2011-12-22-07.01.29.000000                               
DEL KEY4 2011-12-22-07.01.31.000000                               
ADD KEY5 2011-12-22-07.00.35.000000                               
CHG KEY5 2011-12-22-07.01.38.000000                               
CHG KEY6 2011-12-22-07.00.32.000000                               
CHG KEY6 2011-12-22-07.02.43.000000                               
CHG KEY7 2011-12-22-07.03.31.000000                               
DEL KEY7 2011-12-22-07.04.30.000000                               
DEL KEY8 2011-12-22-07.01.33.000000                               
ADD KEY8 2011-12-22-07.07.55.000000                               
CHG KEY8 2011-12-22-07.09.13.000000
//*                               
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)       
//T2       DD DSN=&&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)       
//OUT      DD SYSOUT=*                                           
//TOOLIN   DD *                                                   
  SPLICE FROM(IN) TO(T1) ON(5,4,CH) WITH(1,83) -                 
  WITHALL KEEPBASE KEEPNODUPS USING(CTL1)         
               
  SPLICE FROM(T1) TO(T2) ON(5,4,CH) WITH(1,80) -                 
  WITHALL KEEPBASE KEEPNODUPS USING(CTL2)                         

  SELECT FROM(T2) TO(OUT) ON(5,4,CH) FIRST USING(CTL3)           
//*
//CTL1CNTL DD *                                                   
  OPTION COPY                                                     
  INREC IFTHEN=(WHEN=INIT,                                       
  OVERLAY(81:1,3,3X,SEQNUM,8,ZD,RESTART=(5,4))),                 
  IFTHEN=(WHEN=(87,8,ZD,EQ,1),OVERLAY=(84:1,3))                   
  OUTFIL FNAMES=T1,                                               
  BUILD=(1,80,81:81,6,CHANGE=(1,C'DELADD',C'D'),NOMATCH=(C'K'))   
//*
//CTL2CNTL DD *                                           
  SORT FIELDS=(5,4,CH,A,81,1,CH,A),EQUALS                 
  OUTFIL FNAMES=T2,OMIT=(81,1,CH,EQ,C'D'),BUILD=(1,80)   
//*                                                       
//CTL3CNTL DD *                                           
  SORT FIELDS=(5,4,CH,A,10,26,CH,D),EQUALS               
//*
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Tue Dec 27, 2011 6:19 pm
Reply with quote

Thank you Kolusu for working on this. I made a slight change to make it work.

Code:
//IN       DD DSN=...             
//T1       DD DSN=&&T1,SPACE=(CYL,(5,5)),DISP=(,PASS)           
//T2       DD DSN=&&T2,SPACE=(CYL,(5,5)),DISP=(,PASS)           
//T3       DD DSN=&&T3,SPACE=(CYL,(5,5)),DISP=(,PASS)           
//OUT      DD DSN=...   
//TOOLIN   DD *                                                 
  SORT FROM(IN) TO(T1) USING(CTL1)                               
  SPLICE FROM(T1) TO(T2) ON(5,4,CH) WITHALL KEEPBASE KEEPNODUPS -
    WITH(1,83) USING(CTL2)                                       
  SPLICE FROM(T2) TO(T3) ON(5,4,CH) WITHALL KEEPBASE KEEPNODUPS -
    WITH(1,80) USING(CTL3)                                       
  SELECT FROM(T3) TO(OUT) ON(5,4,CH) FIRST USING(CTL4)           
/*                                                               
//CTL1CNTL DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,                                       
  OVERLAY(81:1,3,3X,SEQNUM,8,ZD,RESTART=(5,4))),                 
  IFTHEN=(WHEN=(87,8,ZD,EQ,1),OVERLAY=(84:1,3))                 
/*                                                               
//CTL2CNTL DD *                                               
  OUTFIL FNAMES=T2,                                           
  BUILD=(1,80,81:81,6,CHANGE=(1,C'DELADD',C'D'),NOMATCH=(C'K'))
/*                                                             
//CTL3CNTL DD *                                               
  SORT FIELDS=(5,4,CH,A,81,1,CH,A),EQUALS                     
  OUTFIL FNAMES=T3,OMIT=(81,1,CH,EQ,C'D'),BUILD=(1,80)         
/*                                                             
//CTL4CNTL DD *                                               
  SORT FIELDS=(5,4,CH,A,10,26,CH,D),EQUALS                     
/*
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Dec 27, 2011 7:56 pm
Reply with quote

remoonline,

I don't see a reason as to why you need an extra sort as the first pass. Also you are NOT sorting as the CTL1CNTL has Option COPY which would make it a copy operation.

Are you telling me that your input isn't sorted on the key (5,4,CH) as shown in your examples? The only time you would need an extra sort is when your input isn't sorted on the key.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top