Tutorial: IMS Segment Layout Editor

Walks you through the process of using the IMS Segment Layout Editor to create COBOL layouts for an IMS database.

The IMS demonstration database used in this tutorial contains data for which you create segment layouts using the Segment Layout Editor. Data formatted in the segments created here are then viewed and edited in the Tutorial: IMS Database Editor topic.

Prerequisites

This tutorial uses the same project used in Tutorial: IMS Support. If you have already completed Tutorial: IMS Support, nothing further is required. However, if you have not completed Tutorial: IMS Support, complete all steps included in the Create and Configure a Project topic, and all steps in the Load the Database section of the Configure IMS topic before proceeding.

Create a Default Segment Layout

You can define one default segment layout for each segment type. You can also define one or more conditional segment layouts for the same segment type. The IMS Database Editor uses the default segment layout to format data for those segment occurrences that do not match any of the conditional segment layouts.

Create a default segment layout for DEMOHDRS
  1. In the Eclipse Project Explorer, expand IMSTutorial > COBOL Programs.
  2. Right-click DEMO00I1.CBL; then select Create Segment Layout File from the context menu.

    The Segment Layout Editor extracts the COBOL layout information from the selected COBOL file's corresponding debug information (.idy) file.

    The New IMS Layout dialog box opens and displays a list of IMS databases. Here, you select the IMS database for which you want to create segment layouts.

  3. As the demo database DEMO03DD is the only database listed, click Create.

    The Segment Layout Editor opens. The left pane of the Segment Layout Editor window displays the Data Division of demo00I1.idy. The right pane is empty because, as yet, you have no segment layouts defined.

    In the next step, you select the DEMOHDRS COBOL layout and apply it to the DEMOHDRS segment type in the DEMO03DD database. Here, the layout and the segment type share the same name (DEMOHDRS), but the two names can be different.

  4. Drag 01 DEMOHDRS from the left pane of the window across to the right pane.
    Note: 01 DEMOHDRS is located near the bottom of the WORKING-STORAGE SECTION list, so you might need to resize the Segment Layout Editor, or scroll down the list to see it.

    This action invokes the New Segment Layout Wizard where you can create a default segment layout for DEMOHDRS based on the 01 DEMOHDRS COBOL layout that you have just dropped into the right pane.

  5. Select the DEMOHDRS segment name; then click Next.
  6. As Default Layout is already selected, click Next.
  7. Click Finish.

    The wizard adds the layout you have just defined for DEMOHDRS to the right pane of the window. As this is the default layout for the segment type DEMOHDRS, the word "DEFAULT" is appended to the segment-name DEMOHDRS.

  8. Click  next to DEMOHDRS-DEFAULT.
  9. Click  next to 01 DEMOHDRS.

    The COBOL layout starts to expand.

  10. Click  against each group item until you can see the entire COBOL layout.
Save the segment layout
Here you name the segment file to match the database file, and save it in the loadlib project subfolder.
  1. Click Save ().
  2. Browse to the loadlib subfolder of your IMSTutorial project.
  3. In the File name field, type DEMO03DD.
  4. Click Save.
  5. Click the x icon on the Micro Focus Data File Tools window to close it.

View the Segment Layout

In this section, you view the new DEMOHDRS-DEFAULT segment layout in the IMS DB Editor. Because you have defined this segment layout, when you open the IMS Database Editor, the DEMOHDRS-DEFAULT layout loads automatically and the data for the DEMOHDRS segment is formatted. This means that from this point on, you can view and edit formatted data in DEMOHDRS segment occurrences.

Start the IMS Database Editor
  1. In the Solution Explorer, right-click the DEMO03DD DBD file; then select Edit Database from the context menu.

    This starts the IMS Database Editor, showing formatted data for the DEMOHDRS segment in the right pane. The key fields are highlighted in red.

Advance to the next segment
  • On the tool bar, click twice to move to the next segment occurrence, which belongs to segment type DEMOELES.

    Because you have not yet defined a segment layout for DEMOELES, the Field Layout View in the right pane empties. The next thing to do, therefore, is to return to the Segment Layout Editor and define a default layout for the DEMOELES segment.

Close Micro Focus Data File Tools
  • From the Micro Focus Data File Tools menu, click File > Exit to close the window.

Create a Second Default Segment Layout

To create a default segment layout for DEMOELES, you edit the DEMO03DD.SLF segment layout file and add a second segment layout to it.

Open the Segment Layout File
  1. In the Project Explorer, right-click DEMO00I1.CBL; then select Create Segment Layout File from the context menu.
  2. As the demo database DEMO03DD is the only database listed, click Create.
  3. Click File > Open.
  4. If not already in the loadlib project subfolder, browse to it.
  5. From the Files of type drop-down list, select All Files (*.*).
  6. Double-click DEMO03DD.SLF.
  7. Click Yes at the prompt.
Load program information
  1. Right-click DEMOHDRS-DEFAULT; then select Load program information from the context menu.
  2. Double-click DEMO00IT.idy.
Create a default segment layout for DEMOELES
  1. Drag 01 DEMOELES from the left pane of the window across to the right pane.
  2. Select the DEMOELES segment name; then click Next.
  3. As Default Layout is already selected, click Next.
  4. Click Finish.

    The wizard adds the layout you have just defined for DEMOELES to the right pane of the window. As this is the default layout for the segment type DEMOELES, the word "DEFAULT" is appended to the segment-name DEMOELES.

  5. Click (Save) to save the new segment in DEMO03DD.SLF.

Create a Conditional Segment Layout

So far, you have created a default segment layout for each of the segment types DEMOHDRS and DEMOELES. You can create additional segment layouts for these segment types and specify the conditions under which those layouts should be used. These other layouts are referred to as conditional segment layouts.

You are going to create a conditional segment layout with a test field for the DEMOELES segment type. The test field determines which DEMOELES segment occurrences use the conditional layout rather than the default layout.

The demo Data Division has only one layout that is suitable for formatting data for DEMOELES segment occurrences. For the purposes of demonstrating conditional segment layouts only, you use this layout again to create a conditional layout for DEMOELES.

  1. Drag 01 DEMOELES from the left pane of the window across to the right pane.
  2. Select the DEMOELES segment name; then click Next.
  3. As Conditional Layout is already selected, click Next.
  4. Click Finish.

    The Segment Layout Editor window now includes the new conditional segment layout for DEMOELES in the right pane.

    As this is not a default layout, the name of the layout is appended by the name of the layout in the COBOL source file. The segment type in the IMS database and the COBOL source layout share the same name which is DEMOELES. Therefore, the new conditional segment layout is named DEMOELES-DEMOELES.

Define a Test for the Conditional Segment Layout

The test field is the field for which you want to set up a condition. To define a test, you need to expand the segment layout DEMOELES-DEMOELES in the right pane and expose the test field.

  1. Expand the conditional segment layout DEMOELES-DEMOELES in the right pane by clicking  until you can see the test field 03 FILLER PIC X(133). This test field is under the group item 02 DEMOELES-ELE-DATA.
  2. Right-click 03 FILLER PIC X(133); then select Properties from the context menu.
  3. From the IF drop-down list, select IS = TO.
  4. In the box to the right of the IF list box, type IMS DC TEST TECHNICIAN.

    Whatever you type in here is used by the IMS Database Editor when deciding which segment layouts to apply to which segment occurrences.

    If you had selected a condition that required two values, you would also type in a second value into the box on the far right.

  5. Click OK.

    In the right pane, the Segment Layout Editor window displays  next to the test field.

  6. Click (Save) to save the conditional segment in DEMO03DD.SLF.
  7. Close the Micro Focus Data File Tools window.