HPlogo HP Data Entry and Forms Management System (VPLUS) Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 5 Reformatting Specifications

Output Field Menu

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

A separate Output Field Menu shown in Figure 5-17 “Output Field Menu”, is displayed for every input field named in the preceding Output Record Menu. The Output Field Menus are issued in the order the field names were entered in the output record definition. No Output Field Menu is issued for constants.

The Output Field Menu displays the information for a field entered on the preceding output record definition. In addition, it allows you to change the data type of a field from CHAR to any of the legal FORMSPEC data types. It also allows some formatting in addition to that performed by default when data is moved from the input field in the batch file to the output field in the output file.

Figure 5-17 Output Field Menu

Output Field Menu

The first line of the menu displays the input field values defined for this field on the preceding Output Record Menu. None of these values can be changed.

The second line displays the output field values defined for this field. Except for the data type, these values were established on the preceding Output Record Menu and cannot be changed on this menu. The data type of all fields to be written to the output file is defaulted to CHAR. This is done because only character type fields are written to the output record exactly as they were entered. If you want the field to be formatted to the format of a particular data type, you must change the data type specification on the Output Field Menu. (Refer to Table 5-2 “Standard Formatting by Data Types” on the following page for the standard formatting by data type.)

The remaining items in the Output Field Menu allow you to specify reformatting to be performed on the data item when it is moved to the output field. Note that these reformatting specifications cannot override the standard conversion and reformatting performed on the item based on the destination data type.

Data Type

You may change the output data type to a type other than CHAR. If, for example, the data type of the input item is NUM2, you can retain this data type by changing the output data type from CHAR to NUM2. This causes the value to be reformatted according to the standard rules for data type reformatting.

To illustrate, when a NUM2 item entered as 000123.12 is moved to a NUM2 field, leading zeros are replaced by blanks and it is right justified in the field. If moved to a CHAR field the value is moved to the output field exactly as entered. For another example, assume a date of type MDY is entered as MAR 6, 1986. If the output data type is left as CHAR, the date is written to the output field as MAR 6, 1986. If, on the other hand, the output data type is changed to MDY, the date is written as 03/06/86. When you change a data type to one other than CHAR and different from the original data type, you must take care since not all data types are interchangeable, and those that are may require conversion of the data. Allowed changes are:

Title not available (Data Type)

Any type to character

No conversion — data is left exactly as it was entered.

Numeric to numeric

Convert numeric value to conform to the destination type (DIGIT, NUM, NUMn, or IMPn).

Date to date

Convert date to dd/dd/dd; the exact order depends on the destination date type (MDY, DMY, or YMD).

Field Formatting

The remaining Output Field Menu specifications affect the actual data in the field. These specifications (STRIP, JUSTIFY, SIGN, FILL, and CHECKDIGIT) are performed in addition to the standard formatting performed when data is moved from an input (batch) field to an output field.

The standard formatting is described in Table 5-2 “Standard Formatting by Data Types” In general, the data is first converted to the destination data type, if necessary. Then all other formatting is performed. Note that the data is converted only if the output field type is specifically changed to a type other than CHAR.

Table 5-2 Standard Formatting by Data Types

Destination Data Type

Standard Formatting

CHAR

Conversion: none. Data movement: Move data to output field, character by character from leftmost character (including blanks) through last character (including blanks). If the data is shorter than the output field, pad with blanks on the right. If the data is longer than the output field, truncate on the right.

Assume a value with length=10 ΔΔΔCHARΔΔΔ moved to CHAR field, length=10 ΔΔΔCHARΔΔΔ to CHAR field, length=15 ΔΔΔCHARΔΔΔΔΔΔΔΔ to CHAR field, length=5 ΔΔΔCH

DATE

Conversion and Movement: Convert entered date to dd/dd/dd, where the order of digits depends on the date type. A date is written to MDY type field as mm/dd/yy; to DMY type field as dd/mm/yy; to YMD field as yy/mm/dd. Write converted date, character by character, to the output field starting with the leftmost character. If the date is shorter than the field, fill with blanks on the right; if longer than the field, issue error message.

Assume an MDY date, length=12 JAN 31, 1986
moved to MDY field, length=12 01/31/86ΔΔΔ
to DMY field, length=8 31/01/86
to YMD field, length=8 86/01/31
to any date field, length=7 ERROR

DIGIT

