Reputation: 307
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 ?
Upvotes: 1
Views: 4758
Reputation: 10563
Yes it is possible to count the number of records matching a criteria in either sort or easytrieve
Most sort utilities have some sort of reporting funvtions that could be used, for DFSort there is the count (http://pic.dhe.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.icea100/ice1ca40124.htm) option in IceTool. Even with out the reporting functions it can be done using in a 2 step process
The sort is roughly:
//STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=H //SORTIN DD DSN=INP1,DISP=SHR,UNIT=3380,VOL=SER=SCR001 //SORTOUT DD DSN=&&OUTPUT,DISP=(,PASS),UNIT=3390, // SPACE=(CYL,(5,1)),DCB=(LRECL=22) //SYSIN DD * OPTION COPY OMIT COND=(653,5,CH,EQ,C' ', OR, 688,2,CH,EQ,C '1 ', OR, 688,2,CH,EQ,C '2 ') OUTREC BUILD=(1,4,X'0000000001') //* //STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=H //SORTIN DD DSN=&&OUTPUT,DISP=SHR,UNIT=3380,VOL=SER=SCR001 //SORTOUT DD SYSOUT=* //SYSIN DD * SORT FIELDS=(5,1,BI) SUM FIELDS=(6,4,BI) OUTREC BUILD=(6,4,BI,TO=ZD,LENGTH=9)
There will be areas you can improve
Upvotes: 2
Reputation: 13076
You can simplify human understanding by using OMIT instead of INCLUDE, to get rid of your negative conditions.
OPTION COPY,VLSCMP
OMIT COND=(653,5,CH,EQ,C' ',
OR,
688,2,CH,EQ,C '1 ',
OR,
688,2,CH,EQ,C '2 ')
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.
Upvotes: 2