I was asked to quickly modify a program. The program currently uses a file, I'll call it FILE1, and the modification was to add a second file, FILE2 to it.
If the user selects to search for a certain type of information the the program would uses FILE1, if they want to search for a different type of information
the program would need to use FILE2.
All of the fields in FILE1 and FILE2 have the same names and attributes, except for the Part number field. The Part number field, PART, in FILE1 is 20 long,
in FILE2 it is 15.
I cannot change FILE2 to make PART be the same length as it is in the other file. I must make the minimum amount of changes to the program to negate the
need for it to be audited by the SOX auditors. What can I do?
The changes I would need to make would be:
- Create a 'which file' field to be used to determine which file the search is for.
- Add USROPN to the File specifications, F-spec, for FILE1 and FILE2. This means that the file will
only be opened if I use the OPEN operation code to open it.
- Use the value in the 'which file' field to condition which file is opened.
- Decide which file to read by using the 'which file' field.
- Close the file opened.
But that still leaves the problem of what to do with the two PART fields.
But how do I cope with the difference between the two PART fields with the minimum of code changes?
Using the PREFIX keyword in the F-spec would not do, as that would rename all the fields in FILE2.
Then it struck me, I could use a way I had used before in RPG III.