Conversion and Movement: Strip any leading zeros. Right justify converted data in the output field. If the data is shorter than the field, pad it with blanks on the left. If the data is too long for the output field, strip any leading blanks, one at a time until the data fits. If, after all leading blanks are removed, the data does not fit, issue error message.

Assume an integer, length=7 0012345
moved to DIGIT field, length=7 ΔΔ12345
to DIGIT field, length=10 ΔΔΔΔΔ12345
to DIGIT field, length=5 12345
to DIGIT field, length=4 ERROR

NUMn\or
\NUM

Conversion and Movement: Strip any commas, sign, or leading zeros. Float any minus sign to position preceding the first nonblank character. Right justify data in the output field. If the data is shorter than the field, pad with blanks on the left. If the data is too long, strip leading blanks one at a time until data fits. If, after all blanks are removed, the data is still too long, strip trailing fractional zeros, one by one. Then, if necessary, round fractional digits, one place at a time, until the value fits in the output field. (Note that rounding may change the value of the integer part.) If the value still does not fit, issue error message.

Assume value with length=10 1,234.510
moved to NUM3 field, length=10 ΔΔ1234.510
to NUM3 field, length=ll ΔΔΔ1234.510
to NUM3 field, length=6 1234.5
to NUM3 field, length=4 1235
to NUM3 field, length=3 ERROR

Assume signed value, length=10 +1234.510Δ
moved to NUM2 field, length=10 ΔΔΔ1234.51
to NUM2 field, length=3 ERROR

Assume signed value, length=7 -12.10Δ
moved to NUM2 field, length=7 Δ-12.10
to NUM2 field, length=3 -12
to NUM2 field, length=2 ERROR

IMPn

Conversion and Movement: Strip any decimal indicator, commas, sign, or leading zeros. Float any minus sign to the position preceding the first nonblank digit. Right justify data in the output field. If the data is shorter than the field, pad with blanks on the left. If the data is too long, strip leading blanks, one by one. If the data does not fit and only the fractional part remains, strip leading fractional zeros. (Trailing fractional zeros are never stripped from an IMPn field.) If the data still does not fit, issue error message.

Assume a value, length=10 -123.0120ΔΔ
moved to IMP4 field, length=10 ΔΔΔ-1230120
to IMP4 field, length=8 -1230120
to IMP4 field, length=7 ERROR

Assume a value, length=7 .0120ΔΔ
to IMP4 field, length=3 120
to IMP4 field, length=2 ERROR

 

REFSPEC performs all formatting (user-defined and standard) in the following order:

  1. Convert data to destination data type (unless type is CHAR). If numeric type data does not fit in the output field after conversion, the output field is set to all blanks,

  2. STRIP (user-specified)

  3. Move data to output field, justified left, and inserting check digit if specified, and padding with blanks as needed. If character type data does not fit, it is truncated on the right. If a data field does not fit, the output field is set to all blanks.

    Perform any CHECKDIGIT (user-specified) and/or JUSTIFY (user-specified).

  4. SIGN (user-specified)

  5. FILL (user-specified)

Note that step 3 includes data type formatting with data movement and user-specified justification and check digit insertion. These steps are performed simultaneously so that significant data is not lost due to justification. For example, if you justify data in a field to the left, the data is justified before movement; but if you justify data to the right, the justification is performed after the data is moved.

Any changes (truncation, conversion, and so forth) made to the data in the output field do not affect the original data in the input field.

STRIP

This option lets you remove a particular character or group of characters from data entered in the field. The following three options are provided:

STRIP ALL characters

Strips each occurrence of each specified character. The remaining characters are shifted left to fill the space created by stripping the specified characters.

STRIP LEADING characters

Strips each occurrence of each specified character only if it appears before any other nonblank characters in the field. Stripped characters are replaced by blanks. It is meaningless to strip leading blanks; if you want to shift data left, use JUSTIFY LEFT.

STRIP TRAILING characters

Strips each occurrence of each specified character only if it appears after all other nonblank characters. Stripped characters are replaced by blanks.

In Table 5-3 “Examples Using STRIP” are examples using STRIP where both the input field and the output field are 12 characters long and are the same data type; a blank is shown by the character Δ.

Table 5-3 Examples Using STRIP

Data Type

Input Value

Specification

Output Value

CHAR

ΔACBAXCBYZBB

none
STRIP ALL "ABC"

