I need to get the count for anything having value other than '1' or '2' in position 688.
IS it possible by Easytrieve or SORT in JCL ? I have done it like this
-[ Character on 653 position should not be spaces AND ( CHeck 688 NE 1 .'AND' 688 NE '2']
INCLUDE COND=
((653,5,CH,NE,C' ',AND,((688,2,CH,NE,C '1 ',AND,688,2,CH,NE,C '2 ')))
can we do it in more efficient or other way ?
You can simplify human understanding by using OMIT instead of INCLUDE, to get rid of your negative conditions.
It would be possible to use field-type SS to contract the tests on position 688, but I'd be wary of that if your data is suspect (only use SS when you are sure of what values there may be).
It could be simplified, to my mind, by using SORT symbols to avoid the repetition, and errors that can go with that.
Since you have short records which may get in the way (cause a failure of the step) I have included OPTION VLSCMP. This will pad all fields on INCLUDE/OMIT which are not contained within a record (because the record is short) with binary zeros. Thus, all records with space at 653,5 will be dropped, all records which are not C'1 ' or C'2 ' at 688,2 will be dropped. All short records will be included, as the criteria for dropping will not be met (fields will be binary zeros for the comparison on INCLUDE/OMIT). A short record which does contain space at 653,5 will be omitted. If this is not what you want, that can be dealt with by extending the conditions.
If you need a formatted count that can easily be done, but if you are just investigating, it could easily be the case that the default counts in the sysout give you what you want.