24
Unit 1. RPG IV Introduction Copyright IBM Corp. 1996, 2000 1-1

IBM AS400 RPG IV Training Course(Course Code OL86)--2

Embed Size (px)

DESCRIPTION

H

Citation preview

Page 1: IBM AS400 RPG IV Training Course(Course Code OL86)--2

Unit 1. RPG IV Introduction

Copyright IBM Corp. 1996, 2000 1-1

Page 2: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-2

Unit Objectives - RPG IV Introduction

After completing this unit, you should be able to:

• Describe the evolution of RPG as a high level language

• Explain the general purpose of each RPG IV specification type

• List the order of RPG IV specification entries in a program

• Describe the steps to code and test an RPG IV program

• List several unique features of the RPG language and discuss RPG ′sstrengths and weaknesses

OL861000

Page 3: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-3

RPG in the Sixties

• 1960

• High Level Language

• Fixed-Logic Cycle

• Indicators

• Batch Oriented

• Card based machinesOL861105

Page 4: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-4

RPG II - RPG III

• 1970

• Mid-range Systems

− System/3− System/32− System/34− System/36

• Interactive applications

− Disk processing support

− Workstation support

• Structured program design for efficiency

• DBMS grew in sophistication

• System/38OL861110

Page 5: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-5

RPG/400

• 1990

• AS/400

• Enhancements

− New operation codes− Named constants− Initialization subroutines− Source code indentation

• Embed SQL statements in RPG codeOL861115

Page 6: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-6

What is RPG IV?

• Available beginning with V3R1• Component of ILE RPG for AS/400 Program Product• Expanded or eliminated language limits• Fulfill RPG programmers ′ requirements

− Longer field names− Free form expressions− Date/time calculations supported

• Positioned for future growth• ILE

− Part of OS/400 beginning with V2R3− More modularity

OL861120

Page 7: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-7

Development Cycle

• Define the problem

• Design the solution

• Write the program

• Test and debug the program

• Document the program

• Maintain the programOL861125

Page 8: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-8

OL86110L

Page 9: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-9

Describing a Programming Solution

• Print headings

• Read an employee record

• Do While more records exist:

− Count each employee record read− Write detail employee information− Read an employee record

• Print total number of employees

• End programOL861130

Page 10: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-10

OL861135

Page 11: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-11

RPG IV Specifications

• Seven types of Specifications:

(H) Control Specifications(F) File description Specifications(D) Definition Specifications(I) Input Specifications(C) Calculation Specifications(O) Output Specifications(P) Procedure Specifications

• Specific functions

• Optional

• Fixed-position / free-formOL861140

Page 12: IBM AS400 RPG IV Training Course(Course Code OL86)--2

Print Program

�FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords....................** ** Define the files **FEmp_Mast IF E DiskFEmp_ReportO E Printer

DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++Comments ** ** Define program work fields **D Count S 3 0

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq ** ** Process data records **C Read Emp_Mast ----40 ** ** Have we read a record? **C If NOT (*in40)C Eval Count = Count + 1C Write DetailC Endif

** ** At EOF, write total and terminate program by setting on LR **C If *In40C Write TotalC Eval *InLR = *ONC Endif

OL861145

Copyright IBM Corp. 1996, 2000 1-12

Page 13: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-13

OL861150

Page 14: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-14

OL861155

Page 15: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-15

OL861160

Page 16: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-16

CRTBNDRPG Compile Options

• GENLVL(10)

• OPTION()

