7dcd6d88d493685e70c2694d6ec359be.ppt
- Количество слайдов: 25
Welcome to RPG 544
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 – 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 Spec Type Description When Introduced H Header (control) RPG F File RPG D Definition RPG IV I Input RPG C Calculation RPG O Output RPG P Procedure RPG IV
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)
F-Specs Position Use 7 -16 File Name 23 -27 Record Length For program described 17 File Type (I, U, or O) 36 -49 Device Disk, Printer, Workstation 18 File Designation Blank – output file F – Full Procedural P – Primary File (logic cycle) S – Secondary File (logic Cycle) R – Record address file T – Table 44 -80 Keywords (see appendix A of text book) 22 File Format F – Program Described E – Externally Described
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 Pos Use 7 – 16 Filename 36 Data Type 17 – 18 Sequence NS – if no sequence required 2 digit number if sequence is required 37 – 46 Field Location 19 Number Leave blank 47 – 48 Decimal Positions Required by numeric fields 20 Option Leave blank 49 – 62 Field Name 6 characters up to RPGIII 14 characters RPG IV 21 – 22 Record id (indicator)
C-Specs (Calculation) • Program logic! Factor 1 Opcode Factor 2 Result Indicators • RPG IV introduces free form RPG for CSpecs
O-Specs (Output) • Define the output of the program. May be report definitions or database. Pos Use 7 -16 File. Name 30 - 43 Field Names 17 Type D-Detail H-Header E-Exception T-Total 53 – 80 Constants / Edit Word 30 – 39 Exception Name 47 – 51 End Position 40 – 45 Skip and Space Entries 52 Edit code
P-Specs • Will discuss later in the course
Add qty 1 add qty 2 qty 3 or add qty 3
Sub qty 1 sub qty 2 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, RPGIII – IFEQ, IFNE, IFLT, IFGE, etc – Ends with endif qty ifeq 0 endif • RPGIV free format – If – Ends with endif If qty = 0; Endif;
Do Loops • RPG, 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;
Itempgm Demo
7dcd6d88d493685e70c2694d6ec359be.ppt