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 

Maximum number of IFTHEN statements in INREC

 
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: Fri Apr 25, 2008 9:22 am    Post subject: Maximum number of IFTHEN statements in INREC Reply with quote

Is there a limit for the number of "IFTHEN=(WHEN=" statement conditions that can be used with INREC?
This is because I tried the execute the following SORT statement and only the first three conditions were executed.

Code:
  INREC IFTHEN=(WHEN=(20,3,CH,EQ,C'   '),OVERLAY=(22:19,1,19:C'000')),
        IFTHEN=(WHEN=(21,2,CH,EQ,C'  '),OVERLAY=(21:19,2,19:C'00')), 
        IFTHEN=(WHEN=(22,1,CH,EQ,C' '),OVERLAY=(20:19,3,19:C'0')),   
        IFTHEN=(WHEN=(7,3,CH,EQ,C'   '),OVERLAY=(7:1,6,1:C'00000'))    <=== This IFTHEN was not executed

    SORT FIELDS=(25,10,CH,A,13,1,CH,A)                                 
    SUM FIELDS=(19,4,ZD)                                             
 OUTFIL FNAMES=SORTOF1,                                               
       INCLUDE=(13,1,CH,EQ,C'S')                                     
 OUTFIL FNAMES=SORTOF2,                                               
       INCLUDE=(13,1,CH,EQ,C'B')                                     
 OUTFIL FNAMES=SORTOF3,                                               
          OMIT=(13,1,CH,EQ,C'B',OR,13,1,CH,EQ,C'S')                   


I put the fourth IFTHEN statement as the first statement followed by the first 3 statements as statement number 2,3 and 4 then the 4th IFTHEN statement was not executed.

Can anyone help? Please let me know If additional information would be required.
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Apr 25, 2008 10:23 am    Post subject: Reply with quote

Since you aren't using HIT=NEXT, once an IFTHEN clause is satisfied for a record, the subsequent IFTHEN clauses will NOT be executed for that record. So if postions 20-22 are blank, the other IFTHEN clauses will not be executed. If you want all of the IFTHEN clauses to be executed, you need to add HIT=NEXT to the first three clauses.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Apr 25, 2008 10:24 am    Post subject: Reply with quote

edkir98,

There is a limit to IFTHEN depending on the length and format of the field but your case is different. The reason it did not work is because one of the previous IFTHEN is satisfied.

IFTHEN in sort works just like Evaluate verb in COBOL. If you want to evaluate every IFTHEN then use the parm HIT=NEXT on the IFTHEN which will make sort to look for the next ifthen.

Code:

  INREC IFTHEN=(WHEN=(20,3,CH,EQ,C' '),       
       OVERLAY=(22:19,1,19:C'000'),HIT=NEXT),
        IFTHEN=(WHEN=(21,2,CH,EQ,C' '),       
       OVERLAY=(21:19,2,19:C'00'),HIT=NEXT), 
        IFTHEN=(WHEN=(22,1,CH,EQ,C' '),       
       OVERLAY=(20:19,3,19:C'0'),HIT=NEXT),   
        IFTHEN=(WHEN=(7,3,CH,EQ,C' '),       
       OVERLAY=(7:1,6,1:C'00000'))           
//*                                           

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


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

PostPosted: Wed Apr 30, 2008 2:26 am    Post subject: Doubt with IFTHEN Reply with quote

Kolusu,

Thanks for your help. But am still not clear.

Please see this JCL that I used

