6 Processing Files and Records
6.1 Defining Files and Records .................................... 6–1
6.1.1 File Organization . ........................................ 6–2
6.1.2 Record Format . . . ........................................ 6–8
6.1.3 File Design .............................................. 6–13
6.2 Identifying Files and Records from Within Your Compaq COBOL
Program................................................... 6–14
6.2.1 Defining a File Connector . . ................................ 6–14
6.2.2 Specifying File Organization and Record Access Mode ............. 6–20
6.3 Creating and Processing Files . . ................................ 6–24
6.3.1 Opening and Closing Files . . ................................ 6–24
6.3.2 File Handling for Sequential and Line Sequential Files ........... 6–26
6.3.3 File Handling for Relative Files .............................. 6–29
6.3.4 File Handling for Indexed Files .............................. 6–32
6.4 Reading Files ............................................... 6–37
6.4.1 Reading a Sequential or Line Sequential File ................... 6–37
6.4.2 Reading a Relative File .................................... 6–38
6.4.3 Reading an Indexed File . . . ................................ 6–42
6.5 Updating Files .............................................. 6–48
6.5.1 Updating a Sequential or Line Sequential File . . . ............... 6–48
6.5.2 Updating a Relative File . . . ................................ 6–50
6.5.2.1 Rewriting a Relative File ................................ 6–50
6.5.2.2 Deleting Records from a Relative File ...................... 6–53
6.5.3 Updating an Indexed File . . ................................ 6–55
6.6 Backing Up Your Files ........................................ 6–60
7 Handling Input/Output Exception Conditions
7.1 Planning for the AT END Condition ............................. 7–2
7.2 Planning for the Invalid Key Condition ........................... 7–2
7.3 Using File Status Values and OpenVMS RMS Completion Codes ....... 7–3
7.3.1 File Status Values ........................................ 7–4
7.3.2 RMS Completion Codes (OpenVMS) . . . ....................... 7–5
7.4 Using Declarative USE Procedures .............................. 7–8
8 Sharing Files and Locking Records
8.1 Controlling Access to Files and Records ........................... 8–1
8.2 Choosing X/Open Standard or Compaq Standard File Sharing and Record
Locking . . . ................................................ 8–3
8.3 Ensuring Successful File Sharing ............................... 8–4
8.3.1 Providing Disk Residency . . . ................................ 8–4
8.3.2 Using File Protection ..................................... 8–4
8.3.3 Determining the Intended Access Mode to a File . . ............... 8–6
8.3.4 Specifying File Access Using X/Open Standard File Sharing . ....... 8–6
8.3.5 Specifying File Access Using Compaq Standard File Sharing ....... 8–8
8.3.6 Error Handling for File Sharing ............................. 8–12
8.4 Ensuring Successful Record Locking ............................. 8–16
8.4.1 X/Open Standard Record Locking ............................ 8–17
8.4.2 Compaq Standard Record Locking ........................... 8–18
8.4.3 Error Handling for Record Locking ........................... 8–23
vii