Cobol file operations with sample programs tutorialbrain. Each file in a program can have a file status item attached to it by specifying the file status clause in its filecontrol entry. File status codes beginning with a 0 are considered successful execution. Display file status information, a suite of cobol programs.
Cobol file status status description 00 successful completion 02 indexed files only. File status 39 cobol file status code lookup and help. After successful execution of the program, all the files used are automatically closed but it is always a good practice to close the file to avoid any issue. For a read statement, the key value for the current key is equal to the value of that same key in the next record in the current key of reference. For example, i can check file status code for end of file, invalid key conditions. A separate item can be used for each files file status, or a single item can be used for the file status of several files. These are verbs you will use often in cobol programming to calculate, say the result of a business transaction. We will cover the compute, divide, multiply, subtract, add, move, and initialize verbs. Is the interrogation of file status codes meant to be a complement to, or a substitute of, the use of normal cobol verbs. Unless otherwise specified, each file status code can be received for operations on any file organizations in any access mode. For every input record from a flat file 1 read vsam using alternate key loop through a sequence. Let us see all the file operations open file in cobol. Cobol 400 subfiles hi terry, thanks a lot for ur reply.
The following example reads an indexed file starting at the fifth record, checks the file status key after each input or output request, and displays the vsam status codes when the file status key is not zero. So, rather than return a generic file status, this cobol system returns an extended file. It will write all the records to the display file, and while in the display routine, the file status will be zere after writing the footer and ctl part. This example also illustrates how output from this program might look if the file being processed contained six records. If the file attribute specified in parameters and options is a record sequential file of variablelength format, make sure that the physical file is a record sequential file of variablelength format. When using ansi74 or ansi85 file status codes, the runtime system returns extended.
1056 799 1168 224 1528 972 800 957 749 212 1338 367 907 396 208 588 651 677 141 884 1178 917 422 2 1357 973 1495 1072 740 1249 565 1295 5 1 508 846 680 1455 1213 583 1050 88 1370 313