El codigo File Status nos indica lo que pasa cada vez que operamos con un archivo. Ya sea a la hora de leer, grabar, eliminar o actualizar un registro.
Te recomiendo que si detectas errores al hacer cualquiera de las 4 operaciones anteriores primero verifiques el file status en el momento de hacer el OPEN.
El valor de cada codigo File Status lo conforman 2 caracteres que tiene un significado propio.
Aquí les dejo los valores de código File Status que maneja el Cobol400. Esto lo encontramos en los manuales on-line de IBM. Está en ingles pero como buenos programadores ya estamos familiarizados con este idioma.
COBOL/400 Reference
Te recomiendo que si detectas errores al hacer cualquiera de las 4 operaciones anteriores primero verifiques el file status en el momento de hacer el OPEN.
El valor de cada codigo File Status lo conforman 2 caracteres que tiene un significado propio.
Aquí les dejo los valores de código File Status que maneja el Cobol400. Esto lo encontramos en los manuales on-line de IBM. Está en ingles pero como buenos programadores ya estamos familiarizados con este idioma.
COBOL/400 Reference
Left- | Meaning | Right- | Meaning |
most Character | most Character | ||
0 | Successful Completion | 0 | No further information |
2 | The READ statement was successfully executed, but a duplicate key was detected. That is, the key value for the current key of reference was equal to the value of the key in the next record. For information about enabling file status 02 see Table 44 in topic 8.29.6 and the accompanying notes under the READ statement. | ||
4 | A READ statement was successfully executed, but the length of the record being processed did not conform to the fixed file attributes for that file. | ||
5 | An OPEN statement is successfully executed, but the referenced optional file is not present at the time the OPEN statement is executed. If the open mode is I-O or EXTEND, the file has been created. | ||
7 | For a CLOSE statement with the NO REWIND, REEL/UNIT, or FOR REMOVAL phrase or for an OPEN statement with the NO REWIND phrase, the referenced file was on a non-reel/unit medium. | ||
M | Last record written to a subfile.CPF5003 | ||
P | The file has been opened successfully, but it contains null-capable fields. | ||
Q | A CLOSE statement for a sequentially-processed relative file was successfully executed. The file was created with the*INZDLT and *NOMAX options, so its boundary has been set to the number of records written. | ||
1 | At end conditions | 0 | END OF FILE. A sequential READ statement was attempted and no next logical record existed in the file because the end of the file has been reached (no invites outstanding) CPF4740, CPF5001, CPF5025. |
2 | No modified subfile record found. CPF5037 | ||
4 | A sequential READ statement was attempted for a relative file and the number of significant digits in the relative record number was larger than the size of the relative key data item described for the file. | ||
2 | Invalid Key | 1 | A sequence error exists for a sequentially accessed indexed file. The prime record key value has been changed by the program between the successful execution of a READ statement and the execution of the next REWRITE statement for that file, or the ascending requirements for successive record key values were violated. Alternatively, the program has changed the record key value between a successful READ and subsequent REWRITE or DELETE operation on a randomly or dynamically-accessed file with duplicate keys. |
2 | DUPLICATE KEY. An attempt was made to write a record that would create a duplicate key in a relative file; or an attempt was made to write or rewrite a record that would create a duplicate prime record key in an indexed file. CPF4759, CPF5008, CPF5026, CPF5034, CPF5084, CPF5085. | ||
3 | RECORD NOT FOUND. An attempt was made to randomly access a record that does not exist in the file. CPF5001, CPF5006, CPF5013, CPF5020, CPF5025. | ||
4 | An attempt was made to write beyond the externally defined boundaries of a relative or indexed file. Or, a sequential WRITE statement was attempted for a relative file and the number of significant digits in the relative record number was larger than the size of the relative record key data item described for the file. CPF5006, CPF5018, CPF5021, CPF5043, CPF5272. | ||
3 | Permanent error condition | 0 | No further information CPF4192, CPF5101, CPF5102, CPF5129, CPF5030, CPF5143. |
4 | A permanent error exists because of a boundary violation; an attempt was made to write beyond the externally-defined boundaries of a sequential file. CPF5116, CPF5018, CPF5272 if organization is sequential. | ||
5 | FILE NOT FOUND. An OPEN statement with the INPUT, I-O, or EXTEND phrase was attempted on a non-optional file that was not present. CPF4101, CPF4102, CPF4103, CPF4207, CPF9812. | ||
7 | An OPEN statement was attempted on a file that would not support the open mode specified in the OPEN statement. Possible violations are: 1. The EXTEND or OUTPUT phrase was specified but the file would not support writeoperations.2. The I-O phrase was specified but the file would not support the input and output operations permitted.3. The INPUT phrase was specified but the file would not support read operations. CPF4194. | ||
8 | An OPEN statement was attempted on a file previously closed with lock. | ||
9 | The OPEN statement was unsuccessful because a conflict was detected between the fixed file attributes and the attributes specified for that file in the program. Level check error. CPF4131. | ||
4 | Logic error condition | 1 | FILE ALREADY OPEN. An OPEN statement was attempted for a file in the open mode. |
2 | FILE ALREADY CLOSED. A CLOSE statement was attempted for a file not in the open mode. | ||
3 | For a sequential file in the sequential access mode, the last input-output statement executed for the associated file prior to the execution of a REWRITE statement was not a successfully executed READ statement. For relative and indexed files in the sequential access mode, the last input-output statement executed for the file prior to the execution of a DELETE or REWRITE statement was not a successfully executed READ statement. | ||
4 | A boundary violation exists because an attempt was made to rewrite a record to a file and the record was not the same size as the record being replaced. | ||
6 | A sequential READ statement was attempted on a file open in the input or I-O mode and no valid next record had been established because the preceding START statement was unsuccessful, or the preceding READ statement was unsuccessful or caused an at endcondition.CPF5001, CPF5025, CPF5183. | ||
7 | The execution of a READ or START statement was attempted on a file not open in the input or I-O mode. | ||
8 | The execution of a WRITE statement was attempted on a sequential file not open in the output, or extend mode. The execution of a WRITE statement was attempted on an indexed or relative file not open in the I-O, output, or extend mode. | ||
9 | The execution of a DELETE or REWRITE statement was attempted on a file not open in the I-O mode. | ||
9 | Other Errors | 0 | ° File not found° Member not found° Unexpected I-O exceptions CPF4101, CPF4102, CPF4103 if a USE is applicable for the file (on OPEN OUTPUT, non-optional file). The following exceptions are monitored generically: CPF4101 through CPF4399 CPF4501 through CPF4699 CPF4701 through CPF4899 CPF4901 through CPF4999 CPF5001 through CPF5099 CPF5101 through CPF5399 CPF5501 through CPF5699 These exceptions are caught, and FILE STATUS is set to 90. With Standard Error Handling: If there is an applicable file status clause (but not an applicable USE procedure), the file status is updated, and control returns to the program. In the absence of a file status clause, USE procedure, AT END clause, or INVALID KEY clause to handle the error, a run-time message is issued, giving you the option to end or return to the program. Without Standard Error Handling: If a USE procedure applies, it runs. Otherwise, the program ends and gives the operator the exception and the option to cancel, take a partial dump, or take a full dump. |
1 | Undefined or unauthorized access type CPF2207, CPF4104, CPF4236,CPF5057, CPF5109, CPF5134,CPF5279. | ||
2 | ° File locked° File already open° I-O to closed file° READ after end of file° CLOSE on unopened file CPF4106, CPF4132, CPF4740,CPF5013, CPF5067, CPF5070,CPF5119, CPF5145, CPF5146,CPF5149, CPF5176, CPF5209. | ||
4 | No file position indicator REWRITE/DELETE when not sequential access, and last operation was not a successful READ. | ||
5 | Invalid or incomplete file information. The file has been successfully opened, but (1) duplicate keys specified in COBOL program, and indexed database file created with unique key; or (2) Duplicate keys not specified in COBOL program, and indexed database file created allowing duplicate keys. | ||
9 | Undefined (display or ICF). | ||
A | Job ended in a controlled manner by CL command ENDJOB, PWRDWNSYS, ENDSYS, or ENDSBS CPF4741. Escape message sent during an accept input operation, READ from invited program device (multiple device listings only). | ||
C | Acquire failed; session was not started. | ||
D | Record is lockedCPF5027, CPF5032. | ||
G | Output exception to device or session. | ||
H | ACQUIRE operation failed. Resource owned by another program, or unavailable. (9H is the result when an ACQUIRE operation causes any of the OS/400 exceptions monitored for 90, or 9N to occur.) | ||
I | WRITE operation failedCPF4702, CPF4737, CPF5052,CPF5076. | ||
K | Invalid format-name; format not found CPF5022, CPF5023, CPF5053,CPF5054, CPF5121, CPF5152,CPF5153, CPF5186, CPF5187. | ||
M | Last record written to subfile.CPF5003. To convert file status 9M to 0M,use PROCESS statement optionFS9MTO0M. | ||
N | Temporary (potentially recoverable) hardware I-O error. (Error during communication session.) Possible cause: Attempting to write bad data to a display file. CPF4145, CPF4146, CPF4193,CPF4229, CPF4291, CPF4299,CPF4354, CPF4526, CPF4542,CPF4577, CPF4592, CPF4602,CPF4603, CPF4611, CPF4612,CPF4616, CPF4617, CPF4622,CPF4623, CPF4624, CPF4625,CPF4628, CPF4629, CPF4630,CPF4631, CPF4632, CPF4705,CPF5107, CPF5128, CPF5166,CPF5198, CPF5280, CPF5282,CPF5287, CPF5293, CPF5352,CPF5353, CPF5517, CPF5524,CPF5529, CPF5530, CPF5532,CPF5533. | ||
P | OPEN failed because file cannot be placed under commitment control CPF4293, CPF4326, CPF4327,CPF4328, CPF4329. | ||
Q | An OPEN statement for a randomly-or dynamically-accessed relative file failed because its size was*NOMAX. Change the file size (for example, using CHGPF) to the size you expect, and submit the program again. | ||
S | REWRITE or DELETE failed because last READ operation specified NO LOCK. | ||
U | Cannot complete READ PRIOR because records are left in block from READ NEXT, or vice versa.CPF5184. Close the file, then open it again. |