Defining variable-length records

The easiest way to define variable-length records in your program is to use RECORD IS VARYING FROM integer-1 TO integer-2 in the FD entry and specify an appropriate value for integer-2. For example, assume that you have determined the length attribute of the data set to be 104 (LRECL=104). Keeping in mind that the maximum record length is determined from the RECORD IS VARYING clause (in which values are specified) and not from the level-01 record descriptions, you could define a format-V file in your program with this code:
  FILE SECTION.
  FD  COMMUTER-FILE-MST
      RECORDING MODE IS V
      RECORD IS VARYING FROM 4 TO 100 CHARACTERS.
  01  COMMUTER-RECORD-A           PIC X(4).
  01  COMMUTER-RECORD-B           PIC X(75).
Assume that the existing file in the previous example was format-U instead of format-V. If the 104 bytes are all user data, you could define the file in your program with this code:
  FILE SECTION.
  FD  COMMUTER-FILE-MST
      RECORDING MODE IS U
      RECORD IS VARYING FROM 4 TO 104 CHARACTERS.
  01  COMMUTER-RECORD-A           PIC X(4).
  01  COMMUTER-RECORD-B           PIC X(75).