Page 1 of 1
a basic doubt on WHEN=(logexp) and WHEN=ANY
Posted: Thu Feb 05, 2009 9:41 pm
by rangab
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.
sorry
Posted: Thu Feb 05, 2009 9:49 pm
by rangab
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.
Posted: Fri Feb 06, 2009 12:35 am
by skolusu
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)
/*
Posted: Fri Feb 06, 2009 4:05 am
by Frank Yaeger
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.
Posted: Fri Feb 06, 2009 5:14 pm
by rangab
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.
Posted: Fri Feb 06, 2009 9:10 pm
by Frank Yaeger
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/