rpg iv n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
RPG IV PowerPoint Presentation
Download Presentation
RPG IV

Loading in 2 Seconds...

play fullscreen
1 / 22

RPG IV - PowerPoint PPT Presentation


  • 148 Views
  • Uploaded on

RPG IV. Maintaining the Past - Chapter 13. Objectives. Discuss the migration of older RPG programs to RPG IV Introduce the features now obsolete in RPG IV Introduce the fixed logic cycle Introduce the conditioning, resulting, and level indicators. Compatibility and Conversion.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'RPG IV' - fordon


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
rpg iv

RPG IV

Maintaining the Past - Chapter 13

objectives
Objectives
  • Discuss the migration of older RPG programs to RPG IV
  • Introduce the features now obsolete in RPG IV
  • Introduce the fixed logic cycle
  • Introduce the conditioning, resulting, and level indicators
compatibility and conversion
Compatibility and Conversion
  • RPG II programs could be compiled under RPG III with only slight changes
  • RPG IV source code lines increased to 100 characters
  • A CL command CVTRPGSRC (Convert RPG Source) will convert pre-RPG IV source code to RPG IV syntax
defining work fields
Defining Work Fields
  • In RPG III, D Specs did not exist
  • Work fields were defined within the C Specs in which the field appeared as a result
performing arithmetic and numeric assignment
Performing Arithmetic and Numeric Assignment
  • The EVAL operation was also not avaibable before RPG IV
  • Specific arithmetic operations were used (ADD, SUB, MULT, DIV)
  • In its basic form, operation ADD adds the value of Factor 1 and Factor 2, storing the answer in the Result field
  • Only one arithmetic opeation is coded per line
performing arithmetic and numeric assignmet cont
Performing Arithmetic and Numeric Assignmet (cont)
  • Z-ADD and Z-SUB were used to assign value to numeric variables
  • The function of the Z-ADD was to zero out the Result field and add Factor 2 to it
  • The function of the Z-SUB was to zero out the Result field and subtract Factor 2 from it
looping and selecting
Looping and Selecting
  • Pre-RPG IV looping and selecting operations are not free-form expressions
  • DOWxx, DOUxx, Ifxx, WHENxx are the operations (the small xx represents relational code)
  • Two unstuctured operations were also available: CABxx and GOTO
manipulating strings
Manipulating Strings
  • SUBST has been superseded by the built-in function %SUBST
  • CAT has been made obsolete by the concatenation (+) operator used within an EVAL operation
delimiting arrays and tables
Delimiting Arrays and Tables
  • Compile time Tables and Arrays use ** rather than **CTDATA and the array/table name
  • Progams with multiple compile time tables/arrays must define the tables/arrays in the same order as the data appears at the programs end
  • E Specs used to define tables/arrays are obsolete
moving data
Moving Data
  • Before EVAL, MOVE and MOVEL were used for all character assignment operations
  • Before the introduction of string operations, arrays and the MOVEA operation were used to inspect and manipulate characters within string fields
rpg ii an initial look
RPG II: An Initial Look
  • RPG II programs rely on RPG’s fixed logic cycle
  • All versions of RPG (including RPG IV) have a built-in read-process-write cycle that could be used to automate part of the processing requirements
  • To start the cycle, the main file must be designated as P (for Primary) instead of F (for Full procedural)
rpg ii an initial look cont
RPG II: An Initial Look (cont)
  • A record-identifying indicator in positions 21-22 on the I Specs is added
  • The indicator will be turned on each time RPG successfully reads a record
  • The indicator will be turned off just befor the next automatic attemp to read the file
  • At EOF the LR indicator is automatically turned on
rpg ii an initial look cont1
RPG II: An Initial Look (cont)
  • Each record format type on the O Specs is changed from E to the type appropriate for a given line:
    • H for heading lines
    • D for detail
    • T for total
  • Remove the line names
rpg ii an initial look cont2
RPG II: An Initial Look (cont)
  • Indicator 1p (First Page) is used for first time headings
  • Indicator OF is used for page overflow
  • Indicator 01 is used to print the detail lines
rpg s fixed logic cycle
RPG’s Fixed Logic Cycle

Turn on 1P indicator

WHILE LR is off

Print detail output (H and D lines)

Turn off 1P, record-identifying, and level indicators

Read record from primary file

IF end-of-file

Turn on LR and all level indicators

ELSE

Turn on record-identifying indicator

IF change in control field

Turn on level indicator(s)

ENDIF

Perform total calculations

Perform total output (T lines)

IF LR is not on

IF overflow indicator is on

Print lines conditioned by overflow

ENDIF

Move data into input fields

Perform detail calculations

ENDIF

ENDWHILE

the fixed logic cycle and control breaks
The Fixed-Logic Cycle and Control Breaks
  • Control-break reports require detecting a change in a control-field value
  • When such a change is detected:
    • Print a subtotal
    • Roll over accumulators
    • Zero out accumulators
    • Reset the hold field
the fixed logic cycle and control breaks cont
The Fixed-Logic Cycle and Control Breaks (cont)
  • Special level indicators, L1-L9, that can be associated with control fields
  • Level indicators eliminate the need for special hold fields
  • Level indicators can condition any calculations and printing out subtotals
  • B in position 45 on O Spec will automatically set the field to zero
decisions in rpg ii
Decisions in RPG II
  • RPG II relies on COMP (Compare) operation for decision logic
  • Operation COMP compares the values of Factor 1 and Factor 2 and turns on an indicator in the Hi, Lo or Eq columns
  • The indicators are then used in calcualtions following the COMP to condition whether the operation was to be performed
resulting indicators and arithmetic
Resulting Indicators and Arithmetic
  • Arithmetic operations used resulting indicators
  • If the result was positive the Hi indicator was turned on
  • If the result was negative the Lo indicator was turned on
  • If the result was 0 the Eq indicator was turned on
iteration and rpg ii
Iteration and RPG II
  • In RPG II, loop logic was implemented using the COMP operand and indicators
  • The indicators conditioned a GOTO that sent control back to prior calculations to repeat procesing steps
improving on the past
Improving on the Past
  • RPG IV free-form exprssions is preferable to using the older specific arithmetic operations, assignment operations and fixed-format decision and iteration operations
  • Data definitions should always take place in the D Specs, rather than within the C Specs
points to remember
Points to Remember
  • RPG has evolved since its introduction in the early 60s
  • Use of the fixed-logic cycle has diminished through time
  • Today’s programmers should avoid outdated techniques in their own code, they still must understand how such methods and operations work