260 likes | 378 Views
Welcome to RPG544. Bit about Cindy. Administrative Stuff. Standards Due Dates Web Page. RPG IV. R – Report P – Program G – Generator Version 4. History of RPG. 1964: RPG - Report Program Generator 1969: RPG II With release of System/3 1979: RPG III Interactive programming Database
E N D
Administrative Stuff • Standards • Due Dates • Web Page
RPG IV R – Report P – Program G – Generator Version 4
History of RPG • 1964: RPG - Report Program Generator • 1969: RPG II • With release of System/3 • 1979: RPG III • Interactive programming • Database • Structured Programming • 1988: RPG/400 • Upgrade to RPG III • 1994: RPG IV • Integrated Language Environment (ILE) • Modular Programming
Things that made RPG unique • Program Cycle Read a record Loop until Eof process the record read a record End of loop • Indicators
Specifications • Programs are organized in a series of specifications and appear in this order
H-Specs (Control Specifications) • Default formats (eg. Date formats) • Changes to normal processing modes • Eg changing the internal method that the program uses to evaluate expressions • Special options to use when compiling the program • Language enhancements that effect the entire program H Datfmt(*ISO) Timfmt(*HMS)
D-Specs (Definition) • Standalone variables • Named constants • Data Structures • Prototypes • Procedure Interfaces
D-Specs • Data name • 15 characters • Must start with a letter of the alphabet or $, # or @ • Remaining characters must be letters, numbers, _, #, $ or @ • Declaration Type • DS – Data Structure • C – Constant • PR – Procedure • PI – Procedure Interface • S – Standalone Variable
D-Specs • Length • Length of Data • Decimal Places • Number of decimal places • Data type
I-Specs (Field Definition) • Used to define fields in the file
C-Specs (Calculation) • Program logic! Factor1 Opcode Factor2 Result Indicators • RPG IV introduces free form RPG for C-Specs
O-Specs (Output) • Define the output of the program. May be report definitions or database.
P-Specs • Will discuss later in the course
Add qty1 add qty2 qty3 or add qty qty3
Sub qty1 sub qty2 diff or sub qty diff
Mult price mult qty sales or mult 0.14 sales
Div sales div qty price or div qty sales
Read • Reads the next record from a database object (sequential read) read sales 99 will ‘turn on’ indicator 99 if the end of file is reached.
EXCPT (EXCEPT) • Writes output to printer files excpt format
IF • RPG, RPGII, RPGIII • IFEQ, IFNE, IFLE, IFLT, IFGT, IFGE, etc • Ends with endif qty ifeq 0 endif • RPGIV free format • If • Ends with endif If qty = 0; Endif;
Do Loops • RPG, RPGII, RPGIII • DOWEQ, DOWNE, DOUEQ, DOUNE etc • Ends with ENDDO Qty Doweq 0 enddo • RPGIV free format • DOW, DOU • Ends with ENDDO Dow qty < 0; enddo;