A BRIEF LANGUAGE


One of the first things anyone should learn about RPG is that it is a brief language. Only a few statements are needed to read a record, change the data in that record, and then update the record. With other languages, such as COBOL, dozens of lines of code are required to perform this process.

Languages such as the C language are often thought to be brief. Actually, RPG is the briefest of all higher-level languages. For example, to read a file containing orders, multiply the quantity ordered by the price, and update the file with the new information, only four RPG statements are required. See Figure 1.4.

start figure

 *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 0010 FORDERS    UPE  E             DISK 0020 C                   Eval      AmtDue = QtyOrd * Price 0030 OORDRCD    D    N1P 0040 O                       AmtDue 

end figure

Figure 1.4: Read a file, calculate price, and update file.

On line 10 of the example shown in Figure 1.4, the file ORDERS is defined as the primary file (indicated with the letter "P" in position 18). The file is declared as an update file (indicated with the letter "U" in position 17). The records that are read are modified on line 20 by multiplying the quantity ordered by the price, giving the amount due. Each record is automatically updated (i.e., rewritten with the new value) on lines 30 and 40 by the RPG cycle. (Line 30 contains the name of the record format for the file ORDERS; line 40 contains the name of the fields that are updated.)

As demonstrated in Figure 1.4, RPG can be one of the fastest programming languages with which to write. Once a programmer has learned the essentials, and adding in the benefit of prompting source code using an IDE or editor, the RPG language can be the easiest language to use and the most productive for general-purpose business applications.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net