− *XREF/*NOXREF− *GEN/*NOGEN− *SHOWCPY/*NOSHOWCPY− *NOSECLVL/*SECLVL− *EXPDDS/*NOEXPDDS− *EXT/*NOEXT

• DBGVIEW(*STMT)

• OUTPUT(*PRINT/*NONE)

• INDENT(*NONE)

• REPLACE(*YES)

• TRUNCNBR(*YES)

• TGTRLS(*CURRENT)OL861165

Page 17: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-17

OL861170

Page 18: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-18

Compiler Dire ctives

• Format the listing

/TITLE/EJECT/SPACE

• Include other members in the compilation

/COPY

• Conditionally include / exclude code

/DEFINE/UNDEFINE

• Documentation / readability

*OL861175

Page 19: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-19

OL861205

Page 20: IBM AS400 RPG IV Training Course(Course Code OL86)--2

Output Report

�Page: 1 EMPLOYEE INFORMATION

NAME SERIAL # DEPT TYPE

Haas 000010 A00 REGULARThompson 000020 B01 MANAGERKwan 000030 C01 MANAGERGeyer 000050 E01 MANAGERStern 000060 D11 MANAGERPulaski 000070 D21 MANAGERHenderson 000090 E11 MANAGERSpenser 000100 E21 MANAGERLucchesi 000110 A00 REGULARO Connell 000120 A00 REGULARQuintana 000130 C01 REGULARNicholls 000140 C01 REGULARAdamson 000150 D11 REGULARPianka 000160 D11 REGULARYoshimura 000170 D11 REGULARScoutten 000180 D11 REGULARWalker 000190 D11 REGULARBrown 000200 D11 REGULARJones 000210 D11 REGULARLutz 000220 D11 REGULARJefferson 000230 D21 REGULARMarino 000240 D21 REGULARSmith 000250 D21 REGULARJohnson 000260 D21 REGULARPerez 000270 D21 REGULARSchneider 000280 E11 REGULARParker 000290 E11 REGULARSmith 000300 E11 REGULARSetrignt 000310 E11 REGULARMehta 000320 E21 REGULARLee 000330 E21 REGULARGounot 000340 E21 REGULAR

NUMBER OF EMPLOYEES 32

OL861210

Copyright IBM Corp. 1996, 2000 1-20

Page 21: IBM AS400 RPG IV Training Course(Course Code OL86)--2

Using the RPG Logic Cycle

�FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++

FEmpMaster IP E K DISKFQprint O F 132 PRINTER OFLIND(*in73)DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsDType S 8DCount S 3 0CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval *in73 = *offC If *InLR = *offC If JOB = ′ MANAGER′C Eval Type = ′ MANAGER′C ElseC Eval Type = ′ REGULAR′C EndIfC Eval Count = Count + 1C EndIfOFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+........................OQprint H 1P 2 2O OR 73O 5 ′ Page:′O PAGE Z 10O 50 ′ EMPLOYEE INFORMATION′O H 1P 2 1O OR 73O 12 ′ NAME′O 34 ′ SERIAL #′O 45 ′ DEPT′O 56 ′ TYPE′O D 1O LastName 20O Empno 32O WorkDept 45O TYPE 60O T LR 1O 20 ′ NUMBER OF EMPLOYEES′O COUNT L 27

OL861215

Copyright IBM Corp. 1996, 2000 1-21

Page 22: IBM AS400 RPG IV Training Course(Course Code OL86)--2

Using Full Procedural - Non-Cycle

�FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++

FEmpMaster IF E Disk FEmpReport O E Printer OflInd(*IN73)

** CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq

** �1� Write report heading and read first recordC Write HeadingC Read Employee ----40 ** �2� Read the file and process until EOF using a loopC DoW *in40 = *OFFC Eval Count=Count + 1C Eval Name = %trimr(Lastname) **C IF Job = ′ MANAGER′C Eval Type = ′ MANAGER′C ELSEC Eval Type = ′ REGULAR′C EndIf ** �3� Check if overflowC If *in73 = *ONC Write HeadingC Eval *in73 = *offC EndIf ** �4� Write record to report and read next recordC Write DetailC Read Employee ----40C EndDo ** �5� Perform EOJC Write TotalC Eval *inlr = *on

OL861215

Copyright IBM Corp. 1996, 2000 1-22

Page 23: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-23

OL86120L

Page 24: IBM AS400 RPG IV Training Course(Course Code OL86)--2

C

op

yrigh

t IBM

Co

rp. 1

99

6, 2

00

01

-24

Unit Summary

Having completed this unit, you should be able to:

• Describe the evolution of RPG as a high level language

• Explain the general purpose of each RPG IV specification type

• List the order of RPG IV specification entries in a program

• Describe the steps to code and test an RPG IV program

• List several unique features of the RPG language and discuss RPG ′sstrengths and weaknesses

OL861ZZZ