The SUBTRACT statement subtracts one numeric item, or the sum of two or more numeric items, from one or more numeric items, and stores the results.
SUBTRACT Statement - Format 1 .------------------. V | >>-SUBTRACT----+-identifier-1-+-+--FROM-------------------------> '-literal-1----' .---------------------------. V | >----identifier-2--+---------+-+--------------------------------> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+--------------+-------------------------------------------->< '-END-SUBTRACT-'
In Format 1, identifiers or literals preceding the keyword FROM are added together, and this initial sum is subtracted from and stored in identifier-2. The initial sum is then subtracted from and stored in each successive occurrence of identifier-2, in the left-to-right order in which identifier-2 is specified.
SUBTRACT Statement - Format 2 - GIVING .------------------. V | >>-SUBTRACT----+-identifier-1-+-+--FROM--+-identifier-2-+-------> '-literal-1----' '-literal-2----' .---------------------------. V | >--GIVING----identifier-3--+---------+-+------------------------> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+--------------+-------------------------------------------->< '-END-SUBTRACT-'
In Format 2, all identifiers or literals preceding the keyword FROM are added together and this sum is subtracted from identifier-2 or literal-2. The result of the subtraction is stored in the data item referenced by identifier-3. Identifier-2 or literal-2 remains unchanged.
SUBTRACT Statement - Format 3 - CORRESPONDING >>-SUBTRACT--+-CORRESPONDING-+--identifier-1--FROM--------------> '-CORR----------' >--identifier-2--+---------+------------------------------------> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+--------------+-------------------------------------------->< '-END-SUBTRACT-'
In Format 3, elementary data items within identifier-1 are subtracted from, and the results are stored in, the corresponding elementary data items within identifier-2.
In Format 2, each identifier-3 following the word GIVING must be a numeric or numeric-edited elementary item.
In Format 3, identifier-1 must be a group item.
The composite of operands is determined by using all of the operands in a given statement excluding the data items that follow the word GIVING. For more information on the composite of operands, see the Size of Operands.
Floating-point data items and literals can be used anywhere numeric data items and literals can be specified.