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

6-: 1
Chapter 6 Compiling an RPG Program
This chapter gives you the information you need to know in order to
successfully compile an RPG program. It explains how to use source
libraries and compiler options. It gives you specific instructions on
how to compile under the MPE XL operating system. The compiler listings
are discussed in detail as well as how to recover from compilation
errors.
Using Source Libraries
Source libraries help to standardize parts of RPG programs and reduce the
manual effort in coding programs. You enter commonly-used source code
into a source library, then copy that code into programs rather than
recoding it in each of them.
An RPG source library is a standard text file containing RPG
specifications. You can create a source library using any text
processor, such as EDITOR. Enter the RPG specifications exactly as they
should appear in a source program. When you want to use the source
libraries in a program, enter a $COPY statement at the beginning of the
program. $COPY enables the source library facility of RPG. At the point
in the program where you want to insert the source library text, enter an
$INCLUDE statement.
Figure 6-1 lists a program that extracts records from the D-ACCOUNTS data
set (see the MARKET schema in Figure 3-23). It prints the extracted
records and writes them to the file EXTRACT. There are two $INCLUDE
statements in the program. The first (line 3) copies the input field
definitions for D-ACCOUNTS. The second (line 5) copies the output field
definitions for the detail report record. Figure 6-2 and Figure 6-3 list
the contents of the source library files and Figure 6-4 shows what the
compiled source program listing looks like.