Previous Topic: MULTIPLYNext Topic: Assignment Command


SUBTRACT

Purpose

Calculates the difference between two variables.

Syntax

►►─── SUBTRACT arithmetic-expression from variable ── options ── . ───────────►◄

Expansion of options

►───┬─────────────────────────────────┬──────────────────────────────────────►◄
    ├─ ROUNDED ───────────────────────┤
    ├─ TRUNCATED ─────────────────────┤
    └─ ALLOWING assignment-condition ─┘

Parameters

arithmetic-expression

Specifies the arithmetic expression being subtracted from the value contained in variable.

from variable

Specifies the data field that contains the value from which arithmetic-expression is subtracted. Following execution of the command, variable contains the result of the SUBTRACT operation.

ROUNDED

Rounds the result of the multiplication to the number of decimal positions found in variable.

TRUNCATED

Truncates the result of the multiplication to the number of decimal positions found in variable.

The default specification is ROUNDED if COBOL moves are enabled is not selected and TRUNCATED if the option is selected.

ALLOWING

Specifies which error conditions would normally abend and should cause control to be returned to the dialog for error handling. The list of allowable assignment-condition names can be found in the section entitled "Arithmetic and Assignment Command Status Condition."

Usage

Definition

The SUBTRACT command is used to perform subtraction. A variable data field value, a numeric literal, or the result of an arithmetic expression is subtracted from a variable data field value. The result is placed in the variable data field that contains the right operand.

Example

The following example illustrates the use of the SUBTRACT command to subtract the value in the QTY-SHIPPED field from the value in the BAL-ON-HAND field:

SUBTRACT QTY-SHIPPED FROM BAL-ON-HAND.

More information:

Assignment Command

Arithmetic Expressions