1 spring 2014 cs 230 – procedural programming rpg language on ibmi power systems rick flagler...

45
1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

Upload: nyla-cutsforth

Post on 30-Mar-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

1

Spring 2014CS 230 – Procedural Programming

RPG language on IBMi POWER Systems

Rick FlaglerAdjunct Professor

Page 2: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

2

Major Concepts of THIS course

Use of RPG, PDM, Rational development tools

Understanding of the mechanics of creating and compiling a program

Application of RPG language to access the built-in DB2 database of IBMi Native DB access Embedded SQL statements

Relationships involved in the nature of data and programs

Page 3: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

3

Level set – where are you in relation to other students and developers?

1- I have never programmed – don’t know what it is2- I’ve done some programming – think RPG = Role Playing Games3- I’ve heard of RPG in this context4- I work in a place using IBMi OS or similar mainframe / programs5- I’ve programmed a lot in other languages 6- I use RPG but want to learn more7- I could sub for Rick as teacher – just here for easy credit

1 2 3 54 6 7

Page 4: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

4

Tonight’s agenda

Introduce IBMi and Power HardwareDiscuss history of how this platform

came to be and why so popular in business world

Discuss tools used for programming and administration of system

Discuss language and Database Access for built-in DB2 database

Page 5: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

5

Class environment

“IBMi – operating system DB2 database Emulation = telnet (5250)

STRPDM command PDM = Program Development Manager

Operations or i Navigator = Client-server GUI Rational Developer for Power Systems

Rdi or RDp

Can get these last two products from Lab MonitorsOr from Professor

Page 6: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

6

Tools you might run into when using IBMi server

Navigator GUI file browser Work area to create DB2 stuff

RDi Integrated Development Environment for iSeries compilers RPG, Java, C, COBOL Debugger Data Views Eclipse foundatioin with IBMi specific plug-ins

Websphere Application Server Server environment for Java Servlets and Web Applications

“Green Screen” – Operations console, command line, various server tasks STRPDM – launchs editor environment CALL – runs programs SBMJOB – submits program calls or commands to batch (background) processing

Page 7: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

7

Navigator – GUI interface of IBMiformerly Operations Navigator

UserID and Password required for server access

PIE3.keene.edu

Page 8: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

8

Navigator - Database Access Database menu allows you to access a LIBRARY, also known by the SQL terms COLLECTION or SCHEMA, and the objects within.

Page 9: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

9

Integrated File System

/ “root

/QDLS – PC-based Document library objects (DLOs) and folders

/QFILESVR.400 –access to other file systems residing on remote iSeries

/QNTC – local/remote Integrated Netfinity Servers running Windows NT or 2000

/QOPENSYS – UNIX-based files and directories

/QOPT – stream files stored on optical media

/QSYS.LIB – iSeries libraries and various objects

/Mounted-name (NFS) – Any Network File System exported by an NFS server

/User-defined file system – contains user-defined/managed file systems

File system “contains” DOS, Windows PC-like file and folders as well as native Objects.

Page 10: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

10

Navigator - IFS view

Page 11: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

11

Emulation = Telnet so-called (green screen)

IBMi Access Windows Versions Emulation sessions Mapped drives Database access Data transfer Application

programming interfaces (APIs) - defined set of programming constructs

iNavigator - the GUI of the system

Page 12: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

12

Client Server development tools

RDi or RDp Rational Developer tools

Part of Eclipse Open Source Consortium

Includes all typical development tools for mainframe, PC and web areas

Part of the Application Development Toolset for the iSeries LPEX = Live Parsing Editor Extensible

cross application editor for creating source code for almost any PC or Host-based languages

Java, CL, RPG and COBOL, DDS

Page 13: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

13Typical Eclipse or RDi interface

Explorer Code

Status

Rational layout

Page 14: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

14

Competencies to gain

To become a successful application developer, you need the following skills: Analysis: How to analyze an existing (or proposed) system

to identify required objects and processes Specification: how to specify system objects and

processes in a way that is useful to the end-users and/or implementers

Design: how to design database files, programs Implementation: how to code to create objects, DB files,

programs etc. Testing: How to test software at the component and

system level Deployment: How to put programs, databases and

software into production use. This course will teach some skills in each of these

important areas.

Page 15: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

15

What is a Database? A database is a set of

