Enhanced-format calculation specifications have been available since RPG IV was introduced. This style specification is the most popular for new applications and for maintenance (i.e., program changes) to existing applications. This style can be easier to use and may provide a level of productivity far beyond that of the traditional fixed-format specification. Figure 12.2 contains an example use of the enhanced-format specifications.
.....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++ 0001 C CustNo Chain CustRec 0002 C if %Found 0003 C Eval Visits = Visits + 1 0004 C Update CustRec 0005 C endif
In Figure 12.2, line one accesses the Customer master file using the traditional CHAIN operation; however no resulting indicators are used. Instead, line 2 uses the %FOUND built-in function to test the result of the CHAIN operation. This built-in function equates to *ON if the CHAIN operation is successful, otherwise it is set to *OFF. Line 3 performs the arithmetic add operation, replacing the ADD operation code. Then, on line 4 the update operation is performed; all the fields of the customer master file are rewritten to the database.