IBM RPG II
From Wikipedia, the free encyclopedia
RPG II is a version of the RPG programming language. It was developed in the late Sixties and was offered on a number of different computers, including the IBM System/3 System/32, System/34, System/36, System/370 and the Wang VS Series.
RPG stands for Report Program Generator. RPG is a fixed-format programming language, which means that code must be placed in exact column locations in order to generate correct results. COBOL and BASIC are considered free-format to some extent because the code can be placed variously and still generate correct results.
RPG also incorporates fixed logic, which means that files are opened when the program begins and closed when the program ends, even though this is not explicitly stated; special variables such as UDATE, UYEAR, PAGE, and so forth, are filled when the program begins or when page overflow occurs, even though there is no explicit instruction for these activities. Total calculations and output are done at "total time," after the detail cycle when L1/LR has been set on by fixed logic.
The concept of RPG fitted neatly with a cyclical machine that read cards, summarised their contents and prints a result, rather like a tabulating machine, The language was extended to handle other input and output devices and provides a fast and efficient method of programming.
Devices such as the workstation (WORKSTN), the keyboard (KEYBORD), or the console (CONSOLE) do not have a fixed number of records at the beginning of the job and therefore, in order to incorporate the fixed-logic RPG "Last Record" cycle, the LR indicator can be set on with a SETON instruction. LR cannot be set off.
[edit] RPGII Specifications
In the popular System/36 implementation of RPG II, there are 7 different specification types: (1) The H or Header spec is at the top of the program and describes compiler options such as maximum compile size, whether the program is a MRT or Multiple Requestor Terminal program, and what type of listing is generated when the program is compiled. (2) The F or File spec(s) are next, and describes the files used in the program. Files may be disk files (DISK) or may be devices such as a printer (PRINTER), the workstation (WORKSTN), keyboard (KEYBORD), unformatted display (CRT or DISPLAY), or user-defined (SPECIAL). Record size, block size, overflow indicators, and external indicators are described. (3) The E or Extension spec(s) are next, and describes arrays and tables, which may be prefetched from disk files (an Input table), drawn from constants placed at the end of the source between ** and /* symbols, or built from calculations. (4) The L or Line Counter spec(s) are next, and if present, describes the form to be printed. It defines the number of lines in a page and the positions where printing begins and ends. (5) The I or Input specs are next, and describe the data areas within files. RPG II permits redefinition of data areas so that a field named FLDA might occupy the same area as an array AR that contains 8 elements of 1 character each. Non-record areas such as data structures can be described. Depending on the values of the input record, indicators may be conditioned. (6) The C or Calculation spec(s) are next. Total fields may be described and accumulated. Complex computations and string manipulations are possible. Indicators may be conditioned. (7) The last specification(s) are O or Output specifications, which describe the output record in terms of fields and output positions. OPERATION CODES appear in columns 28-32 of an RPG-II calculation specification. ADD Add SUB Subtract MULT Multiply DIV Divide Z-ADD Zero and Add Z-SUB Zero and Subtract MVR Move Remainder MOVE Move MOVEL Move Left MHLZO Move High to Low Zone MLHZO Move Low to High Zone MLLZO Move Low to Low Zone MHHZO Move High to High Zone BITON Bit On BITOF Bit Off TESTB Test Bit GOTO Go To TAG Tag (Object of a GOTO) EXSR Execute Subroutine BEGSR Begin Subroutine ENDSR End Subroutine SETON Set On SETOF Set Off EXCPT Exception EXIT Exit RLABL Redefine Label ULABL User Label CALL(*) Call PARM(*) Parameter CHAIN Chain READ Read READE Read Equal READP Read Previous REDPE Read Previous Equal SETLL Set Lower Limits SET Set TIME Time of day (000000-235959) DSPLY Display SORTA Sort Array XFOOT Crossfoot
- CALL/PARM was added to RPG II with Release 6.0 (also known as the VASP.)
CHAIN retrieves the record in the indexed file named in Factor 2 that matches the exact key specified by the value in Factor 1.
SETLL causes the index pointer for the file named in Factor 2 to be positioned at the location specified by the value in Factor 1.
SORTA causes the named array to be sorted in place; that is, the elements appear in order.
Z-SUB calculates Factor 2 with opposite sign and moved to result field.
XFOOT causes an array to be summed and the result moved to result field.
MVR must follow a DIV operation. The integer remainder of the DIV operation is placed in the result field. MVR following the DIV operation for "56 divided by 3" would place the value 2 in the result field.
[edit] I N D I C A T O R S
Standard 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 Halt Indicators H1 H2 H3 H4 H5 H6 H7 H8 H9 Matching Indicators M1 M2 M3 M4 M5 M6 M7 M8 M9 MR Control-Level Indicators L1 L2 L3 L4 L5 L6 L7 L8 L9 Command Key Indicators KA KB KC KD KE KF KG KH KI KJ KK KL KM KN KP KQ KR KS KT KU KV KW KX KY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 (These indicators refer to command keys 1 thru 24. Note there is no "KO" indicator.) First Cycle Indicator 1P Last Record Indicator LR Overflow Indicators OA OB OC OD OE OF OG OV External Indicators U1 U2 U3 U4 U5 U6 U7 U8