Chapter 12: Using Record Layouts with Data Files

This chapter describes the Record Layout Editor that you can use to provide formatting for data file records. You can then use the Data File Editor to view and edit the data in your data files. In particular, you can see the numeric values of data. For more information on using the Data File Editor to edit data files, see the chapter Editing Data Files.

For detailed instructions on using the Record Layout Editor, see the Mainframe Express online help. (Click Help Topics on the Help menu. Then, on the Contents tab, double-click Development Environment, Working with Data Files, Working with Record Layouts.)

12.1 Overview

When you first load a data file into the Data File Editor, the data in the right-hand pane is not formatted for you to view or edit. To enable you to view and edit formatted data, you can use the Record Layout Editor to create one or more layouts for the records in the data file.

To create a record layout, the Record Layout Editor extracts the data layout from the Data Division of a debug information (.idy) file. (You produce this file by compiling a COBOL source (.cbl) file for debug within the project.) The record layout that you create describes the name, length and picture of each field in a data record.

You can create more than one record layout for the records in a data file by setting up conditions on test fields. The Data File Editor uses the test fields to work out which layout to use for which record.

When you create record layouts for a data file for the first time, you save the record layouts in a record layout (.str) file. You can add more layouts later on by editing the .str file. You can also open the .str file and delete record layouts that you no longer require.

Record layout files are also used by the Data File Converter to control which fields in a record are converted when converting between EBCDIC and ANSI.

12.2 Types of Record Layout

There are two types of record layout:

If you do not define any conditional record layouts, all the records in the data file adopt the default record layout if you have set one up.

When you modify data in a record, the Data File Editor works out automatically which record layout to use for the modified record.

12.3 Creating Record Layouts

To create record layouts for a data file for the first time, the Record Layout Editor requires the following information:

In addition, for conditional record layouts only, you need to select the test field(s) and specify the test condition(s). For more information, see the section Setting up a Test Condition.

12.4 Layout-Names

A record layout name is the same as the layout name taken from the Data Division, except that default record layout names are appended by the word "DEFAULT". For example, if you extract a layout named CUSTOMER-REC from the Data Division, this translates as CUSTOMER-REC-DEFAULT for a default record layout and as CUSTOMER-REC for a conditional record layout.

12.5 Opening the Record Layout Editor

The first time you create record layouts for a data file, you go into the Files View of the Project View. You compile the COBOL file that contains the Data Division you want to use, making sure that the Create debug information field is selected in the Build Settings for COBOL. This ensures that you create the Debug Information (.idy) file from which the Record Layout Editor extracts the Data Division. Next, you right-click on the COBOL file in the right-hand pane and select Create Record Layout.

Once you have saved record layouts for a data file in a record layout (.str) file, you can open the record layout file and go into the Record Layout Editor directly.

12.6 The Record Layout Editor Window

The Record Layout Editor has one main window:



Figure 12-1: The Record Layout Editor Window

The Record Layout Editor window divides into two parts:


Tip: If you are editing a record layout (.str) file, a Data Division does not load automatically. You can load a Data Division in the left-hand pane by right-clicking in the Record Layout Editor window and clicking Load Data Division on the popup menu.


12.6.1 Left-hand Pane

The left-hand pane displays the Data Division that you load from the debug information (.idy) file associated with your chosen COBOL source (.cbl) file.

The areas on the left-hand pane of the Record Layout Editor window are described below, from the top down:

12.6.1.1 COBOL Header Bar



Figure 12-2: The COBOL Header Bar

The COBOL Header Bar displays the name of the COBOL program from which the Data Division is taken.

12.6.1.2 Data Division View



Figure 12-3: The Data Division View

The Data Division View Displays the Data Division of the selected COBOL program.

12.6.2 Right-hand Pane

The areas on the right-hand pane of the Record Layout Editor window are described below, from the top down:

12.6.2.1 Header Information Bar



Figure 12-4: The Header Information Bar

The Header Information Bar gives information about the status of the record layout file and is made up of the:

You can toggle the Header Information Bar on and off.

