You are here: Field Rules Reference > Field Rules Summary > MoveNum

MoveNum

Use this field level rule to move numeric data from an extract record to the output field and, if necessary, reformat the data. This rule supports overflow.

The numeric data this rule handles is limited to 15 significant digits. This is a total of all the digits, both to the right and left of the decimal. Here are some examples:

999,999,999,999,999.

.999,999,999,999,999

999,999,999.999,999

The system tries to honor almost any format you supply, but when a conversion has to occur, it can only guarantee 15 significant digits in the result.

The first part of the format mask must contain the input numeric format (X.Y) followed by the output numeric format (X.Y), where X is the size of the number, including any commas, currency symbols, and decimal places, and Y is the number of digits after the decimal. For example, a simple format mask can look like this:

10.2,15.2

This tells the system the input string consists of ten characters and the last two characters are decimals, such as 1234567890. The output string should consist of 15 characters, including two decimals.

To format the output, you can also include any of the following format options after the output numeric format (separate each option with a comma).

Format mask

Mask

Description

-

(one dash) If the number is negative, this option places a minus sign (-) in the left most position. For example, if the format mask is (9.2,12.2,C,$,-), the result is: “- $2,100.00”.

--

(two dashes) If the number is negative, this option places a minus sign (-) immediately before the amount. For example, if the format is (9.2,12.2,C,$,--), the result is “ -$2,100.00”, with a full length of 12.

+

Tells the system to always include a sign with all numbers.

%

Appends a percent sign (%) at the end of the number.

$

Adds a dollar sign. The dollar sign cannot be the first character in the format mask. This limitation arises from the Move_It format option, where a dollar sign ($) in the first character of the mask means to perform a sprintf.

A

Removes the trailing spaces after an extract value if the input data type is neither BCD nor Packed Decimal. For example, assume the data value is “100000 “ (a one followed by five zeros and two spaces).

If you omit this flag and select a 12.2 output format with commas, the value generated will be “ 100,000.00”. If you include this flag, the result will be “ 1,000.00”.

B

Translates a BCD number into a decimal. If the data is in EBCDIC format, use this flag instead of the BA flag.

BA

Translates a BCD number into a decimal. Use this flag for ASCII signed numbers.

C

Adds commas to the output.

C**

Adds commas if the data is in US English format or spaces if the date is in Canadian French format.

CR

Appends CR (credit) to the end of the number.

CS1

CS2

CS731

Enter one of these options to indicate the checksum method.

The system appends a check digit (mod 10) of 0 through 9 to the end of the number. This is typically used in accounting to make sure a number, such as an account number is correct by performing a formula on each digit. For details, see the Checksum Methods.

D

Dollars (a combination of B, C, and $). You must modify GEN_FMT_FmtMaskSaysBinary to recognize this format.

E

Stops a calculation if the search condition is false. The Move_It rule may return a null output buffer if: no record was found; a record was found, but the search mask contained a pairing (offset,data) which extended past the end of the record; or a record was found, but the mapped data was blank.

F

Add a dollar sign ($) and place it in the first position. If the value is negative, move the minus sign (-) to the last position.

G

Tells the MoveNum rule not to use the Move_It rule to get the data from the extract file. See Extracting data for more information.

L

Left justifies the number in the variable field.

-L (or --)

Tells the system to use a floating negative sign on negative values.

+L (or ++)

Tells the system to use a floating sign and to always show that sign.

Lang

The LANG parameter has no effect when using the V (verbiage) option. The V option converts the number result into words and is limited to US English.

M

Money (This format is a combination of formats C and $.)

N

Leave the output buffer blank if the number is zero or negative.

NM

Adds a minus sign (-) to the number.

-O

Places a negative sign outside the right side of the field definition. This allows positive and negative numbers to right align on the page if you use a fixed font. Here is an example using this input format: 10.2,10.2,-O:

input data: 0000009.99

-000012.25

output: 12345678901234567890

**********

9.99

12.25-

On

Sets the output field size to n and overrides the output size of the field. Here is an example using this input format: 10.2,10.2,O8:

input data: 0000009.99

-000012.25

output: 12345678901234567890

**********

9.99

-12.25

 

input format: 10.2,10.2,O12

input data: 0000009.99

-000012.25

output: 12345678901234567890

**********

9.99

-12.25

P

Print leading zeros. You cannot use this format with $, -, C, and F.

Pn

Pads the output zeroes to n total width. This parameter only works with whole numbers, not decimals. Here is an example using this input format: 10.0,10.0,P4:

input data: 0000000001

0000000025

0000012345

output: 12345678901234567890

**********

0001

0025

12345

P**

Prints leading zeros if used without character or symbol enclosed with single quote.

R

Tells the system to retain the minus sign (-) if the result is less than zero. Use with signed numbers.

-R

Places a negative sign on the right side of the field (within the field). Here is an example using this input format: 10.2,10.2,-R:

input data: 0000009.99

-000012.25

output: 12345678901234567890

**********

9.99

12.25-

