|IMS Applications||Editing 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.
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.
If you have closed Mainframe Express, open it as before. If any project window or other windows are open, close them.
In this session you:
To create the project:
You now get a page asking which of the installed options this project uses.
To add your files to the project:
The files are added to the project.
To build the project:
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".
To load the database:
A window opens for the Database Utility.
Messages display. These messages show the load starting and completing successfully.
You are now ready to open the IMS Database Editor.
Open an IMS database that does not have any segment layouts:
The IMS View displays:
Figure 23-1: The IMS View of the Project View
A window opens to list the PCBs that belong to DEMO001T:
Figure 23-2: A List of PCBs
The IMS Database Editor window opens. This window divides into a left-hand pane and a right-hand pane.
Figure 23-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.
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.
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:
The right-hand pane displays a list of the COBOL source (.cbl) files in the project imsdemo.mvp.
When you select a .cbl file, the Segment Layout Editor extracts the COBOL layout information from the 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:
Figure 23-4: The New IMS Layout Dialog Box
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 23-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.
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 23-6: A List of Segments in the Demo IMS Database
The wizard adds the layout you have just defined for DEMOHDRS to the right-hand pane of the window:
Figure 23-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.
The COBOL layout starts to expand.
Before going any further, save the new segment layout in a segment layout (.slf):
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\imsdemo\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.
The layout you have just created is saved in the layout file demo03dd.slf.
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:
The right-hand pane is now showing the COBOL layout you have just defined for DEMOHDRS. The key fields are highlighted in red.
Since 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.
Data for the first DEMOHDRS segment occurrence is formatted and loaded into the right-hand pane:
Figure 23-8: An IMS Database With Segment Layouts Defined for the Data
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.
To retrieve the segment layout file demo03dd.slf that you created earlier and add a default segment layout for DEMOELES:
The Segment Layout Editor opens and displays the segment layout DEMOHDRS-DEFAULT that you created earlier:
Figure 23-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.
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.
The New Segment Layout Wizard appears.
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 23-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.
Next, go back to the IMS Database Editor window and look at the default COBOL layout you have just defined for the DEMOELES segment:
The right-hand pane is now showing the COBOL layout you have just defined for DEMOELES.
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:
The Segment Layout Editor opens and displays the two default layouts that you created earlier: DEMOHDRS-DEFAULT and DEMOELES-DEFAULT.
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.
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.
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.
In the right-hand pane, the Segment Layout Editor window displays next to the test field.
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.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
|IMS Applications||Editing an IMS Database|