Frank and krisprems thanks for your responses. Indeed your sort card would solve my present problem.
I also wanted to learn a generic way to OMIT or INCLUDE records based on pattern of N consecutive characters in the input file. Often we have requirements where a record is omitted if there are N consecutive A's (B's or C's or '9' or AB's...) starting at particular position.
Please suggest if we can have generic sort card for these requirements.
This SORT JOB in the first step creates an SYMNAMES with 10 consecutive A's
In the second step using the SYMNAME-CHECK_FOR you will be including only the records which have 10 consecutive A's in the position 5
Note that the technique shown by Krisprems to use a Symbol will only work for up to 64 characters since that's the limit for the length of a Symbol constant. So it won't work for your example of 167 repeating characters.
What would work is to use INREC to append the repeating constant to the end of each record and compare the field to it. For example, if your input file has RECFM=FB and LRECL=2000 and you want to compare a field starting in position 1013 to 167 A's, you could use these DFSORT control statements:
If in case we have to search for a string without knowing the position, may be we can accomplish like this Code:
But frank, how a substring search can be in your case. If we could do that, then it would be a very helpful trick for us.
Since a substring search requires a constant, my method of creating a field with 167A's wouldn't work for substring search (but that wasn't what the OP asked for).
You could "generate" an INCLUDE statement with the required constant in one step and use that in SYSIN of another step, but the constant wouldn't fit on one line so you'd have to be careful to get the continuation syntax right.
Yes, you could do that kind of thing with Symbols. Of course, for 167A's it would require a 64 character symbol (used twice) and a 39 character symbol. That's not too bad if you can hardcode the lengths, e.g.