I have a pipe-delimited input file of VB records. The file contains several different "record types" as defined by a unique 5-character string in the first position of each record (i.e., in column 5). Some of the "record types" (but not all) must be filtered on a constant 3-character "data code" (call it "XYZ") whose location in the record depends upon the 5-character record type.
Presumably, I need to use IFTHEN with PARSE to find the "data code" field in each record. That's where I get confused; do I do this in INREC? OUTREC? OUTFIL? If the parsed variable containing the data code is equal to "XYZ" (or blanks) then I want to keep the input record exactly as it was given to me originally (i.e., in its original pipe-delimited format). Otherwise, I want to discard the record entirely. Additionally, there are some 5-character "record types" which do not contain the "code" field at all, in which case I want to keep those records unconditionally.
I guess what I'm saying is: I need the IFTHEN PARSE to determine whether or not I want to keep the record or discard it, but I do not want to modify the original record if I'm going to keep it. I didn't want to have to BUILD a new record in fixed-column format after the PARSE, and then reconstruct the original pipe-delimited version of the record. I couldn't figure out if that was possible (and how it could be done).
I hope this makes sense. I can certainly do this using ICETOOL if multiple operators are needed. Can anyone offer an approach?
1. You want to keep all records which are not of particular types
2. Of those of particular types, you need to keep XYX or space at a different particular position determined by the different record type
If so, yes, you'd need PARSE to locate the data for the different record types in 2, one PARSE per different column required.
The thing would be to extend your record, temporarily, so that you can store the PARSEd field to select it later on OUTFIL INCLUDE=/OMIT=.
That helps with your question "where", as it lets out OUTFIL.
Since there is no reason not to do it in INREC (the results do not depend on the order of the file), I think it best to do it in INREC.
To extend a V record:
This copies the RDW (1,4), which is obligatory for V records, then inserts n blanks, then puts your variable data from 5 to the end of the record at the location following the n blanks.
You then have somewhere to store your PARSEd field.
In OUTFIL, you will have something like
BUILD=(1,4,<5+n as a literal value>)
to get you back to your original records.
The nX mentioned is a generally convenient way, it does not have to be blanks inserted, it can be any value. But since you want blanks to be included as a value from your PARSEd field, and you need to have some way to readily get the records which are not being filtered, the blanks are probably going to be what you want.
If you still need assistance beyond that, please give some representative sample input and expected output for that sample.