a basic doubt on WHEN=(logexp) and WHEN=ANY

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

a basic doubt on WHEN=(logexp) and WHEN=ANY

Post by rangab » Thu Feb 05, 2009 9:41 pm

Hi,

How does the combination of WHEN=(logexp) and WHEN=ANY work?

Suppose there are these set of records and if I apply these two expressions on this data, how the output will be?

Input Data:

Code: Select all

MERMA 01 2009
NEXTR 02
VERJO 01 2009
VERJ1 02
BARST 01 2009
VERJ2 02
INREC IFTHEN=(WHEN=(7,2,CH,EQ,C'01'),BUILD=(1,80)),
IFTHEN=(WHEN=ANY,BUILD=(1,80))

Please help. Thanks.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

sorry

Post by rangab » Thu Feb 05, 2009 9:49 pm

Frank, sorry....

Here is the data again......

Code: Select all

MERMA 01 2009 
NEXTR 02      
NEXTR 03      
VERJO 01 2009 
VERJ1 02      
BARST 01 2009 
VERJ2 02      
BARSE 01 2010 
VERJ3 02      
Sysin used:

Code: Select all

//SYSIN    DD *                                         
 OPTION COPY                                            
 INREC IFTHEN=(WHEN=(10,4,CH,EQ,C'2009'),BUILD=(1,80)), 
       IFTHEN=(WHEN=ANY,BUILD=(1,80))                   
/*                                                      
Output received:

Code: Select all

MERMA 01 2009 
NEXTR 02      
NEXTR 03      
VERJO 01 2009 
VERJ1 02      
BARST 01 2009 
VERJ2 02      
BARSE 01 2010 
VERJ3 02      
Why it does not give output like below:

Code: Select all

MERMA 01 2009 
NEXTR 02      
NEXTR 03      
VERJO 01 2009 
VERJ1 02      
BARST 01 2009 
VERJ2 02      
Thanks.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

skolusu
Member
Posts: 43
Joined: Sat Jul 26, 2008 12:38 am

Post by skolusu » Fri Feb 06, 2009 12:35 am

rangab,

If your intention is to pick the group of records which have 2009 then you need the WHEN=GROUP.

Use the following JCL

Code: Select all

//STEP0100 EXEC PGM=ICEMAN                                        
//SYSOUT   DD SYSOUT=*                                            
//SORTIN   DD *                                                   
MERMA 01 2009                                                     
NEXTR 02                                                          
NEXTR 03                                                          
VERJO 01 2009                                                     
VERJ1 02                                                          
BARST 01 2009                                                     
VERJ2 02                                                          
BARSE 01 2010                                                     
VERJ3 02                                                          
//SORTOUT  DD SYSOUT=*                                            
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(7,2,CH,EQ,C'01'),PUSH=(81:10,4))
  OUTFIL INCLUDE=(81,4,CH,EQ,C'2009'),BUILD=(1,80)                
/*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Feb 06, 2009 4:05 am

Code: Select all

 INREC IFTHEN=(WHEN=(10,4,CH,EQ,C'2009'),BUILD=(1,80)), 
       IFTHEN=(WHEN=ANY,BUILD=(1,80))    
This makes no changes to the input records for several reasons.

Since you used BUILD=(1,80) for the WHEN=(logexp) clause, it just "rewrites" the record with no changes when 10-13 is '2009'. Since you don't have HIT=NEXT, the WHEN=ANY clause is ignored when WHEN=(logexp) is true. If you did have HIT=NEXT, then WHEN=ANY still wouldn't do anything else because it would again "rewrite" the record with no changes given that you used BUILD=(1,80).

WHEN=ANY is used whenever any WHEN=(logexp) is satisfied providing that HIT=NEXT is used to continue evaluating subsequent clauses.

Any record that doesn't satisfy the WHEN=(logexp) is just written without changes.

So everything you've done here results in NO changes to the records.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

Post by rangab » Fri Feb 06, 2009 5:14 pm

Kolusu, thank you for the solution you have provided.

Frank, wow......that is a very good piece of info. I thought this detail info is not there in programming guide !

So, how the card should be changed now to meet my criteria after including HIT=NEXT and without build other than the solution suggested by Kolusu?

Thanks.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Feb 06, 2009 9:10 pm

So, how the card should be changed now to meet my criteria after including HIT=NEXT and without build other than the solution suggested by Kolusu?
I don't really know what you thought WHEN=ANY would do for you. You can't delete records by using IFTHEN alone. You have to use INCLUDE, OMIT, OUTFIL INCLUDE or OUTFIL OMIT to remove records.

Kolusu showed you how to do what you wanted. That technique is also documented in the "Include or omit groups of records" Smart DFSORT Trick at:

www.ibm.com/systems/support/storage/sof ... vs/tricks/
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others