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, you 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 DataToolsDemo project ), then click Open.

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

  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.

    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 (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 now close Classic Data File Tools.