Posted: Sun Jan 24, 2010 5:17 pm Post subject: Drop records based on conditions
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. 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
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Mon Jan 25, 2010 5:36 pm Post subject:
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)
//*
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