Joined: 27 Aug 2007 Posts: 102 Topics: 42 Location: Chennai
Posted: Fri Apr 25, 2008 9:22 am Post subject: Maximum number of IFTHEN statements in INREC
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
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
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Apr 25, 2008 10:23 am Post subject:
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
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Apr 25, 2008 10:24 am Post subject:
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.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Apr 30, 2008 10:20 am Post subject:
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:
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
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Apr 30, 2008 10:25 am Post subject:
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
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