RPG (programming language)

from Wikipedia, the free encyclopedia

Report Program Generator ( RPG ) is a problem-oriented programming language for the commercial sector. The language was developed by IBM initially for the creation of commercial lists ( reports ). RPG was later expanded into a programming language.

history

The history of machine data processing written by IBM describes RPG as a "bridge from the pegboard to the database". It therefore enabled the transition from the tabulation machine (pegboard) to the report generator, for which the IBM 1401 system was used as an example .

The former IBM employees Günther Sander and Hans Spengler argue similarly when considering RPG:

“To support the large number of people switching from punch card machines to EDP systems, especially to the IBM 1400 series, IBM developed the Report Program Generator (RPG). This is a description language with which the list structure of tabulating machine applications could be described and a translation program that generated a 1401 program from the descried description forms. "

or here

“In order to facilitate the switch from traditional punch card processing to electronic data processing , the high-level language RPG was developed and was available on many (IBM) computers from the 1960s onwards. Its syntax was based on the way tabulating machines work, but the tedious cabling on breadboards has given way to writing source code and compiling . "

At that time, tabulation machines and punch cards were used in data processing , which is why the language structure was column-oriented before the RPG IV version appeared. Pictured on group change .

The language is mainly used in the area of mainframes , mini-computers like medium-sized data technology , such as on the S / 390 or the AS / 400 ( System i ). RPG evolved from a language for list processing to a programming language that covered all commercial applications, including dialog processing and working with relational databases.

RPG II, RPG III, RPG / 400

Programs that were written with RPG are also maintained today. After further developments (RPG II, RPG III, RPG / 400), newer projects can now be written with the better RPG IV (ILE RPG).

RPG programs are processed in a program cycle, the steps of which are repeated over and over again. In the first step general information of the header (will header ) processes. This is followed by reading a data record and processing it. The next step is to output the processed data. If a certain indicator (the LR indicator) is then set to ON, the program is terminated. If the indicator is still set to OFF, the next record is prepared for processing.

A simple program gets by with five out of ten determinations:

  • Calculation - it is used to process the data. It defines the order and the respective commands
  • File Description - It describes all of the files used by the program. The following information is required for this: 1. File name, 2. Type of file use, 3. Record length in the file, 4. Input or output unit
  • Header definition - it defines general conditions and values.
  • Input - it defines fields, constants or data structures .
  • Output - Describes the fields and records of the output files and the condition under which the output will be performed.

The program cycle takes over the processing rules for the respective file. The programmer does not have to worry about access to each individual data record, which, however, also brings with it a certain inflexibility. The use of the cycle is a relic from RPG II. It is mostly no longer used in today's RPG programs. RPG also had certain limitations: For example, it was not possible to perform more complex calculations such as recursive algorithms.

RPG IV

RPG IV (ILE RPG) is a programming language developed by IBM. The abbreviation ILE stands for Integrated Language Environment and describes a development environment introduced in 1993. The first language that was designed with ILE was ILE C / 400 for version V2R3 of the OS / 400 operating system . The languages ​​ILE RPG, ILE COBOL / 400 and ILE CL (Control Language) were only added in version V3R1. With ILE it is possible to create a program that consists of modules that were written in different programming languages ​​(but which must belong to the ILE family).

As the successor to RPG, ILE RPG offers some significant changes and enhancements:

  • The new D definition (definition definition) is now the standard definition for declaring fields, data structures or constants.
  • Integration of SQL commands for reading or changing databases.
  • It does not matter whether the source code is written in uppercase or lowercase letters.
  • Several restrictions have been corrected, e.g. B. the extension for the maximum character length of field names from 6 characters to 17 characters.
  • Various options for date and time operations.
  • Pointer-oriented operations.
  • A variety of built-in functions such as% trim - remove spaces.
  • Possibility to no longer have to work in a column-oriented manner thanks to the compiler instruction / FREE (only from OS / 400 version 5)
  • Unicode support is constantly being improved; For example, from V5R3 onwards “UnicodeFeld =% UCS2 (character field)” can be coded, from V6R1 “Unicode field = character field” is sufficient.
  • As of V4R4 there is comprehensive support for the connection of Java classes. For this purpose, the new data type "Object" was created, and Java methods in classes can be called directly using prototyped CALL.
  • As of V5R4, RPG programmers can conveniently access the content of XML documents with the newly created operation keys XML-INTO and XML-SAX .
  • As of V6R1, files can also be defined locally (in functions). The limits for character variables and data structures have been increased to 16 MB.

Examples

1. File description

FDateiname+IPEASF.....L.....A.E/AEinh.Schlüsselwörter++
Ftest1     IF   E             DISK

