Chapter 25: Creating Segment Layouts for an IMS Database

Use the Segment Layout Editor to create segment layouts for the segment types in an IMS database. Once you have created segment layouts, you can use the IMS Database Editor to view and edit formatted data in the database.


You need to have read the chapter Start Here for the Tutorials and worked through the first session Using Mainframe Express before you do this session.

You need to have installed IMS Option to do this session. We assume you are familiar with IMS on a mainframe.


25.1 Overview

This session shows you how to use the Segment Layout Editor to create COBOL layouts for an IMS database.

The demo database used in this session is a simple IMS database that you might have downloaded from a mainframe. You create layouts for the data in the database so that you can view and edit the data formatted in the session in the chapter Editing an IMS Database.

25.2 Preparation

If you have closed Mainframe Express, open it as before. If any project window or other windows are open, close them.

25.3 Sample session

In this session you:

25.3.1 Creating a Project

To create the project:

  1. Click New on the File menu, then select Project on the New dialog box and click OK.

  2. Enter imsedemo as the name of the project and change the name of the Project Folder to d:\mfuser\projects\gsdemo\imsedemo, then click Next.

  3. Ensure that Using this wizard is selected and click Next.

  4. Leave the default folder for the catalog unchanged and click Next.

    You now get a page asking which of the installed options this project uses.

  5. Ensure that only the IMS check box has a check mark, and click Next.

  6. Click Finish.

25.3.2 Adding Files to the Project

To add your files to the project:

  1. Click Add Files on the Project menu.

  2. In the Add Files to Project dialog box, open the folder \mfuser\projects\gsdemo\imsedemo\source. Ensure the Files of Type field is set to Source Files.

  3. Click Add All and then click Yes on the confirmation message.

    The files are added to the project.

  4. Click Done.

25.3.3 Building the Project

To build the project:

  1. Click Build on the Build menu.

As you saw in the earlier session Using Mainframe Express, the correct compiler is automatically called for each source file. In this case, the source files are the COBOL, DBD and PSB files. The build finishes with the message "Build finished with no errors".

25.3.4 Loading the Database

To load the database:

  1. Click IMS on the Tools menu, then click Database Utility.

    A window opens for the Database Utility.

  2. To obtain a database listing, type L (for Load) and press F2.

  3. Make sure that the cursor is immediately to the left of DEMO03DD. Then, type S (for Select) and press Enter.

  4. Press Enter again to confirm that you want to load the database.

  5. Against INPUT DSN, type DEMO03DD.DBU and press Enter.

    Messages display. These messages show the load starting and completing successfully.

  6. Press Enter to return to the main screen. Then, press Escape to exit the Database Utility.

    You are now ready to open the IMS Database Editor.

25.3.5 Viewing an IMS Database Without Formatted Data

Open an IMS database that does not have any segment layouts:

  1. In the Project View, click the IMS tab.

    The IMS View displays:



    Figure 25-1: The IMS View of the Project View

  2. On the left-hand pane of the IMS View, click PSB Gens.

  3. On the right-hand pane, right-click DEMO001T. On the popup menu, click Show Entry Details.

    A window opens to list the PCBs that belong to DEMO001T:



    Figure 25-2: A List of PCBs

  4. Right-click DEMO03DD and click Edit PCB #3 from PSB DEMO001T on the popup menu.

    The IMS Database Editor window opens. This window divides into a left-hand pane and a right-hand pane.

  5. Maximize the IMS Database Editor window within Mainframe Express by clicking in the top right of the window. If the right-hand pane is partially or fully obscured, drag the vertical bar between the two panes leftwards across the window, until the window looks similar to the window below:



    Figure 25-3: An IMS Database With No Segment Layouts Defined

    The section Acquainting Yourself With the IMS Database Editor Window in the chapter Editing an IMS Database describes the IMS Database Editor window in detail.

    If you look at the left-hand pane, that pane is displaying two segment types DEMOHDRS and DEMOELES in the demo database.

    If you look at the right-hand pane, that pane is empty. A status bar at the top of the right-hand pane states that no layouts are loaded.

  6. Click Close on the File menu.

    The IMS Database Editor closes.

