IFTHEN clauses execution order



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

IFTHEN clauses execution order

Postby mfrookie » Fri Aug 17, 2012 10:16 pm

Hi,

I am confused with regards WHEN=ANY clause execution.

My understanding is

All IFTHEN=WHEN=INIT / GROUP clause in the order mentioned followed by
All IFTHEN=WHEN=(logical condition) followed by WHEN=ANY (assuming one of the WHEN=logical condition is satisfied)
All IFTHEN=WHEN=NONE clauses (assuming at least one of the WHEN=logical condition is not satisfied)

But looking at the results of following code, it doesn't seem so.

//RFPASTEU EXEC PGM=SYNCTOOL,COND=(0,NE)
//INPUTFIL DD   *                                                 
1                                                                 
2                                                                   
3                                                                   
4                                                                   
/*                                                                 
//OUTPUTFI DD   SYSOUT=*       
//TOOLIN   DD   *                                                 
  COPY FROM(INPUTFIL) USING(EXTR)                           
/*                                                               
//EXTRCNTL DD   *                                           
  INREC IFTHEN=(WHEN=INIT,                                   
                   BUILD=(1,1,                                 
                          C'|',                                 
                          C'PASS1')),                         
        IFTHEN=(WHEN=INIT,                               
                   BUILD=(1,7,                                 
                          C'|',                                   
                          C'PASS2')),                             
        IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),                           
                   BUILD=(1,13,                                   
                          C'|',                                   
                          C'PASS3')),                               
        IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),                           
                   BUILD=(1,19,                                     
                          C'|',                                   
                          C'PASS4')),                           
        IFTHEN=(WHEN=ANY,                                     
                   BUILD=(1,25,                                 
                          C'|',                                   
                          C'PASS5')),                           
        IFTHEN=(WHEN=NONE,                                     
                   BUILD=(1,31,                                   
                          C'|',                                   
                          C'PASS6'))                             
  OUTFIL FNAMES=OUTPUTFI                                         
/*                                                           
//TOOLMSG  DD   SYSOUT=*                                       
//DFSMSG   DD   SYSOUT=*                                         


Results -

----+----1----+----2----+----3----+----4----+
1|PASS1|PASS2|PASS3                   
2|PASS1|PASS2      |PASS4             
3|PASS1|PASS2                  |PASS6 
4|PASS1|PASS2                  |PASS6 


I was expecting 'PASS5' string to appear for 1st 2 records, but it didn't. Does it mean that I must use HIT=NEXT to have the WHEN=ANY clauses executed.

Thanks.
mfrookie
 
Posts: 40
Joined: Mon Apr 25, 2011 8:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IFTHEN clauses execution order

 

Re: IFTHEN clauses execution order

Postby dick scherrer » Fri Aug 17, 2012 11:13 pm

Hello,

I believe so. Suggest you try it and let us know what happens.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: IFTHEN clauses execution order

Postby mfrookie » Fri Aug 17, 2012 11:42 pm

Hi,

I did try it and it worked. But just wanted to know if HIT=NEXT is a must to have WHEN=ANY clause executed.

If that is the case, then it means I will have to put HIT=NEXT on each WHEN=(logical condition) clause which will cause some unnessary conditions being executed.
mfrookie
 
Posts: 40
Joined: Mon Apr 25, 2011 8:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IFTHEN clauses execution order

Postby dick scherrer » Sat Aug 18, 2012 12:22 am

Hello,

Whenever you want a process to continue checking after a hit is found, you need to specify HIT=NEXT.

It is not related to ANY.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: IFTHEN clauses execution order

Postby BillyBoyo » Sat Aug 18, 2012 3:38 am

In the sample you have shown there will be no extra tests because of the HIT=NEXT for both (logexp) IFTHENs - except for the WHEN=ANY, which you want.

If you show the actual code that concerns you, we may have suggestions.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: IFTHEN clauses execution order

Postby mfrookie » Sat Aug 18, 2012 11:20 am

Hi,

In the sample I showed, I will have to put HIT=NEXT on both WHEN logical conditions, if I want the WHEN=ANY clause to be exeecuted. So when the condition,
IFTHEN=(WHEN=(1,1,CH,EQ,C'1') gets satisfied, due to the HIT=NEXT clause, it will also check the IFTHEN=(WHEN=(1,1,CH,EQ,C'2') condition which is an unnecessary check.
Lets say I have 10 WHEN=logical conditions, then if a record satsfies 1st condition, then it will unncessary go thru remaining 9 checks to reach the WHEN=ANY clause,

So is it necessary to have HIT=NEXT clause in order to have WHEN=ANY clause executed. I was under impression that, once the IFTHEN=(WHEN=(1,1,CH,EQ,C'1') check is done, it checks to see if there are WHEN=ANY clauses. But it seems it doesn't.

I checked the manual, couldn't understand much as its not very clear.

WHEN=ANY - The WHEN=ANY subparameter condition is satisfied if one or more of its associated WHEN=(conditions) subparameter conditions have been satisfied. Its associated WHEN=(conditions) subparameters are those that precede it but no other WHEN=ANY subparameter. If the WHEN=ANY subparameter condition is satisfied, it applies the specified second subparameter to the temporary record. The second subparameter is optional. If it is not used, IFTHEN processing simply stops if the WHEN=ANY subparameter condition is satisfied unless the optional HIT=NEXT subparameter has been specified.

The IFTHEN parameters must be specified such that the WHEN subparameters are in the
following order:
• WHEN=INIT and/or WHEN=GROUP
• WHEN=(conditions) and WHEN=ANY
• WHEN=NONE
mfrookie
 
Posts: 40
Joined: Mon Apr 25, 2011 8:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IFTHEN clauses execution order

Postby BillyBoyo » Sat Aug 18, 2012 12:55 pm

Find the manual reference that Dick is referring to.

Maybe Alissa Margulies of Syncsort can clarify, but it works the way it works (not how you want, and not in a way definitive from the manual quote you have given, bearing in mind other manual references to IFTHEN processing (I don't have a manual, but I'm going with what Dick says).

If you show your actual cards, we may have suggestions, as I have said. Do you have an enormous number of records? If not, the extra processing probably won't be noticed much.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: IFTHEN clauses execution order

Postby dick scherrer » Sun Aug 19, 2012 1:33 am

Hello,

Just ran your code with the HIT=NEXT on all of the IFTHENs before the WHEN=ANY. This is the result.

1|PASS1|PASS2|PASS3      |PASS5                     
2|PASS1|PASS2      |PASS4|PASS5                     
3|PASS1|PASS2                  |PASS6               
4|PASS1|PASS2                  |PASS6   


I used SORT rather than SYNCTOOL as SYNCTOOL is installed but appears to be configured incorrectly . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: IFTHEN clauses execution order

Postby mfrookie » Mon Aug 20, 2012 2:44 pm

I think I am probably making it complicated.

Instead of what my SORT control statements are, I will ask a straight question - When does WHEN=ANY clause gets executed.

As far as HIT=NEXT on each IFTHEN condition is concerned, yes I do have more than 150 million records to be processed which is why I asked the question about the additional checks that might result from putting HIT=NEXT on each IFTHEN clause.

My actual SORT card is not much different than what I posted. The only difference is I have around 15 IFTHEN=logical conditions, that's it. Rest all other is same.

And I don't think using EXEC PGM=SYNCSORT or EXEC PGM=SYNCTOOL will make any difference because SYNCTOOL internally invokes SYNCSORT.

Thanks.
mfrookie
 
Posts: 40
Joined: Mon Apr 25, 2011 8:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: IFTHEN clauses execution order

Postby BillyBoyo » Mon Aug 20, 2012 7:34 pm

You have demonstrated how WHEN=ANY works. Not how you want it to.

The point of seeing you cards is to see whether the WHEN=ANY can be avoided, if you find that the performance is heavily degraded. However, I think you need to check first. Try to simulate 15*1500000 tests, and see if it is a problem.

You might be able to, for instance, have your multiple IFTHENs on INREC, and then have a final IFTHEN, which you make equivalent to the WHEN=ANY, on OUTREC.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Next

Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post