This example shows how to set the policy for the test1 file. I defines an input file, F defines a fully procedural file, i.e. H. processing is not left to the program cycle. By E is determined that the file is described externally. DISK indicates that the file is on disk or in single-level storage.

RPG enjoys exceptionally good database support. For example, it is possible to read a certain record of a file using its key (operation key CHAIN), with a performance that SQL on platform "i" has not yet achieved. It is sufficient to specify a K for "keyed access" under the "A" in front of the "input / output unit".

FDateiname+IPEASF.....L.....A.E/AEinh.Schlüsselwörter++
Ftest1     IF   E           K DISK

The compiler uses the E in the file description to define all fields in the file; if auxiliary fields are used that are to be typed exactly like the file fields, "LIKE" is to be used. In this case, when making changes to the database, it is often sufficient to just compile the relevant program. Normally this is necessary anyway, since the operating system prevents programs that were created with an older version of the file from being called by issuing an "update check".

2. Procedures, definitions and calculation rules
Program for calculating the faculty

H DFTACTGRP(*NO)
H************************************************************
D Fak             PR            10I 0
D  Zahl                         10I 0 VALUE
D Wert            S             10I 0
D************************************************************
C                   EVAL      Wert = Fak(5)
C                   DSPLY                   Wert
C                   EVAL      *INLR = *ON
C************************************************************
P Fak             B
D Fak             PI            10I 0
D  Zahl                         10I 0 VALUE
C
C                   IF        Zahl = 1
C                   RETURN    Zahl
C                   ELSE
C                   EVAL      Zahl = Zahl * Fak(Zahl – 1)
C                   RETURN    Zahl
C                   ENDIF
P Fak             E

Fak is defined with PR as a procedure . The 10I 0 indicates that the return value is an integer that is 10 digits long and has 0 decimal places. Number is the first parameter of the procedure. It is declared as a value parameter with VALUE . The procedure must finally be defined under the main arithmetic provisions.

The EVAL instruction assigns certain values ​​to fields. DSPLY outputs a program message . INLR (LR = last record) is the indicator that indicates that the program has ended.

3. RPG-Free format

DName+++++++++++ETDsVon++++Bi/L+++IDG.Schlüsselwörter++++++++
D Array           S             10I 0 DIM(5)
D K               S             10I 0
 /FREE
   FOR k = 1 TO %elem(Array);
     Array(k) = k;
   ENDFOR;
   EVAL *INLR = *ON;   // das EVAL könnte man auch weglassen
 /END-FREE

This example shows the use of the free format. The actual statements must be placed between the compiler directives / FREE and / END-FREE. Comments are introduced with //.

RPG year 2016

“The language that IBM originally developed for those switching to punched cards, for example, provides a range of tools to provide web services - now also completely native in RPG code. ... New in RPG is also the 'free form', in which programming instructions can begin in column 1 and have no length restriction, while in the old 'fixed form' only columns 6 to 80 were allowed to contain code. "

(A standard punch card had 80 columns, columns 1–5 were originally reserved for line numbering in the RPG.)

Platforms

RPG was originally developed for the IBM 1401 . For the systems / 3, / 32, / 34, / 36, / 38, extensions were created again and again, which finally reached the high point with the ILE concept on the AS / 400, iSeries and currently the System i (introduced in 2008) . There are also implementations for Telefunken TR 440 , Siemens BS2000 , WANG VS and HP3000 as well as various compilers for Unix-based systems (Unibol) and PCs (Baby / 400, Lattice-RPG).

Linux / AIX: Based on the formerly publicly accessible project "RPG2CPP" by Edgar Hermanns, an RPG400 to C ++ translator has been developed since 2007 at the company "Phoenix Informatica Bancaria SpA" in Trento, Italy, the RPG400 applications including the associated CL programs in native form Makes C ++ sources executable on Linux and AIX. Currently (as of February 2016) the compiler translates around 98% of the application inventory, which consists of around 30 million lines of code in RPG400. The project makes it possible to continue writing RPG400 programs and running them on the systems mentioned. COPY statements, DDS sources and library lists are supported both during compilation and during runtime. Both MySQL and Oracle can be used as the database.

Web links

Individual evidence

  1. The history of machine data processing. Volume 1, subtitle IBM Encyclopedia of Information Processing, - IBM Form D 12-0028 (3/91), heading page 140
  2. Günther Sander, Hans Spengler: The development of data processing from Hollerith punch card machines to IBM enterprise servers. Self-published, Böblingen 2006, ISBN 3-00-019690-0 , p. 39.
  3. "RPG: Bridge from the pegboard to the database". In: The history of machine data processing. Volume 1: IBM Encyclopedia of Information Processing, IBM Form D 12-0028 (3/91), pages 140-141.
  4. 'From punch cards to web services: IBM i 7.3' Heise online April 12, 2016