Rules for logical file extension:
A file is logically extended up to the last “MODIFIED” page which lies beyond the previous logical last page and is contained in both a save area and a window.
Pages that lie in the new file area and form part of the extended data of the file are written to the file, provided they are contained in both the save area and a window.
Unmodified pages in a new file region are filled with X'00'.
Pages that are not contained in the save area as well as a window are not written to the file.
The DISPOS attribute of the window(s) has no effect on the logical extension of a file.
The logical last page of a file is that page which your own task considers to be the logical last page of the file. If SHARUPD=*YES is specified, a foreign task may have modified the logical last page unnoticed by your own task. This can be used to cancel a file extension effected by a task running in parallel.
Example 1: extending a file logically
Key
1...10 | page numbers (file/window) |
M | modified |
nc | new contents |
M | new logical last page |
oc | old contents |
pllp | previous logical last page |
-- | undefined contents |
Explanation
The physical length of the file is 10 pages (1 page = 4 Kbytes). The logical end-of-file is page 5. The SAVE area covers pages 1-10. The last modified window page in the SAVE area is page 8.
Irrespective of the DISPOS attribute of the window, all modified pages between the previous and the new last logical pages are written to the file on disk, and all unmodified pages are initialized with X'00' in the disk file.
The following cases must be differentiated for the remaining region (from page 1 to the previous logical last page):
If DISPOS=*OBJECT: Only the modified pages are written to the file.
If DISPOS=*UNCHNG: Modified pages are written to the disk file as well.
Unmodified pages that have not yet been written to file (with SAVE), are initialized in the file with X'00' (page 5). They are then set to the status SAVED. The above example assumes that pages 2 and 3 were written to the file (with SAVE) earlier. No action is taken for unmodified pages that have already been written to a file using SAVE (pages 2 and 3).
Example 2: extending a file logically
Key
1...10 | page numbers (file/window) |
M | modified |
nc | new contents |
M | new logical last page |
oc | old contents |
pllp | previous logical last page |
-- | undefined contents |
Explanation
The file is 10 pages long. The logical end-of-file is page 2. Pages 1-3 have been assigned to window 1, pages 6-10 to window 2. An 8-page SAVE area is defined. It is covering window 1 and the first three pages of window 2. The last modified window page of the SAVE area is page 8. Page 8 lies below the previous logical end-of-file and therefore becomes the new logical EOF (new logical last page).
Irrespective of the DISPOS attribute of the window, all modified pages between the previous and the new last logical pages are written to the file on disk (pages 6 and 8), and all unmodified window pages (pages 3 and 7) are initialized with X'00' in the disk file.
The following cases must be differentiated for the remaining region (from page 1 to the previous logical last page):
If DISPOS=*OBJECT: Only the modified pages are written to the file (page 1).
If DISPOS=*UNCHNG: Modified pages are written to the disk file as well. Unmodified pages that have not yet been written to file (with SAVE), are initialized in the file with X'00' (page 2). They are then set to the status SAVED. (No action is taken for unmodified pages that have already been written to the file using SAVE, see also previous example).
Pages 4 and 5 remain unchanged in the disk file, as no window exists for them. Since they are located after the previous logical end-of-file, their contents are undefined.
Modifications to pages 9 and 10 in window 2 are not be written back to disk, since these pages are not in the SAVE area.