computer files to store information.

A database management system (DBMS) is the system software enabling computer users to define and update database files.

DB2 or Universal Database (UDB) for i is an integrated part of i5/OS, the operating system of the IBMi. This is different than other platforms where you buy load DB separately.

LAN

Carbuy.com

Server

Clients

Page 16: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

16

Database Object terminology

DatabaseSchemaTableRowColumn

SchemaASchemaA

SchemaBSchemaB

Table1Table1Table2Table2

RowRowRowRows

Rows

Columns

Database

Page 17: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

17

Database

The software or hardware that enables you to create objects to store and manipulate data in a computer.

Think of the database as a room full of file cabinets. Some names and makers of popular database software

DB2 Oracle MySQL Informix DataComm SQL Server Access – Microsoft Office (not a full database but used by many)

Page 18: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

18

SchemaSchema (aka Library or Collection) – All

these terms mean the same thing. A schema is a container where database objects are stored. Different DB software will use various names. IBM used to call it a Library or a Collection and now a Schema Industry standards influence the naming Think of the Schema as a file cabinet There can be many schemas created in any

databaseYou give each schema a unique name in the database

SchemaSchema

Page 19: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

19

TableTable – Often also called a File, the

Table is the physical object that is created to hold data and store facts about a specific type of data, the shape of data and access information as well. Many tables are created in a schema Think of each Table as a file folder Many times you will hear Tables referred

to as the Database.

SchemaSchemaTableTable

Page 20: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

20

Row

Row – The Row holds a set of related facts and is also referred to as a Record. In database software, rows are numbered

from 1 through however many there are.Usually there is some theoretical maximum

number of rows or records that you probably will not reach.

An Excel spreadsheet can hold only 65535 rows Think of each Row as a piece of paper in a

file folder

SchemaSchema TableTableRows

Page 21: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

21

Column Column – A Column, also called a Field contains

one fact. Each column is assigned a data type. Some of

these types are CHARACTER, DATE, TIME, NUMERIC and a host of others.

A Table will always have at least one Column and usually many In a good design, one or more columns will uniquely

identify a specific row Each Row in the Table has the same layout of columns

In other words, the Column definition applies to all Rows in the Table and is defined when the Table is first created.

As Rows are added or removed from the Table, all columns become available

Think of a Column as a line on a piece of paper

SchemaSchema TableTableRows

Columns

Page 22: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

22

Database processing

Past All data resided on one central host Database contained text only One sequence for data review at a time Sorting of physical data from one sequence

to new sequence when neededNow

Data all over the place – on more than one computer

Multimedia - Sounds, BLOB, CLOB, GIF, JPEG Many “logical” sequences provide access

simultaneously by different people for differing uses – these are called Index objects

Page 23: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

23

IBM Computer History 1960’s - Mainframe systems

System/360 - mainframe 1970’s - Small business computers emerge

System/3, System/32, System/34, System/36 System/370 - next generation mainframe

1978 System/38 – numerous radical concepts single level storage - everything handled as memory device independence – everything is data Allowed new hardware with NO SOFTWARE CHANGES – still revolutionary today!

1980’s through 1990’s - Application System/400 (ie. AS/400) merged System/38 and System/36 hardware reinvented several times since 1988 - now 64-bit double (or triple) horsepower every year

2000 - AS/400e model 8xx - first huge AS/400s 2001 - Renamed from AS/400 to iSeries – joined with pSeries, zSeries 2003 – i890, i870 and other i8xx models with new software packaging announced –

more powerful/competitive than ever 2004 – IBM announces next generation iSeries and pSeries computers for business

and scientific computing – similar architecture, shared hypervisor to allow various operating systems to run in partitions

2008 – IBM combines pSeries/iSeries into POWER Systems such that all systems can run any OS offered (AIX, Linux, “IBM i” and with external box/internal card Windows)

2009 – IBM announces POWER7 – 7th generation of high performance chips 5ghz or more

2011- IBM WATSON system beats humans on quiz show "Jeopardy" 2013 –IBM announces POWER 8 – 12 core chip – doubles performance of Power7

Page 24: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

24

IBM computers – Then and Now

circa 1978, this computer was considered small compared to the mainframes!

small or large IBM Power System today With 1000’s of times the power.

Model 520Under Desk

Model 595RequiresRoom of it’s own

