Changing Field Storage Attributes

Hans Hendriks, Robelle Technical Support

One area that generates a steady stream of support calls is when users need to change the storage format of numeric data fields. For example, lets say somebody sends you an ASCII file of data, and you need to add it to one of your Image datasets. Problem is, some of the numeric fields are stored in the dataset in numeric formats, like integer or packed. How can you convert the storage format of those fields into the format Image expects them to be?

There are two basic things you need to know to accomplish this:

1) You can define ASCII numbers as DISPLAY

The world of data is divided into 2 categories: Byte- or character-type fields (which can contain anything), and Numeric fields (which can only contain numeric values). If you assign a non-numeric character to a numeric field, you have invalid data.

So the first thing you need to know is how to get Suprtool to accept character-type numeric data as a numeric field.

Numeric fields can have any one of a number of different formats. For example:
Integer fields Two's Complement Binary, usually 2 digits per byte
Packed fields 1 digit per nibble (4 bits)
Display 1 digit per byte, leading zeroes optional, sign overpunch in last byte (if signed).
So Display format exactly matches character format, provided there are no illegal characters embedded in the field (like commas, periods, dollar signs, plus or minus signs, etc). Leading blanks are OK, but trailing blanks are not.

Therefore, if you want Suprtool to read the column as a numeric field, just define the field as DISPLAY type.

2) You can create new fields with the DEFINE command

Generally, Suprtool's DEFINE command is used to assign a name and attribute to a specified piece of the input record. Suprtool stores this information in its internal structures, so next time you reference that field it knows which piece of the record you're talking about, and what its storage attributes are.

Lets say, for example, that you know that the first 4 bytes of a record represent invoice-status. You would define it as follows:

 define invoice-status,1,4,byte
If you want the invoice-status field to be included in the output record, then you need to extract it:
   > extract invoice-status
If you don't care what the value of the field is in the input record, but want all your output records to show the invoice-status as "PAID", you can assign that value in the extract command:
   > extract invoice-status = "PAID"
The same applies to numeric fields. You can assign them a new value in the EXTRACT command, and Suprtool will ensure that the value is written to the output file in the correct numeric format for that field.

Now we have all we need to convert numeric values between different storage formats:

- Define the field as it exists in the input record:

   > define amount-char,1,6,display
- The define the field as you want it to appear in the output record:
   > define amount-int,1,4,integer
- then extract the field (in the format you require) and assign it the value of the field in the input record:
   > extract amount-int = amount-char