.jpg)
That's where oncode comes in. It's not a great deal of use in some of the specific on conditions where you know what condition got you there but it's really useful in those blocks that can be called for several different reasons where it can be used to determine the exact reason for the call and it can also be used in the on error block to allow you to handle all of the conditions that you want to handle in your program but which don't have their own on condition.
As an example, if we have a VSAM file that we are reading and updating then we can test for errors on accessing the file using the on key condition. This allows us to handle errors on this file but it doesn't tell us if the error is that the key we are trying to access is not found, we are trying to add a duplicate key, the key might be invalid, or perhaps there's just not enough space in the file to add the new record. We can use the oncode built-in function within the on key block to work out which of these errors is the one that has occurred
No comments:
Post a Comment