Inserting segments

Segments can be inserted using a primary command or a prefix command. When using the primary command (INSERT), you can choose to insert any segment within the database hierarchy. When using the prefix command (I), you can only insert segments of the same type as those displayed.

Note: If your display is in SNGL format, you can only use the INSERT primary command.

To insert new segments using the INSERT primary command:

  1. On the IMS Data panel, enter the INSERT primary command on the Command line. The Segment Selection panel is displayed.
  2. Enter an S in the Cmd field for the segment type that you want to insert. The Insert Segment panel is displayed.

    If you selected a root segment, then the Insert Segment panel shows the initialized fields for the root segment.

    If you selected a child segment, the Insert Segment panel displays the Key Value details of the root segment and each parent segment in the hierarchy between the root and the selected child segment type in the top section of the panel; and the initialized fields of the child segment in the bottom section of the panel. The root segment used is root of whatever segment was displayed at the top of the database window when you entered the command.

    The fields in the new segment are initialized as follows:

    • If the display format is CHAR, HEX or LHEX, then the entire segment is initialized to blanks.
    • If the display format is SNGL or TABL, then the segment is initialized according to the field creation attributes in the current layout. If no creation attributes have been specified:
      • Numeric fields are initialized to zero.
      • Alphanumeric fields are initialized to blanks.
      • If the segment type contains a variable-length array, then the segment is initialized with the minimum number of array elements, and the array size field (or fields, for multi-dimensional arrays) is initialized accordingly.
  3. If necessary, you can adjust the values in the root and parent Key Value fields, to assign a child segment to a different parent or root.
  4. Use the Tab or Return key to move to the first available field in the new segment.
  5. Type the required data in the fields, then press Enter. If any changes you have made in the parent Key Value fields or any data you entered in your new segment breaks the database rules, a message is displayed at this point and you must modify your entries.
  6. Press the Exit function key (F3) to insert the segment and return to the IMS Data panel.

To insert new root segments, using the I prefix command:

  1. In CHAR, HEX, LHEX or TABL display formats, position your cursor in the prefix area of any root segment. Type the I prefix command and press Enter.

    The Insert Segment panel is displayed, and the fields in the new segment are initialized.

  2. Use the Tab or Return key to move to the first available field.
  3. Enter the required data.
  4. Press the Exit function key (F3) to insert the segment and return to the IMS Data panel.

To insert a new child segment, using the I prefix command:

  1. From the Database Positioning panel, ensure that you have selected the child segment type for display.

    You do not have to select the parent segment type, but selecting it makes it easier to identify the child segments of the required parent.

  2. On the IMS Data panel, locate a child segment of the required parent. If the required parent does not have any child segments yet, locate any child segment of the same type that you want to insert.
  3. In CHAR, HEX, LHEX or TABL display formats, position your cursor in the prefix area of one of the existing child segments. Type the I prefix command and press Enter.

    The Insert Segment panel is displayed, and shows the parent segments of the selected child (up to the root segment) and the new child segment. The fields in the child segment are initialized.

  4. If necessary, change the Key Values in the parent segments to that of the required parent for your new child segment.
  5. Use the Tab or Return key to move to the first available field in the child segment.
  6. Enter the required data.
  7. Press the Exit function key (F3) to insert the segment and return to the IMS Data panel.
Note:
  1. New segments are sorted into the appropriate key order for that segment type. If the key for your new segment causes the segment to be sorted to a position prior to the database starting position, you may have to exit to the Database Positioning panel and change the starting Key values in that segment's database hierarchy.
  2. The inserted segments are not committed to the database until a SAVE command is issued on the IMS Data or Database Positioning panels, or until you EXIT from the Database Positioning panel, or until the next automatic checkpoint is issued (if AUTOSAVE has been turned on).

Related topics