SREFORMAT Command

The SREFORMAT command restructures and sorts file items and sends output to another file, or backup medium. The output can also be directed back to the original file specified in the INFO/ACCESS query.

Format

SREFORMAT [DICT] filename [item-list] [selection] [sort-keys] [output] [print] [modifiers] [(options)]

Parameter(s)

DICT

Specifies the file dictionary.

filename

Name of the file.

item-list

List of individual item-IDs. Enclose each item-ID in single quotes. The system sorts these items in the order that you specify with sort-keys.

selection

Specifies one or more conditions that an item must meet to be included in the report. For a complete description of selection expression syntax, see the LIST Command.

sort-keys

Specify which attributes to sort and whether to sort them in ascending or descending order. You can use the following modifiers with sort-keys:

BY

Sorts items in ascending order by the specified attribute.

BY-DSND

Sorts items in descending order by the specified attribute.

BY-EXP

Sorts a MultiValued attribute in ascending order and produces a separate line for each value.

BY-EXP-DSND

Sorts a MultiValued attribute in descending order and produces a separate line for each value.

If more than one sort-key is specified in a SORT command line, the system sorts these attributes from left to right (the leftmost sort-key is the most significant).

output

List of attributes whose values to be transferred. If you do not include this parameter, the SREFORMAT command transfers only item-IDs. You can also specify a phrase.

print

Specifies which values from MultiValued attributes will be transferred. Use relational operators and values immediately following the name of the MultiValued attribute.

modifiers

Include one or more keywords that specify the report format. These parameters affect headers, footers, spacing, and more. For complete information about using these keywords, see the section, Connectives, Modifiers, and Options in the INFO/ACCESS User Reference Guide.

options

Include one or more single-character codes that specify the report format and direct or modify output. They must be enclosed in parentheses, can be entered in any order, and need not be separated by spaces or any delimiters such as commas. For complete information about using these parenthetical options, see the section, Connectives, Modifiers, and Options in the INFO/ACCESS User Reference Guide.

Description

The contents of any attribute in the original file can be made the item-IDs for the items in the restructured destination file. This is useful for creating a new file that consists of a subset of the attributes in an existing file. The values that are to be made into item-IDs must be unique, however; a null or any other set of identical values become the item-ID of one item, and the data in those items are stored as MultiValues in the item in the destination file.

After the SREFORMAT command is entered with accompanying parameters, the system displays the following prompt:

FILE NAME:

At this point, you can perform one of three different operations:

  1. Transfer items to backup medium.You must have already attached the tape unit or floppy disk drive and set the record length with T-ATT.

  2. Transfer items to another file.

    The system copies the selected or specified items to the destination file name.

    If you specify attributes for output and include the ID-SUPP modifier in the INFO/ACCESS query, the values in the first attribute of the output specification become the item-IDs for the items copied to the destination file. The second attribute listed in the output specification becomes Attribute 1 in the destination file, the third attribute becomes Attribute 2, etc. The destination file can thus consist of a subset of the attributes defined for the original file.

    If you restructure files in this way and you want to generate reports from the destination file, you could copy the Attribute Definition items from the dictionary of the original file to the dictionary of the destination file and then edit the attribute numbers to reflect the new item structure.

  3. Transfer items within the same file.

Restructuring and Sorting File Items

The following example uses a newly created file, PHONE-LIST, to contain a subset of the information in the CUSTOMERS file. The customer’s telephone number becomes the item-ID and the last name and first name are the attributes contained in each PHONE-LIST item. The PHONE-LIST file contains customer items in sorted order by phone number.

>SREFORMAT CUSTOMERS BY PHONE PHONE FIRST-NAME LAST-NAME ID-SUPP

 

FILE NAME>PHONE-LIST

 

>COPY DICT CUSTOMERS 'FIRST-NAME' 'LAST-NAME'

TO :(DICT PHONE-LIST)

   1 FIRST-NAME

   2 LAST-NAME

 

2 ITEMS COPIED

 

>

Since FIRST-NAME and LAST-NAME are Attributes 1 and 2 (respectively) in both the old and the new files, there is no need to edit the Attribute Definition items of the PHONE-LIST dictionary.