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 

ICETOOL: Matching amounts equal and opposite

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


Joined: 09 Apr 2007
Posts: 3
Topics: 1

PostPosted: Sun Jul 26, 2009 7:18 am    Post subject: ICETOOL: Matching amounts equal and opposite Reply with quote

I have a file of records, with a key field and a value
There should be 2 records per 'transaction' ie the debit and the credit value
I want to ouput those records which have either
- a missing debit or credit,
- or where the values are not equal and complementary
(I was doing ok until it multiple pairings for the same key came in)
Can you suggest a method
e.g.
KEY1 5000+
KEY1 5000-
KEY1 5000+
KEY1 5000-
KEY1 1500+ --> output
KEY1 5000- --> output
KEY1 5000- --> output
KEY1 5000+
KEY1 5000-
KEY1 1200- --> output
KEY2 3000+
KEY2 3000-
KEY3 4000+ --> output
KEY4 4000+
KEY4 1200+ --> output
KEY4 4000-
KEY5 4000+ --> output
KEY5 3800- --> output
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Jul 27, 2009 10:50 am    Post subject: Reply with quote

mcollins,

The pairing is not consistent. take example of key 1

The first 4 records have a positivie and negative values which cancel out each other. But the next 6 records vary.

Code:

KEY1 1500+ --> output
KEY1 5000- --> output
KEY1 5000- --> output
KEY1 5000+
KEY1 5000-
KEY1 1200- --> output


In the above data 1500 is compared against 5000 which does not match so it is written to output but the next set is 5000 is compared to +5000 so it wouldn't match , so shouldn't you be writting those 2 records also to output? But you matched the next 5000+ to the next 5000- . Shouldn't you be comparing 2 records at a time? what happens if your data is like this ?

Code:

KEYA 5000-  MATCH WITH LAST RECORD   
KEYA 1000-  MATCH WITH NEXT RECORD   
KEYA 1000+  MATCH WITH PREV RECORD   
KEYA 2000-  MATCH WITH NEXT RECORD   
KEYA 2000+  MATCH WITH PREV RECORD   
KEYA 3000-  MATCH WITH NEXT RECORD   
KEYA 3000+  MATCH WITH PREV RECORD   
KEYA 4000-  MATCH WITH NEXT RECORD   
KEYA 4000+  MATCH WITH PREV RECORD   
KEYA 5000+  MATCH WITH FIRST RECORD 


What is the LRECL and RECFM of the input file? What is the position and format of the key field and the amount field?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mcollins
Beginner


Joined: 09 Apr 2007
Posts: 3
Topics: 1

PostPosted: Mon Jul 27, 2009 1:02 pm    Post subject: Reply with quote

Yep thats the problem the recs aren't consistent - I don't know how to best sort and then match them
from rec 5
rec5: 1500+ has nomatching 1500- so output
rec6: 5000- has no matching 5000+ so output
rec8 matches with either rec 7 or rec 9, so output the unmatched
rec10 has no matching +1200


The problem is the order of the file is random so ill have to sort them into some order
So taking your example and then making some of the pairings missing:
KEYA 5000+
KEYA 5000-
KEYA 4000+ unmatched
KEYA 3999+
KEYA 3999-
KEYA 3000- unmatched
KEYA 2000+
KEYA 2000-
KEYA 2000- unmatched
KEYA 1000- unmatched
KEYA 999+ unmatched

required Output
KEYA 4000+
KEYA 3000-
KEYA 2000-
KEYA 1000-
KEYA 999+


lrecl 100, recfm=FB
Key is 1,50
amt is posn 70 length 16 in format 000000000000.00s where s is + or -
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Jul 27, 2009 4:30 pm    Post subject: Reply with quote

mcollins,

The following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD DSN=Your input 100 byte dataset,DISP=SHR               
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)           
//OUT      DD SYSOUT=* 
//TOOLIN   DD *                                                       
  SORT FROM(IN) USING(CTL1)                                           
  SORT FROM(T1) USING(CTL2)                                           
//CTL1CNTL DD *                                                       
  SORT FIELDS=(1,50,CH,A,60,16,SFF,A)                                 
  OUTREC IFTHEN(WHEN=INIT,OVERLAY=(101:1,50,60,16,SFF,ZD,LENGTH=16)),
  IFTHEN(WHEN=INIT,OVERLAY=(167:SEQNUM,8,ZD,RESTART=(101,66))),       
  IFTHEN(WHEN=INIT,OVERLAY=(151:60,16,UFF,ZD,LENGTH=16)),             
  IFTHEN(WHEN=INIT,OVERLAY=(175:60,16,SFF,PD,LENGTH=8))               
  OUTFIL FNAMES=T1                                                   
//CTL2CNTL DD *                                                       
  SORT FIELDS=(101,74,CH,A)                                           
  SUM FIELDS=(175,8,PD)                                               
  OUTFIL FNAMES=OUT,BUILD=(1,100),OMIT=(175,8,PD,EQ,0)               
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mcollins
Beginner


Joined: 09 Apr 2007
Posts: 3
Topics: 1

PostPosted: Tue Jul 28, 2009 3:01 am    Post subject: Reply with quote

Wow... !
Thats amazing - thank you very much.
Am now just going step by step to see how it does it.
am loving the UFF/SFF
Back to top
View user's profile Send private message
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