Link to IBM

Page 25: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

25

Supersize it! - 64-bits

18,446,744,073,709,551,616 bytes

KiloMegaGigaTera (240)Peta (250)Exa (260)

IBM i address space

Page 26: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

26

Why is it called IBM i, System i or iSeries?

The i in stands for: integrated – all components packaged together

and system tested in Rochester, MN at IBM development laboratory

integrity – iSeries security is better than most any system available

innovative – extremely powerful and cutting edge technology

In a class by itself - compared to all other computing machinery – more Fortune 500/1000 companies use IBMi than any other computing platform

Page 27: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

27

IBM i Operating System (OS/400) Basics

Menus - system functions organized by menu

Commands - take vowels out of the words to get meaningful commands Examples:

Work with Active Jobs = WRKACTJOBDisplay Job = DSPJOBStart (Programming Development Manager) PDM

= STRPDMCreate Bound RPG Program = CRTBNDRPGWork with Submitted Jobs = WRKSBMJOBWork with User Jobs = WRKUSRJOB

Page 28: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

28

Finding CommandsFunction Keys

F4 to Prompt parameters F3 to exit a screen/program F1 for HELP

Partial command names GO CMDxxx

Where XXX = ADD, CHG, DSP, WRK, RPGto locate commands based on subject

Prompting commands at command lineFill in the blanks – ease of use

Page 29: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

29

Objects

Everything in the OS is an object 80+ object types in OS

Programs Files

Object contains HEADER information and CONTENTS

Access objects only through COMMANDS

Object Contents

(program instructions, file

data)

Header

COMMAND

Data or objectinformation extracted to display, files or printer

Encapsulation

Type-specific part of object

header

Associated space

(misc object data)

Page 30: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

30

Libraries

Libraries are located in the Integrated File System (IFS) IFS allows OS to support various file systems (Unix, PC, Lib/File)

Libraries are used to organize objects on IBMi Think of a Library like a Unix or MS-DOS directory or a Windows95

folder. Libraries are not nested like in Windows Explorer With one exception (QSYS.LIB) contains other libraries

Files and Programs live inside Libraries, Library and Object names are 10 alphanumeric characters, Objects are “owned” by a User Profile

Call Program

Executable object

Program

Directory, size etc.

Library

Data, record layout,

etc.

File

Open File

Display Library

Page 31: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

31

Object types and sub-types

An object is uniquely identified by the combination of its Qualified Name (Library/Object) and its object type OS will only allow one object with the name CUSTOMER of the

type *FILE in library DATA. OS will allow another object CUSTOMER of type *PGM in library

DATA however but this is NOT a good practice.

APMASTERAccounts payable

open balances

*FILEAP0001

Create Accounts

payable total

*PGM

AP0002Roll over open

balance

*PGM

*LIB - LB0001 Accounts payable applications

APOWNEROwns objects in the AP system

*USRPRF

Page 32: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

32

Files, Record Formats & Members

CUSTID NAME SHPA1 Shpcity ShpST Status

1001 Keene Sentinel 12 West St Keene NH A

1002 Hamshaw Lumber Winchester St Keene NH A

1003 Timken Company 7 Optical Ave Keene NH A

1004 Tire Warehouse Main St Keene NH A

1005 Bagel Works Main Street Keene NH A

1006 Video Headquarters 12 West St Keene NH A

Reco

rds

Fields

1

2

3

4

5

6

RRN = Relative Record (row) number

Page 33: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

33

Records in Members

Each record occupies a unique position in the file member. Record# 1, 2, 3 ….n

This is called the “Relative Record Number” (RRN)

Each physical file has just one record format and all records in every member of the file have the same format

A record is identified as used or deleted. Deleted records can be re-used

Page 34: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

34

File Description - record format (layout) in DB2 database

Fieldname

Data type Length DecimalPositions

StartPosition

Size ColumnHeading

CUSTID Packeddecimal

7 0 1 4 CustomerID

NAME Character 30 N/a 5 30 CustomerName

SHPA1 Character 100 N/a 35 100 ShipAddress

Shpcity Character 30 N/a 135 30 Ship City

ShpST Character 2 N/a 165 2 Ship State

Status Character 1 N/a 167 1 CustomerStatus

Page 35: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

35

Access Paths - two kinds Arrival or Keyed Sequence