You are going to use the Segment Layout Editor to create segment layouts for the two segment types DEMOHDRS and DEMOELES. These layouts will enable you to see formatted data for DEMOHDRS segment occurrences in the right-hand pane of the IMS Database Editor window.

25.3.6 Creating a New 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.

You take a COBOL layout defined in the Data Division of your debug information (.idy) file and apply that layout to the DEMOHDRS segment.

To define a default segment layout for the DEMOHDRS segment:

  1. In the Project View, click the Files tab.

  2. On the left-hand pane, click COBOL.

    The right-hand pane displays a list of the COBOL source (.cbl) files in the project imsedemo.mvp.

    When you select a .cbl file, the Segment Layout Editor extracts the COBOL layout information from the corresponding debug information (.idy) file.

  3. On the right-hand pane, right-click DEMO006L.CBL and click Create Segment Layout on the popup menu.

    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:



    Figure 25-4: The New IMS Layout Dialog Box

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

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



    Figure 25-5: The Segment Layout Editor Window With No Layouts Defined

    You are now going to select a COBOL layout named 01 DEMOHDRS from the Data Division displayed in the left-hand pane and apply that layout to the DEMOHDRS segment type in the IMS database DEMO03DD. Here, the layout and the segment type share the same name DEMOHDRS, but the two names can be different.

  5. Drag 01 DEMOHDRS from the left-hand pane of the window across to the right-hand pane.

    This action invokes the New Segment Layout Wizard. You are going to create a default segment layout for DEMOHDRS based on the COBOL layout 01 DEMOHDRS that you have just selected from the left-hand pane.



    Figure 25-6: A List of Segments in the Demo IMS Database

  6. Click DEMOHDRS and click Next.

  7. As Default Layout is already selected, click Next.

  8. Click Finish.

    The wizard adds the layout you have just defined for DEMOHDRS to the right-hand pane of the window:



    Figure 25-7: The Segment Layout Editor Window With One Layout Added

    As this is the default layout for the segment type DEMOHDRS, the word "DEFAULT" is appended to the segment-name DEMOHDRS.

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

    The COBOL layout starts to expand.

  10. Click against each group item until you can see the whole COBOL layout.

25.3.7 Saving the New Segment Layout in a Segment Layout File

Before going any further, save the new segment layout in a segment layout (.slf):

  1. Click Save As on the File menu.

    The Save As dialog box appears. The basename of the filename defaults to demo03dd which is the name of the IMS database for which you created the segment layout. The folder defaults to the data folder for the project which is \mfuser\projects\gsdemo\imsedemo\data. All segment layout files use the .slf extension.

    Each time you open an IMS database, the IMS Database Editor loads segment layouts automatically by searching the data folder of the project for a segment layout file with the same DBD name as the database and with extension .slf.

  2. Without changing any of the defaults, click Save.

    The layout you have just created is saved in the layout file demo03dd.slf.

  3. Close the Segment Layout Editor window by clicking Close on the File menu.

25.3.8 Viewing the New Segment Layout

From now on, 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 in future you can view and edit formatted data in DEMOHDRS segment occurrences.

To look at the difference in the IMS Database Editor window:

  1. In the Project View, click the IMS tab.

  2. On the left-hand pane of the Project View, click PSB Gens.

  3. On the right-hand pane of the window, right-click DEMO001T. On the popup menu, click Show Entry Details.

  4. Right-click DEMO03DD and click Edit PCB #3 from PSB DEMO001T on the popup menu.

    Because a segment occurrence is not loaded automatically for editing when you first open the IMS Database Editor, you need to make a DL/I call to establish your position in the database.

  5. To look at the first DEMOHDRS segment occurrence, click IMS DB Editor on the View menu, then click Get First Segment with Hold.

    Data for the first DEMOHDRS segment occurrence is formatted and loaded into the right-hand pane. The key fields are highlighted in red:



    Figure 25-8: An IMS Database With Segment Layouts Defined for the Data

  6. Click IMS DB Editor on the View menu, then click GHN 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-hand 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.

  7. Click Close on the File menu.

