Create a Record Layout

You can create a record layout file from the Data Division of a COBOL program that uses the data file. By using the .idy file from the compiled program, you can display the records in a structured way, where the fields are formatted to their intended size.

The datavseq.dat data file contains three types of record: employee, manager, and executive. You need to create a layout for each type of record, and then set criteria for when a particular layout is used. Of the three layouts, you define one as the default; all others are defined as conditional.

In order to create a record layout, we must create a structure file using the Classic Data File Tools editor.

  1. From a Visual COBOL command prompt, type mfdatatools, then press Enter.

    The Classic Data File Tools editor is opened.

  2. Click File > New > Record Layout and click OK.
  3. Navigate to the dfdstaff.idy file (located in the output path of the DataFileTools project ), then click Open.

    A Layout window appears, containing the Data Division of dfdstaff.cbl.

    GUID-6D0DBF3F-038F-47A2-9E9C-071914A872FD-low.png

  4. From the left-hand pane, right-click 01 EMPLOYEE-REC from the FD MF-File Section, then select New Layout.
  5. Select Default Layout, Next, then click Finish.

    The default layout is displayed in the right-hand pane.

  6. In the left-hand pane again, right-click 01 MANAGER-REC, then select New Layout.
  7. Select Conditional Layout, Next, then click Finish.

    The MANAGER-REC conditional layout is displayed in the right-hand pane.

  8. Expand 01 MANAGER-REC > MN-CODE, then right-click 03 MN-POSITION and select Properties.

    GUID-04B11728-1E4B-48DE-86BC-D15175B3336B-low.png

    The Field Properties dialog box appears.

  9. From the Condition section, select IS = TO.
  10. In the middle field, type M (upper case), then click OK.

    This M indicates a Manager record type.

  11. Repeat steps 6 through 10 to create a conditional layout for the Executive record type; substituting the previous structures for 01 EXECUTIVE-REC, EX-CODE, and 03 EX-POSITION, and using E to indicate the record type.
  12. Click GUID-51DEED16-48E4-4C3F-B888-093EC4502398-low.png (Save).

    The Save As dialog box appears.

  13. Navigate to the location of datavseq.dat, then in the File name field, enter datavseq.str and click Save.

    The structure file containing three layouts is now created, which means you can now view the corresponding data file formatted. You can close Classic Data File Tools.