Problem:
When working with ACUCOBOL-GT products and files we soon discover than a file status is defined as a pic x(2). In many cases we can receive extended file status going farther than those two characters.
How can we recover those values and where do they come from?
Resolution:
If you want to recover extended file statuses, you have to use an ACUCOBOL-GT routine called "C$RERR".
CALL "C$RERR"
USING EXTEND-STAT, TEXT-MESSAGE, STATUS-TYPE
Parameters
EXTEND-STAT (returned): PIC X(5) or larger; PIC X(7) or larger under VMS
TEXT-MESSAGE (returned): PIC X(n)
STATUS-TYPE (input): Numeric parameter
When do we need to use it and why?
There are several cases, but the most often ones are:
- Error code 30, we need the extended file status because there we return the OS error-code.
- When we work with transactions.
- When we work with Acu4GL as we can have a 9D and then an extended file status with the code from the Database.
Another way to recover the error is from outside the program, by performing a trace with the runtime option "-x".