25.3.9 Editing the Segment Layout File

To retrieve the segment layout file demo03dd.slf that you created earlier and add a default segment layout for DEMOELES:

  1. Click Open on the File menu.

  2. Under Files of type, select Segment Layout Files (*.SLF). If the folder does not default to \mfuser\projects\gsdemo\imsedemo\data, change folder.

  3. Double-click demo03dd.slf.

    The Segment Layout Editor opens and displays the segment layout DEMOHDRS-DEFAULT that you created earlier:



    Figure 25-9: Opening a Saved Segment Layout File

    You now need to open the COBOL source file from which you are going to extract a COBOL layout for DEMOELES.

  4. Right-click in the window and click Load Data Division on the popup menu.

  5. Double-click DEMO006L.CBL.

    The window splits into two. The left-hand pane shows the Data Division from the COBOL program demo006l.idy. The right-hand pane shows the contents of the layout file demo03dd.slf.

  6. Drag 01 DEMOELES from the left-hand pane of the window across to the right-hand pane.

    The New Segment Layout Wizard appears.

  7. Click DEMOELES and click Next.

  8. As Default Layout is already selected, click Next.

  9. Click Finish.

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



    Figure 25-10: The Segment Layout Editor Window With a Default Layout Defined for DEMOELES

    Now save this new layout so that you can view formatted data for DEMOELES in the IMS Database Editor.

  10. Click Save on the File menu.

  11. Click Close on the File menu.

25.3.10 Viewing a Second Segment Layout

Next, go back to the IMS Database Editor window and look at the default COBOL layout you have just defined for the DEMOELES segment:

  1. In the Project View, click the IMS tab.

  2. On the left-hand pane of the Project View, click PSB Gens.

  3. On the right-hand pane of the window, right-click DEMO001T. On the popup menu, click Show Entry Details.

  4. Right-click DEMO03DD and click Edit PCB #3 from PSB DEMO001T on the popup menu.

  5. To look at DEMOELES, click IMS DB Editor on the View menu, then click Get First Segment with Hold. Then click IMS DB Editor on the View menu, then click GHN.

    The right-hand pane is now showing the COBOL layout you have just defined for DEMOELES.

  6. Click Close on the File menu.

25.3.11 Adding 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, use this layout again to create a conditional layout for DEMOELES:

  1. Click Open on the File menu.

  2. Under Files of type, select Segment Layout Files (*.SLF). If the folder does not default to \mfuser\projects\gsdemo\imsedemo\data, change the folder.

  3. Double-click demo03dd.slf.

    The Segment Layout Editor opens and displays the two default layouts that you created earlier: DEMOHDRS-DEFAULT and DEMOELES-DEFAULT.

  4. To open the COBOL source file, right-click within the window and click Load Data Division on the popup menu.

  5. Click DEMO006L.CBL and click Open.

  6. Drag 01 DEMOELES from the left-hand pane of the window across to the right-hand pane.

  7. Click DEMOELES and click Next.

  8. As Conditional Layout is already selected, click Next.

  9. Click Finish.

    The Segment Layout Editor window now includes the new conditional segment layout for DEMOELES in the right-hand 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.

25.3.12 Defining 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-hand pane and expose the test field.

  1. Expand the conditional segment layout DEMOELES-DEMOELES in the right-hand 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) and click Properties on the popup menu.

  3. In the IF box in the Field Properties dialog box, click IS = TO.

  4. In the box to the right of the IF 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 in the right-hand box.

  5. Click OK.

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

  6. Click Save on the File menu.

  7. Select Close from the File menu.

25.4 Before Continuing

Close the project. If you want to take a break before going on to the next session, you can close Mainframe Express.

Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.


Comments on the books? Click Send Us Comments.


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