12.6.2.2 Record Layout View



Figure 12-5: The Record Layout View

The Record Layout View lists the record layouts currently defined.

Layout Icon
Indicating
A default record layout
A conditional record layout
A field that is part of the layout
A test field in a conditional record layout

To expand a record layout or group item, click . To compress a record layout or group item, click .

To highlight a layout or field, click on the layout or field. The Header Information Bar updates to display the number of conditions, if any, set up for the highlighted layout.


Tips:


12.7 Setting up a Test Condition

For each conditional record layout, you must specify one or more conditions that a record must fulfil to adopt that layout. Each condition is related to a test field. You use the Field Properties dialog box to specify a condition:



Figure 12-6: Conditions Offered by the Field Properties Dialog Box

From the Record Layout Editor window, you can open the Field Properties dialog box by right-clicking on a field and selecting Properties.

When you select a condition, either one or both of the value boxes to the right becomes available. For example, the condition IS = TO only requires you to enter one value, whereas the condition IS BETWEEN requires you to enter two values.

The Record Layout Editor window displays against each test field.

For full instructions on how to create a conditional record layout, see the Mainframe Express online help. (Click Help Topics on the Help menu. Then, on the Contents tab, double-click Development Environment, Working with Record Layouts, Creating and Removing Record Layouts.)

12.8 Converting Between EBCDIC and ANSI

The Field Properties dialog box (see Figure 12-6 in the section Setting up a Test Condition) has a Convert checkbox that controls whether the field is converted during an EBCDIC to ANSI conversion or an ANSI to EBCDIC conversion. By default, Convert is switched on except in the following cases when it is switched off:

You can change the Convert setting for any field in a record layout by right-clicking the field and clicking Properties on the popup menu.


Warning: If you switch the Convert field back on for a field that is redefined, remember to switch it off for that field when it is first defined.


To find out more about the Data File Converter, see the chapter Converting Data Files.

12.9 Record Layout Files

You should store all the record layouts for one data file in a record layout (.str) file.

12.9.1 Saving Record Layouts

Before exiting from the Record Layout Editor, you should save the record layout information in a record layout (.str) file.

12.9.1.1 Saving Record Layouts for Mainframe-style Files

Because you are using a catalog for your data files, you can:

12.9.1.2 Saving Record Layouts for PC-style Files

Since PC-style files are not catalogued, the location and name of the record layout file is crucial. When the Data File Editor opens a data file, the editor looks for a record layout file in the same directory as the data file and with the same basename.

To ensure that record layouts load automatically each time you open the data file, follow the guidelines below when you save the record layout file:

Record Layout File
Guideline
File basename The same file basename as the data file.
File extension .str.
Folder The same folder as the data file.

For example, if the data file is named customers.dat and is located in the c:\data folder, you should save the record layout file as c:\data\customers.str.

12.9.2 Editing a Record Layout File

You can open the record layout file (.str) at any time, as long as you have the data file closed. The Record Layout Editor window opens and displays the record layouts you have already created. You can:

12.9.3 Retrieving Record Layouts

When you load a record layout file with your data file, you can see your record data formatted at field level in the right-hand pane of Data File Editor's window. To view a sample, see the section Data File Editor Window in the chapter Editing Data Files.

12.9.3.1 Retrieving Record Layouts for Mainframe-style Files

To retrieve record layouts:

  1. Open the Data File Editor by opening the data file.

  2. Use the Data Tools > Load Record Layouts option on the File menu to load the required record layouts from the appropriate record layout (.str) file.

  3. Optionally, use the Data Tools > Associate Record Layouts option on the File menu to define a permanent association between the record layout file and the data file. Subsequently, the record layout loads automatically each time you open the data file.

12.9.3.2 Retrieving Record Layouts for PC-style Files

If you are working with PC-style files, the record layout file should load automatically with the data file. For more information, see the section Saving Record Layouts for PC-style Files.

Otherwise, you can load the record layout file separately by selecting the Data Tools > Load Record Layouts option on the File menu.


Copyright © 2001 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.