MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Drop records based on conditions

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
SK2007
Beginner


Joined: 25 Jan 2007
Posts: 40
Topics: 17

PostPosted: Sun Jan 24, 2010 5:17 pm    Post subject: Drop records based on conditions Reply with quote

Hi All,

I am having difficulty in dropping records base don conditions.
Please help me.

My input file is

Quote:

----+----1----+----2----+----3----+----4----+----5
//SORTIN DD *
123456789 NAME1 45.78 2009-01-01 AC 50.00 1
123456789 NAME1 45.78 2009-01-01 AC 50.00 2
123456999 NAME2 55.78 2009-10-01 AC 40.00 1
123456999 NAME2 55.78 2009-10-01 AC 40.00 2
123456122 NAME3 30.00 2007-10-01 AC 30.00 1
123456122 NAME3 30.00 2008-10-01 AC 30.00 1
123456233 NAME4 10.00 2007-10-01 AC 20.00 1
123456233 NAME4 10.00 2008-10-01 AC 20.00 1
123456233 NAME4 10.00 2009-10-01 AC 20.00 2

The structure is
Mbr-id
Name
amount1
date1
paytype
amount2
type

I need to drop records based on two fields type and date1(all other values are same)

If the type and date1 are same for mbr-id, drop any record
If type is different, then dont drop any record
If type is same and date1 are diffrent, then drop record which has maximum date1.

The ouput should be

Quote:

----+----1----+----2----+----3----+----4----+----5
//SORTIN DD *
123456789 NAME1 45.78 2009-01-01 AC 50.00 1
123456789 NAME1 45.78 2009-01-01 AC 50.00 2
123456999 NAME2 55.78 2009-10-01 AC 40.00 1
123456999 NAME2 55.78 2009-10-01 AC 40.00 2
123456122 NAME3 30.00 2007-10-01 AC 30.00 1
123456233 NAME4 10.00 2007-10-01 AC 20.00 1
123456233 NAME4 10.00 2009-10-01 AC 20.00 2



Thanks for your help as always
SK2007
Back to top
View user's profile Send private message
SK2007
Beginner


Joined: 25 Jan 2007
Posts: 40
Topics: 17

PostPosted: Sun Jan 24, 2010 9:07 pm    Post subject: Reply with quote

Additional information:

The input file is FB and 80 bytes length.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Jan 25, 2010 12:29 pm    Post subject: Reply with quote

SK2007,

The following DFSORT/ICETOOL JCL 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
123456789 NAME1 45.78 2009-01-01 AC 50.00 1                         
123456789 NAME1 45.78 2009-01-01 AC 50.00 2                         
123456999 NAME2 55.78 2009-10-01 AC 40.00 1                         
123456999 NAME2 55.78 2009-10-01 AC 40.00 2                         
123456122 NAME3 30.00 2007-10-01 AC 30.00 1                         
123456122 NAME3 30.00 2008-10-01 AC 30.00 1                         
123456233 NAME4 10.00 2007-10-01 AC 20.00 1                         
123456233 NAME4 10.00 2008-10-01 AC 20.00 1                         
123456233 NAME4 10.00 2009-10-01 AC 20.00 2                         
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  SELECT FROM(IN) TO(OUT) ON(1,10,CH) ON(43,1,CH) FIRST USING(CTL1)
//CTL1CNTL DD *                                                     
  SORT FIELDS=(01,10,CH,A,43,1,CH,A,23,10,CH,A)                     
//*

_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Mon Jan 25, 2010 5:33 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SK2007
Beginner


Joined: 25 Jan 2007
Posts: 40
Topics: 17

PostPosted: Mon Jan 25, 2010 3:55 pm    Post subject: Reply with quote

Hi Kolusu,

Thanks for your help. It is working as expected.
But I need one more condition to be considered to sort the records.
In addition to the conditions mentioned, I want to keep records when the date is greater than todays date.
For ex:
Quote:

----+----1----+----2----+----3----+----4----+----5----+----6
123456789 NAME1 45.78 2009-01-01 AC 50.00 1
123456789 NAME1 45.78 2009-01-01 AC 50.00 2
123456999 NAME2 55.78 2009-10-01 AC 40.00 1
123456999 NAME2 55.78 2009-10-01 AC 40.00 2
123456122 NAME3 30.00 2007-10-01 AC 30.00 1
123456122 NAME3 30.00 2008-10-01 AC 30.00 1
123456233 NAME4 10.00 2007-10-01 AC 20.00 1
123456233 NAME4 10.00 2008-10-01 AC 20.00 1
123456233 NAME4 10.00 2009-10-01 AC 20.00 2
123456002 NAMEx 10.00 2010-02-01 AC 20.00 1
123456002 NAMEx 16.22 2010-02-10 AC 45.00 1
123456002 NAMEx 14.69 2010-03-01 AC 20.00 2


The output should be

Quote:

123456789 NAME1 45.11 2009-01-01 AC 50.00 1
123456789 NAME1 45.13 2009-01-01 AC 50.00 2
123456999 NAME2 55.01 2009-10-01 AC 40.00 1
123456999 NAME2 55.99 2009-10-01 AC 40.00 2
123456122 NAME3 30.00 2007-10-01 AC 30.00 1
123456233 NAME4 10.11 2007-10-01 AC 20.00 1
123456233 NAME4 10.00 2009-10-01 AC 20.00 2
123456002 NAMEx 10.00 2010-02-01 AC 20.00 1
123456002 NAMEx 16.22 2010-02-10 AC 45.00 1
123456002 NAMEx 14.69 2010-03-01 AC 20.00 2


Thanks
SK2007
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Jan 25, 2010 5:36 pm    Post subject: Reply with quote

SK2007,

I noticed that my earlier control cards had a typo. I corrected it , it gives the desired results the data would be sorted in the Mbr-id ascending. As for the latest requirement the follwing DFSORT/ICETOOL JCL will give the desired results

Code:

//STEP0200 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD *                                                       
123456789 NAME1 45.78 2009-01-01 AC 50.00 1                           
123456789 NAME1 45.78 2009-01-01 AC 50.00 2                           
123456999 NAME2 55.78 2009-10-01 AC 40.00 1                           
123456999 NAME2 55.78 2009-10-01 AC 40.00 2                           
123456122 NAME3 30.00 2007-10-01 AC 30.00 1                           
123456122 NAME3 30.00 2008-10-01 AC 30.00 1                           
123456233 NAME4 10.00 2007-10-01 AC 20.00 1                           
123456233 NAME4 10.00 2008-10-01 AC 20.00 1                           
123456233 NAME4 10.00 2009-10-01 AC 20.00 2                           
123456002 NAMEX 10.00 2010-02-01 AC 20.00 1                           
123456002 NAMEX 16.22 2010-02-10 AC 45.00 1                           
123456002 NAMEX 14.69 2010-03-01 AC 20.00 2                           
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
  SELECT FROM(IN) TO(OUT) ON(1,10,CH) ON(89,9,CH) FIRST USING(CTL1)   
//CTL1CNTL DD *                                                       
  SORT FIELDS=(01,10,CH,A,89,9,CH,A,23,10,CH,A)                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:23,10,UFF,M11,LENGTH=8,43,1,8X)),
  IFTHEN=(WHEN=(81,8,CH,GT,DATE1),OVERLAY=(90:SEQNUM,8,ZD))           
  OUTFIL FNAMES=OUT,BUILD=(1,80)                                       
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group