Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
4 user(s) are online (3 user(s) are browsing encyclopedia)

Members: 0
Guests: 4

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

RPG programming language

RPG or RPG IV is a native programming language for IBM s iSeries (aka AS/400) minicomputer system. Its latest incarnation includes prototyped functions and procedures, static and dynamic binding, access to C programming language routine libraries, dynamic link library, and fully recursive and re-entrant code.

=Overview=

RPG (aka RPG IV aka RPGLE) is the mainstay programming language of the IBM iSeries platform. Originally designed as a query tool, IBM has enhanced the language to become a full-fledged, powerful programming language.

An RPG program typically starts off with a File Specification, listing all files being written to, read from or updated, followed by a Data Definition Specification containing program elements such as Data Structures and dimensional arrays (much like a Working-Storage section of a COBOL program or var statements in a C program). This is followed by the Calculation Specification, which contains the actual meat of the code. Output Specifications can follow which can be used to determine the layout of a report or the report can be defined externally.

In the early days of RPG, its major strength was known as the program cycle : every RPG program executes within an implied loop, which can apply the program to every record of a file. Alternately, the cycle can make an interactive program continue to run until explicitly stopped. Today, most RPG programmers avoid using the cycle in favor of controlling the flow of the program with standard looping constructs.

=History=

RPG is one of the few languages created for punch card machines that is still in common use today. This is because the language has evolved considerably over time. It was originally developed by International Business Machines in the 1960s and ran on the popular IBM 1401. 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 generally available at the time were either COBOL or BASIC programming language: one verbose, the other a poor tool for development, so RPG became pre-eminent on IBM hardware.

RPG was further developed by IBM for their range of mainframe systems, especially the System 390 - as RPG II.

Because the language syntax was based on the plug-boards used to program unit record equipment, and the System/3 was initially developed as a successor to plug-board programmable unit record machines, RPG II was ported to the System/3, System/32, System/34, and System/36, while an improved version of the language, RPG III, was created for the System/38 and its successor the AS/400 (a minicomputer machine, now evolved into the eServer iSeries) and became RPG/400 with a much cleaner syntax, and tighter integration with the integrated database. This language became the mainstay of development on the AS/400, and its editor was a simple line editor with prompt templates for each specification (type of instruction).

RPG III significantly departed from the original language, providing modern structured constructs like IF-ENDIF blocks, DO loops, and Subroutines.

In 1994, RPG IV (aka RPGLE aka RPG/ILE) was released and the name, officially, was no longer an acronym. RPG IV offered a greater variety of expressions within its new Extended Factor-2 Calculation Specification.

In 2001, with the release of i5/OS V5R1, RPG IV offered even greater freedom for calculations than offered by the Extended Factor-2 Calculation Specification: a free-format text-capable source entry, as an alternative to the original column-dependent source format. The /FREE calculation does not require the operation code to be placed in a particular column; the operation code is optional for the EVAL and CALLP operations; and syntax generally more closely resembles that of mainstream, general-purpose programming languages.

Today, RPG IV is a considerably more robust language. Editing can still be done via the simple editor or it can edited via PC using IBM s Websphere Development Studio. IBM is continually extending it capabilities and adding more built-in functions (BIFs). It has the ability to link to . And yet, it retains a great deal of backward compatibility. So an RPG program written 20 years ago could run today with little or no modification.

=Example 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

    The same program using free calculations:

  • F (file) specs define files and other i/o devices
  • FARMstF1 UF E Disk Rename(ARMST:RARMST)

  • D specs are used to define variables and parameters
  • The prototype for the program is in a separate file
  • allowing other programs to call it
  • /copy cust_pr
  • The procedure interface describes the *ENTRY parameters
  • D getCustInf PI D pCusNo 6p 0 const D pName 30a D pAddr1 30a D pAddr2 30a D pCity 25a D pState 2a D pZip 10a /free // The chain command is used for random access of a keyed file chain pCusNo ARMstF1;

    // If a record is found, move fields from the file into parameters if %found; pName = ARNm01; pAddr1 = ARAd01; pAddr2 = ARAd02; pCity = ARCy01; pState = ARSt01; pZip = ARZp15; endif; // RPG makes use of switches. One switch LR stands for // last record . This ends program execution. *InLR = *On; /end-free