I have an existing variable block sequential file which has a record length of 300 bytes.
Earlier only 200 bytes of data was being written to the file. Now I am updating this file and i am adding additional 100 bytes i.e. now i am using the complete 300 bytes.
When I am issuing the rewrite statement, it gives 44.
BLOCK CONTAINS 0 CHARACTERS
RECORD IS VARYING IN SIZE
LABEL RECORDS STANDARD.
file-rec pic x(300).
Any idea what needs to be done to resolve this issue?
If you look at one of the "stickies" in the COBOL forum you'll find an explanation of the file-status codes. A 44 is:
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, or an attempt was made to write or rewrite a record that was larger than the largest or smaller than the smallest record allowed by the RECORD IS VARYING clause of the associated file-name.
Note, all that an LRECL of 300 says for a dataset is that the maximum length a record can be is 300 bytes (296 bytes of data and four bytes of "control information", the RDW).
You read your existing 200 byte-record (which actually has 204 bytes) and then you try to REWRITE it as 300 bytes (actually 304). Before the 304 can cause you a problem (if it were going to, there is room for mis-description in what you have said) the system carefully notes that you are trying to REWRITE a different length from the record that you READ.
To many, including me, it is a bad idea to update sequential datasets. Much better to just read, and then output a new dataset. Simplifies the JCL, simplifies the COBOL program, and you never get this situation, where you find only at this point that you didn't know enough about how it operates to realise that your file nedded "conversion" to the new-sized records.