RRN or ROWID

CUSTID NAME SHPA1 Shpcity ShpST Status

1 1001 Keene Sentinel 12 West St Keene NH A

2 1002 Hamshaw Lumber Winchester St Keene NH A

3 1003 Timken Company 7 Optical Ave Keene NH A

4 1004 Tire Warehouse Main St Keene NH A

5 1005 Bagel Works Main Street Keene NH A

6 1006 Video Headquarters 12 West St Keene NH A

Reco

rds

Fields

Arrival sequence – records are numbered from 1 through however many. BUT, if deleted records are reused – “arrival” is misnomer – why?

Page 36: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

36

Access Paths - two kinds Arrival or Keyed Sequence

CUSTID NAME SHPA1 Shpcity ShpST Status

1001 Keene Sentinel 12 West St Keene NH A

1002 Hamshaw Lumber Winchester St Keene NH A

1003 Timken Company 7 Optical Ave Keene NH A

1004 Tire Warehouse Main St Keene NH A

1005 Bagel Works Main Street Keene NH A

1006 Video Headquarters 12 West St Keene NH A

Reco

rds

Fields

One or more fields can be the key

Page 37: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

37

Type of Files - Physical and Logical

CUSTID NAME SHPA1 Shpcity ShpST Status

1001 Keene Sentinel 12 West St Keene NH A

1002 Hamshaw Lumber Winchester St Keene NH A

1003 Timken Company 7 Optical Ave Keene NH A

1004 Tire Warehouse Main St Keene NH A

1005 Bagel Works Main Street Keene NH A

1006 Video Headquarters 12 West St Keene NH A

Logical File - may have fewer fields, reordered fields, changed sizes in addition to key ordering and selection/omission of rows

Page 38: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

38

Physical file = TABLE

Container for dataHas one access path by defaultCan be Arrival (as inserted)Can be Keyed (by one of more fields)An SQL Table is a physical file in DB2

on the IBMi OS

Page 39: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

39

Logical file = VIEW or INDEX

Filter for dataHas Keyed access pathCan reorder dataCan select/omit rowsCan include/exclude columnsAn SQL View or SQL Index is a logical

file in DB2 on the IBMi OS

Page 40: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

40

Typical file access - Relationship between physical and logical files

Physical File(s)

Logical File

Higher Level LanguagesRPG, COBOL, JAVA, SQL

File Member

File Member

Page 41: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

41

Creating programs with RPG and files with Data Description Specifications - DDS

Text EditorsSEU source Entry UtilityRDi, RDp, Eclipse, etc.

CompilerCRTRPGPGM commandCRTPF command

Source filesSource Member(s)

Physical or Logical

File

member

program

Page 42: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

42

DDS use and formatting

DDS is columnar DDS uses keywords

to describe file features and field attributes

DDS is entered into a source physical file

DDS is “compiled” to create (CRTxx) a file object

UNIQUER CUSTOMER TEXT(‘CUSTOMERS’) CUSTID 7P 0 COLHDG(‘Customer’

‘ID’) NAME 30A COLHDG(‘Customer’

‘Name’) STATUS 1A COLHDG(‘Customer’

‘Status’) SHPA1 30A COLHDG(‘Customer’

‘Addr’‘line’)

SHPCITY 30A COLHDG(‘Customer’‘City’)

K CUSTID

Page 43: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

43

Creating files with Structured Query Language - SQL

SQL Development KitInteractive SQLOperations Navigator

SQL interpreterCreate TableCreate ViewCreate IndexAlter TableComment ONLabel ON

Table (Physical) or

View (Logical) or

Index (Logical)

member

Page 44: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

44

SQL use and formatting

SQL is free format and “english-like”

SQL uses reserved words

SQL commands are entered into an interactive session therefore no compilation step is required

Create Table DATA/CUSTOMER (CustId Dec(7,0) not Null, Name Char(30) not Null, ShpA1 Char(30), ShpCity Char(30), ShpState Char(2), Status Char(1),Primary Key (CustID))

Page 45: 1 Spring 2014 CS 230 – Procedural Programming RPG language on IBMi POWER Systems Rick Flagler Adjunct Professor

45

Creating tables with Operations Navigator

Point-click or fill-in-blanks method to create a table from scratch or from other pre-existing table(s).