Professional Documents
Culture Documents
cover
Front cover
Student Notebook
ERC 12.1
Student Notebook
Trademarks
IBM is a registered trademark of International Business Machines Corporation.
The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
AS/400
COBOL/400
DB2
i5/OS
Lotus Notes
Power Systems
Rational
SPSS
xSeries
CICS
DB
Integrated Language
Environment
i5/OS
Lotus
Power Systems Software
Redbooks
System i
400
Clementine
DB2 Universal Database
iSeries
Language Environment
Notes
Power
RPG/400
WebSphere
V7.0
Student Notebook
TOC
Contents
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Course description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Agenda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Unit 1. Class administration and introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Course objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Class administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Agenda (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Agenda (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introductions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-1
1-2
1-3
1-4
1-5
1-6
1-7
1-8
Contents
3-1
3-2
3-3
3-4
3-5
3-6
3-8
iii
Student Notebook
V7.0
Student Notebook
TOC
5-20
5-21
5-22
5-23
5-24
5-25
5-26
5-27
5-28
5-29
5-31
5-32
5-34
5-35
5-36
5-37
5-39
5-41
5-42
5-43
5-44
Contents
Student Notebook
V7.0
Student Notebook
TOC
Coding rules (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Information Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Basic CL programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Control work flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CL program structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Declare CL variable (DCL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conditional execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Relational and logical expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IF examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DO group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Nested IF statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PGMB and/or PGMC and/or PGMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PGMB or PGMC or PGMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Branching within a program: GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the DOUNTIL and DOWHILE commands . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the SELECT command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Branching outside a program: TFRCTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Communicating data to a program with CALL . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HLL and CL programs may call each other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CHGVAR: Arithmetic calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CHGVAR: Conversion between *CHAR and *DEC data types . . . . . . . . . . . . . . .
Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data type conversion and concatenation example . . . . . . . . . . . . . . . . . . . . . . . .
Summary of using PDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ILE versus OPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OPM versus ILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Dynamic program call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ILE static call: Bind by copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ILE static call: Bind by reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8-14
8-15
8-16
8-17
8-18
8-19
8-20
8-21
8-22
8-23
8-24
8-25
8-26
8-27
8-28
8-30
8-32
8-33
8-35
8-36
8-37
8-38
8-39
8-40
8-41
8-42
8-43
8-45
8-46
8-48
8-49
8-50
Contents
vii
Student Notebook
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-17
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-18
Unit 10. Creating reports and displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-2
Introduction to data description specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-3
What is DDS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-4
Levels of DDS definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-5
DDS report example (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-6
DDS report example (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-8
DDS screen file example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-9
Designing reports and displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-10
Screen/Report Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-11
What is Screen Designer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-12
WYSIWYG screen and report design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-13
Screen Designer interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-14
Displaying groups of records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-15
Trees, workbooks, and notebooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-16
Designing a display file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-18
Using the display file palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-19
Using the Properties view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-20
Designing a report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-21
Using the printer file palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-22
Working with Screen Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-23
Verifying your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-24
Summary of using Screen/Report Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-25
Machine exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-26
Summary of Screen/Report Designer features . . . . . . . . . . . . . . . . . . . . . . . . . . .10-27
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-28
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-29
Unit 11. IBM DB2 for i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-2
Introduction to relational database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-3
IBM DB2 for i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-4
Working with a relational DBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-5
IBM DB2 for i relational database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-6
IBM DB2 for i is integrated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-8
Traditional program data definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-9
Externally-described IBM i file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-10
Externally-described file example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-11
Externally-described file components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-12
Relational database operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-13
IBM i logical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-14
Legacy coding to define database file CLASSPF . . . . . . . . . . . . . . . . . . . . . . . . .11-15
SQL versus native IBM i DB object terminology . . . . . . . . . . . . . . . . . . . . . . . . . .11-16
More terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-17
IBM DB2 for i offers flexibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-18
viii
V7.0
Student Notebook
TOC
11-20
11-21
11-22
11-23
11-24
11-25
Unit 12. Accessing the IBM i database using SQL and IBM i Navigator . . . . . . . . 12-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
An introduction to SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
Introducing SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
Using SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
Types of SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7
5250 interactive SQL interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-10
Example SQL query using STRSQL (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-11
Example SQL query using STRSQL (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13
Closing an interactive SQL session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-14
SQL source member . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15
Other useful SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-16
Database case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17
Tables used in the school database case study . . . . . . . . . . . . . . . . . . . . . . . . . 12-18
Required case study results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-19
Creating a schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-20
Creating a schema using IBM i Navigator (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . 12-21
Creating a schema using IBM i Navigator (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . 12-22
Objects in schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-23
Create CLASSPF table (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-24
Create CLASSPF table (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-25
Define columns (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-26
Define columns (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27
Column naming rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-29
Adding column headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-30
Run SQL Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-31
Resulting SQL: LABEL ON statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-32
Create index for CLASSPF on column CRSCODE (1 of 2) . . . . . . . . . . . . . . . . 12-33
Create index for CLASSPF on column CRSCODE (2 of 2) . . . . . . . . . . . . . . . . 12-35
Create table GRADEPF99 (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-36
Create table GRADEPF99 (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-37
Create table GRADEPF98 (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-39
Create table GRADEPF98 (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-40
Create table GRADEPF98 (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-41
New Table: GRADEPF98 final review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-42
GRADEPF98 in FACSLIB2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-43
Review the newly created table GRADEPF98 . . . . . . . . . . . . . . . . . . . . . . . . . . 12-44
Display table data: GRADEPF99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-45
Insert new rows in table GRADEPF99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-46
Create index for table GRADEPF99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-47
Create index GRADEPF99I (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-48
Copyright IBM Corp. 1997, 2012
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Contents
ix
Student Notebook
V7.0
Student Notebook
TOC
13-27
13-28
13-29
13-30
13-31
13-32
13-33
13-34
13-35
13-36
13-37
13-38
13-40
13-41
13-42
13-43
13-44
13-45
13-46
13-47
13-48
13-49
13-50
13-51
13-52
13-53
13-54
13-55
13-56
13-57
13-58
13-59
13-60
Contents
xi
Student Notebook
V7.0
Student Notebook
TOC
Contents
xiii
Student Notebook
xiv
V7.0
Student Notebook
TMK
Trademarks
The reader should recognize that the following terms, which appear in the content of this
training document, are official trademarks of IBM or other companies:
IBM is a registered trademark of International Business Machines Corporation.
The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
AS/400
COBOL/400
DB2
CICS
DB
Integrated Language
Environment
i5/OS
Lotus
Power Systems Software
Redbooks
System i
400
i5/OS
Lotus Notes
Power Systems
Rational
SPSS
xSeries
Clementine
DB2 Universal Database
iSeries
Language Environment
Notes
Power
RPG/400
WebSphere
Trademarks
xv
Student Notebook
xvi
V7.0
Student Notebook
pref
Course description
IBM i Programming Facilities Workshop
Duration: 5.0 days
Purpose
This course introduces many IBM i features and programming
facilities, including the following:
Rational Developer for Power Systems Software (LPEX Editor,
Remote Systems Explorer (RSE), Screen Designer, and Report
Designer)
Programming Development Manager (PDM)
Source Entry Utility (SEU)
Control Language
IBM i Access for Windows and IBM i Navigator
Interactive SQL
We also cover, but with less emphasis than the tools above, the
following:
Screen Design Aid (SDA)
Data File Utility (DFU)
Web Query/Query for IBM i
Machine exercises give the student the opportunity to use and
experiment with many of these facilities.
Audience
Application developers and programmers, system analysts and IT
managers who also develop and maintain IBM i applications.
Prerequisites
Before taking this course, students must be able to:
Course description
xvii
Student Notebook
Objectives
After completing this course, you should be able to:
Curriculum relationship
This is part of the IBM i curriculum for programmers. It is a prerequisite
to programming classes that teach RPG (IV), control language, and
SQL. It is also a prerequisite to the database implementation class,
OL62/OL620.
V7.0
Student Notebook
pref
Agenda
Day 1
Unit 1 - Class administration and introduction
Unit 2 - IBM i application development tools
Unit 3 - IBM i concepts and overview
Unit 4 - IBM i Access and IBM i Navigator
Machine Exercise - Navigating IBM i Navigator
Unit 5 - Managing work flow on the IBM i
Unit 6 - Commands, profiles, and libraries
Day 2
Machine exercise - Create library and work with library list
Machine exercise - Modify profile, work with job description and
alternate Job
Unit 7 - Introduction to IBM i security
Unit 8 - Control language programming
Machine exercise - Write a basic CL program
Unit 9 - Basic message handling
Machine exercise - Using messages
Day 3
Unit 10 - Creating reports and displays
Machine exercise - Editing display file source
Machine exercise - Designing and creating display screens
Machine exercise - Designing and creating reports
Unit 11 - IBM DB2 for i
Unit 12 - Accessing the IBM i database using SQL and IBM i
Navigator
Day 4
Unit 12 - Accessing the IBM i database using SQL and IBM i
Navigator (contd)
Machine exercise - Working with the database using IBM i
Navigator
Unit 13 - Defining database files using DDS
Desk exercise - Code a physical and a logical file
Unit 14 - Using the Legacy toolset (PDM, SEU, CPYF)
Agenda
xix
Student Notebook
Day 5
Machine exercise - Using the IBM i Editors
Machine exercise - Code and create files and use file-related
commands
Machine exercise - Copy file
Machine exercise - Additional physical and logical files
Unit 15 - Wrap up and supplemental exercises
Machine exercise - Build display file and HLL program
Machine exercise - Build a menu display format with DDS
Machine exercise - Build a menu using Screen Design Aid
Machine exercise - SDA for screen formats
Machine exercise - Overrides
Machine exercise - Data File Utility (DFU)
Machine exercise - Query for IBM i
xx
V7.0
Student Notebook
Uempty
1-1
Student Notebook
Prerequisites
IBM i
OL4912.1
Notes:
In order to optimize your learning experience, it is important that you meet all of the above
prerequisites.
1-2
V7.0
Student Notebook
Uempty
Course objectives
IBM i
OL4912.1
Notes:
This course is critical to your building a solid foundation of knowledge of the application
development tools that you will be using on a day to day basis in your job as a programmer.
We do not cover all aspects of each and every tool. To do so would require two weeks.
For those areas where you desire additional training, there are other courses that teach
Control Language Programming and the RDP product.
This course is a prerequisite for all programming courses that follow. You should plan to
learn as much as you can in class. Ask questions to clarify any misunderstandings. This is
your class and the instructor is dedicated to maximizing your learning experience.
1-3
Student Notebook
Class administration
IBM i
Student information
S
GE
D
BA
PHO
NES
FA
CIL
ITI
ES
Badges/security
Phones and messages
Facilities
Class hours
Local restaurants
Maps - area and building
SS
CLAURS
HO
Questions
Introductions
FO
O
S
MAP
ST
QUE
S
ION
OL4912.1
Notes:
1-4
V7.0
Student Notebook
Uempty
Agenda (1 of 2)
IBM i
Day 1
Day 2
Machine exercise - Create library and work with library list
Machine exercise - Modify profile/work with job description/alternate job
Unit 7 - Introduction to IBM i security
Unit 8 - Control language programming
Machine exercise - Write a basic CL Program
Unit 9 - Basic message handling
Machine exercise - Using messages
Day 3
Unit 10 - Creating reports and displays
Machine exercise - Editing display file source
Machine exercise - Designing and creating display files
Machine exercise - Using Screed Designer to create reports
Unit 11 - DB2 for IBM i overview
Unit 12 - Accessing the IBM i database using SQL and IBM i Navigator
Copyright IBM Corporation 2012
OL4912.1
Notes:
1-5
Student Notebook
Agenda (2 of 2)
IBM i
Day 4
Unit 12 - Accessing the IBM i database using SQL and IBM i Navigator (cont)
Machine exercise - Working with the database using IBM i Navigator
Day 5
Machine exercise - Build display file and high-level language (HLL) program
Machine exercise - Build a menu display format with DDS
Machine exercise - Building a menu using screen design aid
Machine exercise - SDA for screen formats
Machine exercise - Overrides
Machine exercise - Data File Utility (DFU)
Machine exercise - Query
Copyright IBM Corporation 2012
OL4912.1
Notes:
Web sites:
http://publib.boulder.ibm.com/iseries/
http://www.ibm.com/servers/eserver/iseries/navigator
1-6
V7.0
Student Notebook
Uempty
Introductions
IBM i
OL4912.1
Notes:
1-7
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
1-8
V7.0
Student Notebook
Uempty
2-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
2-2
V7.0
Student Notebook
Uempty
IBM i
application development tools
Copyright IBM Corporation 2012
OL4912.1
Notes:
2-3
Student Notebook
Programming tasks
IBM i
Code programs
Design DB files
Define DB files
Code programs when connected or disconnected to IBM i
OL4912.1
Notes:
As you perform these tasks, many tools are available to assist you. Some of them, such as
debugging, are better discussed with specific program examples. However, we introduce
and discuss many of the tools that you will use in this class. In addition, machine exercises
will enable you to learn enough about the tools that you can begin to apply your new skills
as soon as you return to work.
2-4
V7.0
Student Notebook
Uempty
RDS/RDP 8.0.3
IBM i
i V5.4
5722WDS
i V7.1
5770WDS
Base
Option 21 ADTS
Option 31 ILE RPG
Option 32 S/36 Compatible RPGII
Option 33 S/38 Compatible RPGII
Option 34 RPG/400
Option 35 ILE RPG *PRV Compiler
Option 41 ILE COBOL
Option 42 S/36 Compatible COBOL
Option 43 S/38 Compatible COBOL
Option 44 OPM COBOL
Option 45 ILE COBOL *PRV Compiler
Option 51 ILE C
Option 52 ILE C++
Option 56 IXLC for C/C++
WDSC Unlimited
RDP
COBOL, RPG, C/C++
RAD
Java
Feature: ADTS
Option 21 ADTS
OL4912.1
Notes:
There is one consolidated Application Development product available for IBM i
programmers. The product is called the Rational Development Studio for i V7.1, which
includes the following:
IBM i compilers
-
ILE RPG
ILE COBOL
ILE C
ILE C++
2-5
Student Notebook
Rational Developer for Power Systems Software (RDP) is a workstation-based tool set.
RDP includes:
LPEX Editor
Screen Designer
Report Designer
Debugger
Remote System Explorer
With i 7.1, RDS has three separately priced optional features: ILE compilers, heritage
compilers, and ADTS (legacy development tools). Modernized shops can now avoid the
cost of legacy tools and compilers they no longer use. PC tool users now have the option of
ordering RDP (to use with RDS) or RD for i for SOA at additional license costs.
Entitlement on the 5770-WDS ILE Compilers, Heritage Compilers, and ADTS features are
based on a maximum number of users per processor tier.
Users of the previous WDSC Standard Edition product are not entitled to use either RDP or
RD for i for SOA. RDP and RD for i for SOA are considered separate new products, not an
upgraded WDSC product.
2-6
V7.0
Student Notebook
Uempty
File
para
m
eter
PGM 1
PGM 2
12
Thread 1: X=X + 1
9
Thread 2: OPENFile(customer)
Thread 3: Write record ds
3
6
Figure 2-5. IBM Rational Developer for Power Systems Software v8.0.3
OL4912.1
Notes:
RDP includes:
Application diagram enhancement including support for CL, program calls, and
functional zoom
LPEX editor
Screen Designer
Report Designer
RD for i for SOA includes:
2-7
Student Notebook
RAD
Combines RDP with Rational Application Developer or Rational Software Architect to
design, develop, and test complete Java solutions
Prerequisite tooling for integrating JCA Connectors, wizards and tools to leverage the i
Java Toolbox, and many other Java-specific features
2-8
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
You can use the Source Entry Utility (SEU) to work with source members in source physical
files, and the records contained in source members.
With SEU, you can perform operations such as the following:
Create members.
Edit members.
Print members.
Copy records into a member from another member or spooled file.
ILE RPG
File Description (DDS)
Screen Display File source (DDS)
Report definition source (DDS)
2-9
Student Notebook
Data Description Specifications (DDS) is a common definition used for files, displays, and
reports. Because the IBM i is a database system, it is possible to define fields in one place
and then reference that definition (using DDS) to define other files, displays, and reports.
In this example, we show you some of the source of an ILE RPG source member. You can
work with the member directly on the IBM i.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This is the same source program we showed in the SEU example. You can use whichever
tool you prefer or use them interchangeably.
With the LPEX Editor, you can do the following:
Access local and IBM i source files seamlessly.
Download IBM i source members to the PC and then maintain them in disconnected
mode.
Work concurrently with multiple edit sessions as well as multiple views of the same
source member.
Navigate through multiple programs and subroutines in one or more source members.
Search and compare multiple files at once.
2-11
Student Notebook
OL4912.1
Notes:
You can use the screen design aid (SDA) to perform the following tasks:
Design a menu to present a list of options from which the user makes a selection.
Design a display to help the user navigate through an application program.
Create online help information for displays and menus.
V7.0
Student Notebook
Uempty
Screen Designer
Create and maintain displays and menus
Workstation based
Can design displays, view, and maintain
source
OL4912.1
Notes:
With the Screen Designer you can do the following:
Design and create new DDS screens, printer files, and physical files.
Add text fields to existing DDS-defined screens, by simply clicking and typing.
Insert new screen fields, from a popup menu, for input, output, or both.
Manipulate fields and text using drag-and-drop actions.
Change the attributes and properties of data fields and plain text.
Link DDS fields to IBM i data fields by connecting to the database and selecting the
appropriate fields from a pull-down list.
View the hierarchical relationships among files, records, fields, help specifications,
keys, and keywords in each selected DDS object.
Organize records into groups for a particular screen, report, or printer file.
View the DDS source for each element when you add or update it.
Copyright IBM Corp. 1997, 2012
2-13
Student Notebook
OL4912.1
Notes:
Report Layout Utility (RLU)
RLU is used on the IBM i to create or maintain printer file DDS. Using RLU, you can do
the following:
- Design a report by defining it on the display, saving it as DDS source, and creating a
printer file.
- Create a prototype of a report by printing the report design at any time to make sure
that the report looks the way you want it to.
The report design looks like an actual listing you would generate from your program.
V7.0
Student Notebook
Uempty
Report Designer
OL4912.1
Notes:
Using the Report Designer, you can do the following:
Create new DDS printer files.
Add text to DDS reports, by simply clicking and typing.
Insert new report fields from a popup menu.
Manipulate fields and text using drag-and-drop actions.
Change the attributes and properties of data fields and plain text.
Link DDS fields to IBM i data fields by connecting to the database and selecting the
appropriate fields from a pull-down list.
Organize records into groups for a particular report or printer file.
View the DDS source for each element when you add or update it.
Once you have designed a report using the Designer, you can maintain the DDS directly
using the LPEX Editor or the SEU editor.
Copyright IBM Corp. 1997, 2012
2-15
Student Notebook
OL4912.1
Notes:
The DB2 Web Query base product will provide capabilities to query or build reports
against data stored in DB2 for IBM i databases through the latest browser-based user
interface technologies. Build new reports with ease through Power Painter or Report and
Graph Assistant components. Simplify the management of reports by leveraging
parameterized reporting. Deliver data to end users in many different formats, including
spreadsheets, PDF, HTML or through the Java-based thin client interface browser support.
Import Query/400 definitions and enhance their look and functionality with Power Painter or
Graph Assistant. Interface to all data in i through either DB2 or Open Query File native
adapters that automatically identify the files to be accessed and import the metadata into
DB2 Web Query.
Additional priced features can be added from IBM for OLAP analysis, or disconnected (but
active) reporting. All users licensed to the base product will be able to use OLAP or
Active Report features. Add a Developers Workbench to build more customized reports or
enhance a meta data layer.
V7.0
Student Notebook
Uempty
This product is an OEM agreement with Information Builders Web FOCUS product. Add
additional components from Information Builders such as ERP or other database adapters
(to query Oracle, for instance, youd add an Oracle Adapter). Grow into more complete BI
solutions leveraging the products API support for SPSS Clementine (data mining) or
ESSBASE/400 (cubing) technologies. Add a light weight Extract Transformation and
Loading (ETL) tool for building data marts or data warehouses with Data Migrator.
2-17
Student Notebook
OL4912.1
Notes:
DB2 Web Query for IBM i is a significant step in the evolution of Query/400 or IBM Query
for IBM i. It is a Web-based tool that allows you to enhance your existing Query/400 queries
with additional functionality while giving you an easy and intuitive tool that takes advantage
of the investment that IBM has made in DB2 for i.
V7.0
Student Notebook
Uempty
Then modify
with Report
Assistant
Or rewrite as
new Web Query
to take
advantage of
SQE
OL4912.1
Notes:
DB2 Web Query offers an import function to webify query/400 reports. The first step is to
import the Query/400 definition into DB2 Web Query and then, if desired, the reports can
be enhanced with Report Assistant. Add cross tabs, parameter-driven selection criteria,
style sheets or conditional styling, or burst it into multiple pages for easier navigation.
2-19
Student Notebook
Product packaging
IBM i
Active
Report
Data
Adapter
OLAP
Report
Caster
Developer
Workbench
...
Base product
Report
Assistant
Graph
Assistant
Power
Painter
Query/400
Adapter
OL4912.1
Notes:
The product has a modular focus. IBM has included significant functionality in the base
product.
It is extendable to advanced functions that enable OLAP analysis, remote sales force
productivity, and the creation of executive dashboards.
V7.0
Student Notebook
Uempty
Base product
Base Product
Report
Assistant
Graph
Assista
nt
Power
Painter
Query/400
Adapter
Active
Report
Data
Adapter
OLAP
Report
Caster
Developer
Workbench
...
User licenses
One license for each user who must create and/or run queries
Registered users, not concurrent users
Run time user enablement feature
Allows a user license to reference a group of IBM i users who can run
(not create) reports
OL4912.1
Notes:
You need to buy the base product which includes the function available for 5770QU1 (IBM
Query for i) as well as Report Assistant, Graph Assistant, Power Painter, and Query 400
adapters.
Base product.
Additional modules, if needed.
- Additional modules are ordered as needed. Most customers will buy at least one
copy of the Developers Workbench so they can perform enhanced function.
User licenses.
- One license is required for each registered user who can create and/or run queries.
- In January of 2008, Run Time User Enablement was announced. It allows a group of
users to RUN (not create, not modify) reports already created using a group user
concept. This feature became available on March 21, 2008.
2-21
Student Notebook
- DB2 Web Query contains a power offline function called Active Reports. These
Reports can be distributed to other users after they have been created by a
Registered DB2 Web Query User and those off-line users can work with existing
Active Reports and they dont need a DB2 Web Query license.
- A license allows you to use both the base product and additional modules.
- A predefined number of user licenses are included in the base product based on
your software tier.
V7.0
Student Notebook
Uempty
SW groups
Included users
P05
P10
P20
P30
P40
10
P50
15
P60
20
OL4912.1
Notes:
DB2 Web Query is available on IBM i 5.4, i 6.1, and i 7.1:
Can query data on other systems/partitions on i5/OS V5R3
Customers at V5R4 + Software Maintenance + 5722-QU1 license:
If you have the existing 5722-QU1 Query for IBM i and are on maintenance you are
entitled to request the 5733-QU2 IBM DB2 Web Query for IBM i base product as a free
upgrade for a predefined number of users based on your software tier.
Maintenance not included, 90-day grace period
If its a New 5733QU2 order:
You are entitled to the base product and a predefined number of users based on your
software tier.
One year of maintenance included with new purchase
Maintenance includes additional modules, if purchased
2-23
Student Notebook
Extensible to 3 years
5733QU2 includes license of product 5722QU1 Query for IBM i for unlimited users
5722QU1 is not separately orderable for V5R4, V6R1 or V7R1
V7.0
Student Notebook
Uempty
ibm.com/systems/i/software/db2
General information
See it in action demos
Whats new
Education roadmaps
HOW TO papers
Click Support
Articles and White Papers
OL4912.1
Notes:
Stay tuned to the IBM i DB2 Web page for further enhancements and the latest features.
http://ibm.com/systems/i/software/db2/webquery
This newly designed Web site provides a consistent look and feel with the other IBM i sites,
and includes key benefits, product information, getting started (including education
roadmaps), and links to many technical white papers and articles, coding examples, and
more.
In addition, the Web site includes many self-running, narrated demos covering DB2
products or functions, to help you showcase DB2 functions for other uses.
2-25
Student Notebook
Checkpoint
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Unit summary
IBM i
OL4912.1
Notes:
You now have an appreciation of the tools that are available and where they can be used.
2-27
Student Notebook
V7.0
Student Notebook
Uempty
3-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
3-2
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
3-3
Student Notebook
Application programs
Hardware
OL4912.1
Notes:
Most computer systems had the following characteristics in the past:
Application programs were directly dependent upon the systems instruction set or the
hardware on which they were run.
Programmers had to be hardware experts to write applications at this low-level
interface.
Software was not easily ported from one system to another.
3-4
V7.0
Student Notebook
Uempty
Machine Interface
370 Instruction Set
Supervisor
MVS
OL4912.1
Notes:
If you look at the architecture of many traditional systems, the software is layered, not
integrated.
3-5
Student Notebook
Software
User Program Area
Machine Interface (MI)
Security
Virtual Storage Management
Database Management
File Management
Communications
Supervisor
High-level
Machine
OL4912.1
Notes:
Many functions traditionally performed by system control programs have been integrated
into the IBM i machine as licensed internal code (LIC) and hardware. This provides you
with a more efficient, basic interface.
The machine interface (MI) allows implementation flexibility below the LIC interface:
Machine performance and resources are optimized by implementing the function within
the layer where it operates most efficiently.
New hardware and software technologies can be implemented without affecting
applications.
3-6
V7.0
Student Notebook
Uempty
The IBM i machine architecture is based on a high-level machine that implements many of
the basic supervisory and resource management functions of operating systems and
subsystems:
Raises the level of the MI creating a high-level machine instruction set.
Actual support of the MI distributed through two internal microprogramming levels and
physical hardware.
The MI separates the application programmer from actual hardware implementation.
3-7
Student Notebook
Main Storage
A
A
A
Drive 1
Drive 2
A
A
Drive 3
A
Auxiliary Storage
OL4912.1
Notes:
With Single Level Storage (a single container of objects), the application developer does
not need to be concerned about the actual disk location of an object, only an initial size
allocation. Even the initial size allocation is optional.
You can monitor and control disk capacity and utilization, and make adjustments.
The objective is to improve performance in the exceptional cases where the standard IBM i
method of spreading data across DASD arms may not yield optimum performance results.
With IBM i DASD I/O statistics and the load balancing commands, the following capabilities
are available:
Controlled ability to balance data across disk arms in an ASP based on performance.
- Identify hot (frequently accessed) data versus cold (less frequently accessed data)
and move the cold data to slower DASD.
- Spread data across arms to balance utilization.
3-8
V7.0
Student Notebook
Uempty
3-9
Student Notebook
Capacity balancing is most like the system default for spreading data across all DASD
within the ASP and offers the explicit request to spread data to include newly added DASD
devices. The spreading or respreading is done when the command start ASP balancing
(STRASPBAL) is issued. This is in contrast to the DSKBAL command previously PTFed to
V4R3 or earlier releases.
Usage balancing is useful when performance collection data has indicated a wide range in
the disk utilization (percent arm is busy) among the DASD within the ASP. For example,
DASD devices 1 and 4 show 60% utilization and DASD devices 2 and 3 show 10%
utilization. Usage balancing can be used to redistribute the high use and low use data on
each unit in the ASP in order to balance the arm utilization of each unit within the specified
ASP.
In order to use usage balancing, you need to have started and ended the Trace ASP
balance function. This is done with the TRCASPBAL command with SET(*ON) and
SET(*OFF) options. TRCASPBAL can also be specified to run for a period of time up to
1-9999 or *NOMAX minutes or to clear the trace statistics.
HSM balancing is useful when an ASP contains a mixture of compressed and
uncompressed DASD devices. DASD compression, which was introduced with V4R3, must
be explicitly defined for specific DASD within the ASP, and requires compression capable
DASD controllers:6533 (SPD) or 2741 (PCI).
With HSM balancing, the high-use data is moved to high-performance DASD units and
low-use data is moved to lower performance DASD units. TRCASPBAL must have
completed to provide the statistics for high- and low-use data.
When HSM balancing has completed, the system automatically clears the trace
information. If you used usage balancing, you have to clear the trace information with the
TRCASPBAL SET(*CLEAR) option specified.
V7.0
Student Notebook
Uempty
Virtual storage
IBM i
Main Storage
Auxiliary Storage
Swapping is done with an entire job structure.
Paging is done with a portion of a job structure.
Copyright IBM Corporation 2012
OL4912.1
Notes:
Programs (objects) are not entirely in main storage at one time.
A job has a collection of structures that can be paged out of storage in a single operation
when a job (process) enters or leaves a long wait. Although many different object types are
found in main storage, they fall into two main categories: objects that are shared by jobs
and structures that are unique to a specific job.
When an object is shared, only one copy of it exists. For example, application code used by
20 jobs resides in main storage in only one place but is used by all the jobs. However, the
variables and data in the application do not have the same values for all jobs using the
application. Structures that are unique to a particular job are packaged as a unit.
Whenever a job is active, the pages of this group of structures that are actually in use, must
be in main storage. After the job structures are written to auxiliary storage, the main
storage space is available for other jobs.
3-11
Student Notebook
Single-level storage
IBM i
Program
Data
Data
Program
Data
Data
Program
Program
Data
Data
Data
Program
Data
Data
Data
Program
Program
Program
Program
Job Queue
User Profile
Data
Data
Output Queue
Library
Auxiliary Storage
Main Storage
Copyright IBM Corporation 2012
OL4912.1
Notes:
Single-level storage simply means that the IBM i system treats memory and DASD storage
as a single storage space. Single-level storage is used to hold objects:
An object is something that has a name and is contained in a library.
There are many objects of different types.
On the IBM i, all storage is one large memory space whether the system is addressing real
memory or DASD.
V7.0
Student Notebook
Uempty
AUTL
Authorization List
LIB
CMD
Command
Definition
DTAARA
Data Area
DEVD
FILE
Device
Description
File
FLR
Folder
JOBD
Library
Program
QRYDFN
Query Definition
SBSD
Subsystem
Description
Job Description
USRPRF
User Profile
JOBQ
Job Queue
JRN
Journal
JRNRCV
Journal Receiver
Copyright IBM Corporation 2012
OL4912.1
Notes:
There are many different types of objects on the IBM i. Most programmers would easily
recognize a file and a program (PGM) as objects.
3-13
Student Notebook
Object Description
Object Functional Part
Physical File Members
(Data Records)
Logical File Members
(Access Paths)
Program Code
OL4912.1
Notes:
Each object is made up of two components:
1. Object description
2. Functional part
V7.0
Student Notebook
Uempty
Libraries/objects
IBM i
FILEB
FILEA
FILEC
FILEA
PROGY
LIBA
PROGX
LIBZ
QUEUE1
PROG4
LIBB
FILEB
PROGY
OL4912.1
Notes:
Libraries (also known as schema) provide a method for organizing objects:
Objects must be unique, by name and type, within a library.
A library is an open-ended directory.
Objects are organized within libraries.
3-15
Student Notebook
IBM i library
IBM i
MYLIB
NAME
TYPE
ADDRESS
MYPROG
MYDSPF
MYPF
MYLF
*PGM
*FILE
*FILE
*FILE
ADDRESS
ADDRESS
ADDRESS
ADDRESS
MYPROG
MYPF
MYDSPF
OL4912.1
Notes:
For each object in a specific library, the library contains the objects name, type, and a
system-managed transparent address.
An IBM i library is very different from libraries of other systems. It has an open-ended
directory that never fills up. It contains all object types (files, queues, job descriptions, and
so forth), in addition to programs.
V7.0
Student Notebook
Uempty
Libraries
IBM i
SINGLE
LEVEL
STORAGE
FILEB
PROGY
FILEA
FILEC
LIBA
PROGX
QSYS
LIBZ
QUEUE1
LIBB
PROG4
FILEB
PROGY
Copyright IBM Corporation 2012
OL4912.1
Notes:
Libraries themselves are objects in the IBM i. As such, they also reside in a system library
named QSYS. Libraries can never reside anywhere other than in the QSYS file system.
3-17
Student Notebook
Library/object structure
IBM i
QSYS
LIB A
PGM 1
LIB B
FILE 1
And so
forth
PGM 2
FILE 2
MEMBER 1
And so
forth
MEMBER A
MEMBER B
OL4912.1
Notes:
Notice that File 2 has two distinct sets of data. These sets are known as members. Each
member has a unique name and organizes your data such that Member A data can be
processed independently from Member B data by using the file and member name.
V7.0
Student Notebook
Uempty
Supplied libraries (1 of 2)
IBM i
QSYS
Contains many IBM-supplied
programs, data, and libraries
QGPL
general purpose library
Contains spool queues,
source files, and so forth
OL4912.1
Notes:
Certain libraries come with the system. They contain IBM-supplied programs and objects
that you can use as you write programs and develop applications.
3-19
Student Notebook
Supplied libraries (2 of 2)
IBM i
QTEMP
Automatically created for each job on the system
Lasts only for the duration of the job
Useful place for storing temporary objects
OL4912.1
Notes:
There are other libraries in your system, depending on the software products and the
applications installed in it.
V7.0
Student Notebook
Uempty
User libraries
IBM i
OL4912.1
Notes:
An attribute type is specified when the library is created. Data in a production library can be
protected against accidental update from programmers doing development/testing, or
operators in training.
3-21
Student Notebook
File systems
IBM i
Users
Applications
Integrated
File
System
Application
Menus/Commands
Program Interface
QSYS.LIB
File
System
"Root"
File
System
QOpenSys
File
System
IBM i
File Server
QDLS
File
System
TCP/IP
Network
File System
(NFS)
OL4912.1
Notes:
The Integrated File System (IFS) features:
Stream file support as in PC and UNIX
Hierarchical directory structure
Common interface to all stream files, documents, and IBM i objects
Edit file (EDTF)
Display file (DSPF)
File System Differences:
'/' or root supports hierarchical structure, multiple hard and symbolic links, local sockets,
and is optimized for stream file I/O.
QOpenSys offers support as in the /root file system, but also supports case-sensitive
name searches.
V7.0
Student Notebook
Uempty
QSYS.LIB supports traditional IBM i objects and all programming languages and
facilities that operate on database files.
QDLS supports hierarchical structure, stream files, and office applications.
Edit File and the Display File are native IBM i commands. They allow the displaying and
editing of stream and database files.
For database files, a record length over 4 KB is supported in display mode only.
When a file name entered on the stream file parameter is a directory and not a stream file,
the display will show a list of stream files in that directory. On this display there are options
available for each file in the file list such as Edit, Delete file, Display, Path Size, and
Recursive Delete. There are also column search functions available, an entire field display
function, and a sort function.
The usage of the edit function and commands can be found in the help text.
Pressing F15 on the edit screen brings you to the EDTF Option Screen. Use this screen to
copy data from another file or change the CCSID of this file. You can also change the end
of line character for this display.
3-23
Student Notebook
Checkpoint
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Unit summary
IBM i
OL4912.1
Notes:
3-25
Student Notebook
V7.0
Student Notebook
Uempty
4-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
4-2
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
IBM i Access for Windows delivers TCP/IP connectivity to users running a variety of
Microsoft Windows operating systems.
IBM i Access for Windows offers an all-inclusive client solution for accessing and using
resources from your Windows desktop. It includes 5250 emulation, access to DB2 for IBM i
through its Data Transfer, and utilizes IBM i NetServer for working with the IBM i Integrated
File System and printers. It also has a variety of middle ware for using and developing
client applications to access IBM i resources; and IBM i Navigator, the IBM i GUI, for
administering IBM i servers.
This visual shows you the contents of the IBM i Access for Windows folder that appears
on your desktop after having installed the product. We will focus our attention in this class
on the System i Navigator. It can be started by:
Double-clicking the System i Navigator icon in the IBM i Access for Windows folder.
Double-clicking the System i Navigator icon on your desktop.
Clicking Start > Programs > IBM i Access for Windows > System i Navigator.
Copyright IBM Corp. 1997, 2012
4-3
Student Notebook
IBM i Navigator
IBM i
IBM i Navigator
Copyright IBM Corporation 2012
OL4912.1
Notes:
4-4
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
IBM i Navigator is the graphical user interface to the system. Many of the features are
oriented to system administration; you should be aware of these features and their
capabilities. The following are features that you, as programmers, use:
Browse libraries and files
Create new libraries and files
Explore the properties of files
Modify authorities to objects
Browse OUTQs
Use Run SQL Scripts to access and modify DB objects using SQL
4-5
Student Notebook
OL4912.1
Notes:
The purpose of IBM i Navigator is to provide IBM i system administration and system
operations in the Windows environment to simplify performing IBM i tasks.
IBM i Navigator includes menus and functions that execute most 5250 commands;
however, it does not replace all commands. Many of the commands can be executed from
programmer-like command interfaces included in IBM i Navigator.
4-6
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Benefits of the IBM i Navigator interface:
Administering the IBM i is easier.
Windows users can use System i Navigator to administer an IBM i. This reduces the
need to learn the IBM i command interface. The user interface is what a Windows user
would expect.
Integrates the IBM i into the Windows environment using IBM i Access.
Native GUI
The IBM i Navigator is fully integrated into the Windows desktop. This means that the
administrator can perform IBM i tasks using Windows techniques. For example, you can:
Drag and drop a user onto a group to add that user to the group
Use Context menus and Property sheets to display/change information (for example,
change access authority to a database object)
4-7
Student Notebook
Use the Explorer view of IBM i resources. The Explorer offers various views, such as
small or large icons, a list, or details.
4-8
V7.0
Student Notebook
Uempty
IBM i
Navigator
OL4912.1
Notes:
Management Central is:
A suite of system management functions
An integrated part of IBM i Navigator
Included with IBM i Access
With Management Central, you can manage multiple IBM i systems from a single central
system. You no longer have to worry about configuring communications connections to all
your IBM i systems or juggling multiple login sessions. Management Central is scalable,
flexible, and easily manipulated to fit the needs of your environment.
You can use Management Central to do your tasks on multiple systems quickly and
efficiently. Management Central makes system administration even easier by allowing you
to use sharing. Sharing lets you give other users permission to view or work with your
tasks. Use Management Central to do all your tasks, including:
Managing users and groups across multiple systems
4-9
Student Notebook
Real-time monitoring for your systems, jobs, messages, files, and B2B activity
Historical graphing of system performance
Fixes (PTF) and fix group management
Running commands on multiple IBM i servers
Scheduling tasks
Inventory management - service attributes and contact information, as well as
hardware, software, fixes, system values, and users and groups
Collection Services - Collect performance data for future analysis on multiple IBM i
servers
Saving packages and sending files and folders to multiple IBM i servers
Creating your own products and managing them across multiple systems
Extreme Support for the latest in IBM support
IBM i Navigator for Wireless - From an Internet-ready phone or personal digital
assistant (PDA), you can manage multiple IBM i servers; work with monitors for files,
jobs, messages, and system performance; run commands on multiple IBM i servers;
and work with Integrated xSeries Servers.
V7.0
Student Notebook
Uempty
What is supported on an i? (1 of 2)
IBM i
OL4912.1
Notes:
System i Navigator is able to support multiple IBM i servers running different levels of IBM i.
For example, an i 6.1 client can interface with an i 5.4 or an i5/OS V5R3 server.
When you first create and then activate a connection, the Navigator scans the server to
determine what is supported on that server and presents the icons that match the server's
level of IBM i and product support.
4-11
Student Notebook
What is supported on an i? (2 of 2)
IBM i
Go to: http://publib.boulder.ibm.com/infocenter/systems/scope/i5os/index.jsp
OL4912.1
Notes:
This is a subset of the help support at:
http://publib.boulder.ibm.com/infocenter/systems/scope/i5os/index.jsp?topic
=/rzahg/icmain.htm
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Comprehensive online help is built into IBM i Navigator. The documentation includes how
to use the features of Management Central including what is new for this release, and links
to what features are supported by release as we saw in the previous visual.
4-13
Student Notebook
Machine exercise
IBM i
OL4912.1
Notes:
At this point, we want to open IBM i Navigator and learn where some of the useful features
can be found.
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
OL4912.1
Notes:
4-15
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
5-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
5-2
V7.0
Student Notebook
Uempty
IBM i jobs
IBM i
IBM i jobs
OL4912.1
Notes:
All work on the IBM i is performed in a job. Some characteristics of a IBM i job include the
following:
Each job has a unique name.
Jobs are run within subsystems.
A job is a collection of one or more threads.
Each job has at least one thread, which is identified as the initial thread, created at job
start. The job may have additional secondary threads, depending on the applications
used by the job.
A thread is an independent unit of dispatchable work. Each thread has its own
execution environment, such as a call stack, but the thread shares many of the job
resources. The thread has an identifier unique within its own job.
Sometimes thread and job are used interchangeably. However, when the term job is
used, it refers to all the threads of the job. Most commands and interfaces operate on
5-3
Student Notebook
the entire job. However, some attributes, such as maximum activity levels, operate at
the thread level, and the term thread is used in this situation.
5-4
V7.0
Student Notebook
Uempty
Types of jobs
IBM i
System Jobs
User Jobs
Spooling
Interactive
Autostart
Batch
Communication
OL4912.1
Notes:
All jobs, regardless of type, are either:
1. Interactive
2. Batch
5-5
Student Notebook
Application
Program
Database
Reports
Payroll
1 Checks
2 Adjust
OL4912.1
Notes:
An interactive job begins at the point that the user signs on to the IBM i server and ends at
the point when the user signs off the system. However, the system tracks a job until all of its
residuals are gone (such as spool files in the jobs output queue).
5-6
V7.0
Student Notebook
Uempty
Payroll
1 Checks
2 Adjust
Pay
Job
Qu
eu e
Database
File
Main Storage
Pay 01
Data
Spooled
Files
Report Data
Ou
tp
Report Data
Pay
ut
Qu
eu
OL4912.1
Notes:
Usually, a batch job is submitted from an interactive job. A batch job runs asynchronously
to the interactive job. A batch job is initiated from a job queue.
5-7
Student Notebook
Sign On display
IBM i
OL4912.1
Notes:
To start an interactive job, you Sign on.
Normally, the User and Password fields are the only entries keyed.
Program, Menu, and Current library are optional.
5-8
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Following sign on, the initial panel displayed is determined by values specified when the
user's profile was created (or last changed).
We discuss the user profile later. In this example, the user is presented with the IBM i Main
Menu.
5-9
Student Notebook
Alternate job
IBM i
JOB A
Sign-on Process
System Request
or TFRSECJOB
JOB B
1
2
Sign-on
Process
System Request, Opt 1
or TFRSECJOB
3
Resume
Processing
System Request, Opt 1
or TFRSECJOB
4
Resume
Processing
Sign-off
5
Resume
Processing
Sign-off
Copyright IBM Corporation 2012
OL4912.1
Notes:
In the figure, the arrow shows a change in control. In the next several figures, we show you
an example. Some points of interest:
You Hot Key to an alternate job using the System Request key or by entering the
TFRSECJOB command.
You sign on to the alternate job. While the alternate job is executing your primary job is
suspended. You can toggle back and forth between the two interactive jobs.
Your workstation device need not have multiple addresses.
You can use the same user ID or a different user ID to sign on to the alternate job.
The TFRSECJOB command can be run instead of using option 1 of the System
Request Menu to toggle.
V7.0
Student Notebook
Uempty
First job
IBM i
OL4912.1
Notes:
If you know the option number for the System Request Menu, enter the desired number on
the dotted line that is presented (shown in the figure circled in red) when the System
Request key is pressed. If you do not know the option number, press Enter, and the next
screen gives you a list of valid options, one of which you may choose.
5-11
Student Notebook
OL4912.1
Notes:
Type 1 and press Enter to:
- Start your alternate job (if not already started).
- Switch to the alternate job (if an alternate job was previously started).
You can also reach this display by entering TFRSECJOB on the command line of the
previous display.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
When you sign on to your alternate job, your second sign on can be the same as your initial
sign on, or you can sign on with a different user ID.
5-13
Student Notebook
Alternate job
IBM i
OL4912.1
Notes:
Both jobs have equal status.
Neither is a subordinate of the other.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
You can toggle back to your previous job:
By pressing the System Request key.
By entering the TFRSECJOB command as shown in the visual.
The command, DSPWSUSR, shows whether there is an alternate job at this workstation
and the job names for each job.
5-15
Student Notebook
OL4912.1
Notes:
A job description is an object that provides an initial set of attributes to a job when it starts.
You can create a specific job description or you can let the system choose one for you.
Every IBM i job has a job description.
V7.0
Student Notebook
Uempty
i
*JOBD
*USRPRF
FRED
PAYLIB
OUTQA
QDFTJOBD
QDFTJOBD
DATE *SYSVAL
SWITCH 00000000
Database
LIBRARY LIST
*SYSVAL
_______
_______
System Values
QUSRLIBL
QSYSLIBL
QDATE
Q...
*OUTQ
Payroll
1 Checks
2 Adjust
*LIB
PAYLIB
Reports
OUTQA
OL4912.1
Notes:
A job description provides initial job attributes. Every job has a job description. The default
job description supplied by IBM is QDFTJOBD.
5-17
Student Notebook
Payroll
1 Checks
2 Adjust
PAY
Q
Jo b
u eu
Database
File
Main Storage
PAY01
Data
Spooled
Files
Report Data
Report Data
PAY
Copyright IBM Corporation 2012
OL4912.1
Notes:
Every job, including a batch job, has a job description (JOBD) associated with it. The JOBD
provides initial job attributes.
The default job description in SBMJOB is derived from the *USRPRF.
V7.0
Student Notebook
Uempty
Spooling intercept
IBM i
PROGRAM
Device File
QPRINT
SPOOL(*YES)
Spooling
Intercept
Data
Management
QPRINT
OU
TQ
Spooled
File
Print
Data
OL4912.1
Notes:
Printer output is almost always handled by a process called spooling on the IBM i.
When the printer device specifies SPOOL(*YES), this invokes the data management
routines that direct the print output to an output queue and spool file. The output queue
points to the spool file which has the same name as the printer device file. The spooled file
contains the print data and the attributes which control the printing.
5-19
Student Notebook
PROGRAM
Writes to file QPRINT
=
=
=
=
=
=
=
QPRINT
(*YES)
(*JOB)
(*STD)
(1)
(*FILEEND)
(*NO)
(*JOB)
T
OU
More . . .
OL4912.1
Notes:
A printer device file defines the print attributes for the job. Many of the attributes can be
overridden before the spool data is actually printed.
The printer device file is used by the application programs to define the print attributes for
the job. There are many more parameters on the CRTPRTF command than shown. The
device file could also contain the printed output specifications (on DDS) instead of coding
them in the program.
V7.0
Student Notebook
Uempty
or
SPOOL(*NO) DEV(*JOB)
SPOOL(*YES) OUTQ(*JOB)
Job description
PRTDEV(*USRPRF)
OUTQ(*WRKSTN)
User profile
PRTDEV(*WRKSTN)
Device description
OUTQ(*DEV)
PRTDEV(*SYSVAL)
System value
QPRTDEV(PRT01)
At job initiation, the first named output queue and printer device found
are used as the defaults for the job.
Copyright IBM Corporation 2012
OL4912.1
Notes:
This visual demonstrates how the printer and output queue are determined for a job. If
neither the printer nor the output queue are specified in the device file, the default of *JOB
is used and the output is sent to the default OUTQ and printer for the job.
The default output queue and printer device for a job are determined at job start.
The workstation device description OUTQ(*DEV) points to its own PRTDEV parameter,
which defaults to *SYSVAL. This refers to system value QPRTDEV, which is shipped as
PRT01.
Typically, the user profile has a named output queue; printer device files specify
SPOOL(*YES); and everything else is left at their default values.
5-21
Student Notebook
Print output
IBM i
CRTUSRPRF
CHGUSRPRF
CHGPRF
FRED OUTQ(FREDQ)
QDFTJOBD
*JOBD
FRED
*USRPRF
USRID
PASSWORD
OUTQ *USRPRF
SPOOL
WTR
PROG
JOBD QDFTJOBD
OUTQ FREDQ
INLLIBL *SYSVAL
FRED
*OUTQ
PRT01
*DEVD
PRT01
*OUTQ
SPLF
SPLF
SPLF
SPLF
CHGJOB OUTQ(PRTnn)
OL4912.1
Notes:
Conceptually, there are separate spooled files, which can be found, managed, printed, and
so on through their respective output queues. All of this is managed by the system and is
transparent to the user.
The easiest way for a user to view and manage spooled files is to use the WRKSPLF
command.
V7.0
Student Notebook
Uempty
Opt
___
_5_
___
___
___
___
___
File
PROG1
OVRDUE
DROP
QPJOBLOG
SAVEOPRLIB
SCREENS
QSYSPRT
Device or
Queue
User Data
PRT03
PRT03
PRT03
JOBLOGS
DROP
PRT02
PRT02
PRT03
ser
OPR07
OPR07
OPR07
OPR07
OPR07
OPR07
OPR07
6=Release
Sts
WTR
RDY
RDY
RDY
WTR
RDY
RDY
Total
Pages
3
3
6
10
3
9
7
7=Messages
Cur
Page Copy
1
1
1
1
1
1
1
1
1
Bottom
Parameters for options 1, 2, 3 or command
===>_______________________________________________________________________
F3=Exit
F10=View 3
F11=View 2
F12=Cancel
F22=Printers
F24=More keys
OL4912.1
Notes:
WRKSPLF with no parameter values specified displays all your spooled files, regardless of
which queue was sent the output.
You manage your spooled files by entering an option number in the Opt field.
Option 5 displays the report on your PC monitor. In the next visual, you see the report
displayed.
Using F21 on this display toggles between Basic and Intermediate Assistance Level. The
format shown above is Intermediate Assistance Level. Intermediate Assistance Level
provides capability for the specification of parameters as shown in an upcoming visual. The
Assistance Level specified with F21 will be retained by the system for each individual user
during subsequent sign ons.
5-23
Student Notebook
ACCOUNT
OPRLIB
ACCOUNT
DATE . . . . . . . . .
05/23/08
TIME . . . . . . . . . 11:46:32
02/23/99 11:46:32 Account Telephone List - Overdue Balance (90 Days)
NAME
AREA PHONE
ZIP
ADDRESS Line 2
ADDRESS LINE
CODE
CODE
SMITH,JEFFREY 414
3347085
53095
WEST BEND, WI
4838 SOUTH ST
MUELLER,JANET 507
4452658
52685
ROCHESTER, MI
1478 14TH ST
WEST,CINDY
507
4438987
52369
ROCHESTER, MI
2578 16TH ST
STARK,JAME
312
6458963
60621
CHICAGO, IL
2114 HALL ST
WENZEL,KIM
312
6489214
60125
SKOKIE, IL
840 GRAND ST
HAMMER,GAIL
305
6425584
33125
MIAMI, FL
18 FLAG AVE
FISCHER,BRIAN 954
9452874
33084
DAVIE, FL
121 WEST ST
BRANDT,TONY
404
2314825
30305
ATLANTA, GA
18 ANDREWS DR
Confidential
* * * * * * E N D O F L I S T I N G * * * * * * * *
Bottom
F3=Exit
F12=Cancel
F19=Left
F20=Right
F24=More keys
Press F16
OL4912.1
Notes:
You can search for a string of data in the displayed report by entering data in the Find field,
and then pressing F16 to scan the output displayed.
This search is case sensitive.
V7.0
Student Notebook
Uempty
2=Change
Additional
Output queue . . . . .
Library . . . . . .
File separators . . .
Page range to print:
Starting page. . . .
Ending page. . . . .
File becomes available
Save file. . . . . . .
OVRDUE
QDFTJOBD
OPR07
020874
5
PRT03___
*SAME___
*STD____
1_______
*STRPAGE
Parameters
.
*DEV____
.
________
.
_0______
.
.
.
.
_1______
_*END____
_*FILEEND
_*NO_____
OL4912.1
Notes:
Specifying option 2 in the display of spooled files (see earlier figure) lets you change a
spooled file's attributes.
A common use of option 2 is to change (move) a spooled file from an inactive output queue
to an active output queue where it will physically print on a printer.
5-25
Student Notebook
Opt
___
_2_
_2_
___
___
___
_2_
File
PROG1
OVRDUE
DROP
QPJOBLOG
SAVEOPRLIB
SCREENS
QSYSPRT
Device
User
OPR07
OPR07
OPR07
OPR07
OPR07
OPR07
OPR07
or
Queue
PRT03
PRT03
PRT03
JOBLOGS
PRT02
PRT02
PRT03
User Data
DROP
Total
Sts
WTR
RDY
RDY
RDY
WTR
RDY
RDY
6=Release
Cur
Pages
3
3
6
10
3
9
7
7=Messages
Page
1
Copy
1
1
1
1
1
1
1
Bottom
Parameters for options 1, 2, 3 or Command
===>__OUTQ(PRT01) COPIES(2)_______________________________________________
F3=Exit
F10=View 3
F11=View 2
F12=Cancel
OL4912.1
Notes:
This visual explains an easy way to change multiple spooled files:
If your display does not show an input-capable field for Parameters at the bottom of the
screen, press F21 to change from Basic to Intermediate Assistance Level. Only with the
Intermediate Assistance Level format can you take advantage of the easy change
technique shown above.
Make the entries as shown, then press Enter. They are all changed to the PRT01 queue
(typically the active queue for the system printer), and two copies of each report are
printed.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
5-27
Student Notebook
OL4912.1
Notes:
To view your spooled output using IBM i Navigator:
Expand Basic Operations.
Click Printer Output.
The view shown on the right side of the pane can be tailored.
Using IBM i Navigator to manage printed output is like using the native IBM i Work with
Spooled Files (WRKSPLF) command.
V7.0
Student Notebook
Uempty
Hold/Release
Send or move to another
printer/output queue
Delete
Reply to messages
Print next
Properties
OL4912.1
Notes:
The user can:
Open the printer output to view it using the AFP Workbench for Windows - the AFP
Viewer.
Hold the output - Either immediately or at page end.
Release the output.
Send the output to one or more users on the same or other systems (including
VM/MVS). This function is equivalent to the Send Network Spooled File
(SNDNETSPLF) command.
Reply to messages.
Print next - on a green screen this is done using option 2 (Change) on the WRKSPLF
menu or with the Change Spooled File Attributes (CHGSPLFA) command,
Parameter PRTSEQ.
5-29
Student Notebook
Move to another printer or to another output queue (on the green screen this is also
accomplished with the CHGSPLF command).
Delete the printed output.
The Printer Output Properties are comparable to the Spooled File Attributes. On a green
screen, the user can either display or change these attributes using two different
commands - WRKSPLFA or CHGSPLFA.
V7.0
Student Notebook
Uempty
Using AFP
Workbench Viewer
Full-function viewer
is included at no
charge
OL4912.1
Notes:
You can display (Open) any IBM i printed output using the AFP Workbench Viewer for
Windows - the AFP Viewer. This viewer is installed with IBM i Access. If it is not currently
installed, you can use IBM i Access Selective Setup to install it.
5-31
Student Notebook
OL4912.1
Notes:
The Printer Output Properties are comparable to the Spooled File Attributes. On a 5250
emulation screen, the user can either display or change these attributes using two different
commands - WRKSPLFA or CHGSPLFA.
These are the changeable properties:
General - User specified data (description of the output) and Save after printing
Printer/Queue - Printer name, Output queue, and Priority
Copies - Total Copies and Copies (number of copies left to be printed)
Pages - Starting page, Ending page, and Restart printing
Forms - Form type, Align page, Number of separator pages, and Form feed
Layout 1 - Print on both sides and Pages per side
Overlay - Front/Back side overlay and Front/Back side overlay offset
Other 1 - Print fidelity, Print quality, and Output becomes available
5-32 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
5-33
Student Notebook
OL4912.1
Notes:
Depending on a user's rights, the user is able to filter the display of the list of printer output.
This is done by selecting View > Customize this view > Include. The user can subset the
list of printer output shown in the right pane based on:
User - you can select to view the output for more than one user at any time
Printer
Output queue
From type
User-specified data
Status
Job name
V7.0
Student Notebook
Uempty
IBM i subsystems
IBM i
IBM i subsystems
OL4912.1
Notes:
5-35
Student Notebook
What is a subsystem?
IBM i
Subsystem
Subsystem
Interactive
Processing
Batch
Processing
Spooling
Subsystem
Copyright IBM Corporation 2012
OL4912.1
Notes:
From our earlier discussion about different types of jobs (interactive, batch, spooling), you
might correctly assume that any particular job would run most efficiently on a system
designed to run only that specific type of job.
The IBM i can contain one or more operating environments called subsystems. A
subsystem is a single, predefined operating environment through which the system
coordinates the work flow and system resources. Each job, as it starts, is assigned to a
subsystem.
By using different subsystems, each with its own unique operating characteristics, IBM i
work management makes it appear to the jobs running in each subsystem that the entire
system was designed to run only that type of job.
V7.0
Student Notebook
Uempty
Defines how much work can enter a subsystem and where that
work is performed
Maximum number of concurrent jobs
Pools of main storage used by the subsystem, private or shared
OL4912.1
Notes:
All work within a subsystem is controlled by an IBM i program known as a subsystem
monitor. All subsystem monitors are identical, regardless of the subsystem they control or
the type of jobs run in that subsystem. But what makes one subsystem different from
another?
Each subsystem monitor uses a different subsystem description when performing its
control functions. A subsystem description is an object that contains information defining
the characteristics of an operating environment which can handle specific types of
processing, such as interactive, batch, spooling, or communications. It defines how many
jobs the subsystem runs at one time, where and how those jobs run, where the subsystem
looks for jobs to run, and which resources the subsystem uses to perform the work.
A subsystem description can contain work entries (sources of work) for one or more of the
following:
Autostart jobs.
Workstations (individual or by type).
Copyright IBM Corp. 1997, 2012
5-37
Student Notebook
Job queues.
Communications.
A subsystem description also defines the amount of main storage that is available for jobs
which run in the subsystem. The subsystem description is used by the subsystem monitor
to establish the environment for the jobs that run in that subsystem.
When a subsystem is started, it is known by the name of the subsystem description it uses.
*SBSD is the object identifier for subsystems.
V7.0
Student Notebook
Uempty
QBASE
QSPL
Spooling
QSYSWRK
System Functions
QSERVER
File Server
QINTER
Interactive
QBATCH
Batch
Autostart Job
QCTL
Console
Complex environment
QCTLSBSD = QCTL
QSPL
Spooling
QCMN
Communications
QSERVER
File Server
QSYSWRK
System Functions
OL4912.1
Notes:
IBM ships predefined subsystem descriptions that can be used to provide the environments
needed on most IBM i systems.
The default subsystem configuration consists of a controlling subsystem called QBASE, a
system function subsystem called QSYSWRK, a file server subsystem called QSERVER,
and a spooling subsystem called QSPL. In this environment, all jobs on the system, except
some system jobs and spooling jobs, run under the control of the QBASE subsystem.
Certain system jobs run under the control of QSYSWRK and QSERVER. Spooling jobs run
under the control of the QSPL subsystem.
A more complex subsystem configuration is also provided and can be used instead of the
default QBASE/QSPL configuration. It consists of QCTL as the controlling subsystem
(console job only), QSYSWRK which runs certain system functions, QINTER as the
subsystem for interactive jobs, QBATCH as the subsystem for batch jobs, and QSPL as
the subsystem for spooling.
If you use communications (other than remote workstation support), you may also use the
QCMN subsystem. If you use file serving, you may also use the QCMN subsystem.
Copyright IBM Corp. 1997, 2012
5-39
Student Notebook
V7.0
Student Notebook
Uempty
Storage pool
IBM i
What?
A logical area of main memory in which jobs are run
Pool size determines amount of memory
Why?
Jobs need main memory to run and they compete for available
memory
System performance degraded if unlike jobs compete for some
memory
How?
A subsystem defines one or more storage pools or identifies shared
pools and directs each job it controls to run in a specific storage pool.
Different types of jobs are directed to run in different pools.
Copyright IBM Corporation 2012
OL4912.1
Notes:
A Storage Pool is an arbitrary partitioning of main memory. It is assigned to a subsystem.
Its purpose is to relieve contention between subsystems.
5-41
Student Notebook
SBMJOB
JOBQ
BATCH
OUTQ
WRITER
PRINTER
CALL
INTERACTIVE
WRKJOBQ
WRKACTJOB
WRKOUTQ
WRKSPLF
WRKWTR
WRKUSRJOB
WRKSBMJOB
Copyright IBM Corporation 2012
OL4912.1
Notes:
There are a number of commands that enable you to perform work management activities:
WRKWTR
WRKOUTQ
WRKSPLF
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
OL4912.1
Notes:
5-43
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
6-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
6-2
V7.0
Student Notebook
Uempty
Figure 6-2. Overview of using commands, user profiles, and library lists
OL4912.1
Notes:
6-3
Student Notebook
IBM i commands (1 of 2)
IBM i
Function:
Run a program
CALL HerProgram
Copy a file
Delete a file
Dltf OldFile
Display a library
DSPLIB ourlib
Power off
Pwrdwnsys delay(120)
Reorganize a file
Rgzpfm disorgfile
Send a message
OL4912.1
Notes:
You interface with IBM i functions using commands. These commands come with the
system. As a user, you may also create your own command interfaces to your application
programs.
6-4
V7.0
Student Notebook
Uempty
IBM i commands (2 of 2)
IBM i
Verb
Item
Command
Create
Create
Create
Create
Create
Create
Create
Create
Physical File
Logical File
Display File
ILE RPG Module
Bound RPG Program
CL Program
Bound COBOL Program
Library
CRTPF
CRTLF
CRTDSPF
CRTRPGMOD
CRTBNDRPG
CRTCLPGM
CRTBNDCBL
CRTLIB
Delete
Delete
Delete
Program
File
Library
DLTPGM
DLTF
DLTLIB
Change
Display
Hold
Release
Command
Data area
Output queue
Spooled file
CHGCMD
DSPDTAARA
HLDOUTQ
RLSSPLF
Work with
User profile
WRKUSRPRF
OL4912.1
Notes:
When you examine IBM i commands, they can generally be broken down into verb and
item.
For example, the command DLTLIB, means delete library.
However, not all combinations of verbs and item abbreviations are valid commands.
6-5
Student Notebook
Command syntax (1 of 2)
IBM i
Command
DSPLIB
Action
Item
Abbrev.
Parameter
LIB(PAYLIB)
Keyword
Value
OL4912.1
Notes:
Each i command is composed by concatenating:
A verb or action represented by three characters
with:
An item of up to seven characters (often three characters)
In addition to the command, one or more parameters are the target of the command.
The example shown here is the DSPLIB command which means we are asking, i, please
DiSPlay the objects of a LIBrary for me. The name of the LIBrary is PAYLIB.
Most commands are this simple to understand. Even those that are not quite as obvious
can be understood once you have had a little experience.
6-6
V7.0
Student Notebook
Uempty
Command syntax (2 of 2)
IBM i
(P)
CRTLIB-LIB(-library-name-)
TYPE(
*PROD
*TEST
*SYSVAL
*CHANGE
*ALL
*USE
*EXCLUDE
authorization-list-name
CRTAUT (
*SYSVAL
*NONE
*USRPRF
*CHANGE
*ALL
CRTOBJAUD (
1
ASP-- (
*LIBCRTAUT
*CHANGE
*ALL
*USE
*EXCLUDE
authorization-list-name
) AUT(
*BLANK
asp-identifier
TEXT--(
'description'
NOTE:
P All parameters preceding this point can be specified positionally
F4=Prompt
Copyright IBM Corporation 2012
OL4912.1
Notes:
There are two ways of specifying parameters that can be used, sometimes
interchangeably, within a command:
1. Keyword format
2. Positional format
Some parameters must always be in Keyword format.
The (P) denotes the end of positional notation. All subsequent parameters must be
specified in keyword format.
If a parameter has a default value, it is the first or uppermost entry in the list of valid
values.
Some commands may be used only in certain environments. For example, ENDDBG is
invalid unless you are already in debug mode. Some commands can only be used
interactively and are not valid in batch mode.
6-7
Student Notebook
To assist you, you can enter the command with any parameters and then use prompting
(F4). Help and further prompting is available for the individual parameters.
6-8
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
We have just been assigned to a new programming project. One of the first things we need
to do is to create a library for the project. We will step though the process and highlight the
command and the parameters used.
First, enter the CRTLIB command, then press F4. Doing this prompts the command.
6-9
Student Notebook
OL4912.1
Notes:
The prompt display shows prompts for only those parameters that are required and that are
most common.
Most commands have many parameters that are not shown on the initial prompt
screen.
To view the less commonly used parameters, press F10 (for additional parameters).
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Normally, you would fill in the parameter values for those that are required and any optional
ones that you want. Then to view any more parameters and fill in their values, you would
scroll, using the Page Up/Page Down keys. This process would continue as long as More...
is displayed in the lower right hand corner of the display.
Note the uses for some other function keys:
Press F24 to scroll the function key legend at the bottom of the panel.
Press F11 for Keyword format.
6-11
Student Notebook
OL4912.1
Notes:
F11 is a toggle. You can view the parameter keywords in front of the entry field, or view the
entry field followed by available choices. Since you can also prompt the parameter values
or use help, you have a great deal of flexibility as well as system assistance in completing
the command successfully.
Later, you will find a way to make this selection a permanent part of your personal user
environment.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
You can use the Help key (F1) to learn more about the parameter as well the meanings of
values. The Help key is cursor-sensitive and takes you directly to more information about
the parameter for which you requested help.
If more help is available than will fit in the Help window, you can page down to view the
additional Help text. Also, you can press F20 to temporally expand the Help window to a full
screen.
You can also tailor your personal environment to show help in a window or on a full screen.
6-13
Student Notebook
Special Characters
Function Keys
&
+
>
<
Increase length
F1:
Help
Add after
F3:
Exit
Insert
F4:
Prompt
Delete
F5:
Refresh
F9:
All parameters
F10:
Additional parameters
F11:
Keyword/Choices
F12:
Cancel
F13:
F14:
Command string
F15:
Error messages
F16:
Command complete
F24:
More keys
OL4912.1
Notes:
The special characters above can be used to manipulate what you enter as a parameter or
as parameters of a command. For example, the & increases the length of the parameter
field presented on the display.
The following function keys are available on the prompt display and on displays associated
with the prompt display. Some function keys may not be active on all displays.
F1=Help
Provides more information about the command.
F3=Exit
Exits the prompt display and associated displays without running the command.
F4=Prompt
Shows the permissible values for the entry field. If the cursor is on an entry field for a
parameter of TYPE(*COMMAND) or TYPE(*CMDSTR), Pressing F4 shows a prompt
display for the command.
6-14 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
F5=Refresh
Resets all parameters to their original default values.
F9=All parameters
Shows entry fields for all parameters, including those not selected by entries on
previous parameters and those not commonly used. It does not show parameters which
have been defined with the selective prompt character ?-.
F10=Additional parameters
Shows entry fields for the parameters that are not commonly used.
F11=Keyword or F11=Choices
Toggles between the version of the prompt display that shows possible choices and the
version that shows parameter keywords.
F12=Cancel
Shows the previous display.
F13=How to use this display
Shows help for the prompt display or associated display you are currently using.
F14=Command string
Shows the resulting command as it would run with the parameter values currently
entered.
F15=Error messages
Shows all error messages that pertain to the command being entered.
F16=Command complete
Indicates that all values needed have been entered, and requests the system to run the
command without showing additional displays.
F18=Start/End DBCS conversion
Shows the conversion prompt line on double-byte character set (DBCS) display
stations. On this line, you can enter the alphanumeric word to be converted, and the
system displays related DBCS words.
F24=More keys
This shows additional function keys that can be used for this display.
Enter - If pressed on the prompt display, it runs the command. If pressed on another
command display associated with the prompt display, it returns to the prompt display. Any
entries or changes made on the other display are included on the prompt display.
Help - Provides more information about the command.
Page Down or Roll Up - Moves forward to show additional information for this display.
6-15
Student Notebook
Page Up or Roll Down - Moves backward to show additional information for this display.
Print - Prints the information currently shown on your screen.
Sys Req - Interrupts your current job and shows a menu from which you can do tasks such
as:
Start a second interactive job at the same display station.
End your previous request.
Display information about your current job.
Display and send messages.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Menus are commonly used on the IBM i system. Many menus are developed by you, the
programmers. Many are created by IBM and are included as part of IBM i to enable you to
navigate system functions and to execute system commands more easily.
The MAJOR menu is a good one to show you. It enables you to determine which command
to use in a particular situation.
There are several ways to get to the MAJOR menu (shown in next visual):
- Press the ? or Enter key.
- Press F4 while the command entry line is blank.
- Type GO MAJOR.
6-17
Student Notebook
OL4912.1
Notes:
Commands are grouped by subject, verb, function, and so forth.
V7.0
Student Notebook
Uempty
Example: Go command
IBM i
OL4912.1
Notes:
You can use GO MAJOR as you have seen previously to access individual commands or
groups of related commands.
You can bypass MAJOR and go directly to the sub level menu. In this example, we entered:
Go CMDSAV*
using a wildcard.
6-19
Student Notebook
OL4912.1
Notes:
You know that you use the CALL command to execute or run a system or customer-written
program.
The QCMD command entry display is a popular tool for entering and retrieving previously
entered commands. You can use the command entry display by issuing:
call qcmd
Commands may be entered, one at a time, on this display. After they are entered and
processed, they are displayed as history above the command entry line. During an
interactive session, the history can grow to many pages.
V7.0
Student Notebook
Uempty
QCMD messages
IBM i
OL4912.1
Notes:
As you enter commands, they are logged starting at the top of the display. As this history
area fills, it will scroll down. All commands entered correctly and incorrectly are recorded.
Messages are displayed explaining whether the command was completed successfully or if
there was an error.
Previously entered commands may be retrieved and placed on the command line by
moving the cursor to the desired command at the top of the screen and pressing F9. The
last command entered may be retrieved without moving the cursor. Just press F9 in the
command entry area.
You can press F10 to see more detailed messages.
6-21
Student Notebook
OL4912.1
Notes:
From the QCMD display, pressing F10 expands the display vertically to include related
messages.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Each user on the IBM i must have a user profile that defines the environment in which the
user will operate on the system. The user profile also defines the users authority to objects
on the system.
The user profile can be created and maintained using 5250 commands and in IBM i
Navigator.
This example shows the command, CRTUSRPRF.
6-23
Student Notebook
OL4912.1
Notes:
The initial menu defaults to MAIN, meaning that the MAIN menu will be displayed
immediately after this user signs on to the system, unless we change the menu.
You must enter a value for the User profile parameter. The remaining parameters are
optional.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
A new user can also be created using IBM i Navigator.
A new user can either be created by using the context menu item New User on the User
and Groups, or All Users icon (right mouse button). The Create User menu is a simplified
interface compared to the Create user Profile (CRTUSRPRF) command. Only three to five
fields have to be filled in to create a new user profile.
User name field - Up to 10 characters are supported, but it is recommended that user
IDs be kept to 8 or fewer as some functions (for example, Lotus Notes) require a user
ID with a maximum of 8 characters.
Description field (optional).
User must change password at next sign-on - Notice that this is checked. It is
opposite the value of the default for the CRTUSRPRF command.
Enable user for processing - If this checkbox is checked, the user is enabled. If it is
blank, the user is disabled.
6-25
Student Notebook
All other parameters have been organized into functional groups. These additional
attributes can be accessed after clicking the corresponding button, for example, Jobs
(current library, job description, print device, and so forth), Capabilities (formally called
Security-special authorities, password expiration, auditing, application administration, and
so forth), Personal (name, address, telephone, mail service level, and so forth), Groups
(add a user to one or more groups) and Networks (information about environments
administered from IBM i, such as Lotus Notes or Novell Netware, and access to remote
servers). All of them have default values so the administrator does not have to select any of
them.
The user who creates or changes a user profile must have *SECADM special authority. If
the user does not have the required authority, the New User and New User Group menu
items and corresponding toolbar icons are grayed out. To create or change auditing
information for a user profile, the administrator must have special authority *AUDIT. In
addition, to change a user profile, the administrator must have *USE and *OBJMGT
authorities.
The following parameters of the CRTUSRPRF/CHGUSRPRF commands are not
accessible from within IBM i Navigator:
Special environment (SPCENV) - This value defaults to *SYSVAL.
Authority (AUT) - Default is *EXCLUDE. Authority has to be granted through the
Security Administration screens of Unity.
Owner (OWNER) - This value defaults to *USRPRF.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
The Display session page contains IBM i job attributes defined on the
CRTUSRPRF/CHGUSRPRF commands that are specific to interactive sessions (NPT or
emulation), such as:
Initial program (INLPGM) - None or specify name and library of a program.
Initial menu (INLMNU) - MAIN, sign off or name and library of a menu.
Attention program (ATNPGM) - System value QATNPGM, attention program
QSYS/QEZMAIN, name/library of program or don't use an attention program.
Limit initial program/menu capabilities (LMTCPB) - This option controls whether a
user can change the initial program, menu, current library, attention, initial program and
whether or not a user can interactively enter commands that are restricted from limited
users.
The available values are:
- Do not limit (LMTCPB *NO). The administrator must have *NO to grant this level.
6-27
Student Notebook
V7.0
Student Notebook
Uempty
Fred signs on
IBM i
OL4912.1
Notes:
Fred is now an IBM i user. He can sign on using his id, Fred. The system can be accessed
through 5250 emulation from IBM i Navigator. You may recall that the IBM i Navigator icons
displayed are determined by what is supported by the system itself and the user class of
the user profile.
The value typed in the password field is not displayed (hidden).
Now, the user, Fred, may sign on (and start an interactive job).
6-29
Student Notebook
Unqualified:
Qualified:
CALL
CALL
PAY02
PAYTSTLIB/PAY02
INQLIB
QSYS
QCVVV QCXXX
PAY77
AP60
QCZZZ
PAY99
AP55
QCYYY
PAYTSTLIB
PAYLIB
AP55
PAY02
PAY01
PAY04
PAY01
AP05
PAY02
PAY05
...
*/
*/
...
OL4912.1
Notes:
IBM i finds objects with unqualified names by using a top-down search of each library in the
library list until an object with a matching name and type is found. Once the first object that
satisfies the search is found, the search is terminated.
The library list is ignored for qualified object names.
V7.0
Student Notebook
Uempty
QSYSLIBL
QSYS
QHLPSYS
QUSRSYS
QSYS
QHLPSYS
QUSRSYS
System
Part
Program
Product
Part
USER PROFILE
CURLIB(FREDLIB)
FREDLIB
Current
Library
QUSRLIBL
QGPL
QTEMP
Job Descr INLLIBL
QGPL
QTEMP
PAYLIB
2
QGPL
QTEMP
PAYLIB
User
Part
SIGN ON
CURRENT LIBRARY FREDLIB
OL4912.1
Notes:
When you sign on, the system looks at the system values of QSYSLIBL and QUSRLIBL.
The job description for this user will override the user portion of the library list with its
INLLIBL values, if they are specified.
The current library may be set in the user profile and can be overridden at the Sign On
display. Your current library is your main library where all unqualified objects that you create
are created. It is the first library that is searched for unqualified references.
6-31
Student Notebook
CHGSYSLIBL
QSYS
QHLPSYS
QUSRSYS
*LIBL
System
Part
Program
Product
Part
CHGCURLIB
FREDLIB
Current
Library
ADDLIBLE
RMVLIBLE
EDTLIBL
QGPL
QTEMP
PAYLIB
User
Part
CHGLIBL
*CURLIB *USRLIBL
OL4912.1
Notes:
The commands in the visual are used to change the values in a job's library list.
V7.0
Student Notebook
Uempty
Does
No
QGPL
Yes
job have a
current
library?
Current
library
Exceptions:
QSYS is always the library for these object types:
*LIB
*CTLD
*USRPRF
*DEVD
*MODD
*AUTL
*LIND
*COSD
*EDTD
Copyright IBM Corporation 2012
OL4912.1
Notes:
If you cannot find an object that you just created, look in your current library or in QGPL as
shown in the visual.
6-33
Student Notebook
By application
For security
By user
For backup
By object type: Programs or files
By use: Production or test
OL4912.1
Notes:
These are just a few things to consider when you are creating and organizing libraries.
Most companies have practices in place to help you get started.
V7.0
Student Notebook
Uempty
Create a library
(CRTLIB)
Delete a library
(DLTLIB)
Display a library
(DSPLIB)
Clear a library
(CLRLIB)
Change a library
(CHGLIB)
(ADDLIBLE)
(RMVLIBLE)
(EDTLIBL)
(CHGLIBL)
(CHGCURLIB)
(DSPLIBL)
(CHGSYSLIBL)
(CHGSYSVAL)
OL4912.1
Notes:
CHGSYSLIBL - for any library referenced, the public authority cannot be greater than
*USE. The command CHGSYSLIBL is shipped with public authority *EXCLUDE and can
only be used by users with *ALLOBJ authority. This can be modified, if you wish, by
granting authority.
6-35
Student Notebook
Machine exercises
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
OL4912.1
Notes:
6-37
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
7-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
7-2
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
7-3
Student Notebook
Signon:
Mary
Menu
Authority
Payroll
menu
Authority
PAYEDIT
program
Authority
Data rights
Read
Update
Add
Delete
Payroll
data
OL4912.1
Notes:
Every time an object is accessed by a user, the system checks whether the user has
adequate authority to perform the desired function on that object.
7-4
V7.0
Student Notebook
Uempty
Layers of security
IBM i
User profile
Physical
DSP07
User
Password
Integrity
USER7
JON8S
Special
cases
Resource
*LIB: PAYLIB
*LIB: QSYS
*PGM: PAY01
Physical
Logical
*FILE: PAYLF
Selected records
Selected fields
*FILE:
PAYMAST
*USRPRF
USER7
*DEVD
DSP07
OL4912.1
Notes:
Some examples:
A specific display may be restricted for use to specific users. You may want to set the
PC in payroll for use only by payroll department employees. You could require a specific
user ID and password for sign-on.
A user can be limited in capability. For example, you could restrict a user to be able to
run only a specific program. You could implement this by setting an initial program in the
user profile. You could also limit the applications that a user can execute by setting an
initial menu for a user using their user profile.
The user profile can be constructed to prevent the user from executing most
commands.
7-5
Student Notebook
OL4912.1
Notes:
QSECURITY determines the system security level. This value specifies the level of security
on the system. If you make a change to this system value, it takes effect at the next IPL.
The shipped value is 40.
The possible system security levels are:
10
The system does not require a password to sign on. Users have
access to all system resources. Note: Security level 10 is no
longer supported.
20
30
40
7-6
V7.0
Student Notebook
Uempty
50
7-7
Student Notebook
People
(Users)
Objects
(Resources)
User
profiles
Individual
objects
Job
descriptions
Libraries
Group
profiles
Authorization
lists
System values
OL4912.1
Notes:
Everything on the IBM i system is an object. An object can be a file, a program, a display
station or a menu, for example.
Every time a user requests access to any object in any way, the system checks to see that
the user is authorized to use that object in the way that has been requested.
Even on a system with QSECURITY set at level 10 or 20, this security checking occurs.
However, with a level 10 or 20 system, all users have ALLOBJ special authority, so the
system grants access to just about any object for any purpose to every user.
7-8
V7.0
Student Notebook
Uempty
User profile
IBM i
User profile
Information
about the user
List of
objects owned
Specific
object
authorizations
CRT...
CHGOBJOWN
GRTOBJAUT
RVKOBJAUT
OL4912.1
Notes:
A user profile contains more than the users id and password. It also contains a list of all
objects that have been created by this user profile and a list of objects to which specific
authorization has been granted to this user profile.
Most security authorizations are more easily granted by using public authority, group
profiles and authorization lists, rather than by using specific object authorizations to
individual profiles, as shown here.
7-9
Student Notebook
Customer use
Security
officer
Full
service
functions
QSRV
(*NONE)
Basic
service
functions
QSRVBAS
(*NONE)
Test
request
functions
QTSTRQS
(*NONE)
QSECOFR (QSECOFR)
Programmer
System
operator
QPGMR (*NONE)
QSYSOPR(*NONE)
User
QUSER (*NONE)
Default
owner
QDFTOWN (*NONE)
. . . and more
Copyright IBM Corporation 2012
OL4912.1
Notes:
This visual lists the user profiles created by IBM that are shipped with the system. You
should change and keep a record of the QSECOFR password. Also, you should file it in a
secure location.
V7.0
Student Notebook
Uempty
System authority
IBM i
System authority
Special
authority
Specific
authority
Object authority
*SPLCTL
Data authority
*SERVICE
*OBJOPR
*READ
*JOBCTL
*OBJMGT
*ADD
*SAVSYS
*OBJEXIST
*UPD
*SECADM
*OBJREF
*DLT
*ALLOBJ
*OBJALTER
*EXECUTE
*AUDIT
*EXCLUDE
*IOSYSCFG
Copyright IBM Corporation 2012
OL4912.1
Notes:
Authorities are classified in several different ways:
1. Special Authority
*SPLCTL (Spool Control) - Access to manage other users' spooled files.
*SERVICE (Service) - Display and alter service function.
*JOBCTL (Job Control) - Manage output queues, job queues and printers; change a
job; stop subsystems; IPL.
*SAVSYS (Save System) - Save and restore operations.
*SECADM (Security Administration) - Create/change/delete user profiles.
*ALLOBJ (All Object) - Access to all system resources.
*AUDIT (Audit) - Control of audit system values.
*IOSYSCFG (I/O System Configuration) - Add, change and remove devices from
system.
Copyright IBM Corp. 1997, 2012
7-11
Student Notebook
V7.0
Student Notebook
Uempty
*ALL
*E
XE
C
*R UTE
EA
D
*A
DD
*U
PD
*D
LT
System
defined
authority
combinations
*O
BJ
*O MGT
BJ
E
*O XIS
BJ
T
*O REF
BJ
AL
T
*O
BJ ER
OP
R
IBM i
*CHANGE
*USE
*EXCLUDE
*LIBCRTAUT
OL4912.1
Notes:
For your IBM i system, IBM has defined some logical combinations that can be applied to
objects:
*ALL
*CHANGE
*USE
*EXCLUDE
User-defined authority is a combination of object and/or data authority that is not included
as one of the system-defined combinations.
The EDTOBJAUT command should be used to change the authority of an object.
When an object is created, the user can specify public authority. Public authority applies to
all users who do not have specific private authority to the object through their user profiles,
a group profile, or an authorization list.
7-13
Student Notebook
If the user does not specify *ALL, *CHANGE, *USE or *EXCLUDE when creating an object,
the *LIBCRTAUT value (which will equal one of these four values), stored in the library in
which this object is being created, is used.
V7.0
Student Notebook
Uempty
GRPMGRS
SPCAUT(*JOBCTL)
CHRIS
Michelle's authorities
*JOBCTL
*SPLCTL
PGM1
*USE
FILE1
*CHANGE
FILE2
*EXCLUDE
Source
Group
Self
Group
Group
Self
Chris' authorities
*JOBCTL
PGM1
FILE1
FILE2
*USE
*CHANGE
*READ
OL4912.1
Notes:
A user may access objects authorized to his/her profile or using the group profile that is
associated with the user profile. A group profile and up to 15 supplemental group profiles
can be specified with a user profile.
A user's group authority is checked if no specific private authority is granted for the user.
A group profile cannot be included as a member of another group profile.
7-15
Student Notebook
User : GREGORY
Group: DEPTA
Supplemental group: DEPTB
Object:
CUSTOMER
Authority
Object Authorities
*OBJOPR
*OBJMGT
*OBJEXIST
*OBJALTER
*OBJREF
Data Authorities
*READ
*ADD
*UPD
*DLT
*EXECUTE
*EXCLUDE
DEPTOWN
X
X
X
X
X
X
X
X
X
X
X
*PUBLIC
X
X
X
X
Q: Will Gregory be allowed to read, add, update and delete records in the CUSTOMER file?
Copyright IBM Corporation 2012
OL4912.1
Notes:
There are three group profiles associated with the CUSTOMER file. They are DEPTOWN,
DEPTA, and DEPTB with the authorities listed in each column.
V7.0
Student Notebook
Uempty
Authorization lists
IBM i
Name:
Owner:
AUTL1
USER3
LIBA
LFILEB
PFILEC
PROGD
Authorities:
USER3
USER1
USER2
USER4
*PUBLIC
*ALL
*AUTLMGT
*USE
*CHANGE
*ALL
*EXCLUDE
AUT(AUT-LIST-NAME)
CRT...
AUTL( )
GRTOBJAUT
CRTAUTL
EDTAUTL
WRKAUTL
OL4912.1
Notes:
Another way to grant authority to an object is by using an authorization list. An
authorization list:
Is an object in QSYS
Contains a list of objects
Contains a list of users with their specific level of individual access to the list of objects
Objects point to the authorization list.
7-17
Student Notebook
OL4912.1
Notes:
A new authorization list can be created using the New option from the context menu of the
Authorization List folder. You can then specify a Name, Description, and the Public
Authority for the authorization list. This function uses the Create Authorization List
(CRTAUTL) command on the IBM i. It is also possible to delete an authorization list using
the Delete option of an authorization list. This is based on the Delete Authorization List
(DLTAUTL) command.
The following actions can be performed on an authorization list from its Properties pages:
Add users or groups (Add Authorization List Entry - ADDAUTLE)
Remove users or groups (Remove Authorization List Entry - RMVAUTLE)
Change users or groups (Change Authorization List Entry - CHGAUTLE)
Change owner
Change primary group
V7.0
Student Notebook
Uempty
In order to perform any of the above actions, a user needs authorization list management
rights as well as the grant or revoke authorities.
Furthermore, a list of objects secured by the authorization list can be displayed.
7-19
Student Notebook
Sign On display
IBM i
OL4912.1
Notes:
When you sign on to the IBM i system, your user ID and your password are required
whether you sign on using 5250 emulation or from a client application such as System i
Navigator.
The Program/procedure, Menu, and Current library fields are optional. If they are not
specified here, their values are determined elsewhere.
V7.0
Student Notebook
Uempty
Sign on processing (1 of 2)
IBM i
No
Valid User/Password?
Error message
Yes
No
Error message
Authorized to device?
Yes
Yes
Program/Menu/Lib
exceed capability?
Error message
No
Program
keyed?
No
INLPGM in profile?
No
Yes
Yes
Call INLPGM
Call keyed
program
A
Copyright IBM Corporation 2012
OL4912.1
Notes:
When you sign on there is a specific process that is followed. This process is detailed in
this and the subsequent visual.
7-21
Student Notebook
Sign on processing (2 of 2)
IBM i
A
No
Menu keyed?
Yes
Yes
Display
keyed menu
Signoff user
INLMNU(*SIGNOFF)?
No
Display
profile menu
Copyright IBM Corporation 2012
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
*ALLOBJ
Private
authorization list
None
found
*ALLOBJ
Primary group
private
authorization list
None
found
Object
authorization list
Insufficient
Adopted
Copyright IBM Corporation 2012
OL4912.1
Notes:
7-23
Student Notebook
Authorization flow (1 of 2)
IBM i
USER
Yes
GROUPs
START
*ALLOBJ
Special
authority
?
PUBLIC
*ALLOBJ
Special
authority
?
No
No
Yes
Yes
User
specific
authorities
Group
Yes
Public
specific
authorities
?
specific
authorities
?
No
No
Yes
No
User on
authorization
list
?
Yes
Group on
authorization
list
?
No
Use *PUBLIC
authority from
authorization list
No
A
Copyright IBM Corporation 2012
OL4912.1
Notes:
The figure shows (in more detail) the path followed by IBM i to check for authority.
If a test for the requested authority is not satisfied, i stops and does not look further.
Adopted authority - The owner of a program can specify that anyone authorized to run
this program also has authority to objects used by that program while it is executing.
V7.0
Student Notebook
Uempty
Authorization flow (2 of 2)
IBM i
Yes
Allow access
to object
Adequate
authority
?
No
Any
adopted
authority
?
No
Access
denied
Yes
Allow
access
Yes
Adopted
authority
sufficient
?
No
Access
denied
OL4912.1
Notes:
The last authority check performed by the IBM i is for adopted authority. A user with
adopted authority access to an object may temporarily have the appropriate authority to an
object when running a program.
7-25
Student Notebook
EDTOBJAUT command
IBM i
EMPLOYEE
PAYLIB
*FILE
Owner . . . . . . . :
Primary group . . . :
COMPANYA
*NONE
User
COMPANYA
DEPTA
DAVISW
*PUBLIC
Object
Authority
*ALL
*USE
USER DEF
*CHANGE
Group
-------------------Object---------------Opr
Mgt
Exist
Alter
Ref
X
X
X
X
X
X
_
_
_
_
X
X
_
_
_
X
_
_
_
_
Bottom
F3=Exit
F5=Refresh
F6=Add new users F10=Grant with reference object
F11=Display data authorities F=12Cancel
F17=Top
F18=Bottom
OL4912.1
Notes:
The EDTOBJAUT command allows you to make interactive changes. EDTOBJAUT
combines the function of the GRTOBJAUT and the RVKOBJAUT commands.
There are also other ways to implement security:
Security menus:
- GO SECURITY
- GO CMDUSRPRF
User profile commands:
- CHGPRF - my user profile
- CHGUSRPRF - another user's profile
V7.0
Student Notebook
Uempty
EMPLOYEE
PAYLIB
*FILE
Owner . . . . . . . :
Primary group . . . :
COMPANYA
*NONE
User
COMPANYA
DEPTA
DAVISW
*PUBLIC
Object
Authority
*ALL
*USE
USER DEF
*CHANGE
Group
. .
. . ..
-------------------Data----------------Read
Add
Update
Delete
Execute
X
X
X
X
X
X
_
_
_
X
X
X
X
X
X
X
X
X
X
X
Bottom
F3=Exit
F5=Refresh
F11=Display object authorities
OL4912.1
Notes:
By pressing F11, you can display the data authorities for users attempting to operate on an
object.
7-27
Student Notebook
OL4912.1
Notes:
It is very easy to change individual access rights, the authorization list, the owner, the
primary group, the default public authority for newly created objects, or the sensitivity level
of an object. All of these tasks can be done using the Permissions panel. Here, you can
select these functions using a button. If you want to add a user to the list of authorized
users and groups, you simply click the Add button. Then you can display the lists of All
Users, Groups, or Users Not in a Group. Choose the desired users from the list. In the
same way, you can select a new owner, an authorization list, and a primary group.
Adding a new user/group or changing a user's/group's authority is the same as the
GRTOBJAUT command.
Removing an authorized user/group is the same as the RVKOBJAUT command. Changing
the owner of an object is the same as the CHGOBJOWN command.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
The security wizard helps you to define the proper security settings for your IBM i system.
To use the Security Wizard, open IBM i Navigator, expand the tree to view your IBM i,
right-click Security and click Configuration.
The Security Wizard leads you through a set of questions. It then creates an Administrator
Report and a User Report. You can view these reports and, if you agree with the suggested
changes, these values can be applied to your system.
The Administrator Report explains the suggested changes. You can use the following
methods to change system values:
Before applying the Security Wizard's recommended changes, use the Details button.
This allows you to view the recommended settings and override them if you choose.
After applying the Security Wizard changes, use the Security option from IBM i
Navigator. You can then use the security policy panels to change specific
security-relevant system values. If you decide that the selected setting for a specific
system value is not appropriate for your situation, you can change it to another setting.
Copyright IBM Corp. 1997, 2012
7-29
Student Notebook
After applying the Security Wizard changes, use the Work with System Values
(WRKSYSVAL) command to change the setting for any system value.
The User Report explains the IBM i security rules to the IBM i end user. It helps end users
define their passwords and explains some security details that every user should know.
You can find more about security-relevant system values in the Security Reference book.
Security Wizard is a component of IBM i Access and IBM i Navigator. It can be used with
any supported release of IBM i.
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
OL4912.1
Notes:
7-31
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
8-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
8-2
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
8-3
Student Notebook
Users
Operators
Programmers
CL Programs:
Better performance
Manage exceptions
Control sequence of application programs
Front end to application programs
- Overrides
- Library list
- Allocate objects
- Open files
Programmer/Operator Tools
Frequently used commands
Utility functions
Control Language
CL Commands:
Consistent interface
Prompting and Help
OL4912.1
Notes:
On some computer systems, programmers write high-level programs to do part of the
application and surround it with instructions to the supervisor language to execute the
program. Operator functions often require instructions to the supervisor program in a
different format.
On the IBM i, CL programs span both of these areas. A function that previously required a
user to type a series of instructions one at a time, from a run book, can now be put into a
CL program and be run in one step. A CL program can solve some of the application
requirements that are normally written in RPG, COBOL, or another high-level language.
All system functions are run using CL. CL may be entered interactively at a workstation.
Several statements may be typed together in a diskette or in a source file source member,
then submitted to a job queue as a job stream. They may be entered into the system as the
source for a program. That program can be compiled and run like any other high-level
language program. CL can be run in an interactive or batch environment.
CL can be compiled. The advantages of compiling CL are that it runs faster and can include
logic.
8-4
V7.0
Student Notebook
Uempty
8-5
Student Notebook
Like a procedure
Manage flow of work for an application
Can set up user environment
Made up of variables and arithmetic / logical operations
Can access screen (display) files and DB files
OL4912.1
Notes:
The control of work flow is a primary function of CLP.
A CL program is similar to a job control language or procedure language on another
system.
As you can see in the visual, CL programs are based on IBM i commands, Control
Language. While there are many things that you can do with CL programs, we will cover
the basics in this unit.
For further knowledge of CLP, you should plan on attending the OL20/OL201 Control
Language Programming Workshop.
8-6
V7.0
Student Notebook
Uempty
CL program structure
IBM i
PGM
Declaration
DCL
DCLF
Program function
SNDRCVF
CHGVAR
DSPMSG
IF
ELSE
...
Most CL
commands
are allowed in
CL programs
Passing control
CALL
SIGNOFF
RETURN
TFRCTL
ENDPGM
Copyright IBM Corporation 2012
OL4912.1
Notes:
A CL program is framed by the PGM and ENDPGM statements. There are various sections
of a CL program:
1. Declaration - In this section you declare any variables that you are going to pass to or
from your CL program.
2. Program Function - This is where you perform the logic of the program.
3. Pass Control - This can happen anywhere in the logic of the program. You pass control
by issuing a call to another program or by issuing a return to the program that called this
CL program. There are several other commands but these are the two that are used
most often.
8-7
Student Notebook
Command format
IBM i
Parameter
LABEL:
CRTLIB
Command
label
Command
name
LIB(A)
Keyword
Value
Keyword / Positional
OL4912.1
Notes:
CL programs use the same command format as system commands with the addition of the
ability to code a label (used to set a branching point within the CL program).
8-8
V7.0
Student Notebook
Uempty
CL command syntax (1 of 4)
IBM i
Optional
?...
label-name. . .
library-name. . .
LABEL1:
DSPLIB LIB(PAYLIB)
no space
blank
OUTPUT(*PRINT)
blank
OL4912.1
Notes:
Labels are only used when the command is in a CL program.
8-9
Student Notebook
CL command syntax (2 of 4)
IBM i
Keyword format
DSPLIB
LIB(PAYLIB)
OUTPUT(*PRINT)
DSPLIB
OUTPUT(*PRINT) LIB(PAYLIB)
Positional format
DSPLIB
PAYLIB
Combination format
DSPLIB
PAYLIB
OUTPUT(*PRINT)
OL4912.1
Notes:
When F4 is used to prompt for a command, it is entered in keyword format.
This figure shows both the keyword form and the positional form for entering CL
commands.
The keywords may be omitted if the parameter values are entered in the sequence in which
they are listed in the reference material in the Information Center. All three commands in
this figure perform exactly the same function.
V7.0
Student Notebook
Uempty
CL command syntax (3 of 4)
IBM i
continuation
within a program
variables
start with
and
SNDUSRMSG
comment
OL4912.1
Notes:
Notice that a single quote is represented by double quotes.
8-11
Student Notebook
CL command syntax (4 of 4)
IBM i
/*
*/
DSPOBJD
OBJ(PAYLIB/PAY*)
OBJTYPE(*PGM *FILE)
Connects parts
of a qualified
name
Blank to separate
list elements
OL4912.1
Notes:
Defaults for positional parameters are designated with an *N. A blank is used to separate
list elements (values) of a parameter.
V7.0
Student Notebook
Uempty
Coding rules (1 of 2)
IBM i
Variable name
To store and update data, and to receive parameters
It must begin with an & character
Colon
Separates the label from the command
Blanks
Separate command parameters
Parentheses
Separate keywords and values
Slash
Connects parts of qualified names
Apostrophes
Appear at the beginning and at the end of a quoted character string
Copyright IBM Corporation 2012
OL4912.1
Notes:
The first character of every variable name must be an &.
8-13
Student Notebook
Coding rules (2 of 2)
IBM i
/* and */
Use to frame a comment
Predefined values
Start with * such as *ALL
Generic names
Names end with * such as PAY*
*N
Indicates the absence of a positional parameter
Copyright IBM Corporation 2012
OL4912.1
Notes:
Using comments is encouraged. Comments are valuable documentation. The + and - signs
are used for continuation. If you use prompting in the editor, statements will be created
correctly for you.
V7.0
Student Notebook
Uempty
Information Center
IBM i
OL4912.1
Notes:
The IBM Information Center is the main reference source. This visual shows you what is
available, including the CL Programming Reference. This and other reference manuals are
stored in PDF format. They may be downloaded to your personal PC and viewed using
Adobe Acrobat Reader. The above screen can be seen at the following URL:
http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp
8-15
Student Notebook
Basic CL programming
IBM i
Basic CL programming
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
PGM
*/
CALL PGMA
*/
CALL PGMB
/ * CL PROG - STEP 2
*/
CALL PGMC
*/
ENDPGM
OL4912.1
Notes:
This is an example of a very simple CL program.
8-17
Student Notebook
CL program structure
IBM i
Description
Start of program
Program statement
PGM (Optional)
IBM Commands
COMMAND
MONMSG
MONMSG
Command-Level
Monitor Messages
and/or
User commands
End of program
ENDPGM (optional)
Copyright IBM Corporation 2012
OL4912.1
Notes:
There are some distinct components of a CL program.
PGM - optional. Required if the program is to receive parameters when called.
DCL - declare a variable.
DCLF - declare a file and its variables.
ENDPGM - optional. Assumed if not present.
Most commands are valid in CL programs.
An important source of information can be found in the syntax diagrams for individual
commands in the Alphabetic List of Commands listed in the IBM Information Center. Each
syntax diagram lists a group of codes such as Job: B,I Pgm: B,I. If the code includes Pgm,
the command may be used in a CL program. The B (batch) and I (interactive) codes
indicate the type of job in which the CL program can run.
V7.0
Student Notebook
Uempty
DCL
VAR(&NAME)
TYPE ( )
TYPE(
LEN(
LEN( )
VALUE( )
*DEC
default (15 5)
max. (15 9)
default ( 0 )
*CHAR
default (32)
max. (9999)
default ( b )
*LGL
VALUE( )
Examples:
(1) DCL &A *LGL VALUE ( ' 1 ' )
(2) DCL &B *CHAR 5 ABCD
(3) DCL &C *DEC (6 2) 543.21
OL4912.1
Notes:
Use the DCL command to declare any variables needed in your CL program that are not
already implicitly declared. Declaring a file implicitly declares all the fields in the file as CL
variables. Logical variables may be either a character '1' (true) or '0' (false). If a field is
declared, but is not referenced by any other command in the program, the variable is not
included in the compiled program.
The figure above shows the default lengths and initial values for the three different types of
variables. The examples below the table show how to declare a logical, character, and
decimal variable:
1. In example 1, field &A is declared as a logical variable with initial value of character '1'
(true).
2. In the second example, field &B is declared as a character variable, five positions long,
with initial value ABCD .
3. In the third example, variable &C is declared as a decimal variable, six positions long.
For &C, the last two positions are to the right of the decimal point, and the initial value is
0543.21.
Copyright IBM Corp. 1997, 2012
8-19
Student Notebook
Conditional execution
IBM i
IF COND
relational
or logical
expression
THEN (command)
TRUE
IF
THEN
ELSE
CMD(command)
FALSE
THEN parameter or ELSE command is
optional.
ELSE
OL4912.1
Notes:
You can code expressions that are tested for true or false. The THEN and ELSE
statements are conditionally-executed based on the result of the test. However, the THEN
and ELSE statements are optional. The following list shows what happens for each
situation:
a. THEN parameter is omitted; ELSE command is specified:
True condition: Control passes to the command after the ELSE statement.
False condition: Execute the command in the ELSE statement.
a. THEN parameter is specified; ELSE command is omitted:
True condition: Execute the command in the THEN parameter.
False condition: Control passes to the command after the IF statement.
V7.0
Student Notebook
Uempty
Expression:
(Operand Operator Operand)
Result of a relational or logical expression: '1' True or '0' False
Operands:
Constant, Variable, Another Expression
Operators
Description
<
LT
Less Than
*EQ
Equal To
>
*GT
Greater Than
<=
*LE
<
*NL
>
*NG
>=
*GE
*NE
Not Equal To
&
*AND
*OR
*NOT
Copyright IBM Corporation 2012
OL4912.1
Notes:
Logical and relational expressions are either true or false. The system represents a true
condition with a '1', and represents a false condition with a '0'. These are character values.
This figure shows two ways of representing operators. You may use either the
mathematical symbols, or the equivalent English abbreviations to show a relationship.
8-21
Student Notebook
IF examples
IBM i
OL4912.1
Notes:
In the space below, write a description of what happens when:
1. &RESP = 5 _________________________________________________________
2. &AMTDUE is > 10,000 ________________________________________________
3. &A does not = &B ____________________________________________________
4. &IN03 is true ________________________________________________________
V7.0
Student Notebook
Uempty
DO group
IBM i
THEN(DO)
CALL PGM1
CALL PGM2
ENDDO
ELSE CMD(DO)
CALL PGM3
CALL PGM4
ENDDO
CALL PGM5
OL4912.1
Notes:
The DO command is valid in the THEN parameter of an IF statement or in the CMD
parameter of an ELSE statement. It groups all commands between it and an ENDDO
command.
In this example, either PGM1 and PGM2 are executed or PGM3 and PGM4 are executed,
but not both groups. PGM5 will be executed in either case.
CL program syntax allows indentation for readability.
8-23
Student Notebook
Nested IF statements
IBM i
T
&RESP=1
&A = 5
&B = N
CALL PGMA
Keyword form:
IF
Positional form:
IF
COND(&RESP = 1) THEN(DO) /*
IF
COND(&A
= 5) THEN(DO) /*
IF
COND(&B
= N) THEN(DO) /*
CALL
PGMA
ENDDO /* #3 */
ENDDO /* #2 */
ENDDO /* #1 */
*AND (&A = 5)
#1
#2
#3
*/
*/
*/
OL4912.1
Notes:
This is a flowchart for nested IF statements, representing a complex condition. The coding
is shown in three coding styles, all equivalent to the flowchart.
If the nested IFs are discarded and replaced with a compound expression, the same logic
can be put into a single IF statement. Notice the last example.
V7.0
Student Notebook
Uempty
&A=&B
PGMB
&A=&C
PGMC
&A=&D
PGMD
F
Copyright IBM Corporation 2012
OL4912.1
Notes:
This figure shows a structured flow chart and the corresponding CL statements. These
statements are a series of IF statements. The condition is tested in each case. If &A = &B
= &C = &D, all three programs, PGMB, PGMC, and PGMD, are run.
8-25
Student Notebook
&A=&B
PGMB
F
&A=&C
PGMC
F
&A=&D
PGMD
IF
COND(&A = &B) THEN(CALL PGM(PGMB))
ELSE CMD(IF COND(&A = &C) THEN(CALL PGM(PGMC)) )
ELSE CMD(IF COND(&A = &D) THEN(CALL PGM(PGMD)) )
Copyright IBM Corporation 2012
OL4912.1
Notes:
This figure shows a structured flow chart with the corresponding IF and ELSE statements.
The second and third IF statements are embedded. When a condition tests true,
embedded IF statements that follow are bypassed. This logic is normally found in the
programs used in conjunction with menus.
V7.0
Student Notebook
Uempty
START:
END:
PGM
SNDRCVF RCDFMT(MENU)
.
.
.
IF (&OPTION = 12) GOTO CMDLBL(END)
.
.
.
.
.
GOTO START
ENDPGM
OL4912.1
Notes:
Any command in a CL program may have a statement label. Labels have one to 10
characters and are followed by a colon. A label is used as the target of the GOTO
command. In this program, when the GOTO START command is executed, control is
passed to the statement with label START at the beginning of the program. If &OPTION =
12, the GOTO command sends control to the ENDPGM statement.
8-27
Student Notebook
DOUNTIL (&LGL)
.
.
.
CHGVAR &INT (&INT + 1)
IF (&INT *GT 5) (CHGVAR &LGL '1')
ENDDO
DOWHILE (&LGL)
.
.
.
IF (&INT *EQ 2) (CHGVAR &LGL '0')
ENDDO
Copyright IBM Corporation 2012
OL4912.1
Notes:
The Do Until (DOUNTIL) command processes a group of CL commands one or more
times. The group of commands is defined as those commands between the DOUNTIL and
the matching ENDDO command. After the group of commands is processed, the stated
condition is evaluated. If the condition is true, the DOUNTIL group is exited and processing
will resume with the next command following the associated ENDDO. If the condition is
false, the group continues processing with the first command in the group.
The logical expression on the COND parameter may be a single logical variable or
constant, or it must describe a relationship between two or more operands; the expression
is then evaluated as true or false.
The body of the DOUNTIL group is run at least one time. If the initial value of the &INT
variable is 5 or more, &LGL is set to true on the first time and processing continues
following the ENDDO when the expression is evaluated at the end of the group. If the initial
value is less than 5, the body of the group continues to be repeated until the value of &INT
is greater than 5 and the value of &LGL is changed to true.
V7.0
Student Notebook
Uempty
The Do While (DOWHILE) command lets you process a group of commands zero or more
times while the value of a logical expression is true. The DOWHILE command is used to
state a condition that, if true, specifies a command or group of commands in the program to
run. The group of commands is defined as those commands between the DOWHILE and
the matching ENDDO command. After the group of commands is processed, the stated
processing resumes with the next command following the associated ENDDO. If the
condition is true, the group continues processing with the first command in the group.
When the ENDDO command is reached, control returns to the DOWHILE command to
again evaluate the condition. The logical expression on the COND parameter may be a
single logical variable or constant, or it must describe a relationship between two or more
operands; the expression is then evaluated as true or false.
When the DOWHILE group is processed, the stated condition is evaluated. If the condition
is true, the group of commands in the DOWHILE group is processed. If the condition is
false, processing continues with the command following the associated ENDDO command.
If the value of &LGL is true, the commands in the DOWHILE group are run until &INT is
equal to 2 causing the &LGL variable to be set to false.
8-29
Student Notebook
SELECT
WHEN (condition-1) THEN(command-1)
.
.
.
WHEN (condition-n) THEN(command-n)
OTHERWISE command-x
ENDSELECT
SELECT
WHEN (&LGL)
WHEN (&INT *LT 0) THEN(CHGVAR &INT 0)
WHEN (&INT *GT 0) (DOUNTIL (&INT *EQ 0))
CHGVAR &INT (&INT -1)
ENDDO
OTHERWISE (CHGVAR &LGL '1')
ENDSELECT
Copyright IBM Corporation 2012
OL4912.1
Notes:
The SELECT command is used to identify one or more conditions and an associated group
of commands to process when that condition is true. A special group of commands may
also be specified to be processed when none of the stated conditions are true. Only one of
the groups of commands identified by the WHEN or OTHERWISE commands will be
processed within the group.
The general structure of the SELECT command is as follows:
SELECT
WHEN (condition-1) THEN(COMMAND-1)
............................
.............................
WHEN (condition-n) THEN(command-n)
OTHERWISE command-x
ENDSELECT
8-30 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
A SELECT group must specify at least one WHEN command. The WHEN command
includes an expression, which is tested (true or false), and an optional THEN parameter
that specifies the action to take if the condition is true. The logical expression on the COND
parameter may be a single logical variable or constant or it must describe a relationship
between two or more operands; the expression is then evaluated as true or false.
If the condition described by the logical expression is evaluated as true, the program
processes the CL command on the THEN parameter. This may be a single command or a
group of commands specified by the DO, DOWHILE, or DOUNTIL commands. If the
condition is not true, the condition specified on the next WHEN command in the SELECT
group is evaluated. If there is no WHEN command following this one, the command
identified by the OTHERWISE command, if any, is processed. If there is no next WHEN
and no OTHERWISE command, processing continues with the command following the
associated ENDSELECT command.
In the example, if the initial value of &LGL is true ('1'), processing continues with the
command following the ENDSELECT, because there is no THEN parameter. If the initial
value of &LGL is false ('0'), the COND of the second WHEN is evaluated. If &INT is less
than zero, the CHGVAR is processed, setting the value of &INT to zero. Processing then
continues with the command following the ENDSELECT. If the first two conditions are not
met, the value of &INT is checked to determine if it is greater than zero. If the value is
greater than zero, the DOUNTIL group is entered and the value of &INT is decremented
until it reaches zero. When &INT reaches zero, the DOUNTIL group is exited and
processing continues with the next command following the ENDSELECT. If none of the
conditions on any of the WHEN commands is evaluated as true, the CHGVAR specified on
the CMD parameter of the OTHERWISE command is processed. The value of &INT
remains unchanged while &LGL is set to be true. Processing then continues with the next
command following the ENDSELECT.
8-31
Student Notebook
Top
Level n
PGMA
PGM
.
.
CALL PGMB
...........
.
.
.
Program Stack
Level n+1
PGMB
PGM
.
.
CALL PGMC
...........
.
.
.
TFRCTL PGMD
.
.
.
Bottom
Level n+2
PGMC
PGM
.
.
.
ENDPGM
PGMD
PGM
.
.
.
RETURN
Copyright IBM Corporation 2012
OL4912.1
Notes:
When program PGMB executes the TFRCTL PGMD statement, PGMB is removed from
the program stack.
Parameters passed by the TFRCTL command must have been received as parameters in
the program containing the TFRCTL command. TFRCTL is only valid within a CL program.
V7.0
Student Notebook
Uempty
*PGM: A
PGM
DCL VAR(&COUNTA) TYPE(*DEC) LEN(3 0)
.
.
.
CALL
PGM(B) +
PARM( '0' &COUNTA 100 'ABC Co.')
*CHAR.
*DEC
*CHAR
(32) .
(15 5)
(32)
.
Job's process
access group
Variables for A
&COUNTA 005
006
*PGM: B
PGM PARM(&IN99 &COUNTB &X &CO)
DCL &IN99
*LGL
DCL &COUNTB *DEC
(3 0)
DCL &X
*DEC
(15 5)
DCL &CO
*CHAR (20)
.
.
.
CHGVAR VAR(&COUNTB) VALUE(&COUNTB + 1)
.
.
.
Variables for B
&IN99
&COUNTB
&X
&CO
.
.
.
OL4912.1
Notes:
This figure illustrates the rules of passing data to a CL program:
Logical variables are either character 1 or 0.
Decimal constants are always passed with a length of (15 5), the default length in a
DCL statement.
Character constants pass with a 32-position length if the character string is 32 positions
or fewer. If the character string is greater than 32 positions, the exact length of the
character string is passed to the CL program.
Variables must be in the same sequence in the PARM parameter of the PGM command
of the called program as they are in the PARM parameter of the CALL.
When a variable is changed in the called program, it is automatically changed in the
calling program. The variables must be defined with the same characteristics in the
called program as in the calling program, but do not have to have the same names.
When parameters are passed from one CL program to another, no new storage area is
allocated in the called program for the variables received as parameters.
Copyright IBM Corp. 1997, 2012
8-33
Student Notebook
V7.0
Student Notebook
Uempty
CL
DCL VAR(&IN98)
DCL VAR(&CUSTZ)
CALL PGM(
TYPE(*LGL)
TYPE(*DEC) LEN(5 0)
) PARM(&CUSTZ &IN98)
RPG IV
COBOL
D Customer
D CustZ
D Indic
PR
5 0
N
Linkage Section.
01 Customer PIC S99999 COMP-3.
01 IN98
PIC 1.
Procedure Division
Using Customer, IN98.
OL4912.1
Notes:
From the standpoint of the calling CL program, there is no difference in calling an RPG,
COBOL, CL, PL/1 or any other type of program.
8-35
Student Notebook
+
/
*
operand)
OL4912.1
Notes:
CHGVAR can be used for arithmetic calculations by putting the calculation in the VALUE
parameter as an arithmetic expression.
The CHGVAR command is the general command used to perform arithmetic calculations,
data type conversion, and character string manipulation.
V7.0
Student Notebook
Uempty
CHGVAR VAR(&A)
VALUE(&B)
LEN
Converted Result
LEN
Specified Value
7
7
7
0023.00
-003.90
-123.67
52
52
52
23.00 or +23
-3.9
-123.67
CHGVAR VAR(&B)
VALUE(&A)
Character Variable &A
Converted Result
LEN
Specified Value
52
50
52
123.10
123
-123.00
10
10
10
'bb+123.1bb'
'bbb+123.00'
'-123bbbbbb'
Figure 8-32. CHGVAR: Conversion between *CHAR and *DEC data types
OL4912.1
Notes:
Data type conversion is often used in CLP to convert decimal data into character data in
order to use it in character string operations.
In the above example, the decimal fields are shown with signs and decimal points for
clarity. Decimal points are actually implied and the code for a plus or minus number
occupies half of the low-order byte.
8-37
Student Notebook
Concatenation
IBM i
&LAST
*CAT
DAVIS
&NAME
MARY
DAVIS
*TCAT
DAVIS
MARYDAVIS
*BCAT
DAVIS
MARY DAVIS
VAR(&NAME) VALUE(&FIRST
|>
&LAST)
OL4912.1
Notes:
The operands in a character string expression must be quoted or unquoted character
strings, variables, or the substring (%SUBSTRING or %SST) built-in function.
*CAT - Concatenate without editing.
*TCAT - All trailing blanks in the first character string are truncated, then the two
character strings are concatenated. Any leading blanks of the second operand are not
truncated.
*BCAT - Trailing blanks in the first character string are truncated, one blank is inserted,
then the two character strings are concatenated. Any leading blanks of the second
operand are not truncated.
V7.0
Student Notebook
Uempty
&NAME
&CUSNUMA
Resulting message:
Customer XYZ CORPORATION, account number 54321,
is overdue by 030 days.
&DAYSA
CHGVAR
CHGVAR
SNDMSG
VAR(&DAYSA)
VALUE(&DAYS)
VAR(&CUSNUMA) VALUE(&CUSNUM)
MSG('Customer' *BCAT &NAME *TCAT ', account +
number' *BCAT &CUSNUMA *CAT ', is overdue +
by' *BCAT &DAYSA *BCAT 'days.') TOMSGQ(ARDEPT)
TYPE
*CHAR
*DEC
*CHAR
*DEC
*CHAR
LENGTH
25
(5 0)
5
(3 0)
3
VALUE
XYZ CORPORATION
54321
30
Copyright IBM Corporation 2012
OL4912.1
Notes:
Decimal variables must be converted to character variables before they can be used in
message text.
8-39
Student Notebook
2
Code
CL
source
QCLSRC
Enter
CL
source
Source file
Syntax
checking
3
Compile
listing and
errors
Member X
Member Y
Create CL
program
(compile
CLP
source)
Member Z
4
Call
CL
program
CL
program
object
OL4912.1
Notes:
This visual represents the steps that you follow when you use PDM to create a CL program
source member that will be compiled into a program. The steps are the same process that
you would follow using the LPEX tool as well:
1. Write or make notes on the CL program you intend to write.
2. Use the SEU editor to enter your code into a source member of type CLP. Many
developers perform steps 1 and 2 in a single step. The LPEX editor is also an option
that could be used.
3. Once the source has been entered, exit SEU, save the member, and then compile it
using PDM option 14.
4. The new program object that you have created (if all goes well) can be executed by
using the CALL command with the name of your program.
V7.0
Student Notebook
Uempty
Machine exercise
IBM i
OL4912.1
Notes:
8-41
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
ILE
OPM
Single
language
focus
Mixed
language
focus
Common error
handling
+
Language-specific
error handling
Languagespecific
error handling
Compilation
results
in a running
program
Compilation
results
*MODULE or
*PGM
Compile,
run
Compile, bind,
run
Copyright IBM Corporation 2012
OL4912.1
Notes:
When programming on the IBM i, you will hear the terms OPM and ILE. The programming
concepts and compilation commands that have been covered are considered part of the
Original Programming Model (OPM). The IBM i now also supports a newer model called
Integrated Language Environment (ILE).
The OPM model focuses on a single programmable language and offers error handling
specific to that language. For example, interactions between RPG and COBOL programs
are difficult to predict.
The ILE model allows for programs written in different languages to run as a single unit.
The output of an ILE compiler is a non-executable module. One or more modules are then
bound together to form an executable program.
ILE also allows for:
Modularity
Better code optimization
More extensive control over resources
Copyright IBM Corp. 1997, 2012
8-43
Student Notebook
Different commands and compilers are used for ILE programming. When programming in
ILE CL, the source member type is CLLE, and the compile command is CRTBNDCL.
The main advantages of ILE come into play when you write programs in high-level
languages, or your programs are complicated (for example, involving multiple calls to other
programs). For the simple CL programs that we have discussed, the OPM model can
continue to be used.
A *MODULE is not executable unless it becomes a part of a program (*PGM). A program
may consist of one or more *MODULEs.
V7.0
Student Notebook
Uempty
*PGM MAIN
*PGM B1
START
CALL B1
CALL B2
CALL B2A
END
START
CALL DATE
END
*PGM B2
*PGM DATE
START
...
CALL DATE
...
END
START
STANDARD
DATE
PROCESSING
END
*PGM B2A
START
CALL DATE
...
IF TOTAL >7
CALL UPDTOT
END
OL4912.1
Notes:
Each *PGM object has been compiled from source member. The CALL operation code
used to call another program is resolved at execution time.
We know how to compile a single executable program object from a source member. A
dynamic program call from program MAIN to either B1, B2, or B2A, is resolved at the time
we actually run the programs. That is, program objects B1, B2, and B2A need not exist at
the time that program MAIN is compiled. Indeed, program UPDTOT, called from B2A does
not exist, and any dynamic program call to a missing program object will not fail until the
program is executed. Not until each program is actually called during execution of program
MAIN, will the individual user's authority, and the program object's virtual address be
resolved. This address resolution might only be performed on the first call to each of the
programs B1, B2, and B2A from within MAIN, or, depending on HLL and the specific coding
technique used, might be performed on each call.
We are encouraged to write small, modular routines, that can be easily reused, or called
from other programs, but the dynamic program call can have significant impact on system
performance.
Copyright IBM Corp. 1997, 2012
8-45
Student Notebook
QCLSRC MAIN
*MODULE MAIN
QCBLLESRC B1
*MODULE B1
QRPGLESRC B2
CRTxxxMOD
*MODULE B2
QCLSRC B2A
*MODULE B2A
QCSRC DATE
*MODULE DATE
CRTPGM PGM(MAIN)
MODULE(MAIN B1 B2 B2A DATE)
ENTMOD(MAIN)
*PGM MAIN
===>
MAIN
B1
B2
CALL MAIN
B2A
DATE
Copyright IBM Corporation 2012
OL4912.1
Notes:
Each module (*MODULE object) created from a source member.
Each program created by binding one or more modules into a *PGM object and
specifying the name of the *MODULE to initially receive control (called the Program
Entry Procedure (PEP)).
Each module can be written in any ILE language.
Static Program Call (CALLB) has less overhead than a dynamic call (CALL).
Each *MODULE within each *PGM has a unique virtual address.
Dynamic Program Call remains supported
The ILE Static Call (known as a bound call - CALLB) gives you a better way to call and
execute other programs. Instead of calling independent, separately compiled program
V7.0
Student Notebook
Uempty
8-47
Student Notebook
QCLSRC MAIN
QCBLLESRC B1
*MODULE MAIN
QRPGLESRC B2
*MODULE B1
CRTxxxMOD
QCLSRC B2A
*MODULE B2
QCSRC DATE
*MODULE B2A
QCSRC TAX
*MODULE DATE
2
*MODULE TAX
CRTSRVPGM SRVPGM(MYUTIL)
MODULE(DATE TAX)
*SRVPGM MYUTIL
*PGM MAIN
CRTPGM PGM(MAIN)
MODULE(MAIN B1 B2 B2A)
BNDSRVPGM(MYUTIL)
ENTMOD(MAIN)
CALL MAIN
===>
DATE
TAX
MAIN
B1
B2
B2A
DATE
OL4912.1
Notes:
As mentioned in the previous visual, modules called by many programs might severely
impact memory requirements, because each copy of the module has a unique virtual
address since it is bound by copy into individual program objects.
Suppose that after you have created each module, you package groups of modules into
non-executable objects (or containers) called service programs. Next, executable program
objects, which contain copies of modules, can be created. These program objects can also
reference modules in a service program. Doing this enables you to achieve the best
compromise of usability and call performance.
Many IBM i software vendors package libraries of procedures/subroutines as modules in
service programs.
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
OL4912.1
Notes:
8-49
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
9-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
9-2
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
9-3
Student Notebook
CRTDEVDSP
CRTUSRPRF
DSP01
*DEVD
DAVIS
*USRPRF
DSP01
*MSGQ
DAVIS
*MSGQ
User
message
queue
Workstation
message
queue
JOB
ARDEPT
*MSGQ
User
message
queue
QSYSOPR
*MSGQ
System operator
message
queue
CRTMSGQ
System supplied
OL4912.1
Notes:
Messages are communications that are sent from a person, program, or the IBM i server to
a message queue. Each user profile and workstation has a message queue associated
with it. All message queues are named based upon the user profile or workstation they are
associated with, and get created automatically when the user signs onto the system for the
first time, or when the workstation is first defined. The message queue for the QSYSOPR
profile is particularly important, because the IBM i server sends many messages about job
completion and system status there.
Messages are sent to a specific message queue. A message queue is like a mail box for
messages. Your IBM i server has several message queues that hold messages that
provide helpful information when finding and reporting problems. Understanding the
location of history files, error messages, and system messages can help you solve
problems by holding important system information.
There are several types of message queues.
9-4
V7.0
Student Notebook
Uempty
NOTIFY
QU
EU
E
QU
EU
E
User
Workstation
At Sign on
At Sign off
Deallocated
Attention light on
Audible alarm sound
OL4912.1
Notes:
The user message queue associated with a user is usually named the same as the user
profile.
9-5
Student Notebook
SNDMSG
TOUSR(DAVIS)
OR
TOMSGQ(DSP01)
DAVIS
DSP01
Qu
eu
e
Qu
e ue
DSPMSG
MSGQ(*WRKUSR)
OR
MSGQ(*WRKSTN)
OL4912.1
Notes:
Messages can be sent to the user message queue or to the display station message
queue.
9-6
V7.0
Student Notebook
Uempty
SNDMSG
MSGTYPE(*INQ)
TOMSGQ(QSYSOPR)
RPYMSGQ(*WRKSTN)
What is the
volume ID for
the payroll
backup
tape?
________
The
volume
ID is
PAYBKP
Qu
eu
e
Qu
eu
e
Copyright IBM Corporation 2012
OL4912.1
Notes:
An inquiry message expects a reply. It has a MSGTYPE(*INQ). They are sent with a ? and
an input capable field for the reply. The value in the RPYMSGQ parameter determines
which message queue will get the response message. The value *WRKSTN is the default
for the RPYMSGQ parameter. *WRKSTN means that the workstation that sent the inquiry
message is prompted for the reply.
9-7
Student Notebook
Displaying messages
IBM i
DSPMSG
MSGQ(*WRKUSR)
Work with Messages
System:
Message for:
DSP07
Qu
eue
__
FAC01
__
__
Qu
eue
ATLANTA
FAC01
Message
Messages needing a reply
What is the volume ID for the payroll backup tape?
FROM:
BERT
02/27/98 10:08:15
Messages not needing a reply
I have created a new profile for Fred.
FROM:
QSECOFR
02/27/98 11:21:19
Accounts receivable totals balance to the control sheet
FROM:
MARY
02/27/98 10:45:52
Employees updates are finished.
FROM:
BERT
02/27/98 10:03:49
Bottom
F1=Help F3=Exit F5=Refresh
F6=Display system operator messages
F16=Remove messages not needing a reply
F17=Top F24=More keys
OL4912.1
Notes:
For MSGQ(*), which has a default of workstation, messages are displayed using the
workstation message queue only if it contains messages. The user profile message queue,
MSGQ(*USRPRF) is always displayed, whether there are messages or not.
The display shown above represents the format for Basic Assistance Level. There are
three levels of assistance:
1. Basic
2. Intermediate
3. Advanced
Your assistance level is determined by the system value, QASTLVL, and can be overridden
by a parameter in your user profile.
If you press F21 on this display you will toggle between Basic and Intermediate Assistance
Level. The Assistance Level format last selected is retained for each individual user ID.
9-8
V7.0
Student Notebook
Uempty
The Assistance Level specified here, for displaying messages, is independent of the
Assistance Level you may choose on the Work with All Spooled Files (WRKSPLF) display.
9-9
Student Notebook
SNDBRKMSG
TOMSGQ(DSP07)
Display Messages
System:
Queue . . .:
Library . :
Severity . :
DSP07
DSP07
QSYS
00
Program . . :
Library. . :
Delivery. . :
ATLANTA
*DSPMSG
*NOTIFY
Qu
eue
FROM . . :
QSECOFR
Power down in 5 minutes
02/26/98 10:09:48
FAC01
Bottom
Que
ue
F3=Exit
F13=Remove all
F11=Remove a message
F16=Remove all except unanswered
F12=Cancel
F24=More keys
OL4912.1
Notes:
Sometimes you may want to interrupt the user with an important message that requires
user action. Perhaps a user has a job that is in a loop and the operator wants to end it.
You can also send a message to all users by specifying TOMSGQ(*ALLWS) which sends
your break message to all workstation message queues, even if no user is signed on.
As we mentioned, the default mode for receiving messages can also be set in the user
profile.
Break messages can be sent to workstation queues only.
V7.0
Student Notebook
Uempty
Selection or command
===> SDPMSG_________________________
___Command SDPMSG, in library *LIBL not found.
HELP
Message ID . . :
Message type . :
Date sent . . .:
CPD0030
Severity . . . : 30
Diagnostic
09/07/98 Time Sent . . .: 19:32:33
OL4912.1
Notes:
Additional explanation or information about a message can be displayed by positioning the
cursor on the message text and pressing the Help key.
Pressing F10 will take you to the job log. As developers, you will find that the job log is very
useful when debugging a failed job.
9-11
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Sending messages
IBM i
OL4912.1
Notes:
Using IBM i Navigator, you can send as well as view messages. In order to send a
message, right-click Messages, and click Send Message. You will see a new window in
which you can specify the message and its parameters. Notice that you can send a
message to a specific user or workstation as well as all users, all signed on users, the
system operator, or all workstations.
9-13
Student Notebook
OL4912.1
Notes:
The Messages function allows the user to display, reply to, delete, and send messages.
This function is similar to the Display Messages (DSPMSG), Send Message (SNDMSG),
and Send Break Message (SNDBRKMSG) commands.
Depending on the user's access rights, the user is able to display his or her own messages,
other users messages, or System operator messages by setting user preferences in the
Include dialog of the View menu.
In addition, the context menu allows users to display message details, and to delete
messages from a message queue if they have the proper access rights.
The properties of messages provide information such as the User, the Message ID and a
short Message text, Date and Time sent, Severity, Message type, Message queue, From
job, and From program.
V7.0
Student Notebook
Uempty
View messages
IBM i
OL4912.1
Notes:
Depending on a user's rights, the user can filter the display of messages. This is done by
selecting Include from the View menu bar (or right-click Messages). The user can subset
the list of messages shown in the right pane based on the User or the Message Severity.
This is especially useful if you want to monitor all of the system operator messages.
9-15
Student Notebook
Machine exercise
IBM i
Using Messages
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
OL4912.1
Notes:
9-17
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
10-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Introduction to data
description specifications
Copyright IBM Corporation 2012
OL4912.1
Notes:
10-3
Student Notebook
What is DDS?
IBM i
OL4912.1
Notes:
DDS is the native IBM i language that defines data in database physical and logical files
(PF and LF), report definitions (PRTF), and display screens (DSPF).
A traditional means of describing data attributes (such as the names and lengths of records
and fields) is to specify the data attributes in the application programs themselves.
However, a convenient and powerful alternative is available on the IBM i server. DDS
describe data attributes in file descriptions external to the application program that
processes the data.
You will be exposed to DDS in this unit when you use the Screen Designer and Report
Designer tools to create displays and reports. Before we discuss DDS in further detail in
the unit that describes the IBM i database, you should become acquainted with DDS and
what it looks like.
The Screen Designer and Report Designer tools will generate the DDS for you. We are not
going to be concerned with the details of DDS at this point, but you should be able to
recognize it when you see it. Also, you should be able to identify a line of DDS code in a
source member and describe what it is doing.
10-4 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
FORMAT
FIELD .................. Field-level keywords
- constant (for example, Headings)
FIELD - variable (from program for example, CustNo)
- system (for example, System date)
FORMAT
OL4912.1
Notes:
DDS is coded at three levels when it is defining any file, whether it be a data file, a report,
or a display:
1. File level - keywords are enabled and apply to the complete file (for example, function
keys).
2. Record Format level - keywords are enabled for a specific record format only (for
example, spacing or skipping in a report format).
3. Field level - keywords are enabled and apply to a specific field (for example, editing).
10-5
Student Notebook
OL4912.1
Notes:
Notice the three levels of definition, File, Record and Field, that are illustrated in this visual.
File level keywords are entered before the first record format name. The file level is
terminated when the first record format name is processed.
Record level keywords start on the same line as the record format name. The record level
is terminated by the first field or constant is named. Notice the R to the left of the record
format name, VNDADD_FMT.
Field level keywords start on the same line as the field with which they are associated and
are terminated when the next field or constant is specified.
Additional Notes
Keywords and Parameter Values:
Code all DDS entries in uppercase except character literals enclosed in apostrophes.
The LPEX Editor and Screen Designer will assist you to comply with this requirement
(as you will learn in the exercises).
V7.0
Student Notebook
Uempty
Code keywords on the same (or subsequent) line as the entry with which they are
associated.
Separate multiple keywords with at least one blank. Parameter values for keywords
must be enclosed in parentheses following the keyword.
Use apostrophes to enclose character values. Numeric values appear without
apostrophes.
Use a minus (-) sign or a plus (+) sign as a continuation character when a keyword and
its value does not fit on a single line. The sign must be the last non-blank character in
the functions field.
10-7
Student Notebook
Reference
Field name
Literal
Space after
OL4912.1
Notes:
This visual illustrates a few of the common coding techniques used within a printer file.
Data fields that are to appear in the report are named and referenced with database fields
for their attributes. Literal text, database fields and line spacing are all specified within a
named record format.
V7.0
Student Notebook
Uempty
3
Copyright IBM Corporation 2012
OL4912.1
Notes:
This DSPF illustrates the following elements:
1. F-keys at file/format level
2. Field-level keywords (EDTCDE)
3. DSPATR and COLOR keywords at field level
4. Elementary error message handling (ERRMSG)
5. Conditioning Indicator for field existence and presentation on the display
10-9
Student Notebook
OL4912.1
Notes:
One of the responsibilities that you will have as developers is to design and create reports
and displays. The design process is usually performed before you write a single line of
application logic to produce your designed output.
While you may never have the responsibility of database design, you will need to
understand that on the IBM i system, everything is based on the database.
Before we discuss the IBM DB2 for i database, we will discuss report and screen design
and creation using the Screen and Report Designer tools.
V7.0
Student Notebook
Uempty
Screen/Report Designer
IBM i
OL4912.1
Notes:
Screen and Report Designer are editors like SDA and RLU, for WYSIWYG development of
display files and printer files. They also supports physical files.
To make access to this tool easy, there is a right-click action to launch it from a selected
member.
10-11
Student Notebook
OL4912.1
Notes:
This is the Screen Designer. As you can see, it launches in its own main window.
Screen Designer is the replacement for Screen Design Aid (SDA). The graphical
capabilities of Screen Designer, along with the power of the PC and a mouse, make Screen
Designer much more powerful than host tools.
Screen Designer provides a consistent interface for display files, thus reducing the learning
curve.
V7.0
Student Notebook
Uempty
Enables novice user to design screens and reports quickly and easily
WYSIWYG graphical design
Drag/drop environment
Integrated verifier
Correct errors on PC before compile on IBM i
OL4912.1
Notes:
The Screen Designer and Report Designer provide an environment in which you visually
create and edit display and printer files.
With the Screen Designer or Report Designer, you can navigate through groups, records,
fields, subfiles and files, record and field keywords.
You can use its built-in verifier to ensure that the generated screen and report definitions
will compile successfully on the IBM i.
Screens and reports are defined in DDS.
10-13
Student Notebook
OL4912.1
Notes:
This is the menu that you used in the CLP exercise.
Notice that in the center of the window is an image of what the display will look like.
On the left, notice the explorer-like view of the various components of the display definition.
On the near-right side is a palette of objects that can go into the window design.
On the bottom-left of the window is a display of the properties for the particular field that
has been selected in the design window.
V7.0
Student Notebook
Uempty
Heading
Prompt (record key)
Results (output of record chain/select)
Format keys
OL4912.1
Notes:
The Screen Designer enhances the process of screen and report design by providing a
grouping of records into a Screen.
This is used in the Screen Designer Preview mode to know which records to display in its
design pages. We will show you a design page shortly.
10-15
Student Notebook
Toolbar
Palette
DDS tree
Design page
Utility
notebook
Copyright IBM Corporation 2012
OL4912.1
Notes:
All screen and report definitions are described using DDS.
The DDS Tree is an Explorer-like navigational view of the DDS source.
The Utility Notebook is used to view the DDS that will be generated, field Properties,
comments for selected DDS, and the Error List as well as other possible views.
The Design Page is where you will perform most of your work. It contains the Details view
of the selected item in the DDS Tree. There will be one design page for each screen. The
design page is used to graphically design the DDS. There is also a Source tab which
shows the complete generated source and allows you to toggle edit mode on and off on the
source. In addition, a Preview tab allows you to view the whole screen design which may
consist of multiple records in a certain order.
The Palette shows a list of items that may be placed on the design page. This is done by
dragging and dropping items using the mouse.
V7.0
Student Notebook
Uempty
Note: This is the default setup for the DDS Design Perspective. It is very flexible and tabs
can be moved from one window to another, the order of the tabs can be changed, and tabs
can be closed or new tabs can be selected to be added to the display window.
10-17
Student Notebook
Ruler
Design page
Palette use
mouse to drag
and drop.
OL4912.1
Notes:
Let us focus on the Design Page and Palette of the Designer window. The main
components of the Design Page are the following:
Ruler - Assists you in positioning fields on the Design Page.
Design Page The current design as it would appear on a 5250 screen.
Design Page screen controls Select which record to edit, create screens, select
which records are part of a screen.
Palette - Contains many drag and drop objects to assist you in creating the most
commonly used objects in screen design such as a text constant, date field, or a
reference to a IBM i database field.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This visual shows the different palette items which can be used to design records and fields
in a display file.
10-19
Student Notebook
OL4912.1
Notes:
The Properties view is available for fields and records and provides an intuitive means of
modifying DDS constructs. When selecting items, appropriate keywords are added when
the Screen Designer generates DDS source for you.
V7.0
Student Notebook
Uempty
Designing a report
IBM i
OL4912.1
Notes:
The design page for a printer file is very similar to that of a screen.
10-21
Student Notebook
OL4912.1
Notes:
The printer file palette, while similar to that of a display file, has some noticeable
differences.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
These are some fundamental techniques to employ when designing displays and reports.
You will be able to practice using them during the machine exercises.
10-23
Student Notebook
Error messages
Copyright IBM Corporation 2012
OL4912.1
Notes:
Once you are satisfied with your design, you can check (verify) it on your PC prior to
compilation on the IBM i server.
Following a verify, errors are displayed in the following ways:
In the Error list tab, you see the errors in the same way that you would if you verified
the source in LPEX Editor.
The errors will be inserted in the Source view listing if you double click on one of the
errors in the Error List tab.
To correct your errors you have the following choices (you may need to use a combination
of these options):
Fix the errors in the design page
Fix the errors in the DDS Tree or Details view, using pop-up menus
Fix the errors using Properties notebooks
Fix the errors in the Source view page when in Edit mode
10-24 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
2
Design
Display
or Printer
File
QDDSSRC
Screen
Designer
produces
DDS
Screen
Designer
compiles
DDS
Source
Source file
Optional
DDS edit and
validity
checks
Member X
Member Y
Member Z
4
Write a
PGM using
Display or
Printer File
Display
or Printer
File
OL4912.1
Notes:
This visual represents the steps that you follow when you use Screen Designer or Report
Designer to create a display file or printer file that is compiled and used in a program. The
steps are the same process that you would follow regardless as to whether you are coding
a display or printer file:
1. Use Screen Designer or Report Designer to lay out your display or printer file.
2. Screen Designer or Report Designer takes your input and places the DDS equivalent
into a source member of a source file. You may edit and syntax this DDS if you like.
3. Screen Designer or Report Designer then creates the display file or printer file object.
4. Now you can use your display file or printer file object in your programs of choice.
10-25
Student Notebook
Machine exercises
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
10-27
Student Notebook
Checkpoint
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Unit summary
IBM i
OL4912.1
Notes:
10-29
Student Notebook
V7.0
Student Notebook
Uempty
11-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
11-3
Student Notebook
Optimizer
Lock manager
11 12 1
10
2
3
9
4
8
7 6 5
Security
Logging
Continuous operation
OL4912.1
Notes:
A database management system provides a set of integrated data management services.
These services may include, but are not limited to the following:
Concurrency
Integrity
Security
Tracing
Recovery
Optimization
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
In the visual, the term RELATIONAL means TABULAR. Or, put another way, a database
TABLE represents RELATIONS.
A relational database management system is a table-oriented database management
system. The DBMS manages data that we think of as being stored in a table format
(columns and rows).
Since we work with tables every day, thinking about data stored in them is second nature.
11-5
Student Notebook
OL4912.1
Notes:
AS/400 (original name for IBM i) did relational database before SQL was widely-adopted,
so it includes proprietary, native interfaces for database definition and access.
Other IBM i components also use IBM DB2 for i to accomplish their needed tasks. For
example, the spool component uses database files to create a printed spool file.
IBM i provides a transaction manager (system support for commitment control and
journaling) for DB2 to use. You do not need to install a separate Transaction Manager
component.
IBM DB2 for i. Version 5 Release 4 complies with the following IBM and Industry SQL
Standards:
ISO (International Standards Organization) 9075: 1992, Database Language SQL Entry Level
ISO (International Standards Organization) 9075-4: 1996, Database Language SQL Part 4: Persistent Stored Modules (SQL/PSM)
V7.0
Student Notebook
Uempty
ISO (International Standards Organization) 9075: 1999, Database Language SQL Core
ANSI (American National Standards Institute) X3.135-1992, Database Language SQL Entry Level
ANSI (American National Standards Institute) X3.1354: 1996, Database Language
SQL - Part 4: Persistent Stored Modules (SQL/PSM)
ANSI (American National Standards Institute) X3.135-1999, Database Language SQL Core
11-7
Student Notebook
IBM i
DB2
Interactive
Multimedia
Systems Management
TIMI
Licensed Internal Code
IBM DB2 for i
Security
Communications
Transaction Management
IBM i Hardware
OL4912.1
Notes:
This visual shows how the database is an integral part of the system.
V7.0
Student Notebook
Uempty
Class File
Program 4
Program 3
Program 2
L001
L103
L211
L214
L303
Program 1
COBOL
DATA (DEFINITION)
DIVISION
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
001
002
003
004
005
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
RPG
INPUT SPECIFICATIONS
OL4912.1
Notes:
Many of you may have seen programs that define data in each and every program. The
same file may be defined over and over in different programs.
The problem is that it is all too easy for a program to be written incorrectly and have
definitions coded that do not match the data in the file. This is a classic problem with which
many can identify.
11-9
Student Notebook
Program 1
CRTxxxPGM
Data Definition
Data
Definition
Data
Records
Program 2
Data Definition
Database File
CLASSPF
Program 3
Data Definition
OL4912.1
Notes:
When a file is externally-described and the program is coded to refer to the external
description, the file's external description is copied and becomes part of the program object
when the program is created (compiled).
IBM i data files contain a record format at the front end of each file.
Programmers do not write definitions in their programs; they simply define the file as
externally-described. This causes the compiler to extract and copy the record definitions in
from the file.
V7.0
Student Notebook
Uempty
CLASSPF
Field
Data
Type
Field
Length
Column
Heading
CRSCODE
CHAR
Crs
Code
CRSTITLE
CHAR
Course
Title
INSTNO
CHAR
Ins
No
INSTLNAME
CHAR
Instr
Name
L001
L103
L211
L214
L303
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
001
002
003
004
005
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
Data
Definition
Data
OL4912.1
Notes:
At program creation (compilation) time, the data definition is copied into the program
object, that is, the executable program.
11-11
Student Notebook
L001
L103
L211
L214
L303
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
001
002
003
004
005
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
Data
Member CLASSPF
File Description
OL4912.1
Notes:
In a relational database, an externally-described file must have only one record format.
Also, a file or table has only one member.
In the example, you see the note about no access path (index) to an externally-described
file. This is a rule of SQL. SQL creates tables in arrival sequence only. An index over the
table must be created in order to access the data in a different sequence.
In native IBM i support, an access path can be included with a physical file. This is different
than the SQL implementation using the CREATE TABLE statement.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
In traditional terms:
Row = Record
Table = File
Column = Field
When you perform a projection, conceptually the resulting table is the same width, but has
more rows.
When you perform a join, conceptually (in the simplest case), the resulting table has the
same number of rows, but is wider.
11-13
Student Notebook
Physical file
Logical file
Description
Description
Access path
Access path
Data
OL4912.1
Notes:
IBM i logical files come in three variations:
1. DDS defined and created using CRTLF - you can perform all of the relational operations
(selection, projection, sequence, union, and join) individually or in almost any
combination.
2. SQL created as a view - contains all or a subset of a tables columns and/or rows.
3. SQL created as an index - keyed access to all the rows and columns of a table.
All three variations contain a file description but no data.
An SQL view contains an access path in arrival sequence for the table(s) it references.
An SQL index contains a keyed access path.
When you define a logical file to an HLL program, it looks like a regular physical file or a
table.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Now that you have seen DDS in your display and report exercises, you should be able to
recognize this type of coding.
DDS is often used to define IBM i database objects and exists because SQL was not being
widely used during the creation of the initial database architecture.
11-15
Student Notebook
Physical file
SQL: Table
L001
L103
L211
L214
L303
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
001
002
003
004
005
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
Native: Records
SQL: Rows
Native: Fields
SQL: Columns
OL4912.1
Notes:
Table - A table is a two-dimensional object consisting of rows and columns. It is used to
store user data. Tables are physical files that are maintained by the database manager.
Rows and Columns - Tables are made up of columns and rows. There is no inherent order
of the rows within a table. At the intersection of every column and row is a specific data
item called a value. A column is a set of the same type. A row is a sequence of values of
the same type. A row is a sequence of values such as that the nth value is a value of the
nth column of the table.
In a pure SQL environment, SQL tables are contained in a schema.
A schema has a journal, a journal receiver and a catalog. They are not shown in this figure.
Schema - The objects in a relational database are organized into sets called schema. A
schema provides a logical classification of objects in the database. A schema is sometimes
called a collection on the IBM i.
Schema (collections) are similar to IBM i libraries.
V7.0
Student Notebook
Uempty
More terminology
IBM i
TABLE
ROW
RECORD
COLUMN
FIELD
VIEW
LOGICAL FILE
INDEX
COLLECTION
LIBRARY
Industry terms
SCHEMA
SCHEMA
LOG
JOURNAL
ISOLATION LEVEL
COMMITMENT CONTROL
LEVEL
SQL term
OL4912.1
Notes:
The terms on the left equate to the terms on the right. Traditional IBM i users are
accustomed to using the terms on the right. While the terms used may be different, the
function provided is the same.
In some interfaces, you may see the term Collection. An SQL Collection is a Schema.
11-17
Student Notebook
OL4912.1
Notes:
This visual shows how embedded SQL can be used in an RPG IV program to access data.
With IBM DB2 for i you have a lot of flexibility:
1. Create data files using the native DDS interface.
a. Can access these files using native toolset (such as QUERY/400) or SQL (using a
SELECT)
b. Can access these files from an HLL program using native I/O (such as a CHAIN in
RPG IV)
2. Create tables using SQL.
a. Can access these files using native toolset (such as QUERY/400) or SQL (using a
SELECT)
b. Can access these files from an HLL program using native I/O (such as a CHAIN in
RPG IV)
V7.0
Student Notebook
Uempty
11-19
Student Notebook
Library
Schema
Native PF
Contains no data and no member
Simplifies process of creating/maintaining files and tables
Standardizes field definition
Use field reference in DDS to create PF and LF
Use IBM i Navigator to select desired fields for SQL table
OL4912.1
Notes:
You will encounter different terms when using native database tools and methods versus
SQL.
A schema could be said to be a superset of a library. When you CRTLIB, all that is created
is the *LIB object.
When you CREATE SCHEMA, in addition to the *LIB object, a journal, journal receiver, and
an SQL Catalog for that schema are created.
While it is true that SQL can create tables based upon an IBM i Field Reference File, there
is no equivalent object defined within the SQL language.
V7.0
Student Notebook
Uempty
SQL catalogs
IBM i
OL4912.1
Notes:
SQL uses catalogs to maintain an inventory of what tables, views, indexes, and other SQL
objects are located in a schema. SQL also maintains a system-wide set of catalogs in
QSYS and QSYS2.
SQL catalogs are *FILE objects and can be queried using SQL or Query/400 or information
can be retrieved about them using the IBM i commands:
DSPFD - Display File Description
DSPFFD - Display File Field Description
DSPDBR - Display Data Base Relations
11-21
Student Notebook
OL4912.1
Notes:
Not only do you have flexibility when accessing SQL and native file objects, you also have
flexibility as stated in the visual on where they exist.
V7.0
Student Notebook
Uempty
Similarities
SQL syntax
Universal functionality
Open, common interfaces (DRDA, JDBC, ODBC, CLI)
Common tools and middleware
DataJoiner, DPropR, DataGuide, Visual Warehouse
Differences
Not the same code base
Some algorithms and technology is ported
Administration and integration
IBM i has single system-wide database instance; no need for multiple
database instances like the other DB2s
Copyright IBM Corporation 2012
OL4912.1
Notes:
The IBM DB2 for i database includes many features in common with the DB2 family. Some
features were available first on the IBM i such as SQL Stored Procedures.
For further information, visit the DB2 family Web site at:
http://www-01.ibm.com/software/data/db2/
11-23
Student Notebook
Checkpoint
IBM i
3. Are files created using DDS and SQL compatible on the IBM
i?
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Unit summary
IBM i
OL4912.1
Notes:
11-25
Student Notebook
V7.0
Student Notebook
Uempty
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
An introduction to SQL
IBM i
An introduction to SQL
OL4912.1
Notes:
While this class is not meant to teach you the SQL language, it provides you with an
understanding of some of the features that are available in the language and how they
might be used.
There are other courses that teach SQL:
OL370/OL37 - Accessing the IBM i Database Using SQL (Accessing the IBM i
Database Using SQL)
OL380/OL38 - Developing IBM i Applications Using SQL (Developing IBM i Applications
Using SQL)
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-3
Student Notebook
Introducing SQL
IBM i
Introducing SQL,
Structured Query Language
Copyright IBM Corporation 2012
OL4912.1
Notes:
Structured Query Language (SQL) has been the de facto standard query tool in IT for a
number of years. SQL/400 has been available on the AS/400 and IBM i since 1988.
SQL is a standardized language for defining and manipulating data in a relational
database. In accordance with the relational model of data, the database is perceived as a
set of tables. Relationships are represented by values in tables, and data is retrieved by
specifying a result table that can be derived from one or more base tables.
The ability to create SQL objects is built into IBM DB2 for i, which is part of IBM i. However,
the ability to query these objects requires that DB2 Query Manager and SQL Development
Kit (5770-ST1 for Version 7.1 of IBM i) be installed on your system.
In addition to the SQL Development Kit, or as an alternative, you could use IBM i Navigator
which enables the use of SQL using JDBC to access DB2 objects on the IBM i.
SQL statements are executed by the DB2 database manager. One of the functions of the
database manager is to transform the specification of a result table into a sequence of
V7.0
Student Notebook
Uempty
internal operations that optimize data retrieval. This transformation occurs when the SQL
statement is prepared. This transformation is also known as binding.
All SQL statements must be prepared before they can be executed. The result of
preparation is the executable or operational form of the statement. The method of
preparing a SQL statement and the persistence of its operational form distinguish static
SQL from dynamic SQL.
SQL can be used to create and manage databases and to extract information from and
about databases. SQL can be run either interactively, from within an application program,
or using IBM i Navigator. Queries may also be designed and managed by Query Manager,
which is a component of the DB2 Query Manager and SQL Development Kit.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-5
Student Notebook
Using SQL
IBM i
IBM i Navigator
GUI interface
Run SQL scripts
Copyright IBM Corporation 2012
OL4912.1
Notes:
Many SQL-based applications can be run without any special software. However, to
develop new SQL applications and for end-user support, many companies install both IBM
i Access and the DB2 Query Manager and SQL Development Kit (separate charge
software).
V7.0
Student Notebook
Uempty
Data definition
Security
SQL
CREATE
DROP
ALTER
and so on
GRANT
Structured Query
Language
REVOKE
Data
manipulation
SELECT
INSERT
UPDATE
DELETE
and so on
Dynamic
Miscellaneous
CONNECT
DECLARE
CALL
WHENEVER
DESCRIBE
EXECUTE
PREPARE
OL4912.1
Notes:
Many of you have not seen much of SQL (or maybe not heard much) beyond the basic
SELECT statement which is used to query DB2 tables and views (as well as physical and
logical files).
This visual tells you that SQL is much more than a query language. It includes statements
to manage DB objects and security to DB objects, to enable functional coding in HLL
programs, and other statements.
These are the major components of SQL:
Data Definition Language (DDL) is used to create, drop, and alter SQL objects and their
descriptions and definitions.
For example, you can define a column or field and then add a constraint to restrict the
range of data allowed. The IBM i supports the following DDL statements:
- ALTER TABLE
- COMMENT ON
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-7
Student Notebook
- CREATE SCHEMA
- CREATE INDEX
- CREATE PROCEDURE
- CREATE SCHEMA
- CREATE TABLE
- CREATE VIEW
- DROP SCHEMA
- DROP INDEX
- DROP PACKAGE
- DROP PROCEDURE
- DROP SCHEMA
- DROP TABLE
- DROP VIEW
- LABEL ON
- RENAME
The GRANT and REVOKE statements are also considered DDL statements but are
grouped under the CONTROL category in the visual.
Data Manipulation Language (DML) is used to select and present data, and change the
value of columns or fields.
The IBM i supports the following DML statements:
- CLOSE
- COMMIT
- DECLARE CURSOR
- DELETE
- FETCH
- INSERT
- LOCK TABLE
- OPEN
- ROLLBACK
- SELECT INTO
- UPDATE
CONTROL - these statements are actually DDL statements but are being addressed
separately because they are used to grant or revoke authority to SQL objects.
12-8 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-9
Student Notebook
OL4912.1
Notes:
Interactive SQL is a 5250-based interface. It is used as a prototyping tool when you are
testing SQL statements.
Interactive SQL allows you to run individual SQL statements only. You can use the Run
SQL Scripts feature of IBM i Navigator to run SQL statements from a GUI interface rather
than a 5250 interface.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
To use the native IBM i interactive SQL interface, shown in this visual, you first enter the
STRSQL command. There are a number of parameters that should be checked when you
enter the command. They include such things as the date format and the naming
convention used to reference database files. You can use the normal IBM i library/file
convention or the SQL schema.table convention in queries.
Notice that the sessions history is saved in a fashion similar to that of QCMD. You can
retrieve queries using your cursor and F9. In the history you can see the completion and
error messages as well.
On this display, you enter your SQL statements, one at a time. This is an interactive
environment.
Pressing F4 displays a list of SQL statements, most of which can be prompted as well.
This tool is best suited as a prototyping tool to test individual SQL statements.
One thing that you can do is to save your session data to a source member in a source
physical file. Following some cleanup and editing, you could run a series of SQL
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-11
Student Notebook
statements as a group using the RUNSQLSTM command. Statements are still prepared
one by one sequentially. Any error in a statement causes an error at that point. No syntax
checking is done.
Remember that the primary use of this tool is for prototyping. It is not designed to be an end
user production tool.
Shortly, we will discuss the IBM i Navigator tool, Run SQL Scripts.
V7.0
Student Notebook
Uempty
Result set
OL4912.1
Notes:
This visual shows the result set or result table derived by this query. The rows have not
been ordered in any way (done by using the ORDER BY clause).
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-13
Student Notebook
OL4912.1
Notes:
Pressing F3 from the ENTER SQL STATEMENTS display gets you to this display. By
default, Option 1, Save and exit session, is selected. If you wish, you may save your
complete SQL session, including messages, in a source file.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This visual shows you a source member composed of multiple SQL statements. Five
statements are shown here. In order to delimit each statement, notice that the statements
are terminated by a semicolon.
These statements were tested individually and then the session was saved. When you
save a session, even the messages are saved. Prior to being able to use the source
member, it is necessary to edit the source using LPEX (or the IBM i editor, SEU). You would
delete all the messages, and add the semicolons at a minimum.
Once the statements have been cleaned up and saved, RUNSQLSTM is a command that
runs a set of SQL statements in sequence that have been entered or saved into a source
member.
In the example, this set of statements drops (deletes) a series of tables and then recreates
them using the CREATE TABLE SQL statement and restores data to the tables from
master data using INSERT SQL statements.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-15
Student Notebook
OL4912.1
Notes:
The INSERT statement display lets you insert rows (records) into a table (physical file)
or view (logical file). Inserting a row into a view inserts the row into the table upon which
the view is based. The view cannot be read-only.
The DELETE statement display lets you delete rows (records) from a table (physical
file) or view (logical file). Deleting a row from the view deletes the row from the table that
the view is based on. The view cannot be read-only.
The UPDATE statement display lets you update the values of specified columns (fields)
in rows (records) of a table (physical file) or view (logical file). If a view is specified, it
cannot be a read-only view.
The ALTER TABLE statement display lets you alter a defined table (file) by adding a
constraint, dropping a constraint, adding a column (field), altering a column (field), or
dropping a column (field).
These statements can be prompted as well. IBM i Navigators Run SQL Scripts provides
templates that can be used to build SQL statements.
12-16 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
We now use a case study to show you how to create and manipulate SQL database
objects using basic functions of SQL.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-17
Student Notebook
Data Type
CHAR
CHAR
CHAR
CHAR
Length
4
7
3
7
Description
Course Code
Course Title
Instructor Number
Instructor Last Name
Data Type
CHAR
CHAR
PACKED
CHAR
CHAR
PACKED
Length
4
4
1,0
3
7
3,0
Description
Course Code
Class Year
Class Quarter
Student Number
Student Last Name
Grade
OL4912.1
Notes:
This is a very simple application. There are three tables:
1. CLASSPF contains the records of students enrolled by course.
2. GRADEPF98 contains the records of grades obtained for each course for each student
for one year (1998).
3. GRADEPF99 contains the records of grades obtained for each course for each student
for another year (1999).
Each of these tables needs an index:
1. CLASSPF - index is CRSCODE.
2. GRADEPF98 - index is STUDNO.
3. GRADEPF99 - index is STUDNO.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
In addition to the indexes to be created over the tables in the previous visual, CLASSPFI,
GRADEPF98I, and GRADEPF99I, we require some other objects to be created.
In the visual, notice the other functions that we have to provide in our case study. We use
SQL to produce the results of each requirement. Follow along and you will soon learn more
about the power of SQL as well as the DB2 database.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-19
Student Notebook
Creating a schema
IBM i
OL4912.1
Notes:
We introduced the term schema when we introduced the database and SQL in the previous
unit. The first thing we need to do is create a schema that holds our class database objects.
You recall that a schema contains objects just like a library. However, SQL automatically
creates a catalog as well as a journal and a journal receiver.
When a table, view, or index is created, it is assigned to exactly one schema. That is, when
you create a table, you assign it to a specific schema in the CREATE statement in a
manner similar to the way in which you assign a file to a library.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
1. Open IBM i Navigator.
2. Sign on when prompted.
3. Right-click Schemas.
4. Select New - > Schemas.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-21
Student Notebook
OL4912.1
Notes:
1. Complete the fields in the window.
2. Do not check Create as a standard library.
3. Click OK.
Notice that the option to add the new schema to the list of displayed libraries is checked by
default. Doing this does not modify your library list. A more permanent solution would be to
change your library list in your job description to include the new library (schema).
V7.0
Student Notebook
Uempty
Objects in schema
IBM i
OL4912.1
Notes:
To display the contents of the new schema, click the new schema, and click All objects.
In the right side of the window, you can see that the schema contains a journal, a journal
receiver, and several views that are collectively known as a SQL catalog.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-23
Student Notebook
OL4912.1
Notes:
To create a new table in the FACSLIB2 schema:
1. Right-click FACSLIB2.
2. Click New > Table > Table.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
In this visual, we name the table we want to create and enter a description. Then we click
the Columns tab to define the fields for our table.
Check the Volatile checkbox to indicate that your table's data changes often. When the
optimizer encounters a table defined as volatile, it will be more likely to use an index to
access the table.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-25
Student Notebook
Define columns (1 of 2)
IBM i
OL4912.1
Notes:
This is the window presented to define the columns in a table.
Next, we need to fill in the entries to define each column.
V7.0
Student Notebook
Uempty
Define columns (2 of 2)
IBM i
OL4912.1
Notes:
An SQL table has the following features:
A unique name, such as CLASSPF.
Consists of rows and columns.
All values in one column are the same data type.
0, () (blank), and NULL are different values.
Every column is available in an SQL statement.
Is created as a Physical File:
- Maximum number of columns is 8000.
- Maximum length of a row is 3,758,096,383 bytes.
- Update/Add/Delete capable.
- Size = *NOMAX.
- Contiguous = *NO.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-27
Student Notebook
- Allocate = *NO.
- Table Name length = 128.
This is how the display for defining the columns in a table initially appears.
You could enter SQL statements using Run SQL Scripts. The equivalent SQL statement to
create this table and define the columns is as follows:
CREATE TABLE FACSLIB2/CLASSPF
(CRSCODE CHAR (4 ) NOT NULL WITH DEFAULT,
CRSTITLE CHAR (7 ) NOT NULL WITH DEFAULT,
INSTNO CHAR (3 ) NOT NULL WITH DEFAULT,
INSTLNAME CHAR (7 ) NOT NULL WITH DEFAULT)
NOT NULL WITH DEFAULT means that the field cannot contain nulls and a default value is
used to initialize the field. For example, a character field is set to blanks, a numeric field is
set to zeroes, and so on.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
SQL allows names that are fairly long and that may cause problems in other interfaces that
you might use on the IBM i. You can choose to limit the number of characters in your SQL
names or use SQL statements to rename columns to shorter names using the Short
Column Name box you saw in the previous visual for these other interfaces.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-29
Student Notebook
OL4912.1
Notes:
Let us assume that we did not specify column headings when we created the table but we
have decided to add them now. The easiest way to accomplish this is to use Run SQL
Scripts.
To do this:
1. Right-click the database name (system name in this example).
2. Click Run SQL Scripts.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
A new window appears. By clicking the Edit > Insert from Examples menu item, another
window appears (SQL Statement Examples) from which you can pick a sample SQL
statement and use the Insert button to insert the statement into the Run SQL Statement
window. Notice that help is available. You cannot prompt statements as we are able to do
with the IBM i STRSQL interface, but the help provides you with detailed information on the
constructs of any SQL statement. Using the samples, you should be able to code basic
SQL statements.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-31
Student Notebook
OL4912.1
Notes:
This visual shows you the LABEL ON statement that creates column headings for the
columns.
Column headings are entered as a character string with a length of up to 60 characters. For
each separate line of column heading, enter 20 characters (notice the blanks we entered in
the example above).
The column headings are displayed when you run SQL queries. Since the database is
integrated, the same column headings are used by other IBM i tools such as Query, Query
Manager, and the Screen Designer.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
IBM i Navigator makes creating an index fairly simple. The two graphics above show you
how. The steps are as follows:
1. Right-click the file, in this case CLASSPF, to which you want to add an index
2. Click New > Index.
3. Specify a name for the index, whether the index type is unique or not, and then select
the Key tab in order to select the columns that will be used to construct the index.
4. Set ascending or descending order for each field of your key (index).
Doing this is like running the CREATE INDEX SQL statement. This statement creates an
access path for a table. Indexes are used to enhance performance. Some characteristics of
an index include the following:
They are not part of a table.
They are created as IBM i logical files.
Indexes are created in the table's schema.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-33
Student Notebook
UNIQUE prevents the table from containing two or more rows with the same value of
the index key.
Maximum key length = 2000 bytes.
As discussed before, an index is a keyed logical file that the system uses for faster data
retrieval. A key is one or more columns that are identified as such in the description of an
index. The same column can be part of more than one key. A key composed of more than
one column is called a composite key.
A composite key is an ordered set of columns of the same table. The ordering of the
columns is not constrained by their ordering within the table. The term value, when used
with respect to a composite key, denotes a composite value.
In the example, we are creating an index over the CLASSPF table that will have a single
column as the key.
A system column (field) name and a column (field) name always exist. The system
column (field) name is different from the column (field) name only when the column
(field) name does not follow the IBM i rules for field names.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This is an index that we have already created. Select it from your list of objects. After
right-clicking and clicking Definition, you see the characteristics of the index. It is based on
CRSCODE, is ascending, and is not unique.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-35
Student Notebook
OL4912.1
Notes:
1. From the main IBM i Navigator display, right-click the schema named FACSLIB2.
2. Click New > Table > Table.
3. Specify the name of the new table, a text description, and click the Columns tab.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This visual shows you the completed field definitions for the table.
Caution: Do not click OK until each column is defined. Clicking OK causes the table to be
created. Use the cursor and tab keys to navigate between different column definitions and
fields.
Once the table is created, the column name and type cannot be changed. The table must
be dropped and recreated.
This window is used to define a new table. It provides for the name, data type, length of
each column for a new table, and shows you the information for an existing table. The
description of a column is optional when creating a new table.
There are some further details that we can describe here now that you are seeing this
window for the second time.
There are many data types supported by SQL. You select the data type for each column as
you enter it:
VARGRAPHIC
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-37
Student Notebook
DATE
TIME
TIMESTAMP
DATALINK
CLOB
BLOB
DBLOB
Note: Some data types have a predetermined size; the size is filled in and you cannot
change the value.
New Table-Column
You can define the following additional properties for the currently selected column in
the grid for a new table.
Short column name
Allows you to specify a short IBM i name for the column. If you do specify a name, the
IBM i generates a name for you. If your column name is longer than 10 characters, a
10-character short column name is generated for you using the first five characters of
the column name followed by a five-digit unique number.
Heading
Defines the column heading that is used when displaying or printing query results. You
are limited to 60 characters, 20 per line.
Nullable
Check this to allow the column to contain null values.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Another table can be browsed and pre-existing column definitions can be copied and used
to define a new table.
We know that the column definitions for GRADEPF98 are identical to those of
GRADEPF99. So, lets minimize our work, and reuse definitions that we have already
created.
To do this:
1. Right-click the FACSlib2 schema.
2. Click New > Table > Table.
3. In the new Table columns tab window, click Browse.
4. Click the plus (+) next to FACSLIB2 to expand it.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-39
Student Notebook
OL4912.1
Notes:
1. When FACSLIB2 is expanded, click GRADEPF99.
2. The columns and their attributes appear in the window on the right.
3. Click each of the desired columns and click the Add button. Do this for every column
you would like added to the new file.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
1. The basic column definitions have been copied.
2. If you need to modify the copied columns for this file, click on the column and then click
Definition.
3. Also, you could designate whether or not you wanted null values for each column.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-41
Student Notebook
OL4912.1
Notes:
1. Review the definition of each column for final review.
2. Insure that all columns have been included.
3. Insure the column name, type, length, and column headings are correct.
4. Click OK to create the table.
V7.0
Student Notebook
Uempty
GRADEPF98 in FACSLIB2
IBM i
OL4912.1
Notes:
In the main IBM i Navigator window, click the library name, FACSLIB2, and click All
Objects to see the new table GRADEPF98.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-43
Student Notebook
OL4912.1
Notes:
1. Right-click table name GRADEPF98, and click Definition.
2. Review the information. You can still modify a table by adding columns to it.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
We have built our basic tables.
Once a table has been populated with data it can be displayed by right-clicking the table
name and clicking View Contents.
In this visual, we are checking the values of the columns of the GRADEPF99 table.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-45
Student Notebook
OL4912.1
Notes:
New rows can be inserted by right-clicking the object and clicking Edit Contents. Click the
Rows menu option in order to insert new rows into the table.
Rows can be added to a table at any time. It does not matter whether there is existing data.
Note: This is one tool that you can use to create test data. Once the table has been
created, simply right-click Edit Contents, and click Rows > Insert.
You can also use the SQL INSERT statement to assign values to columns for testing
purposes.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
1. Right-click the file, GRADEPF99.
2. Click New > Index.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-47
Student Notebook
OL4912.1
Notes:
Enter the name of the index, GRADEPF99I, in the index window.
Select and add the columns on which your index is based.
Change the sequence from ascending to descending if desired, or
Click OK to create index GRADEPF99I.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
1. The new index will appear in your schema. Display it by clicking Indexes under the
schema, FACSLIB2.
2. Right-click the index, GRADEPF99I. Click Definition to use the properties.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-49
Student Notebook
OL4912.1
Notes:
As you did in your second lab exercise, you may manage authority for your tables using the
Permissions window:
1. Right-click the name of the object, in this case table GRADEPF99.
2. Click Permissions. The Permissions window opens.
3. Click the desired authorities.
4. Click OK or Apply.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This is a checkpoint of what we have done so far. In the next topic, we manipulate the data
with SQL.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-51
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
SELECT statement
IBM i
SELECT
....
FROM ....
WHERE ....
GROUP BY ....
HAVING ....
ORDER BY ....
Fine
William
Goes
Home
Often
OL4912.1
Notes:
The SELECT statement is the data retrieval statement in SQL. The SELECT statement is
composed of the verb SELECT and a number of clauses known as predicates. These
predicates must be coded in a specific order.
An easy way to remember the order to code the predicates is to remember this sentence,
Fine William Goes Home Often.
A predicate specifies a condition that is true, false, or unknown about a given row or group.
1. FROM
The FROM clause specifies that an intermediate result table is to be produced. If only
one table or view is specified, the intermediate result table is simply that table or view.
2. WHERE
The WHERE clause specifies that an intermediate result table is to be produced. It will
consist of a grouping of those rows of a result set from the SELECT statement for which
the search condition is true.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-53
Student Notebook
3. GROUP BY
The GROUP BY clause specifies that an intermediate result table is to be produced. It
will consist of a grouping of the rows of the result set of the SELECT statement.
4. HAVING
The HAVING clause specifies that an intermediate result table is to be produced. It will
consist of those groups of the result set of the SELECT statement for which the search
condition is true.
5. ORDER BY
The ORDER BY clause specifies an ordering of the rows of the result table. If a single
column is identified, the rows are ordered by the values of that column. If more than one
column is identified, the rows are ordered by the values in the first identified column,
then by the values that the second identified column, and so on. Each specified column
can be listed in either ascending or descending order.
The clauses must be coded in this order. When using interactive SQL, the F4 key will
prompt the correct order. When coding embedded SQL statements in a high-level
language, you need to know the order.
When coding, you should place each keyword of the SELECT statement on a separate line
and indent it as shown in the visual. Your code is more easily debugged and maintained.
SELECT statements can also be nested in what are known as subselects. A subselect,
when used, is a component of the fullselect, the CREATE VIEW statement, and the
INSERT statement. A fullselect specifies a result table is to be generated. The subselect is
also a component of certain predicates, which in turn, are components of a subselect. A
subselect that is a component of a predicate is called a subquery.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-55
Student Notebook
OL4912.1
Notes:
We use the IBM i Navigator Run SQL window. To start:
1. Right-click the database name (system name in this case).
2. Click Run SQL Scripts.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
By clicking the Edit menu item, another window opens (SQL Statement Examples) from
which you can pick a sample SQL statement and use the Insert button to insert the
statement into the Run SQL Statement window. You may enter one or more SQL
statements, separated by semicolons. If you enter only one statement, the use of the
semicolon is optional. However, it is good practice to always enter the semicolon.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-57
Student Notebook
OL4912.1
Notes:
We enter our SQL statement.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
To execute the statement:
1. Select the SQL statement.
2. From the menu, click Run > Selected.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-59
Student Notebook
OL4912.1
Notes:
The result set is presented below.
1. If unsuccessful, the errors will be displayed.
2. If successful, the result set is displayed. Sometimes, the number of rows is too wide or
too numerous to display conveniently. From the Options menu, click Display Results
in a separate Window.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
The UNION SQL operation enables you to consolidate the results from two or more
SELECT statements. In this case, we want to obtain a result set of the grades over two
years and then sort by student number using ORDER BY.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-61
Student Notebook
OL4912.1
Notes:
As before, after we have entered our statement:
1. Select the statement (notice that we added it below the previous select).
2. Click Run > Selected.
Our result set is not displayed. Instead we get an error message.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
In this visual, we corrected the query. Notice that we resized the result set tab pane. You
can see that we have grades for both years ordered by student number.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-63
Student Notebook
Requirement
Result set of course grades for each student ordered by course within
student including columns from CLASSPF and the 1999 GRADE table
Figure 12-55. Case study requirement: Select data from related tables
OL4912.1
Notes:
We researched this requirement and we learned that we need a result set composed of
rows from the CLASSPF table showing student name with the course code and grades for
the year 1999. We need to be able to get values from the GRADEPF99 table based on the
student number.
The columns that we need are:
CRSCODE
CRSTITLE
INSTLNAME
STUDLNAME
GRADE
V7.0
Student Notebook
Uempty
Deptno
A00
B01
C01
D01
D11
D21
E01
E11
E21
A00
A00
A00
B01
C01
C01
C01
D11
D11
D11
D11
D11
DEPARTMENT
Deptname
SPIFFY Computer Service Div.
Planning
Information Center
Development Center
Manufacturing Systems
Administration Systems
Support Services
Operations
Software Support
OL4912.1
Notes:
This is an example we obtained from another department. Personnel has many different
tables of course, but, two main ones are the EMPLOYEE table and the DEPARTMENT
table. Suppose we wanted a result set that contained the employee name, department
number, and department name.
You can see that the columns we want are contained in the two tables. Using the common
column, DEPTNO, we can join the two tables and then extract the columns we want from
either to produce our result set.
This is the most common type of join where the EMPLOYEE table is the primary table. This
type of JOIN is called an INNER JOIN.
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-65
Student Notebook
OL4912.1
Notes:
Remember our original requirement:
Produce a result set of course grades for each student, ordered by grade, and
descending within student including columns from CLASSPF and the 1999 GRADE
tables.
Take a close look at the SQL statement below:
select studlname, grade, a.crscode, crstitle, instlname
from facslib2/classpf a
inner join facslib2/gradepf99 b
on a.crscode = b.crscode
order by studlname, grade desc;
What do you notice about the columns to be displayed? ___________________________
Which columns are extracted from the CLASSPF table? __________________________
_____________________________________________________________________
V7.0
Student Notebook
Uempty
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-67
Student Notebook
OL4912.1
Notes:
In this visual, focus your attention on the result set. Notice the columns where there is a
dash (-). These are known as null values. When there is no row on the joined table that
corresponds with the primary table (also known as the table on the left), all columns in the
secondary table are assigned a null value in the result set.
In this example, neither Sting nor Madonna were enrolled in Italian. Therefore, the values
for GRADE are displayed as null.
V7.0
Student Notebook
Uempty
Machine exercise
IBM i
OL4912.1
Notes:
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-69
Student Notebook
Checkpoint
IBM i
1. List three methods that you could use to run SQL statements
on an IBM i.
2. What are the two main categories of statements for the SQL
language?
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Unit summary
IBM i
OL4912.1
Notes:
Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-71
Student Notebook
V7.0
Student Notebook
Uempty
13-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
In addition to the SQL interface to the IBM i database, the system also offers a
comprehensive native interface.
DDS enables you to define all database objects including some complex joins.
13-3
Student Notebook
Data Type
*********
CHAR
CHAR
CHAR
CHAR
Length
******
4
7
3
7
Description
***********
Course Code
Course Title
Instructor Number
Instructor Last Name
Data Type
*********
CHAR
CHAR
PACKED
CHAR
CHAR
PACKED
Length
******
4
4
1,0
3
7
3,0
Description
***********
Course Code
Class Year
Class Quarter
Student Number
Student Last Name
Grade
Figure 13-3. Physical files used in the school database case study
OL4912.1
Notes:
These are the same files that we defined as tables in the school database case study. The
native interface offers a few features that vary from the SQL tables that we defined:
In DDS, we can define a key (access path) as part of the file itself. This is not permitted
in SQL.
DDS requires a record format name; a physical file can have only one record format.
V7.0
Student Notebook
Uempty
GRADELF99
Logical file based upon GRADEPF99 records
Course L001 only, sequenced by student number
Record format GRADEREC
ROSTERLF
Union of CLASSPF and GRADEPF99 files
Sequenced by student number within course number
Two record formats: CLASSREC and GRADEREC
GRADE9899U
Union and projection of 1998 and 1999 grade files
Sequenced by student number
Record format YRSTUGRD:
CRSCODE
CLSYR
CLSQTR
STUDNO (Key)
GRADE
Copyright IBM Corporation 2012
Figure 13-4. Logical files used in the school database case study (1 of 2)
OL4912.1
Notes:
We use DDS to define these three logical files. We define a union that is slightly different
from the union of grades for both years that we did using SQL. Also, in DDS, you can
define a join and its conditions to create a logical file. As we said earlier, the SELECT
statement that we created in SQL could have been used to create a logical file as well
(SQL View).
A physical file is like an SQL table.
A logical file is like an SQL view.
13-5
Student Notebook
GRADELF99
Inner Join
Joined records from CLASSPF and GRADEPF99
Records matched on course code, sequenced by course code
Record format CLSGRDFMT:
CRSCODE (Key)
CRSTITLE
INSTLNAME
STUDLNAME
GRADE
CLSGRDOJ99
Left Outer Join
Same as CLSGRDIJ99, except:
Default values will be supplied for unmatched GRADEPF99 records.
Copyright IBM Corporation 2012
Figure 13-5. Logical files used in the school database case study (2 of 2)
OL4912.1
Notes:
We create logical files to show you both an inner join and a left outer join. Note the
definitions:
INNER JOIN or JOIN - The result of an INNER JOIN of two files consists of their paired
records. Unpaired records, based on the JOIN condition are not included.
LEFT JOIN or LEFT OUTER JOIN - The result of LEFT OUTER JOIN consists of the
paired records of the two files, and, for each unpaired (unmatched) record of the primary
file, the concatenation of that record with the null row of the secondary file.
Joins can only be defined using logical files. Therefore, the term used is JOIN LOGICAL
file.
V7.0
Student Notebook
Uempty
Physical file
IBM i
CLASSPF
File description
attributes
access path description
member names
record format name
triggers
constraints
DSPFFD
Record format:CLASSREC
Field descriptions
Access path
L001-1 L103-2
L214-4 L303-5
Data records
L001
ITALLIAN
L103
ENGLISH
L211
SPANISH
L214
GREEK
L303
CHINESE
DSPFD
L211-3
001
002
003
004
005
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
Member
CLASSPF
OL4912.1
Notes:
A physical file contains information about itself:
1. File Description information - This information can be obtained using the DSPFD
(Display File Description) command.
2. Record Format information and field information - This information can be obtained
using the DSPFFD (Display File Field Description) command.
3. Member - Contains the actual data records and the access path based on the key
definition for the file.
13-7
Student Notebook
OL4912.1
Notes:
This is the first display of what is displayed using the DSPFD command. We do not cover
all the output; we discuss the more significant ones that are highlighted in the visuals.
The file/library information is obvious.
The file description header tells us what type of file this is and whether or not it may
contain data. Remember, field reference files do not contain data.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Note that the maximum number of members for a physical file is one.
13-9
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Remember that our school database study required that we have a record key. It is noted in
this visual.
13-11
Student Notebook
OL4912.1
Notes:
Note that the member name is the same as the name of the physical file.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
There are five records currently in the file.
13-13
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Journaling is a file integrity feature of the IBM i. Notice that the access path can be shared
by more than one job and that the access path is updated when changes are processed.
13-15
Student Notebook
OL4912.1
Notes:
There are four fields in this file. The total length is 21 bytes.
The format level identifier is also known as the level check value. Level checks are useful
when a file is changed and recompiled. Any programs that reference the changed file
examine the format level identifier and make sure that the program references the current
version of the file.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
13-17
Student Notebook
DSPFFD CLASSPF (1 of 3)
IBM i
OL4912.1
Notes:
Some of the same information provided by DSPFFD is repeated by this command.
V7.0
Student Notebook
Uempty
DSPFFD CLASSPF (2 of 3)
IBM i
OL4912.1
Notes:
Note the field definitions here and continued on next visual.
13-19
Student Notebook
DSPFFD CLASSPF (3 of 3)
IBM i
OL4912.1
Notes:
This visual shows the last of the defined fields.
V7.0
Student Notebook
Uempty
Format
CLASSREC
CRSCODE
CRSTITLE
INSTNO
INSTLNAME
CRSCODE
4
7
3
7
Key is CRSCODE
SCHOOLA
DATA RECORDS
Members
Key is CRSCODE
SCHOOLB
DATA RECORDS
Key is CRSCODE
SCHOOLC
DATA RECORDS
Copyright IBM Corporation 2012
OL4912.1
Notes:
Imagine a situation where we have the same courses offered at different locations. The
format of the data is the same as our CLASSPF file. However, we want to keep the
information for each school separately.
A multiple member physical file is appropriate for sets of data that are formatted the same,
but must be maintained individually.
13-21
Student Notebook
Format
Access path
SRCSEQ
SRCDAT
SRCDTA
6
6
80
2
0
Key is
PROGA
DATA RECORDS
Members
PROGB
DATA RECORDS
Data records
(Source statements)
PROGC
DATA RECORDS
Copyright IBM Corporation 2012
OL4912.1
Notes:
All IBM i source code is stored in members of a source physical file.
A source physical file is created using the CRTSRCPF command. This command creates a
file with a record format with three fields:
seq # - 6 positions
date - 6 positions
data - varies but is usually 80 positions (80 positions for RPG III or 100 positions for
RPG IV).
The source physical file is created with a default of MAXMBRS (*NOMAX). An editor
(CODE or SEU) is used to create and maintain source members that contain the
specifications in source data records.
Source physical files do not have a keyed access path. They use an arrival sequence
access path only.
V7.0
Student Notebook
Uempty
Commands
Database files
Display files
Report (Printer) files
Menus
Programs (COBOL, RPG, C, and so forth)
Source
Physical File
OL4912.1
Notes:
Source is used to create many different types of objects, including programs. There are
other uses for source physical files.
13-23
Student Notebook
COBOL
ILE COBOL
QCLSRC
CONTROL LANGUAGE
QCMDSRC
COMMAND DEFINITION
QDDSSRC
QMNUSRC
MENUS
QRPGLESRC
QRPGSRC
OL4912.1
Notes:
This is a list of some of the types of source that are most commonly used on the IBM i.
Using the recommended file names listed in the visual means that when you create a new
member, the type of that member automatically defaults to the type established for these
standard source file names. QRPGLESRC, for example, defaults to type RPGLE.
Thus, when you are editing, the templates that are needed for that type are made available
to you automatically. Also, the editor (SEU or LPEX) retrieves the correct object type value
in order to support interactive syntax checking during editing.
V7.0
Student Notebook
Uempty
CRTSRCPF FILE(FACxx/QDDSSRC)
RCDLEN(92)
MBR(*NONE)
TEXT('DDS Source File for FACnn')
OL4912.1
Notes:
For the machine exercises that follow, you create some of these source files:
CRTSRCPF QDDSSRC
CRTSRCPF QCBLSRC
CRTSRCPF QRPGSRC
CRTSRCPF QCLSRC
CRTSRCPF QMNUSRC
13-25
Student Notebook
QDDSSRC
2
ENTER DDS
SOURCE
CODE
DDS
SOURCE
SOURCE FILE
SYNTAX
CHECKING
LISTING OF
SOURCE
DESCRIPTION
AND ERRORS
MEMBER X
3
CREATE
DATABASE
FILE
(COMPILE
DDS
SOURCE)
DFU
or
RPG
or
COBOL
FILE
DESCRIPTION
MEMBER
Data Path
User Steps
OL4912.1
Notes:
The flowchart above illustrates the process of creating a database file. The steps are as
follows:
1. Code the DDS.
2. Use an editor to enter the course code into a source member. The editor would be
either LPEX or SEU. Most programmers perform steps 1 and 2 concurrently.
3. Once the source has been entered, you must compile (create) it.
4. When you have successfully created the physical file, you need to enter data. Often the
data is created and maintained by a program (COBOL, RPG, C, and so forth). A utility
such as Data File Utility (DFU) can be used to create data records. Typically a tool such
as DFU is useful for the creation of test data. Test data can also be created using
System i Navigator and SQL INSERT statements as you have seen previously.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Underscores can be used as shown, after the first character of the file name. However, you
may not use a hyphen anywhere in a file name.
13-27
Student Notebook
OL4912.1
Notes:
These are the same fields that we showed you earlier using SQL. You should notice the
following:
TEXT is used for documentation.
COLHDG is used for reports and displays. We suggest that you make the width of the
column headings no wider than the data it describes. It does not make sense in every
case, but keeping this in mind eliminates unnecessary blank space between columns of
data.
The R to the left of the record format name, CLASSREC, indicates that this is a record
format definition.
The K to the left of CRSCODE at the bottom indicates that CRSCODE is the key to the
file.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Again, notice that we have a key defined for the GRADEPF98 (and 99) files. This key is
made up of more than one field. The fields are listed in primary, secondary sequence:
The major key field is CRSCODE.
The minor key field is STUDNO.
Each year this DDS is compiled to create a new GRADEPF file, with the last two digits of
the year appended to the name. At file creation time, the file name, which defaults to the
source member name, can be overridden.
13-29
Student Notebook
CRTSRCPF QDDSSRC
FACOUTQxx
Library
FACxx
FACOUTQx
x
PAYROLxx
FACJOBDxx
ODDSSRC
PAYROLxx
FACJOBDxx
QDDSSRC
SRCSEQ
SRCDAT
SRCDTA
OL4912.1
Notes:
In an earlier exercise, you created a number of objects in your FACnn libraries. Here, we
create a source physical file that contains your DDS for the physical and logical files in the
case study.
Notice the command that is used. We accept the defaults. If you ran this command in your
library, a QDDSSRC PF would be added in addition to the existing objects.
V7.0
Student Notebook
Uempty
PDM / SEU
F6 = CREATE NEW MEMBER (NAMED CLASSPF)
FACOUTQxx
PAYROLxx
Library
FACxx
FACJOBDxx
QDDSSRC
SRCSEQ
SRCDAT
SRCDTA
FACOUTQxx
PAYROLxx
FACJOBDxx
ODDSSRC
CLASSPF
R CLASSREC
CRSCODE 4 ...
CRSTITLE 7 ...
INSTNO
3 ...
INSTLNAME 7 ...
K CRSCODE
OL4912.1
Notes:
Now that we have a QDDSSRC PF, we can add members to this file. When you use the
native editor, SEU, press F6 to open the editor for a new member.
13-31
Student Notebook
FACOUTQxx
PAYROLxx
FACJOBDxx
Library
FACxx
QDDSSRC
FACOUTQxx
PAYROLxx
FACJOBDxx
ODDSSRC
CLASSPF
CLASSPF
R
SRCSEQ
SRCDAT
SRCDTA
CLASSREC
CRSCODE
CRSTITLE
INSTNO
INSTLNAME
CRSCODE
R
Member
CLASSPF
K
CLASSREC
CRSCODE
CRSTITLE
INSTNO
INSTLNAME
CRSCODE
4
7
3
7
...
...
...
...
Access Path
Key is CRSCODE
4
7
3
7
...
...
...
...
Member
CLASSPF
DATA
OL4912.1
Notes:
Once the member has been created and saved, we can compile it. To do this, we use
option 14 of the Program Development Manager (PDM). On the right hand side, you can
see the new PF, CLASSPF. It is type PF (Physical File).
Option 14 of PDM uses the member type of the source member created in order to
determine what to create.
V7.0
Student Notebook
Uempty
FACOUTQxx
PAYROLxx
FACJOBDxx
CLASSPF
Description
Library
FACxx
QDDSSRC
Format
SRCSEQ
SRCDAT
SRCDTA
FACOUTQxx
PAYROLxx
FACJOBDxx
QDDSSRC
CLASSPF
GRADEPF99
Access path
Data records
GRADEPF99
Member CLASSPF
Source DDS
Description
Format
Member GRADEPF
Source DDS
Access path
Data records
OL4912.1
Notes:
After we have created CLASSPF, we enter the DDS for the GRADEPF99 file and create
the *FILE object for it as well.
13-33
Student Notebook
QDDSSRC
2
ENTER DDS
SOURCE
CODE
DDS
SOURCE
SOURCE FILE
SYNTAX
CHECKING
LISTING OF
SOURCE
DESCRIPTION
AND ERRORS
MEMBER X
3
CREATE
DATABASE
FILE
(COMPILE
DDS
SOURCE)
DFU
or
RPG
or
COBOL
FILE
DESCRIPTION
MEMBER
Data path
User steps
OL4912.1
Notes:
The flowchart reviews the process of creating a database file. As a review, the steps are
the following:
1. Code the DDS.
2. Use an editor to enter the course code into a source member. The editor would be
either LPEX or SEU. Most programmers perform steps 1 and 2 concurrently.
3. Once the source has been entered, you must compile (create) it.
4. When you have successfully created the physical file, you need to enter data.
V7.0
Student Notebook
Uempty
Logical files
IBM i
OL4912.1
Notes:
Logical files on the IBM i are used to present the data from one or more physical files in a
different fashion. You might want an employee to be able to change name and address
information, but not be able to change salary information. A logical file would limit
maintenance to the name and address fields. This means that no coding is needed in a
program to handle this constraint. The database handles the constraint.
Logical files are declared exactly like any other file. Once they are declared, you can
access the fields included in the view without having to declare the underlying physical
files.
13-35
Student Notebook
OL4912.1
Notes:
You can perform the relational operations above on logical files.
V7.0
Student Notebook
Uempty
Logical file
requirements:
GRADEPF99
Physical File
R
K
K
GRADEREC
CRSCODE
CLSYR
CLSQTR
STUDNO
STUDLNAME
GRADE
CRSCODE
STUDNO
4
4
1
3
7
3
Same format
Only L001 records
Sequence by
student number
Access Path
Crs
Code
LOO1
L001
L001
L103
L214
L410
L303
L001
L001
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 2
1999 2
Stu
No
102
103
101
101
108
106
107
105
107
Student
Name
LAUPER
TURNER
BOWIE
BOWIE
NELSON
HOLIDAY
STING
MADONNA
STING
Stu
Grd
72
79
93
62
97
75
86
-
Member
GRADEPF99
OL4912.1
Notes:
In the native implementation of the case study, one logical file uses the same record format
as the physical file upon which it is based, GRADEPF99. However, we:
View only course code L001 (projection).
Sequence the records by student number (sequence).
13-37
Student Notebook
1
3
GRADELF99
GRADEPF99
Fmt: GRADEREC
Fmt: GRADEREC
Access path
Based on
101-3
102-1
105-8
107-9
103-2
Member
GRADELF99
Access path
Data
OL4912.1
Notes:
Notice that the logical file is based upon GRADEPF99:
1. Format-name
If the same fields are desired in the logical file as in the physical file, you only need to
specify the same format name as in the physical file, and specify no fields below.
If a subset (fewer records) of the physical files is desired, you would specify a new
format name and specify the desired fields individually below. The PFILE keyword links
the logical file to the physical file.
If two or more physical files are to be merged to form a union of the files, multiple
formats must be specified, unless all of the referenced physical files have the same
record format.
2. Field-name
If a projection of the physical file (subset of the fields) is desired, specify the desired
fields. The logical file format name must be different from the physical file format name.
V7.0
Student Notebook
Uempty
If the physical and logical files are to share the same format, specify no field names at
all and insure that the format name specified for the logical file is the same as the
physical file's format name.
We do not need to specify individual fields as we are interested in all fields.
3. Specify the key fields
Multiple key fields are allowed. You specify keys from major to minor, in a top to bottom
order.
If a subset of the physical file's records is desired, you can specify selection or omission
criteria, based on field values.
In the case shown here, the physical file has only one member. If it had multiple members,
the logical file would have to know over which members of the physical file to build its
access path. This decision is made using the DTAMBRS parameter when the logical file is
created.
Each logical file access path entry contains a logical file key and position of the
corresponding record in the physical file. The logical file appears to contain data, but it
does not.
13-39
Student Notebook
GRADEPF99 records
Crs
Code
L001
L001
L001
L103
L214
L410
L303
L001
L001
101-3
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 2
1999 3
Stu
No
102
103
101
101
108
106
107
105
107
Student
Name
LAUPER
TURNER
BOWIE
BOWIE
NELSON
HOLIDAY
STING
MADONNA
STING
Stu
Grd
72
79
93
62
97
75
86
-
Crs
Code
L001
L001
L001
L001
L001
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 2
1999 3
Stu
No
101
102
103
105
107
Student
Name
BOWIE
LAUPER
TURNER
MADONNA
STING
Stu
Grd
93
72
79
-
OL4912.1
Notes:
GRADELF99 does not contain records. It is only an access path that points to the actual
records in physical file GRADEPF99.
In the visual, notice that all the data is contained in GRADE99PF. GRADE99LF contains
only an access path that points it to the records shown.
V7.0
Student Notebook
Uempty
DSPFD GRADELF99 (1 of 8)
IBM i
OL4912.1
Notes:
Notice that GRADELF99 is a logical file.
13-41
Student Notebook
DSPFD GRADELF99 (2 of 8)
IBM i
OL4912.1
Notes:
Similar to the display of the CLASSPF physical file, the display of the GRADELF99 logical
file shows file attributes that are common to both physical and logical files, such as creation
date, maximum number of data members, and the access path maintenance plan.
V7.0
Student Notebook
Uempty
DSPFD GRADELF99 (3 of 8)
IBM i
OL4912.1
Notes:
This display continues with attributes shared between physical and logical files. However, it
is the select/omit file attribute listed on the last line of this display that indicates that
GRADELF99 is a logical file. Only logical files can use the select/omit record criteria as part
of their definition.
13-43
Student Notebook
DSPFD GRADELF99 (4 of 8)
IBM i
OL4912.1
Notes:
Our logical file is based upon GRADEPF99, using record format GRADEREC. The view is
based upon selection criteria where the CRSCODE = L001 (continued on the next visual).
V7.0
Student Notebook
Uempty
DSPFD GRADELF99 (5 of 8)
IBM i
OL4912.1
Notes:
We are only interested in course code L001.
13-45
Student Notebook
DSPFD GRADELF99 (6 of 8)
IBM i
OL4912.1
Notes:
Notice how the sixth display of the DSPFD command example shows access path statistics
information that is maintained by the IBM i.
V7.0
Student Notebook
Uempty
DSPFD GRADELF99 (7 of 8)
IBM i
OL4912.1
Notes:
Notice the record format list is the same as it was for the physical file, GRADEPF99.
13-47
Student Notebook
DSPFD GRADELF99 (8 of 8)
IBM i
OL4912.1
Notes:
This last display from the DSPFD command example is shown for completeness.
V7.0
Student Notebook
Uempty
DSPFFD GRADELF99 (1 of 3)
IBM i
OL4912.1
Notes:
This visual is the first of three resulting from the DSPFFD command for the GRADELF99
logical file.
13-49
Student Notebook
DSPFFD GRADELF99 (2 of 3)
IBM i
OL4912.1
Notes:
The fields in the DSPFFD for the logical are the same as the physical file.
V7.0
Student Notebook
Uempty
DSPFFD GRADELF99 (3 of 3)
IBM i
OL4912.1
Notes:
This visual shows the last of the fields included in the GRADELF99 logical file.
13-51
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
File by name
Record by name
Fields by name
Access arrival/keyed sequence
CLSYR
4
COLHDG('Cls' 'Yr')
CLSQTR
1 0
TEXT('Class Year')
TEXT('Class Quarter')
SCHOOLREF
CLASSPF
REF(SCHOOLREF)
R CLASSREC
CRSCODE
CRSTITLE
INSTNO
INSTLNAME
L001
L103
L211
L214
L303
R
*FIELDS FOR
R
R
R
R
ITALLIAN
ENGLISH
SPANISH
GREEK
CHINESE
001
002
003
004
005
SCHOOLFMT
CLASSPF
CRSCODE
4
CRSTITLE
INSTNO
INSTLNAME 7
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
TEXT(. .
COLHDG(.
TEXT(. .
COLHDG(.
TEXT(. .
COLHDG(.
TEXT(. .
COLHDG(.
.
.
.
.
.
.
.
.
.
.
.
.
Figure 13-51. Using a field reference file for our case study
OL4912.1
Notes:
Let us suppose that we have defined a Field Reference File (FRF) named SCHOOLREF.
This file defines each and every field used across our application. All fields to be included in
a record format for physical or logical files can be included by referencing the
SCHOOLREF file.
Using an FRF means:
You define each field only once (in an FRF).
To define a field in a physical or logical file, you only need to reference the FRF.
13-53
Student Notebook
Physical file
SCHOOLREF
R SCHOOLFMT
Format
CRSCODE
CRSTITLE
INSTNO
TEXT(. . .
COLHDG(. . .
TEXT(. . .
COLHDG(. . .
TEXT(. . .
COLHDG(. . .
Access path
NO KEY FIELD
Data
NO DATA RECORDS
OL4912.1
Notes:
An FRF contains a complete definition for each field. You reference the FRF for all other
physical and logical files of the application. Of course, you could have a corporate FRF.
An FRF has the following qualities:
No defined keys.
No data records.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
If we moved all the definitions for our physical files into a single FRF, the FRF would look
like this.
13-55
Student Notebook
OL4912.1
Notes:
Notice how the fields have been organized by record format name by using comment lines
within the DDS.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
This is an example of the DDS coding of the CLASSPF physical file using the field
reference file technique.
13-57
Student Notebook
Machine exercise
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Checkpoint
IBM i
2. What are two of the commands that you could use to display
that information?
OL4912.1
Notes:
13-59
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
14-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Application Development
ToolSet (ADTS)
OL4912.1
Notes:
Now that you have become familiar with how files are defined and created, you should
understand the IBM i native tools that are on your systems. You can use these tools, in
addition to RDP and IBM i Navigator tools, to maintain your systems.
14-3
Student Notebook
Components of 5770-WDS:
Source Entry Utility (SEU)
Screen Design Aid (SDA)
Report Layout Utility (RLU)
Data File Utility (DFU)
Character Generator Utility (CGU)
Advanced Printer Function (APF)
Programming Development Manager (PDM)
Interactive Source Debugger (ISDB)
File Compare and Merge Utility (FCMU)
OL4912.1
Notes:
The Program Development Manager (PDM) is the main component of this integrated
application development environment. PDM manages lists of items to be developed or
maintained. By subsetting and selecting from lists, the developer can manipulate any
number of objects. This enhances the productivity of analysts, programmers, and other
support personnel in managing programs, data, and systems information, by focusing
activities on a grouping of objects or items to be worked on. The other tools are fully
integrated; the user always returns to the PDM list when use of a tool is complete. Also,
by automatically invoking the appropriate command with correct parameters and
syntax, keying and errors are reduced. This integration is further enhanced by
user-definable options to extend this environment with the user's own tools.
The Source Entry Utility (SEU) is the native IBM i full-screen editor providing syntax
checking of compiler source statements.
The Screen Design Aid (SDA) can be used to interactively design, create, and
maintain customer application panels (displays and menus).
V7.0
Student Notebook
Uempty
The Data File Utility (DFU) can be used to define, create, and maintain database
applications that are primarily oriented to data entry, inquiry, or file maintenance. It is
especially useful for the creation of test data for an application under development.
The following tools are mentioned here but will not be covered in class:
Report Layout Utility (RLU) allows a programmer to define the layout of a printed
report on the screen.
File Compose and Merge Utility (FCMU) is a compare function.
Interactive Source Debugger (ISDB) is used to debug programs.
14-5
Student Notebook
OL4912.1
Notes:
To use the PDM, type strpdm from an IBM i command line and press Enter.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Options 1 through 3 are the most frequently used functions of PDM.
14-7
Student Notebook
PDM options
IBM i
OL4912.1
Notes:
Using the PDM options, you can use function keys and options that vary depending upon
the PDM option that you chose:
1. Work with LIBRARIES (or library lists)
Change, Copy, Display, Rename, Display Description, Save, Restore, Work with
contents, Change text, Rearrange library list.
2. Work with OBJECTS in a library
Select objects from library by name and type, and then Change, Copy, Delete, Display,
Rename, Display Description, Save, Restore, Move, Work with, Change text, Copy file,
Run, Change using DFU, Find string, Create (service) program, Debug, Compare.
3. Work with MEMBERS in a source file
Select members from file by name and type, and then Edit, Copy, Delete, Display, Print,
Rename, Display Description, Save, Change text, Compile, Create Module, Run
Procedure, Change with SDA/RLU, Find String, Compare, Merge.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
To work with the members of a source file, you first type 3.
14-9
Student Notebook
OL4912.1
Notes:
When you are presented with this display in the exercise that follows:
You specify the name of your existing source file.
If your current library is your team library, you can save keystrokes and specify *LIBL.
For now, be sure to leave the defaults of *ALL in the last two parameters.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
PDM will display all the members in your source file. This is what you would have after
having created several source members in your QDDSSRC source file.
To work with any member, enter an option number in the field to the left of the name of the
member you wish to work with. The available options are listed above your member list.
The list of options will change (expand) if you press F23.
You would use this display to work with members in a source physical file by selecting
options or pressing function keys.
For additional options, press F23=More options. For additional function keys, press
F24=More keys.
To select an option, type the option number in the Opt column and press Enter or
F4=Prompt. For more information about an option, move the cursor to the Opt column and
press Help.
14-11
Student Notebook
To run a command, type the command on the command line and press Enter. For help in
entering a command, type the command name and press F4=Prompt. You cannot choose
options in the Opt column if you are running a command on the command line.
The following information is included for your reference:
Library
This prompt initially contains the value you entered in the Library prompt on the Specify
Members to Work With display. It is the name of the library that contains the file
containing the members displayed in the list. You can display a file containing the
members in a different library by changing this value. This prompt works in conjunction
with the File prompt. Choose from the following:
*CURLIB
Type *CURLIB to specify that the file containing the members you want to work with is
in the current library. If no current library is defined, QGPL is assumed.
You can also type parameters on the command line corresponding to the options you typed
in the list. The parameters are then added to the command when the option is performed.
If you press Enter without changing any prompts, typing an option or typing anything on the
command line, you return to the Programming Development Manager (PDM) menu. If
you use the WRKMBRPDM command, you return to the display where the command was
called.
If you see More... on the lower right side of your display, there is more information to view.
Press Page Down (Roll Up) to move toward the end of the information. Press Page Up
(Roll Down) to move toward the beginning of the information. If you see Bottom instead of
More..., you are at the end of the list.
To switch from the display showing the options and function keys, to full display mode and
back, press F18=Change defaults and change the Full screen mode prompt on the
Change defaults display.
File
This prompt initially contains the value you entered in the File prompt on the Specify
Members to Work With display or the FILE parameter on the WRKMBRPDM command. It
is the name of the file that contains the members displayed in the list. You can display
members in a different file by changing this value. This prompt works in conjunction with
the Library prompt.
*LIBL
Type *LIBL to specify that the file containing the members you want to work with is in one of
the libraries in the library list.
Library name
Type the name of the library that contains the file containing the members you want to work
with.
V7.0
Student Notebook
Uempty
Position to
Use this prompt to go to a particular area in the list. Use it for quick repositioning of the list,
not for creating a subset of the list. Choose from the following:
*TOP
Type *TOP to go to the top of the list.
*BOT
Type *BOT to go to the bottom of the list.
Name or partial name
Type the name or partial name of the member you want to go to in the list. The list of
members is positioned to the first member name beginning with the string specified. If no
members exist in the present list, then the list is positioned to the item immediately
preceding the position you want.
Opt
Use this column to perform different operations on individual members. Type the option
number next to a member and press Enter or F4=Prompt. You can type the same option
next to more than one member at a time, and you can also type different options next to
different members at the same time.
Choose from the following:
2=Edit
Type 2 to edit one or more members using the SEU.
3=Copy
Type 3 to copy one or more members to one or more new members. You can also copy
members to another file, another library, or both.
4=Delete
Type 4 to delete one or more members from the file.
5=Display
Type 5 to display one or more members using the SEU.
6=Print
Type 6 to print one or more members using the SEU.
7=Rename
Type 7 to change the name of one or more members.
8=Display description
Type 8 to display information about one or more members.
9=Save
14-13
Student Notebook
V7.0
Student Notebook
Uempty
If the former type of member MNU is entered, SDA converts this to MNUDDS.
Note: Menu members for PDM have type MNUDDS for the image member and type
MNUCMD for the command source member. The two are linked together to constitute a
group, so that specifying one of the types means that you can also operate on the linked
member at the same time.
19=Change using RLU
Type 19 to use Report Layout Utility (RLU) to work with the chosen members.
25=Find string
Type 25 to search for a given character string and perform any valid PDM option or
user-defined option on the members where a match occurs. Prompts allow you to
perform the option interactively or in a batch, and you can print a list of all members
where a match is encountered. You also have the option of printing the individual
records that contain the string.
54=Compare file member
Type 54 to compare file members. You can use this option only on data physical files
(*FILE PF-DTA) or source physical files (*FILE PF-SRC). If you try to use Compare file
member on any other type of object, you will receive an error message.
55=Merge file member
Type 55 to merge file members. You can use this option only on source physical files
(*FILE PF-SRC).
Member
A list of all the member names that meet the criteria on the Specify Members to Work With
display (WRKMBRPDM) command, or Subset Member List display.
Type
A list of the types of all the members that meet the criteria on the Specify Members to Work
With display, WRKMBRPDM command, or Subset Member List display. If you have update
authority to the file, you can change this column to change the type of specific members.
Using the Change Default display, you can turn off the ability to change the member type.
You can create your own member type, or use one of the following standard member types
used by PDM commands:
BAS
Basic
BAS36
Basic System/36
BAS38
Basic System/38
BASP
BASP38
C Language
14-15
Student Notebook
CBL
COBOL
CBLLE
CBL36
COBOL System/36
CBL38
COBOL System/38
CICSC
CICS C
CICSCBL
CICS COBOL
CICSMAP
CICS Map
CICSSQLCBL
CLD
C Locale Description
CLLE
CLP
Control Language
CLP38
CMD
Command
CMD38
Command System/38
DSPF
Display File
DSPF36
DSPF38
FTN
FORTRAN/400
ICFF
LF
Logical File
LF38
MENU
UIM Menu
MNU
Menu
MNUCMD
Menu Command
MNUDDS
MNU36
MSGF36
OCL36
PAS
Pascal
PF
Physical File
PF38
PLI
PL/I
V7.0
Student Notebook
Uempty
PLI38
PL/I System/38
PNLGRP
Panel Group
PRTF
Printer File
PRTF38
QRY38
System/38 QUERY
REXX
RMC
RM/COBOL-85**
RPG
RPG
RPGLE
RPG36
RPG System/36
RPG38
RPG System/38
RPT
RPT36
RPT38
SPADCT
SQLC
SQLCBL
SQLCBLLE
SQLFTN
SQLPLI
SQLRPG
SQLRPGLE
SRT36
Sort System/36
TBL
Table
TXT
Text
TXT36
Text System/36
Text
A list of the text descriptions of all the members in the list. If you have update authority to
the file, you can change this column. Using the Change Defaults display, you can turn on or
off the ability to change the text.
14-17
Student Notebook
Function keys
F1=Help
Press F1 to see information about this display.
F3=Exit
Press F3 to end the current task and return to the previous entry point (either the PDM
menu or at whatever entry point from which you originally ran the PDM).
F4=Prompt
Press F4 to provide assistance for the options selected in the list or a command on the
command line. The PDM fills in the known parameters. If you enter parameters on the
command line that are not specified by the PDM, they replace the corresponding values
in the prompt display.
If you press F4=prompt when the command line is blank and no options have been
typed in the list, you get a list of valid groups of commands. From here you can select all
commands or a group of commands.
F5=Refresh
Press F5 to rebuild the list and display it again. Whatever item is at the top of the page
when you press F5 becomes the top item of the page of the refreshed list. If you created
a subset of a list, it remains as a subset.
F6=Create
Press F6 to create a member in the file specified in the File prompt in the library
specified in the Library prompt. This brings you into SEU.
You can also choose to create members with SDA or DFU by using your own
user-defined options.
F9=Retrieve
Press F9 to display the last command you typed on the command line. Press F9 again
to see the next-to-last command you typed.
F10=Command entry
Press F10 to show a command entry display with all of the commands that have been
run from the PDM command line and the errors that have occurred during the current
session.
If you see More... on the lower right side of you display, there is more information to
view. Press Page Down (Roll Up) to move toward the end of the information. Press
Page Up (Roll Down) to move toward the beginning of the information.
If you see Bottom instead of More..., you are at the end of the list.
V7.0
Student Notebook
Uempty
14-19
Student Notebook
F21=Print list
Press F21 to print the current form of the list. If a subset of the list is displayed, only the
subset is printed. The file is sent to the output queue and can be viewed using the
WRKSPLF command.
F23=More options
Press F23 to display the next set of options available for this display.
F24=More keys
Press F24 to display the next set of function keys available for this display.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
Once you have elected a member and an option, you will be presented with another
display. In our case, we chose EDIT (option 2) of the file EMPMST. The editor is the SEU.
14-21
Student Notebook
OL4912.1
Notes:
When you are working with a list of members in a source file, you press F6=Create to open
a session to add a new member to that source file.
Of course, when you want to create a new member, PDM/SEU needs to know the name of
the source member you wish to create.
The source type parameter is very important. It determines the type of edit checking that
will be performed as you key the source statements, and determines which compiler will be
invoked to compile this member into an object. The Text field is helpful after you have
created many source members and objects in your system. You should add meaningful text
here. By default, it becomes descriptive text for the compiled object.
You can position the cursor on the Source Type prompt and press F1 or Help to see a list
of source types from which to choose.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
SEU has templates (formats) included on the IBM i system. You can use these templates to
assist you in your coding. Many developers code directly into the editor, after they have
designed the record formats. If you prefer, you can also draft your DDS on a piece of paper.
14-23
Student Notebook
OL4912.1
Notes:
Once you have specified the name of the new member you want to create, this is the next
screen format you will see. In this screen, you can start keying source statements.
Type IP? in the upper left as shown. Normally you would type IPA* (Insert with Prompting
using the A* - DDS comment format). However, if you are not sure of the format to use, just
type IP? (Insert with Prompting). The ? takes you to the Prompt Selection screen.
SEU commands provide shortcuts to the functions available in the Find/Change Options,
Find Options, Exit, and Change Session Defaults displays without leaving the work screen.
SEU commands are free format commands. The command parameters are either required
and positional, or optional and can be entered in any order.
To run an SEU command, you simply type it on the command line and press a positional
function key, such as Enter, Roll Up or Down, F19=Left, or F20=Right.
Some commands have abbreviations. For example, you can enter F or FIND to run the
FIND command. To retrieve the last command you entered, press F9=Retrieve. If the
cursor is in the data area, you can press F10=Cursor to move the cursor back and forth
14-24 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
between the data area and the command line. SEU remembers up to 50 commands. To
see help for an SEU command, type the command on the command line and press the
Help key.
Note: You cannot enter system commands on the command line, but you can enter a
system command on the work screen by pressing F21=System command. A window
appears where you can enter a system command.
Additional Information
You can enter the following SEU commands on any command line on the work screen
(Edit, Browse, or Split displays):
FIND or F
CHANGE or C
SAVE
CANCEL or CAN
FILE
HIDE
TOP
BOTTOM
SET or S
Note: FILE, SAVE, and CHANGE commands can only be used in an Edit session or in the
top session of a split Edit/Browse display.
The SET command has the following options:
MATCH
CAPS
TABS
ROLL
EXPERT
SHIFT
Note: The SHIFT and TABS options can only be used in an Edit session or in the top
session of a Split Edit/Browse display.
The Sequence number prompt displays the sequence number of the record and is used
for entering line commands. You can use user-defined line commands or system-defined
line commands. To use a line command, type the command over the digits that make up
the sequence number. If the sequence number area does not contain a sequence number,
type the command starting in the first position of the sequence number area followed by a
blank.
14-25
Student Notebook
V7.0
Student Notebook
Uempty
14-27
Student Notebook
V7.0
Student Notebook
Uempty
14-29
Student Notebook
V7.0
Student Notebook
Uempty
14-31
Student Notebook
You can specify an entire sequence number, or a value in the form of n, .n, or n.n,
optionally followed by a blank.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
The cursor is placed at the input field for the Prompt type at the top of the screen. Search
the available formats and find the prompt type letter code below that matches with the type
of statements you wish to enter, then type the letter code and press Enter.
You would select PF for the template for a Physical File.
14-33
Student Notebook
OL4912.1
Notes:
We have entered a number of lines of DDS coding. The visual shows us using the prompter
which provides us with a field by field area in which to enter the DDS.
Once you are familiar with this editor, you can easily use the format line at the top of the
editor work area as a guide to entering your lines of code in a free-form fashion.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
As each line of code is entered, it is added to the source member. After typing values in
numeric fields, press Field Exit (usually the + key on the numeric pad) to right-adjust the
value and position the cursor in the next field of the prompt.
Once you have completed your coding, press F3 to exit.
14-35
Student Notebook
OL4912.1
Notes:
This display gives you information regarding saving your member. The fields on this display
are completed for you.
If you have any outstanding syntax errors, the Return to editing parameter will be set to Y.
V7.0
Student Notebook
Uempty
Compile DDS (1 of 8)
IBM i
OL4912.1
Notes:
Once you have saved your member, you will be returned to the screen that shows your list
of members.
This visual shows you what you will see. Notice that NEWFRF has been added to the list of
members.
Type 14 in the corresponding Opt field to compile the DDS and create the Field Reference
File.
14-37
Student Notebook
Compile DDS (2 of 8)
IBM i
OL4912.1
Notes:
A message indicating that the compile has been submitted to a batch job queue is
displayed at the bottom of the screen.
V7.0
Student Notebook
Uempty
Compile DDS (3 of 8)
IBM i
OL4912.1
Notes:
You can use the DSPMSG command or PDM option DM (entered on any Opt line)
command to see your compile message when the message light comes on and / or the
alarm sounds.
Or, you may look at the spooled compile listing by using either PDM option SP (entered on
any line in the Opt column) or CL command WRKSPLF entered on the command line.
14-39
Student Notebook
Compile DDS (4 of 8)
IBM i
OL4912.1
Notes:
The compile was successful.
Your message display can be changed to suit your needs. Pressing F21 allows you to
select basic or intermediate assistance level.
V7.0
Student Notebook
Uempty
Compile DDS (5 of 8)
IBM i
OL4912.1
Notes:
To work with all your spooled files, enter the command WRKSPLF on the command line or
use PDM option SP entered on any Opt line to run CL command WRKSPLF.
14-41
Student Notebook
Compile DDS (6 of 8)
IBM i
OL4912.1
Notes:
Type option 5 to display the compile listing.
V7.0
Student Notebook
Uempty
Compile DDS (7 of 8)
IBM i
OL4912.1
Notes:
This is the first page of the spooled compiled listing.
The entry field is used to select and control the paging, rolling, and windowing functions.
The format of this field consists of a single character function code, an optional directional
code ('+' or '-'), and an optional integer to represent the positioning. ('f+/-n' is the format.)
The functions that you can perform on this display are:
14-43
Student Notebook
For example, to page forward five pages, type P+5 and press the Enter key. To go back
twelve pages, type P-12 and press the Enter key.
To display page three, type P3 and press the Enter key.
To roll forward to the next lines type + in this field followed by the number of lines you want
to roll and then press the Enter key. To roll backward, type - followed by the number of lines
you want to roll and press the Enter key.
To display a specific line, type the number of the line you want to display in this field and
press the Enter key.
To window to the left, type W-20 and press Enter. To go to the right you would type W+42
and press the Enter key.
To window to column fifteen, type W15 and press the Enter key.
To go to the top of this file, type T or *TOP and press the Enter key.
V7.0
Student Notebook
Uempty
Compile DDS (8 of 8)
IBM i
OL4912.1
Notes:
An asterisk in the left margin highlights messages.
Example: CPD7492 Keyword specified more than once in one specification.
This means we entered the edit code keyword twice.
Once you have determined the error, resubmit the compile. Once you have finished with
the spool file listings, enter option 4 beside each one to delete them.
14-45
Student Notebook
Browse/Copy options (1 of 4)
IBM i
OL4912.1
Notes:
Type option 2 to edit the source member.
V7.0
Student Notebook
Uempty
Browse/Copy options (2 of 4)
IBM i
OL4912.1
Notes:
Press F15 = Browse/Copy options.
14-47
Student Notebook
Browse/Copy Options (3 of 4)
IBM i
OL4912.1
Notes:
Type option 2 to browse your compile list. You will see the most recent compilation
output member by default. You can press F4 to see a list of all members in your OUTQ.
V7.0
Student Notebook
Uempty
Browse/Copy options (4 of 4)
IBM i
OL4912.1
Notes:
The display is split. The upper portion is your edit session while the lower portion is your
browse session of the spool file member.
Type F *ERR on the SEU command line of the browsed spool file and press Enter. This will
take you to the first error in the file and display the related error message at the bottom of
the display. For additional help, position the cursor on the related error message at the
bottom of the display and press Help.
View the error and make the correction.
Press F16 to search for more errors.
14-49
Student Notebook
A
A
A
A
A
A
A
A
A
A
ALTDES
30
BALANC
CNAME
COMSTS
COMSTT
CCITY
CRLIM
25
1
1
25
5
0
0
2
A
A
A
A
A
A
A
A
A
A
ALTDES
30
BALANC
CNAME
COMSTS
COMSTT
CCITY
CRLIM
25
1
1
25
5
A
A
A
A
A
A
A
A
A
A
ALTDES
BALANC
30
7
CNAME
COMSTS
COMSTT
CCITY
CRLIM
25
1
1
25
5
0
0
2
Results in:
0007.00
0009.00
0010.00
0011.00
0012.00
0013.00
0014.00
0015.00
0016.00
0016.01
0
0
2
OL4912.1
Notes:
To use SEU functions such as Copy, Move, and Delete:
Position the cursor on a line sequence number.
Type the line command such as C, M, D or A.
If you need Help, press F1 to see the operations that can be performed from this area.
Additional help describes the commands you can use in the SEU command area at the
top of the EDIT panel. They include block commands, such as copy, move, and delete,
and the ability to create a skeleton line and insert the skeleton.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
You can define a line of data you type repeatedly as a skeleton line. Once the line is
defined as a skeleton line, it can be inserted into the member as needed. You can keep the
same data or use the line as a template to enter new data.
Define a skeleton by typing S and place the cursor where needed before pressing Enter.
This is a useful feature to have when writing repetitive lines of code where one (or a few)
letters change from line to line.
14-51
Student Notebook
OL4912.1
Notes:
Insert Skeleton can be done as shown, or in the format ISn, where n is the number of
skeleton lines you want to insert.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
By typing only IS without specifying a number of lines to be inserted, one skeleton line will
be inserted. The developer makes a change where the cursor is positioned and then
pressed Enter.
A new skeleton line will be inserted at that point and it can be edited as desired. The
skeleton line will continue to be redisplayed until no change is made and the Enter key is
pressed.
14-53
Student Notebook
OL4912.1
Notes:
You can copy a complete member or a portion of a member into your new member:
Selection = 1
Copy all records = Y or N
Typing Y to copy all records from the browsed member will place CC on the first and
last statement of the browsed member. All you have to do is specify the target in your
source member with A for after or B for before.
You can also browse another member or, spooled file, or output queue.
V7.0
Student Notebook
Uempty
To
here
From
here
OL4912.1
Notes:
In order to see more of one member and less of the other, you can move the line that splits
the screen between the two members:
Position the cursor to the line where you want to position the split between the two
sessions. Press F6 to move the split line to that point.
You can copy from the bottom member (being browsed) to the top member (being
edited).
Press F12 to exit the browse/copy and return to your edit session in full screen mode.
14-55
Student Notebook
OL4912.1
Notes:
SEU offers the ability to find a string and replace it with something else, if needed.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
To select SEU Session Default options, press F13 from the Edit panel. This visual shows
you the first of two displays.
SEU Session Defaults are unique for each user.
14-57
Student Notebook
OL4912.1
Notes:
To review and change the PDM Default options, press F18 from the PDM Work With...
panels. This visual is the first of two displays.
PDM Default Options are retained and are unique for each user.
Use this display to assign defaults for the system command associated with an option. You
can define defaults for compile and run commands, the authority to change a member type
and text, the active user-defined options, and the mode in which specific displays are
shown. You can also define whether to save your programming development manager
session defaults permanently in your user profile, and whether you want to save or restore
objects and members with a separate command for each item or with one command for all
of them.
Object Library
Type the name of the library where you want to place objects resulting from a compilation if
the Compile option is entered on the Work with Members Using PDM display. Choose from
the following options:
14-58 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
Library name
Type the name of the library you want to be the object library.
*CURLIB
Type *CURLIB to use the current library as the object library. If no current library is
defined, QGPL is used.
*SRCLIB
Type *SRCLIB to use the library in which the source member exists as the object
library.
Replace Object
Use this prompt to indicate that you want to delete the existing object and replace it with the
new object created when you compile a member or create a module. Choose from the
following:
Y=Yes
Type Y to delete the existing object before starting to compile a member or create a
module. If the compilation fails, the object is not restored.
N=No
Type N if you do not want to delete the existing object before starting to compile a
member or create a module. If the object exists, the Confirm Member Compile display
appears.
Compile in batch
Use this prompt to choose whether to submit a job to batch when compiling members or
creating modules. Choose from the following:
Y=Yes
Type Y to compile members or create modules in batch.
N=No
Type N if you do not want to compile members or create modules in batch.
Run in batch
Use this prompt to choose whether to submit a job to batch when running objects. Choose
from the following:
Y=Yes
Type Y if you want objects run in batch.
N=No
Type N if you want objects to run in batch.
14-59
Student Notebook
V7.0
Student Notebook
Uempty
Type *B* to display a list of all items that have the character B anywhere in the name.
For example, B, BALL, or ABCD.
A*C
Type A*C to display a list of all items that begin with the character A and end with the
character C. For example, AC, ABC, AZZZC.
"a*"
Type "a*" to display a list of all items within quotation marks that start with a. For
example, a, aB, or aD.
Name
If you type a job description name and then press F4, you will see a list containing all of
the job descriptions in the specified library.
Generic name
Type a partial name qualified by an asterisk (*) to display a specific subset. The generic
name can be in one of the following formats:
ABC*
Displays a list of all items that begin with the characters ABC. For example, ABC,
ABCD, or ABCTEST.
**ALL
Displays a list of all items ending with ALL. For example, ALL, BALL, or TESTALL. The
double asterisk is needed in this case, since *ALL is defined as a special value to
display a list of all items.
*USRPRF
Type *USRPRF and press Enter if you want to specify the job description that is in your
user profile. The Library prompt, in this case, must be left blank.
You can also use *USRPRF as a generic name and press F4 to create a list of job
descriptions matching that criteria, but a library name must be specified.
Library
Use this prompt to specify the name of the library containing the job description. This
prompt must be blank if you are using *USRPRF as the job description.
Change type and text
Use this prompt to indicate if you want to change the Type and Text prompts by typing
over them on the Work with Members Using PDM display. Choose from the following:
Y=Yes
Type Y to indicate that you can change the Type and Text prompts on the Work with
Members Using PDM display if you have the authority to do so.
14-61
Student Notebook
N=No
Type N to indicate that you cannot change the Type and Text prompts on the Work with
Members Using PDM display.
Option file
Use this prompt to indicate the name of the file that contains the member with the
user-defined options. The user-defined options in this file are the active user-defined
options. The user-defined option file has a particular format.
Library
Use this prompt to indicate the name of the library containing the file with the member with
the user-defined options. The user-defined options in the file in this library are the active
user-defined options.
Member
Use this prompt to indicate the name of the member that contains the user-defined options.
The user-defined options in this member are the active user-defined options.
Full screen mode
Use this prompt to indicate if you want the options and function keys shown on the Work
with Displays. This option does not apply to the Work with User-Defined Options display.
Choose from the following:
Y=Yes
Type Y to indicate that you want Work with... displays shown in full screen mode without
the options and function keys.
N=No
Type N to indicate that you do not want Work with... displays shown in full screen mode
and want the options and function keys displayed.
Scan hierarchy
Use this prompt to choose whether or not the project hierarchy is searched for a particular
part. This value determines what parts appear in the Work with Parts Using PDM display
and what groups appear in the Work with Groups Using PDM display.
For example, if you specify No and type a development group name on the Specify Parts to
Work With display, only the parts in the development group are displayed. If you specify
Yes and type a development group on the Specify Parts to Work With display, all parts in
the project hierarchy are displayed.
This prompt is also used by the options chosen on those displays. Choose from the
following:
Y=Yes
Type Y if you want the project hierarchy searched if the part is not found in the specified
group. All groups in the path from the specified group up to the root group are searched.
14-62 IBM i Programming Facilities
V7.0
Student Notebook
Uempty
N=No
Type N if you want only the specified group searched. The project hierarchy is not
searched.
Search path
Use this prompt to choose the search path for options and list items on the Work with Parts
Using PDM display and the Work with Parts in a Part List Using PDM display. A search
path is the arrangement of groups that determines the order in which groups in a project
hierarchy are searched when looking for parts. The value specified determines the search
path used to find parts on the Work with Parts Using PDM display and Work with Parts in a
Part List Using PDM display. The specified search path does not determine the list of
groups displayed on the Work with Groups Using PDM display. The substitution variable
&ZS is replaced by this value on all options that use this variable. Choose from the
following:
Name
Type the name of the search path part that you want to use to find parts. A search path
part has the part type SCHPTH.
Specify QDFT if you want to find parts using the search path defined in part QDFT of
type SCHPTH.
*DFT
Type *DFT if you want to use the default project hierarchy as the search path. All the
groups from the specified group to the root group are searched.
In this situation, if the SCHPTH QDFT part exists, it is not to be used to determine the
list of items for the Work with Parts Using PDM display, or the Work with Parts in a Part
List Using PDM display. However, all part development commands use the command
SCHPTH QDFT.
Note: The specified search path must exist in the default project and group hierarchy, and
must contain the current project and group that you are using in the Work with Parts Using
PDM display, or the Work with Parts in a Part List Using PDM display. If you are working on
several parts contained in different groups and projects, type *DFT for the search path.
Build scope
Use this prompt to specify the extent, or scope, of the build operation resulting from
choosing option 14=Build. This value determines what parts the build option actually
builds. This prompt corresponds to the SCOPE parameter of the BLDPRT command.
Choose from the following:
1=Normal
Type 1 if you want to build the specified part and all other parts on which it depends,
and on which they depend, and so on.
14-63
Student Notebook
2=Limited
Type 2 if you want to build only the specified part.
3=Extended
Type 3 if you want to build the specified part and all the parts on which it depends, and
on which they depend, and so on, as well as any parts dependent on the specified part.
Any parts related to parts that are built are also built.
4=Direct Chain
Type 4 if you want to build the specified part and all the parts on which it depends.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
You have already seen some of the PDM short form commands such as DM for DSPMSG
and SP for WRKSPLF. PDM allows you to create your own options, shortcuts for
commands to call programs or perform tasks while in PDM.
To work with user-defined options-select menu option 9 from the main PDM panel, or press
F16 from one of the PDM Work with... displays (such as Work with Objects).
14-65
Student Notebook
OL4912.1
Notes:
Each developer can have a private file of user-defined options.
You can create your own user-defined options in your library. A good idea is to make a copy
of the system supplied QAUOPT member in your library. Then, modify this member to tailor
your own shortcuts to commands.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
IBM supplies a standard set of options:
Member: QAUOOPT
File: QAUOOPT
Library: QGPL
The letters prefixed with an & in the visual are substitution values.
14-67
Student Notebook
Command Called
CALL &O/&N
CC
CHGCURLIB
CURLIB(&L)
CD
STRDFU OPTION(2)
CHGCURLIB
CURLIB(&N)
STRSDA OPTION(2)
SRCFILE(&L/&F)
??SRCMBR( )
CL
CM
CS
DM
EA
STRSDA OPTION(1)
SRCFILE(&L/&F)
??SRCMBR()
DSPMSG
EDTOBJAUT
OBJ(&L/&N)
OBJTYPE(&T)
Explanation
OL4912.1
Notes:
The Option Name column contains the PDM option that you would enter in the Opt column
of a PDM Work with display.
V7.0
Student Notebook
Uempty
Option
Name
GO
Command Called
GO &L/ &N
Explanation
Allows you to display the menu for a menu object
JL
DSPJOBLOG
SL
SBMJOB ??CMD
(SAVLIB LIB(&N))
SBMJOB ??CMD(SAVOBJ
OBJ(&F) LIB(&L)
OBJTYPE (*FILE)
FILEMBR ((&F(&N))))
SM
SO
SBMJOB ??CMD(SAVOBJ
OBJ(&N) LIB(&L))
SP
WRKSPLF
WS
WRKSBMJOB
OL4912.1
Notes:
The available substitution parameters, for example &L and &N are explained in the help
text of the edit displays for pdm options. THese are shown on the next visuals.
14-69
Student Notebook
Parm
Meaning
Description
&A
Object attribute
&B
List type
&C
Option
&D
&E
Run in batch
&F
File name
OL4912.1
Notes:
You may create your own options for PDM, using complete CL commands, CL commands
with prompting and/or CL commands with values substituted from PDM. The parameters
shown (&A, &B, and so forth) are values substituted from PDM in a CL command that runs
as a user option.
V7.0
Student Notebook
Uempty
Parm
Meaning
Description
&G
Job description
library
&H
Job description
name
&J
Job description
&L
Library name
&N
Item name
&O
Object library
&P
Compile in batch
OL4912.1
Notes:
Here is page two of three showing more substitution variables for user-defined options.
14-71
Student Notebook
Parm
&R
&S
Meaning
Description
Replace object
'*'
&T
'*'
&U
User-Defined Option
File
&V
User-Defined
Option Library
&W
User-Defined Option
File Member
Item text
&X
OL4912.1
Notes:
Here is the last page of substitution variables for user-defined options.
V7.0
Student Notebook
Uempty
OL4912.1
Notes:
When you add a new user-defined option, you can use F4 prompting/nested-prompting
when building the command to ensure correct syntax. In this example, we are creating a
short-cut for signoff. Now, when you type O in any PDM option field and press Enter, you
will be signed off the system.
14-73
Student Notebook
QDDSSRC
2
ENTER DDS
SOURCE
CODE
SOURCE FILE
DDS
SOURCE
MEMBER X
OPTIONAL
SYNTAX
CHECKING
LISTING OF
SOURCE
DESCRIPTION
AND ERRORS
MEMBER Y
3
CREATE
DATABASE
FILE
(COMPILE
DDS
SOURCE)
MEMBER Z
DFU
or
RPG
or
COBOL
FILE
DESCRIPTION
MEMBER
Data path
User steps
OL4912.1
Notes:
This visual represents the steps that you follow when you use PDM to create DDS that will
be used in a program. The steps are the same process that you would follow using the
LPEX tool as well:
1. Write the DDS.
2. Use the SEU editor to enter your code into a source member. Many developers perform
steps 1 and 2 in a single step.
3. Once the source has been entered, exit SEU, save the member, and then compile it
using PDM option 14.
4. The new file that you have created can be populated with data using a utility such as
DFU (or SQL). An HLL program can also be run to populate the file with data.
V7.0
Student Notebook
Uempty
File-related commands
IBM i
Command (Parameter)
Provides
Existence
Contents
Size
Members
# records
# deleted records
Record formats
Fields
DSPLIB library-name
DSPFD file-name
DSPFFD file-name
DSPPFM file-name (Member-name)
Data
DLTF file-name
Delete
DSPMBR file-name
OL4912.1
Notes:
There are many useful commands and these are the ones that are the most-commonly
used.
14-75
Student Notebook
FNDSTRPDM
IBM i
Edit/Browse
Compile
Print
Copy
Delete
Reverse
User-defined options
Copyright IBM Corporation 2012
OL4912.1
Notes:
This command allows you to search for character or hex strings in source physical files or
physical files (that contain data).
V7.0
Student Notebook
Uempty
Machine exercise
IBM i
OL4912.1
Notes:
14-77
Student Notebook
Maintaining your
DB2 database
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Database maintenance
IBM i
OL4912.1
Notes:
One of the tasks of a database administrator is to evaluate the impact of changing the
definition of an existing database field or of adding a field to a file.
As developers, you should understand the impact of changing or adding a field as your
applications will be impacted.
14-79
Student Notebook
File - PF
Field Reference File
OL4912.1
Notes:
One of the elements that will change over time is the size of fields, particularly those that
accumulate history, such as period sales.
V7.0
Student Notebook
Uempty
*File - PF
Field Reference File
*File - PF
*File - PRTF
*File - LF
*File - DSPF
*PGM
OL4912.1
Notes:
Any object that uses that field must be examined for the impact of the change. The first task
we have is to determine which objects use the changed field.
14-81
Student Notebook
*File - PF
Field Reference File
*File - PF
*File - PRTF
*File - LF
DSPFFD
*File - DSPF
*PGM
Copyright IBM Corporation 2012
OL4912.1
Notes:
Any object that uses that field must be examined for the impact of the change. The first is to
determine which objects use the field.
DSPFFD shows the fields in a file. Included in the output are the following:
File name, library, type, member, creation date, number of records, record format name,
format level identifier, text, record length, number of fields in format
Field name, type, length, edit code, edit word, column headings, validity checking
information
For fields referencing other fields, the name of the referenced file, record format, and
field; if any attributes of the referenced field were changed, the attribute type is provided
V7.0
Student Notebook
Uempty
*File - PF
Field Reference File
*File - PF
*File - PRTF
*File - LF
*File - DSPF
*PGM
DSPPGMREF
Copyright IBM Corporation 2012
OL4912.1
Notes:
DSPPGMREF shows which files a program uses.
If you combine the output of DSPFFD and DSPPGMREF, you can find which programs are
affected by a particular field change.
DSPPGMREF shows a list of the system objects to which the specified program refers. For
files, the following is shown:
Name
Use (input, output, update, unspecified)
Number of record formats
Name of record format and its record format identifier
Number of fields referenced for each format
14-83
Student Notebook
*File - PF
Field Reference File
*File - PF
*File - PRTF
*File - LF
*File - DSPF
*PGM
OL4912.1
Notes:
DSPDBR identifies the physical and logical files that are dependent on specific files, files
that use a specific record format, or file members that are dependent on a specific file
member.
V7.0
Student Notebook
Uempty
FNDSTRPDM
IBM i
OL4912.1
Notes:
FNDSTRPDM is an alternative to the preceding commands and is a way to determine
where a field is used. FNDSTRPDM examines source files while the DSPFFD, DSBDBR,
and DSPPGMREF examine *PGM and *FILE objects.
14-85
Student Notebook
FNDSTRPDM parameters
IBM i
STRING
FILE
MBR
OPTION
PROMPT
PRTMBRLIST
MARK
PRTRCDS
( 'string')
( library/QxxxSRC)
( *ALL)
*RNM *SDA *COPY *DSPD *RLU
( *EDIT
*DLT *SAVE *DSP *CHGT *PRT *CMPL)
( *NONPROMPT *PROMPT )
( *NO *YES )
( *MARK *NOMARK )
*CHAR *MARK *FOLD *ALL *HEX
)
( *NONE
*NOMARK *TRUNCATE number *ALTHEX
Copyright IBM Corporation 2012
OL4912.1
Notes:
FNDSTRPDM can be executed as an option from the PDM member list. In the Option field
of the first member to be searched, type 25. The F13 key will repeat the option for the
remaining members. The user will be prompted for the search string when the Enter key is
pressed.
How do you find the files where the field is referenced?
Find string PDM (FNDSTRPDM) will:
1. Search the members of the file named for the given character string.
2. As shown above, the command will search all members of QDDSSRC and print a list of
those that contain the field named in the STRING parameter.
3. Display, delete, compile, print, or edit members containing the string if requested in the
OPTION parameter.
V7.0
Student Notebook
Uempty
1.
2.
DSPFFD
or DSPFFD ... OUTPUT(*OUTFILE) and SQL or QUERY
or FNDSTRPDM
3.
4.
CHGPF FILE(physical-file-name)
SRCFILE(source-file-name)
SRCMBR(source-file-member-name)
5.
Find affected display files and externally described printer files using
methods in step 2.
6.
OL4912.1
Notes:
When SRCFILE is specified on the CHGPF command, the specifications in the source file
are used to change the physical file. The specifications describe the record format and its
fields, and the access path for the file and its members. The data in the existing file is
mapped to the new format based on field names. If the name of a field is changed, its
existing data is lost.
It is strongly recommended that you save the file before you issue this command. A new
access path may have to be built. If data is corrected or a new access path is built, this
command could take a long time to complete.
14-87
Student Notebook
DSPPGMREF... OUTFILE(Y)
PGMX
FILEA
''
FILEB
FIELDB
''
PGMY
''
FIELDC
''
''
FILEC
FILED
OL4912.1
Notes:
SQL (or Query) can be used to join the two files output from DSPFFD and DSPPGMREG
on file name. Then you could select records based on the field that is being changed, listing
all impacted programs.
V7.0
Student Notebook
Uempty
Machine exercise
IBM i
OL4912.1
Notes:
14-89
Student Notebook
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
CPYF
Copy file
CPYSRCF
CPYFRMDKT
Copy to diskette
CPYTODKT
CPYFRMTAP
CPYTOTAP
Copy to tape
DUPDKT
Duplicate diskette
DUPTAP
Duplicate tape
CRTDUPOBJ
OL4912.1
Notes:
CPYF, in conjunction with an OVRxxxF command can perform the functions of the copy
commands shown above. However, the other copy commands include the function of an
override in their parameters.
14-91
Student Notebook
From
file
Physical
Logical
Diskette
Tape
Inline Data
To file
Physical
Undefined
Printer
Diskette
Tape
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
OL4912.1
Notes:
An undefined file is one that has not been created. It does not exist before the copy
command is started.
Inline data is data contained in a command stream submitted to the system for processing.
V7.0
Student Notebook
Uempty
Selecting members
IBM i
member name
generic name
*ALL
*FIRST
TOMBR(
)
member name
*FROMMBR
*FIRST
OL4912.1
Notes:
Data resides in one or more members of a physical file, and CPYF supports the copying of
data from members, to members.
A member name of *FIRST refers to the oldest member in the file, not the first member in a
stored list of member names.
14-93
Student Notebook
Default
FROMMBR
*FIRST
MBR3
*ALL
*ALL
TOMBR
*FIRST
*FIRST
*FIRST
*FROMMBR
MBR1
MBR1
MBR2
MBR2
MBR3
MBR3
FROMFILE
MBR1
TOFILE
MBR2
MBR1
MBR3
MBR3
OL4912.1
Notes:
The member names represent the content of the respective members.
V7.0
Student Notebook
Uempty
TOFILE
Before
After
NONE
CRTFILE (*YES)
FROMFILE
MBROPT (*ADD)
MBROPT (*REPLACE)
OL4912.1
Notes:
If you are copying data to a nonexistent file, the CRTFILE parameter of CPYF must be
*YES. A physical output file will be created.
If you are copying data to an existing database file, the MBROPT parameter must always
be *ADD or *REPLACE. Any other value will result in an error message.
14-95
Student Notebook
102
103
106
105
103
108
105
108
FROMRCD(3)
TORCD(5)
OL4912.1
Notes:
These two parameters are used to selectively copy based on relative record position within
the file.
V7.0
Student Notebook
Uempty
102
106
103
103
105
106
105
108
FROMKEY(103)
TOKEY(106)
OL4912.1
Notes:
Another form of selective copying is available using record keys. You can copy all records
within (and including) a range of keys.
14-97
Student Notebook
NBRRCDS(50)
/*
*/
Instead of
TORCD
-orTOKEY
OL4912.1
Notes:
NBRRCDS is another form of selective copying of data. You specify NBRRCDS for n
records. It can be useful when you want to create test data.
V7.0
Student Notebook
Uempty
102 SMITH
106 DAVIS
106 DAVIS
103 SAMPSON
108 DAVIDSON
OL4912.1
Notes:
Another form of selective copying is the ability to include records based upon a character
test. This example includes all records where, starting in position 1 of the NAME field, the
field contains (*CT) the characters DAV.
14-99
Student Notebook
102
59
106
160
103
175
105
23
108
132
106
160
103
175
OL4912.1
Notes:
Another form of selective copying is to include records based upon a relation test.
In this example, records should be included IF the field AMT is greater than 150.
V7.0
Student Notebook
Uempty
FMTOPT(*DROP)
FROM
FLDA
TO
FLDA
FLDB
FLDC
FLDC
FLDD
FLDD
FMTOPT(*MAP)
FROM
TO
FLDA
FLDB
FLDC
FLDD
10
12
FLDB
FLDC
FLDD
FLDA
7
15
OL4912.1
Notes:
The *MAP and *DROP parameters give CPYF the power to reformat database files when
field sizes must be changed, such as zip (postal) code from 5 to 9 positions, or BALDUE
from 5,2 to 7,2, or if fields need to be dropped from the record format.
If copying to a file having a format with fields (same field names) of a different length, *MAP
must be specified. CPYF does a field by field copy. *MAP will decimally align numbered
fields and left justify alphanumeric fields when mapping data to a new format where the
fields have different lengths. *DROP must be specified if the target file/format does not
contain all the fields present in the source file/format.
FMTOPT(*DROP) - This must be specified if any of the field names in the from-file
record format do not exist in the to-file format.
FMTOPT(*MAP) - Fields with the same name in the from-file and the to-file record
formats are occupied. Any fields in the to-file that do not exist in the from-file format are
set to the default values specified on the DFT keyword for the DDS of the to-file or zero
for numeric, blanks for character fields, current date/time for date/time fields, or null
value for null-capable fields.
Copyright IBM Corp. 1997, 2012
Student Notebook
If *DROP is specified, *MAP can also be specified. When *DROP is specified, all the field
names that exist in both record formats must have the same attributes and relative
positions in the from-file and to-file record formats, or *MAP must also be specified.
V7.0
Student Notebook
Uempty
FROM
TO
OL4912.1
Notes:
When FMTOPT(*NOCHK) is specified, then if the record formats of the database files are
different, the copy operation continues despite the differences. The record data is copied
directly (left to right) from one file to the other, byte by byte without regard to field
boundaries or data type.
Student Notebook
CPYF
FROMFILE(PAYLIB/EMP1)
TOFILE(TESTLIB/EMP1T)
FROMMBR(*FIRST)
TOMBR(*FIRST)
MBROPT(*REPLACE)
OL4912.1
Notes:
In the space provided below, write down what you think this example is doing:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
V7.0
Student Notebook
Uempty
Print options
IBM i
TOFILE(
*PRINT
SEU type listing for CPYSRCF
OUTFMT(
*CHAR
*HEX
PRINT(
*COPIED
*EXCLUDED
OL4912.1
Notes:
CPYF supports the copying of data from a file to an OUTQ using *PRINT.
Specify OUTFMT(*HEX) if you have numeric data (which is packed) that you want to see.
In addition to TOFILE(*PRINT), you may specify PRINT(*COPIED) to get a printout of all
records copied from one database file to another. PRINT(*EXCLUDED) will give a printed
report of all records not included in the copy from one database file to another.
Student Notebook
CPYF
FROMFILE(BILL/CUSTOMER)
TOFILE(QGPL/CUSTOMER)
CRTFILE(*YES)
INCREL((*IF CRDLMT *GE 10000))
OL4912.1
Notes:
Example of CRTFILE(*YES).
V7.0
Student Notebook
Uempty
Machine exercise
IBM i
Copy file
OL4912.1
Notes:
Student Notebook
Additional database
capabilities
Copyright IBM Corporation 2012
OL4912.1
Notes:
We will continue to use our case study school database to illustrate some additional
features, implementing JOINs and UNIONs in DDS.
V7.0
Student Notebook
Uempty
Logical File:
Union, projection, and sequence (1 of 2)
IBM i
GRADEPF98
Crs
Code
L001
L001
L001
L001
L001
Cls Cls
Yr
Qtr
1998 3
1998 3
1998 3
1998 4
1998 4
Stu
No
110
113
115
117
118
Student
Name
PARKER
TORME
KENTON
DAVIS
BRUBECK
Stu
Grd
93
86
96
81
90
Crs
Code
L001
L103
L001
L001
L001
L410
L303
L001
L214
L001
L001
L001
L001
L001
GRADEPF99
Crs
Code
L001
L001
L001
L103
L214
L410
L303
L001
L001
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 2
1999 3
Stu
No
102
103
101
101
108
106
107
105
107
Student
Name
LAUPER
TURNER
BOWIE
BOWIE
NELSON
HOLIDAY
STING
MADONNA
STING
Stu
Grd
72
79
93
62
97
75
86
-
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 3
1999 2
1998 3
1998 3
1998 3
1998 4
1998 4
Stu
No
101
101
102
103
105
106
107
107
108
110
113
115
117
118
Stu
Grd
93
62
72
79
75
86
97
93
86
96
81
90
OL4912.1
Notes:
A union also requires a sequence. The same DDS could be used for both GRADEPF98
and GRADEPF99. The eventual file name is determined by the CRTPF or CRTLF
command, not by the DDS.
Student Notebook
Logical file:
Union, projection, and sequence (2 of 2)
IBM i
OL4912.1
Notes:
We define a new logical file, GRADE9899U, a union over the two grade physical files.
YRSTUGRD is a new format which does not include all the physical file's fields. This is a
projection. If a projection was not desired, the format of the physical files could have been
used. In this case, no fields would be specified.
V7.0
Student Notebook
Uempty
GRADEPF99
CLASSPF
Crs
Code
L001
L103
L211
L214
L303
Course
Title
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
Ins
No
001
002
003
004
005
Instr
Name
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
ROSTERLF
L001
L103
L211
L214
L303
ITALLIAN
L001
101
L001
102
L001
103
L001
105
L001
107
ENGLISH
L103
101
SPANISH
GREEK
L214
108
CHINESE
L303
107
L410
106
001
1999
1999
1999
1999
1999
002
1999
003
004
1999
005
1999
1999
DANTE
1
1
1
2
3
HIGGINS
1
PICASSO
HOMER
2
TSUNG
3
1
Crs
Code
L001
L001
L001
L103
L214
L410
L303
L001
L001
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 2
1999 3
BOWIE
LAUPER
TURNER
MADONNA
STING
93
72
79
-
BOWIE
62
NELSON
97
STING
HOLIDAY
86
75
Stu
No
102
103
101
101
108
106
107
105
107
Student
Name
LAUPER
TURNER
BOWIE
BOWIE
NELSON
HOLIDAY
STING
MADONNA
STING
Stu
Grd
72
79
93
62
97
75
86
-
OL4912.1
Notes:
The records from CLASSPF and GRADEPF99 are presented as though they had been
sorted and merged by logical file ROSTERLF.
Student Notebook
OL4912.1
Notes:
Each physical file is identified by a PFILE keyword.
Since no STUDNO was specified for the CLASSPF, values of blanks are assumed.
Therefore, the CLASSPF records, for the same course code, will appear before the
GRADEPF99 records.
V7.0
Student Notebook
Uempty
CLASSPF
Crs
Code
L001
L103
L211
L214
L303
Course
Title
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
Ins
No
001
002
003
004
005
GRADEPF99
Instr
Name
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
Crs
Code
L001
L001
L001
L103
L214
L410
L303
L001
L001
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 2
1999 3
Stu
No
102
103
101
101
108
106
107
105
107
Student
Name
LAUPER
TURNER
BOWIE
BOWIE
NELSON
HOLIDAY
STING
MADONNA
STING
Stu
Grd
72
79
93
62
97
75
86
-
Student
Name
BOWIE
LAUPER
MADONNA
STING
TURNER
BOWIE
NELSON
STING
Stu
Grd
93
72
79
62
97
86
Course
Title
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ENGLISH
GREEK
CHINESE
Instr
Name
DANTE
DANTE
DANTE
DANTE
DANTE
HIGGINS
HOMER
TSUNG
CLSGRDIJ99
OL4912.1
Notes:
This is like the JOIN we did earlier using SQL. Notice that certain records are not shown in
the resulting logical file:
L211 from CLASSPF has no matching secondary.
L410 from GRADEPF99 has no matching primary.
Student Notebook
OL4912.1
Notes:
Notice these points:
The JFILE keyword replaces PFILE. The first file specified becomes the primary. The
second (through 32nd) files specified are secondary files.
JOIN specifies which two files are being joined.
JFLD specifies which fields are used to join the two files specified by the JOIN keyword.
JREF specifies from which file to use a field if there are duplicate field names among
the joined files.
The JDUPSEQ keyword specifies that duplicates should be sequenced by
STUDLNAME (student last name).
V7.0
Student Notebook
Uempty
CLASSPF
Crs
Code
L001
L103
L211
L214
L303
Course
Title
ITALLIAN
ENGLISH
SPANISH
GREEK
CHINESE
Ins
No
001
002
003
004
005
GRADEPF99
Instr
Name
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
Crs
Code
L001
L001
L001
L103
L214
L410
L303
L001
L001
Cls Cls
Yr
Qtr
1999 1
1999 1
1999 1
1999 1
1999 2
1999 1
1999 3
1999 2
1999 3
Stu
No
102
103
101
101
108
106
107
105
107
Student
Name
LAUPER
TURNER
BOWIE
BOWIE
NELSON
HOLIDAY
STING
MADONNA
STING
Stu
Grd
72
79
93
62
97
75
86
-
Student
Name
BOWIE
LAUPER
MADONNA
STING
TURNER
BOWIE
Stu
Grd
93
72
79
62
97
86
Course
Title
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE
Instr
Name
DANTE
DANTE
DANTE
DANTE
DANTE
HIGGINS
PICASSO
HOMER
TSUNG
NELSON
STING
CLSGRDOJ99
OL4912.1
Notes:
A left outer join supplies default values for missing secondary records.
Student Notebook
OL4912.1
Notes:
Specifying the JDFTVAL keyword makes this a left outer join.
V7.0
Student Notebook
Uempty
QDDSSRC
ENTER DDS
SOURCE
CODE
SOURCE FILE
DDS
SOURCE
OPTIONAL
SYNTAX
CHECKING
DATA
MEMBER Y
PHYSICAL
FILE X
MEMBER X
CREATE
DATABASE
FILE
(COMPILE
DDS
SOURCE)
LISTING OF
SOURCE
DESCRIPTION
AND ERRORS
4
DFU
or
RPG
or
COBOL
LOGICAL FILE
Y
Data path
User steps
Copyright IBM Corporation 2012
OL4912.1
Notes:
Creating a logical file DDS source follows the same steps as creating a physical file.
Student Notebook
FACOUTQxx
*LIB: FACxx
FACOUTQxx
PAYROLxx
FACJOBDxx
QDDSSRC
CLASSPF
GRADEPF98
GRADEPF99
GRADELF99
ROSTERLF
GRADE9899
U
GRADEIJ99
GRADEOJ99
PAYROLxx
QDDSSRC
Mbr: CLASSPF
DDS
Mbr: GRADEPF
DDS
FACJOBDxx
CLSGRDIJ99
CLASSPF
ROSTERLF
Data
Access Path
Mbr: GRADELF99
DDS
GRADEPF99
Mbr: ROSTERLF
DDS
Access Path
Mbr: GRADE9899U
DDS
Mbr: GRADEIJ99
DDS
Mbr: GRADEOJ99
DDS
Access Path
Access Path
CLSGRDOJ99
Access Path
Data
GRADELF99
GRADEPF98
Access Path
GRADE9899U
Access Path
Data
Access Path
OL4912.1
Notes:
This visual summarizes all the objects that we have described and created in the lecture.
V7.0
Student Notebook
Uempty
Machine exercise
IBM i
OL4912.1
Notes:
Student Notebook
Checkpoint
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Unit summary
IBM i
OL4912.1
Notes:
Student Notebook
V7.0
Student Notebook
Uempty
15-1
Student Notebook
Unit objectives
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
Uempty
Next step
IBM i
Next step
OL4912.1
Notes:
15-3
Student Notebook
OL4912.1
Notes:
We have covered a lot of tools in this class and you may feel a little overwhelmed.
However, once you return to the office and begin to use the tools, you will find that the
introduction to the tools provided in this class has given you a solid foundation of
knowledge.
But, you have more work to do!
V7.0
Student Notebook
Uempty
Programming courses
IBM i
RPG IV:
Version 7 free format coding
AS06/AS060 RPG IV Version 7 Programming Fundamentals
Workshop for IBM i
AS07/AS070 RPG IV Version 7 Programming Intermediate Workshop
for IBM i
AS10/AS100 RPG IV Version 7 Programming Advanced Workshop
for IBM i
OL4912.1
Notes:
Go to the following Web site:
http://www-304.ibm.com/jct03001c/services/learning/ites.wss/us/en?pageType=
page&c=a0000607
15-5
Student Notebook
Database courses
IBM i
OL4912.1
Notes:
In order to know how to use SQL, you should definitely attend OD47 or OL37 (OL370 US).
OL38 (OL380 US) will teach you how to embed SQL in RPG IV programs and how to code
Stored Procedures (external).
V7.0
Student Notebook
Uempty
WDSC/RDP courses
IBM i
OL4912.1
Notes:
If you enjoyed working with the LPEX Editor and Screen/Report Designer tools, you may
benefit from attending the Application Development class listed above.
Note: At the time this course was updated, these classes were currently updated To WDSC
V7.0 or V6.0 as noted in the course descriptions on the course catalog Web site.
The following URL directs you to the IBM Education Assistant. There you will find short
video topics on the LPEX Editor, Screen Designer and the Report Designer.
http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/index.jsp?topic=/com.ibm.iea.rdp/
rdp/8.0/IBMi.html
15-7
Student Notebook
Java anyone?
IBM i
OL4912.1
Notes:
RPG IV programmers can get a better feel for Java with this course.
V7.0
Student Notebook
Uempty
Machine exercises
IBM i
OL4912.1
Notes:
These exercises will enable you to use other tools including Screen Design Aid, Data File
Utility, and Query.
You should read through and attempt all these remaining exercises before departing the
class.
15-9
Student Notebook
Unit summary
IBM i
OL4912.1
Notes:
V7.0
Student Notebook
AP
Checkpoint solutions
IBM i
1. Name two of the main development tools available for the IBM i and
where each of them run.
The answers are:
A-1
Student Notebook
Checkpoint solutions
IBM i
A-2
V7.0
Student Notebook
AP
Checkpoint solutions
IBM i
A-3
Student Notebook
Checkpoint solutions
IBM i
4.
A-4
V7.0
Student Notebook
AP
Checkpoint solutions
IBM i
A-5
Student Notebook
Checkpoint solutions
IBM i
A-6
V7.0
Student Notebook
AP
Checkpoint solutions
IBM i
A-7
Student Notebook
Checkpoint solutions
IBM i
A-8
V7.0
Student Notebook
AP
Checkpoint solutions
IBM i
A-9
Student Notebook
Checkpoint solutions
IBM i
3. Are files created using DDS and SQL compatible on the IBM
i?
The answer is yes, for the most part they are interchangeable. There
are some slight differences in the features available.
Copyright IBM Corporation 2012
V7.0
Student Notebook
AP
Unit 12, "Accessing the IBM i database using SQL and IBM i
Navigator"
Solutions for Figure 12-60, "Checkpoint," on page 12-70
Checkpoint solutions
IBM i
1. List three methods that you could use to run SQL statements on an
IBM i.
The answers are:
Interactive SQL (STRSQL)
RUNSQLSTM
IBM i Navigator (Run SQL Scripts)
A HLL program with embedded SQL
Call-level interfaces such as CLI, ODBC, JDBC
Web Query
2. What are the two main categories of statements for the SQL
language?
The answers are Data Definition Language (DDL) and Data Manipulation
Language (DML).
3. What SQL statement can you use to retrieve data (result sets) from
tables?
The answer is SELECT.
A-11
Student Notebook
Checkpoint solutions
IBM i
2. What are two of the commands that you could use to display
that information?
The answer is DSPFD and DSPFFD.
V7.0
Student Notebook
AP
Checkpoint solutions
IBM i
A-13
Student Notebook
V7.0
Student Notebook
bibl
Appendix X. Bibliography
Documentation and Other Useful WEB Sites:
http://www.ibm.com
IBM's Internet Connection WEB site
http://publib.boulder.ibm.com/eserver/ibmi.html
Internet site for IBM System i Information
Center
http://www.redbooks.ibm.com
Internet site for ITSO redbooks
http://www-304.ibm.com/jct03001c/services/learning/ites.wss/zz/
en?pageType=page&c=a0011023
IBM Training Web site
http://www-03.ibm.com/systems/i/software/db2//
DB2 UDB for i homepage
http://www-03.ibm.com/certify/
Certification
http://www.midrangenews.com/
Mid Range News
http://www.iprodeveloper.com/
System i Network Website
http://www.midrange.com/
Midrange Website
http://www.ibmsystemsmag.com/
IBM Systems Magazine
http://www.mcpressonline.com/
MC Press
CD-ROMs:
SK3T-4091
SK2T-2849
Redbooks:
SG24-4249
SG24-6503
SG24-5402
Appendix X. Bibliography
X1
Student Notebook
X2
V7.0
backpg
Back page