The iSeries/AS400 is the follow-on to the System/38 database machine initially released in 1985. AS400 (known as Silverlake) was released in 1989, and the product line was refreshed and named iSeries in 2000.
Originally, RPG was an acronym for Report Program Generator, descriptive of the purpose of the language: generation of reports from data files, including matching record and sub-total reports.
The alternative languages available were COBOL or BASIC, one verbose, the other a poor tool for development, so RPG became pre-eminent.
RPG III significantly departed from the original language, providing modern structured constructs like IF-ENDIF blocks, DO loops, and subroutines.
In 1998 RPG IV (aka RPG/LE) was released and the name, officially, was no longer an acronym.
This latest incarnation includes prototyped functions and procedures, static and dynamic binding, access to C routine libraries, dynamic link libraries, and fully recursive and re-entrant code.
Sample RPG Code:
The following program receives a customer number as an input parameter and returns the name and address as output parameters.
* Historically RPG is columnar in nature, though free-formatting
* is allowed under particular circumstances.
* The purpose of various lines code are determined by a
* letter code in column 6.
* An asterisk (*) in column 7 denotes a comment line
* "F" (file) specs define files and other i/o devices
FARMstF1 UF E Disk Rename(ARMST:RARMST)
* "D" specs are used to define variables
D pCusNo S 6p 0
D pName S 30a
D pAddr1 S 30a
D pAddr2 S 30a
D pCity S 25a
D pState S 2a
D pZip S 10a
* "C" (calculation) specs are used for executable statements
* Parameters are defined using plist and parm opcodes
C *entry plist
C parm pCusNo
C parm pName
C parm pAddr1
C parm pAddr2
C parm pCity
C parm pState
C parm pZip
* The "chain" command is used for random access of a keyed file
C pCusNo chain ARMstF1
* If a record is found, move fields from the file into parameters
C if %found
C eval pName = ARNm01
C eval pAddr1 = ARAd01
C eval pAddr2 = ARAd02
C eval pCity = ARCy01
C eval pState = ARSt01
C eval pZip = ARZp15
C endif
* RPG makes use of switches. One switch "LR" stands for
* "last record". This ends program execution.
C eval *InLR = *On