STRIP LEADING "ABC"
STRIP TRAILING "ABC"

ΔACBAXCBYZBB
ΔXYZΔΔΔΔΔΔΔΔ
ΔΔΔΔΔXCBYZBB
ΔACBAXCBYZΔΔ

DIGIT

Δ234567ΔΔΔΔ

none
STRIP ALL "35"

STRIP LEADING "0"
STRIP TRAILING "7"

ΔΔΔΔΔ1234567 ΔΔΔΔΔ12467ΔΔΔ ΔΔΔΔΔ12345.67
ΔΔΔΔΔ3456Δ

NUM2

Δ12,345.67ΔΔ

none
STRIP ALL "35"

STRIP LEADING "01"
STRIP TRAILING "7"

ΔΔΔ-12345.67
ΔΔΔ-124.67ΔΔ
ΔΔΔΔ-2345.67
ΔΔΔ-12345.6Δ

IMP2

Δ12,34567ΔΔΔ

none
STRIP ALL "35"
STRIP LEADING "01"
STRIP TRAILING "7"

ΔΔΔΔ-1234567
ΔΔΔΔ-12467ΔΔ
ΔΔΔΔΔ-234567
ΔΔΔΔ-123456Δ

 

Note that in the last IMP2 example, stripping the last character moves the implied decimal to the position between 4 and 5.

JUSTIFY

This specification lets you move data to the right or left boundary of the output field or to center it in the field. These three options are specified as:

JUSTIFY RIGHT

Moves the data to the right until the last character in the output field is nonblank, padding with blanks on the left as the data is moved.

JUSTIFY LEFT

Moves data to the left until the first character in the output field is nonblank, padding with blanks on the right as the data is moved.

JUSTIFY CENTER

Positions the data so that there is an equal number of blanks to the right and left of the nonblank data. If the total number of blanks in the field is not even, the extra blank is on the right.

If JUSTIFY is not specified, numeric type data is justified right and date type data is justified left. No justification is performed on character type data. In Table 5-3 “Examples Using STRIP”, the examples illustrate the three types of justification. It is assumed the input and output data types are the same.

Table 5-4 Examples of Three Types of Justification

Data Type

Input Value

Specification

Output Value

CHAR

ΔABCDEFΔΔ

JUSTIFY R
JUSTIFY L

JUSTIFY C

ΔΔΔΔABCDEF
ABCDEFΔΔΔΔ
ΔΔABCDEF

DATE

1/30/86ΔΔΔ

none
JUSTIFY R

JUSTIFY C

1/30/86ΔΔ
ΔΔ01/30/86

Δ01/30/86Δ

DIGIT NUM or IMP

ΔΔ123456ΔΔ

none
JUSTIFY L

JUSTIFY C

ΔΔΔΔ123456
123456ΔΔΔΔ
ΔΔ123456ΔΔ

 

Sign

With the SIGN specification, you can indicate where you want either a plus or minus sign placed in the output field. Any plus sign is removed automatically when a number is moved to the output field unless you specifically request that it be included with the PLUS option of SIGN. SIGN has the following options:

SIGN LEFT

The sign is placed in the first character position of the field. If this position contains a blank, the sign replaces it. Otherwise, data may be moved to the right of a leading zero stripped to accommodate the sign. If needed, a fractional digit is rounded. If the sign still does not fit, an error occurs and the field is set to blanks.

SIGN RIGHT

The sign is placed in the last character position in the field. As with SIGN
LEFT
, every attempt is made to fit the sign in the field, but if it results in too many characters, an error occurs and the field is set to blanks.

SIGN FLOAT

The sign is placed immediately preceding the first nonblank digit in the field. As with SIGN LEFT a leading zero may need to be stripped or a fractional digit rounded to accommodate the sign. If it still does not fit, an error occurs and the field is set to blanks.

SIGN ZONE

The sign is represented as an "overpunch" character in the last digit of the field. (See Table 5-2 “Standard Formatting by Data Types” for the value of a zoned sign.) No movement of data is required for this option.

NO SIGN

Any sign in the input field is stripped from the field when it is moved to the output record.

PLUS

All the preceding specifications apply to either a minus or a plus sign. The default is to insert only minus signs. If you want to retain a plus sign, you must enter Y in the PLUS option as well as indicate where you want the sign positioned.

If SIGN is not specified, a minus sign is floated for numeric type data and any plus sign is stripped; character type data is written exactly as entered.

