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 

Handle overlapping conditions using IFTHEN

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


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Wed Oct 01, 2008 8:07 am    Post subject: Handle overlapping conditions using IFTHEN Reply with quote

I am required to sum the amounts in the input file based on the range of data available in a particular field..

for ex.

Code:
field1   amt(in pd)
001      100
002      200
003      300
004      400
005      500
006      600
007      700
008      800
009      900
010      1000
011      1100
012      1200

now the condition is i need to sum the amounts for values of field1 '001' to '004' then sum the amounts for values of field1 as '005' to '008' then sum the amounts for values of field1 as '002' to '008'. I tried using the following logic, but am facing problems with the third set of values for field1

Code:
   SORT FIELDS=(50,3,CH,A)                                     
    SUM FIELDS=(10,9,PD)                                       
  INREC IFTHEN=(WHEN=(1,3,CH,GE,C'001',AND,1,3,CH,LE,C'004'),
             OVERLAY=(50:C'001')),                             
   IFTHEN=(WHEN=(1,3,CH,GE,C'005',AND,1,3,CH,LE,C'008'),
             OVERLAY=(50:C'002'))
 OUTFIL FNAMES=SORTOUT,
   OUTREC=(1:50,3,5X,9:10,9)

This is giving me an output as follows

Code:
001     1300
002     2600

this is fine for me... but how do i do the overlap case? ie. sum the amounts for values of field1 between '002' to '008'.
can anyone please help...
hope I'm clear.
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Oct 01, 2008 10:40 am    Post subject: Reply with quote

edkir98,

Use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                                     
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=your input file,DISP=SHR                                 
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION  EQUALS                                               
  SORT FIELDS=(50,3,CH,A)                                       
  SUM FIELDS=(53,9,62,9,71,9),FORMAT=PD                         
  INREC IFTHEN=(WHEN=INIT,                                     
  OVERLAY=(50:C'001',+0,TO=PD,LENGTH=9,53,9,53,9)),             
  IFTHEN=(WHEN=(1,3,CH,GE,C'001',AND,1,3,CH,LE,C'004'),         
  OVERLAY=(53:10,9),HIT=NEXT),                                 
  IFTHEN=(WHEN=(1,3,CH,GE,C'002',AND,1,3,CH,LE,C'008'),         
  OVERLAY=(62:10,9),HIT=NEXT),                                 
  IFTHEN=(WHEN=(1,3,CH,GE,C'005',AND,1,3,CH,LE,C'008'),         
  OVERLAY=(71:10,9))                                           
                                                               
  OUTFIL BUILD=(C'SUM OF 001 - 004 : ',53,9,PD,M26,LENGTH=18,/,
                C'SUM OF 002 - 008 : ',62,9,PD,M26,LENGTH=18,/,
                C'SUM OF 005 - 008 : ',71,9,PD,M26,LENGTH=18)   
/*


The output from this job is

Code:

SUM OF 001 - 004 : +00000000000001000
SUM OF 002 - 008 : +00000000000003500
SUM OF 005 - 008 : +00000000000002600


If you don't like the edit mask , just remove it

Hope this helps...

Cheers
_________________
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