R**

Retains the sign when translating a signed data value into decimal. Use with the S flag.

S

Translates signed data to a decimal.

SLZ

Suppress leading zeros. For example, 00.25 becomes .25.

T

Adds text before or after a number. Use the less than (<) symbol for inserting before, the greater than (>) symbol for inserting after. Use the comma as a separator.

Use with the NegText, Text, and ZeroText data options.

You can also use this option to place currency symbols before or after amounts. For instance, T>£ places the British pound sterling symbol (Alt+0163) before an amount.

TA

Same as T>

TB

Same as T<

SP

Same as E

V

Spells out the numeric value in US English.

X

Adds X to the front of the number.

Z

Print a number even if it is zero.

Z2

Prints two zeros.

For example…

Input string

Format mask

Output string

1234567890

10.2,15.2,C,$,L

$12,345,678.90

This example tells the system to take a ten-character input string with two decimals (10.2) and output it as a 15-character string with two decimals (15.2), commas (C), a dollar sign ($), and left-justified (L).

This rule respects the number of decimals in the source. For instance, if you have the number “ 1.2" defined as using a mask of 6.2, the system outputs 1.20 instead of 0.12.

Checksum Methods

The MoveNum and AccumulateVariableTotal rules support three checksum methods. These methods only work on the integer portion of a number. The system ignores the decimal portion of the number.

CS1 works from right to left. CS2 works from left to right. These two algorithms are exactly the same except for the direction in which they work. The calculation works like this:

The odd number digits are multiplied by 2. If that result is greater than 9, then 9 is subtracted from the value. The result is added to the sum. The even number digits are simply added to the sum.

Once all the digits values have been summed, the total is divided by 10. The remainder of this division is subtracted from 10 and that becomes the check-digit. If the resulting value is 10, then zero (0) will be the check-digit.

Here are some examples. In all cases, assume the value is 346,100.99. The CS1 calculation works like this: (notice the digits are addressed backwards)

(0 x 2) + 0 + (1 x 2) + 6 + (4 x 2) + 3

0 + 0 + 2 + 6 + 8 + 3 = 19

( 19 mod 10) = 9

10 - 9 = 1

The resulting number will be 346,100.991.

The CS2 calculation works like this:

(3 x 2) + 4 + ((6 x 2)-9) + 1 + (0 x 2) + 0

6 + 4 + 3 + 1 + 0 = 14

(14 mod 10) = 4

10 - 4 = 6

The resulting number will be 346,100.996

Note that in the CS1 example, the third digit—an odd number digit—is multiplied by 2 and exceeds 9. Therefore 9 is subtracted from that result before proceeding to the next number).

CS731 is the other checksum method. This method works from left to right. Unlike the other two methods which use an even/odd multiplier, this method has three multipliers. The first digit is multiplied by 7, the next by 3, and the next by 1. This process is repeated until all digits have been multiplied. Unlike the other methods, it does not matter if a the result of a digit multiplication exceeds 9.

CS731 calculation works like this:

(3 x 7) + (4 x 3) + (6 x 1) + (1 x 7) + (0 x 3) + (0 x 1)

21 + 12 + 6 + 7 + 0 + 0 = 46

(46 mod 10) = 6

10 - 6 = 4

The resulting number will be 346,100.994

Data

The data can contain a calculation to be performed on the number in the extract record. Separate the calculation from the search criteria with a space, enclosed in parentheses. Use spaces to separate each element (including parentheses) in the equation string.

An X in the calculation is replaced by the value moved from the extract record. You must place parentheses around each operator and its accompanying operands.

Note If you have zeros in your extract file, the MoveNum rule converts these zeros into blanks unless you include the Z option.

Option

Description

NegText

If the value is negative, this option lets you insert user-defined text before and/or after the negative value.

RPN (x)

Allows a calculation to be performed using reverse Polish notation.

Text

Lets you print text before and after the number.

X

Adds X to the front of the number.

ZeroText

If the result is zero, this option lets you insert user-defined text instead of the zero value.

Extracting data

Typically, the MoveNum rule uses the Move_It rule to get numeric data from the extract record before formatting the numeric data. The Move_It rule only copies the least number of characters possible. If the destination length is shorter than the source length, this means that the destination length is used instead of the source.

Normally, this is fine with numeric processing because extract files typically contain unformatted data. For example, you might pick up 123456 and turn it into $$$$$1,234.56 or some other valid format. In these cases, the destination is almost always longer than the source length.

There are cases, however, where the extract data is already formatted in some fashion that’s longer than the expected destination. For example 00000001234 might appear in the extract and yet the desired format expected for output is known to never exceed 6.2, such as 9999.99.

In this case, if you use the Move_It rule to get the data the result would be 0000000 because the destination length is only seven characters—shorter than the 11 character source length.

The G flag tells the MoveNum rule not to call the Move_It rule and instead use an alternate function that retrieves the entire source length before it formats the data for the destination length.

Note You can use format E to stop the calculation when the search condition is false.

See also