Table 5-5 Correspondence Between Signed Digits and Characters

Positive Values

Positive Values

Negative Values

Negative Values

Signed Digit

Character

Signed Digit

Character

+0

{

-0

}

+1

A

-1

J

+2

B

-2

K

+3

C

-3

L

+4

D

-4

M

+5

E

-5

N

+6

F

-6

O

+7

G

-7

P

+8

H

-8

Q

+9

I

-9

R

 

In Table 5-6 “Example Using the SIGN Option” are examples that illustrate the use of the SIGN option. The input and output fields are assumed to be the same data type.

Table 5-6 Example Using the SIGN Option

Data Type

Input Value

Spec.

Output Value

NUMO

-123456
+123456

-123456
-1234567
+1234567

-1234567

none
none
NO SIGN
SIGN ZONE
SIGN ZONE, PLUS
SIGN RIGHT

ΔΔΔ-123456
ΔΔΔΔ123456
ΔΔΔΔ123456
ΔΔΔ123456P
ΔΔΔ123456G
ΔΔ1234567-

 

Fill

This specification allows you to replace leading, trailing, or all blanks in a field by a particular character. The specified character may be any printable character. It may not be a nonprinting control character, nor may it be more than one character. If FILL is not specified, no default replacement is made.

FILL ALL character

Replaces all blanks in the data with the specified character.

FILL LEADING character

Replaces all leading blanks with the specified character.

FILL TRAILING character

Replaces all trailing blanks with the specified character.

Default = none

You can specify both FILL LEADING and FILL TRAILING with no redundancy. But, you must not specify either FILL LEADING or FILL TRAILING with FILL ALL. Since the FILL ALL fills all the blanks, any other FILL specification for the field is diagnosed as an error. The examples in Table 5-7 “Examples Using the FILL Option” illustrate use of the FILL option. The input and output data types are the same.

Table 5-7 Examples Using the FILL Option

Data Type

Input Value

Specification

Output Value

CHAR

ΔΔABCΔDEFΔΔ

FILL ALL*
FILL LEADING*
FILL TRAILING*

**ABC*DEF**
**ABCΔDEFΔΔ

ΔΔABCΔDEF**

NUM2

ΔΔΔΔΔ123.75

FILL LEADING*

*****123.75

 

FILL LEADING and FILL ALL are not sensitive to the sign of a signed number. For example, the first set of specifications in Table 5-8 “Example Using the FILL LEADING and FILL ALL Option” produces a meaningless result because the sign is floated before the field is filled with zeros; the second set of specifications produces the desired result.

Table 5-8 Example Using the FILL LEADING and FILL ALL Option

Input Value

Specification

Output Value

-ΔΔ999

FLOAT SIGN
FILL LEADING 0

000-999

-ΔΔΔ999

SIGN LEFT
FILL ALL 0

-ΔΔΔ999
-000999

 

Check Digit

You can request that a check digit be added to the end of any digit or alphabetic value by entering 10 or 11 in the CHECKDIGIT option of the Output Field Menu. The check digit is calculated by modulo 10 or modulo 11 depending on which you specify.

Check digits can be added only to fields that are type DIG or type CHAR and that contain only digits or letters of the alphabet.

If ADD CHECK DIGIT is not specified as 10 or 11, no check digit is added.

NOTE: This specification adds a check digit. If you want to verify a number that contains a check digit, this can be requested in the original form design using FORMSPEC (refer to Chapter 4).

If the data is right justified, the nonblank digits in the field are moved left one character position to make room for the check digit. Note that when a check digit is to be added to a field, the length of the output field must be specified as at least one character longer than the input field. (Field length is increased on the Output Record Menu, not the Output Field Menu.) Refer to Appendix D for a description of how check digits are calculated if modulo 10 or modulo 11 is specified.

Examples:

CHECKDIGIT 10

Calculate check digit according to modulo 10 formula and add it following rightmost nonblank digit.

CHECKDIGIT 11

Calculate check digit according to modulo 11 formula and add it following rightmost nonblank digit.

If the product generated by a CHECKDIGIT 11 calculation evaluates to 10, this is considered invalid and the following message is issued when REFORMAT is executed:

"Check digit is invalid for modulus 11 calculation."

If the product generated by a CHECKDIGIT 11 calculation evaluates to 11, a zero is appended to the basic number.

Feedback to webmaster