Code:
//R010    EXEC PGM=SORT                                         
//SYSOUT    DD SYSOUT=*                                         
//SORTIN    DD *                                                 
1111AAAA                                                         
2222BBBB                                                         
1111AAAA                                                         
2222BBBB                                                         
3333AAAA                                                         
4444BBBB                                                         
/*                                                               
//SORTOUT   DD SYSOUT=*                                         
//SYSIN     DD *                                                 
  SORT FIELDS=COPY                                               
 OUTREC IFTHEN=(WHEN=(1,4,CH,EQ,C'1111'),OVERLAY=(5:C'XXXX')),   
        IFTHEN=(WHEN=(1,4,CH,EQ,C'2222'),OVERLAY=(5:C'YYYY')),   
        IFTHEN=(WHEN=(1,4,CH,EQ,C'3333'),OVERLAY=(5:C'ZZZZ')),   
        IFTHEN=(WHEN=(1,4,CH,EQ,C'4444'),OVERLAY=(5:C'MMMM'))   


The output was

Code:
********
1111XXXX
2222YYYY
1111XXXX
2222YYYY
3333ZZZZ
4444MMMM
********


Again I used the HIT=NEXT

Code:
//R010    EXEC PGM=SORT                                               
//SYSOUT    DD SYSOUT=*                                               
//SORTIN    DD *                                                       
1111AAAA                                                               
2222BBBB                                                               
1111AAAA                                                               
2222BBBB                                                               
3333AAAA                                                               
4444BBBB                                                               
/*                                                                     
//SORTOUT   DD SYSOUT=*                                               
//SYSIN     DD *                                                       
  SORT FIELDS=COPY                                                     
 OUTREC IFTHEN=(WHEN=(1,4,CH,EQ,C'1111'),OVERLAY=(5:C'XXXX'),HIT=NEXT),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'2222'),OVERLAY=(5:C'YYYY'),HIT=NEXT),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'3333'),OVERLAY=(5:C'ZZZZ'),HIT=NEXT),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'4444'),OVERLAY=(5:C'MMMM'))         


Again the output was the same

Code:
********
1111XXXX
2222YYYY
1111XXXX
2222YYYY
3333ZZZZ
4444MMMM
********


Am I making any mistake? Please advise.
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Apr 30, 2008 10:20 am    Post subject: Reply with quote

Chennai,

HIT=NEXT doesn't make any difference in this case because the four conditions are mutually exclusive. If 1,4 = '1111', it can't be '2222' or '3333' or '4444'. If 1,4 = '2222', it can't be any of the others, etc. So HIT=NEXT has no effect in this case. Only one condition can be satisfied and only one OVERLAY can be performed whether or not HIT=NEXT is specified. What did you expect HIT=NEXT to do in this case?

HIT=NEXT does make a difference when you're testing different conditions, e.g. consider these IFTHEN statements:

IFTHEN=(WHEN=(1,4,CH,EQ,C'AAAA'),OVERLAY=(25:C'A')),
IFTHEN=(WHEN=(21,2,CH,EQ,C'BB'),OVERLAY=(28:C'B'))

If 1,4 = 'AAAA', we will not execute the second IFTHEN condition because we don't have HIT=NEXT. So we won't test for 21,2 = 'BB'.

But with:

IFTHEN=(WHEN=(1,4,CH,EQ,C'AAAA'),OVERLAY=(25:C'A'),HIT=NEXT),
IFTHEN=(WHEN=(21,2,CH,EQ,C'BB'),OVERLAY=(28:C'B'))

If 1,4 = 'AAAA', we will still execute the second IFTHEN condition because we have HIT=NEXT. So we will test for 21,2 = 'BB'.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Apr 30, 2008 10:25 am    Post subject: Reply with quote

edkir98,

The reason HIT=NEXT did not make an difference is because u are validating the same field on all the IFTHEN and at any given point only 1 IFTHEN is true.

try running the following JCL and see the difference HIT=NEXT makes

Code:

//STEP0100 EXEC PGM=ICEMAN                                     
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
ABC   123                                                       
ABC   555                                                       
DEF   567                                                       
EFG   333                                                       
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                             
  INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'ABC'),OVERLAY=(15:C'TRUE')), 
        IFTHEN=(WHEN=(1,3,CH,EQ,C'DEF'),OVERLAY=(15:C'TRUE')), 
        IFTHEN=(WHEN=(1,3,CH,EQ,C'EFG'),OVERLAY=(15:C'TRUE')), 
        IFTHEN=(WHEN=(7,3,CH,EQ,C'555'),OVERLAY=(20:C'FALSE')) 
//*


Code:

//STEP0100 EXEC PGM=ICEMAN                                           
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
ABC   123                                                             
ABC   555                                                             
DEF   567                                                             
EFG   333                                                             
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
 SORT FIELDS=COPY                                                     
 INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'ABC'),OVERLAY=(15:C'TRUE'),HIT=NEXT),
       IFTHEN=(WHEN=(1,3,CH,EQ,C'DEF'),OVERLAY=(15:C'TRUE'),HIT=NEXT),
       IFTHEN=(WHEN=(1,3,CH,EQ,C'EFG'),OVERLAY=(15:C'TRUE'),HIT=NEXT),
       IFTHEN=(WHEN=(7,3,CH,EQ,C'555'),OVERLAY=(20:C'FALSE'))         


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
edkir98
Beginner


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

PostPosted: Fri May 02, 2008 6:07 am    Post subject: Reply with quote

Thanks very much Kolusu and Frank...Its clear now..
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
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