RPG Tutorial: Calculation Specifications

The Calculation specification is used to define arithmetic and data manipulation operations which are performed either at Total time or Detail time in the RPG Logic cycle.

Column(s) Field Name Use
7 - 8 Control Level enter a control level indicator (L0 through L9, or LR) to specify that this operation is to be performed at total. time; leave blank if operation is to be performed at detail time
9
12
15
Negate indicator enter N if the corresponding indicator is to be OFF to condition this operation
10 - 11
13 - 14
16 - 17
Indicators enter one to three indicators to condition this operation; if more than one indicator is entered, they are considered in an AND relationship
18 - 27 Factor 1 enter field name or literal to use in operation; alphanumeric literals must be enclosed in apostrophes
28 - 32 Operation enter one of the operation codes; an entry is required in this field in each specification statement except in a comment (* in column seven)
33 - 42 Factor 2 enter field name or literal to use in operations requiring a second operand
43 - 48 Result Field enter the field name to receive the result of the operation
49 - 51 Result Field Length enter the number of storage positions to reserve for the result field; maximum length of numeric fields is 15 digits; maximum length of alphanumeric fields is 256 characters; may be left blank if result field has been previously defined in prior calculation specification or input specification 
52 Decimal Positions enter number of decimal positions (0 to 9) to reserve for the result field; required for all numeric result fields used with arithmetic operations; the number of integer positions (left of the decimal place) is calculated by subtracting this value from the field length (49-51)
53 Half Adjust enter H to round the result of arithmetic operations to the nearest whole number
54 - 55 +
1 > 2
HI
after arithmetic operation, the indicator to turn on if result is positive; after compare operation, the indicator to turn on if Factor 1 > Factor 2; after LOKUP or TESTZ, the indicator to turn on for High condition
56 - 57 -
1 < 2
LO
after arithmetic operation, the indicator to turn on if result is negative; after compare operation, the indicator to turn on if Factor 1 < Factor 2; after LOKUP or TESTZ, the indicator to turn on for Low condition
58 - 59 zero
1 = 2
EQUAL
after arithmetic operation, the indicator to turn on if result is zero; after compare operation, the indicator to turn on if Factor 1 = Factor 2; after LOKUP the indicator to turn on for Equal; after TESTZ the indicator to turn on for no zone or any other zone

Summary of RPG I Operations: 

Operation

Control Level

Indicators

Factor 1

Operation Code

Factor 2

Result Field

Field Length

Decimal Positions

Half Adjust

Resulting Indicators

Add

O

O R ADD R R O O O O
Zero and Add O O blank Z-ADD R R O O O O
Subtract O O R SUB R R O O O O
Zero and Subtract O O blank Z-SUB R R O O O O
Multiply O O R MULT R R O O O O
Divide O O R DIV R R O O O O
Move Remainder O O blank MVR blank R O O blank O
Move O O blank MOVE R R O blank blank O
Move Left O O blank MOVEL R R O blank blank O
Move High-to-Low Zone O O blank MHLZO R R O blank blank blank
Move Low-to-High Zone O O blank MLHZO R R O blank blank blank
Move High-to-High Zone O O blank MHHZO R R O blank blank blank
Move Low-to-Low Zone O O blank MLLZO R R O blank blank blank
Compare O O R COMP R blank blank blank blank R
Test Zone O O blank TESTZ blank R R R blank R
Exit to a Subroutine O O blank EXIT R blank blank blank blank blank
RPG Label O blank blank RLABL blank R O O blank blank
User's Label O blank blank ULABL blank R R R blank blank
Branching O O blank GOTO R blank blank blank blank blank
Label for Branch O blank R TAG blank blank blank blank blank blank
Set Indicators ON O O blank SETON blank blank blank blank blank R
Set Indicators OFF O O blank SETOF blank blank blank blank blank R
Table Lookup O O R LOKUP R O O O blank R
RPG Conversion O blank R RPGCV blank R R blank blank blank
End of RPG Conversion O blank blank ERPGC blank blank blank blank blank blank
External Conversion Routine O blank R EXTCV R R R blank blank blank
Record Key O blank blank KEYCV blank R O O blank blank
O = Optional       R = Required       blank = must be blank


Return to Site Home Page 


This page was last updated on January 17, 2015.