HP RPG/XL Programmer's Guide (30318-90001)

9- 3
* Use the Error Dump File Name (columns 7-14) to avoid lengthy program
dumps to the terminal.
* Use N for the Line # Option (column 20) to decrease code segment
size. (Leave this field blank during testing.)
File Description and File Extension Specifications
* When you don't need to process a KSAM file in key order, put a C in
column 32 of the File Description Specification. This accesses a
file chronologically and does not use the key file. For information
on accessing a KSAM file chronologically, see "Reading a KSAM File
Chronologically" in Chapter 3.
* Use the DSNAME facility to access a file more than one way, rather
than using file equations. DSNAME files share a common file buffer.
For information on the DSNAME feature, see "Reading a KSAM File
Randomly and Sequentially Using Different Keys" in Chapter 3.
* Use the file blocking guidelines for MPE and KSAM files and
TurboIMAGE data bases in this chapter.
Input Specifications
* When files have more than one record type, start with the one that
occurs most often.
* Define only those record types in a file that are used in the
program.
* Define only those fields in a record that are used in the program.
* Define record identification codes as characters (C in column 26, 33
or 40) rather than zones or digits. This speeds up the processing of
those records.
* Only describe a field as numeric when it is used in arithmetic
operations or is edited for numeric contents.
* Avoid describing a numeric field as unpacked numeric or binary. RPG
does all arithmetic in packed decimal format, so it must first pack
non-packed fields.
* Use data structures to reformat fields instead of Calculation
Specification MOVE operations.
* Do not define fields that are not used.
Calculation Specifications
* Minimize the number of work fields by reusing them.
* Minimize the number of indicators by reusing them.
* Define a work field with the minimum size possible.
* Use *BLANK and *ZERO to initialize fields instead of work fields
containing blanks or zeros.
* Only define a work field as numeric when it is used in an arithmetic
operation.
* CLOSE files as soon as you're finished with them. This frees system
resources and makes the files available to other programs.
* Use GOTO operations to branch around calculation lines rather than
conditioning the calculation lines with indicators.
* In MULT operations, enter the smallest field in the Factor 2 field.
* To zero a field, subtract the field from itself. This is more
efficient than using Z-ADD or moving zeros to the field.
* When doing table searches, decide whether the table should be
searched sequentially or in a binary fashion. If most of the
searches in the table are for a few items, put those items first in
the table and search it sequentially (column 34 in the Header
Specification is blank). If the table consists of a large number of