You are on page 1of 618

V7.

cover

Front cover

IBM i Programming Facilities


Workshop
(Course code OL49)

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

Adobe is either a registered trademark or a trademark of Adobe Systems Incorporated in


the United States, and/or other countries.
Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its
subsidiaries in the United States and other countries.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or
both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other
countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of
Oracle and/or its affiliates.
Other product and service names might be trademarks of IBM or other companies.

June 2012 edition


The information contained in this document has not been submitted to any formal IBM test and is distributed on an as is basis without
any warranty either express or implied. The use of this information or the implementation of any of these techniques is a customer
responsibility and depends on the customers ability to evaluate and integrate them into the customers operational environment. While
each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results will
result elsewhere. Customers attempting to adapt these techniques to their own environments do so at their own risk.

Copyright International Business Machines Corporation 1997, 2012.


This document may not be reproduced in whole or in part without the prior written permission of IBM.
Note to U.S. Government Users Documentation related to restricted rights Use, duplication or disclosure is subject to restrictions
set forth in GSA ADP Schedule Contract with IBM Corp.

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

Unit 2. IBM i application development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1


Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
IBM i application development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Programming tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
RDS/RDP 8.0.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
IBM Rational Developer for Power Systems Software v8.0.3 . . . . . . . . . . . . . . . . . 2-7
Tool choices: Editors (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Tool choices: Editors (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Tool choices: Displays and reports (1 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Tool choices: Displays and reports (2 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Tool choices: Displays and reports (3 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Tool choices: Displays and reports (4 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
IBM DB2 Web Query for IBM i (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
IBM DB2 Web Query for IBM i (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Preserve investment in Query/400 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Product packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
What do you need to buy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
How do you get 5733-QU2? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
DB2 for i home page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
Unit 3. IBM i concepts and overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introducing the IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Early relationship of applications to hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Traditional system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IBM i high-level machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Architecture: Single-level storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Copyright IBM Corp. 1997, 2012


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Contents

3-1
3-2
3-3
3-4
3-5
3-6
3-8

iii

Student Notebook

Virtual storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-11


Single-level storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-12
IBM i object types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-13
The IBM i object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-14
Libraries/objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-15
IBM i library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-16
Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-17
Library/object structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-18
Supplied libraries (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-19
Supplied libraries (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-20
User libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-21
File systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-22
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-24
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-25
Unit 4. IBM i Access and IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-2
IBM i Access components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4
What is IBM i Navigator? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-5
Purpose of IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
Simplified IBM i administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7
Management Central overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-9
What is supported on an i? (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-11
What is supported on an i? (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-12
Management Central help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-13
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-14
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-15
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-16
Unit 5. Managing work flow on the IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
IBM i jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
Types of jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-5
User view of an interactive job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-6
User view of a batch job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-7
Sign On display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-8
IBM i Main Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-9
Alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-10
First job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11
System Request menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-12
Sign On to alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-13
Alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-14
Toggling from alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-15
IBM i job descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-16
System view of an interactive job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-17
System view of a batch job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-18
Spooling intercept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-19
iv

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

TOC

Printer device file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Printer queue and printer device file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Print output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Work with All Spooled Files: WRKSPLF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Display Spooled Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Change Spooled File Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Changing multiple spooled members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using IBM i Navigator to work with printed output . . . . . . . . . . . . . . . . . . . . . . . . .
Printer output functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Manage printer output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Viewing printed output using AFP Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . .
Printer output properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Customizing the view of printer output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IBM i subsystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
What is a subsystem? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents of subsystem description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Subsystem configurations shipped by IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Storage pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Work management summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

Unit 6. Commands, profiles, and libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1


Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Overview of using commands, user profiles, and library lists . . . . . . . . . . . . . . . . . 6-3
IBM i commands (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
IBM i commands (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
Command syntax (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Command syntax (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
Example: Executing a command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
Example: Prompting parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10
Example: Additional command parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
Example: Parameter keyword view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12
Example: Prompting for help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13
Special characters and function keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14
Example: Using a menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17
Example: The Major menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18
Example: Go command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19
QCMD command interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20
QCMD messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21
QCMD detailed messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-22
Create a user profile (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23
Create a user profile (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24
Create user profile: IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25
User profile properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
Fred signs on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29
Unqualified versus qualified name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-30
How your library list is constructed at sign on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-31
Copyright IBM Corp. 1997, 2012
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Contents

Student Notebook

How to change your library after sign on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-32


In which library is an object created? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-33
Use libraries to organize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-34
Library related commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-35
Machine exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-36
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-37
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-38
Unit 7. Introduction to IBM i security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-2
IBM i security concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3
Security is always active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
Layers of security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5
QSECURITY system value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-6
Components of IBM i security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
User profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-9
User profiles shipped with IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-10
System authority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-11
System-defined authority combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-13
Group profile example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-15
How multiple group profiles work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-16
Authorization lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-17
Managing authorization lists using IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . .7-18
Sign On display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20
Sign on processing (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21
Sign on processing (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-22
Authority search process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-23
Authorization flow (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-24
Authorization flow (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-25
EDTOBJAUT command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-26
Display object authorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-27
Managing security using IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-28
IBM i Navigator Security Configuration Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-29
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-31
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-32
Unit 8. Control language programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-2
Structure and rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-3
Why use control language programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-4
Control language program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
CL program structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
Command format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
CL command syntax (1 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-9
CL command syntax (2 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-10
CL command syntax (3 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-11
CL command syntax (4 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-12
Coding rules (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-13
vi

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Unit 9. Basic message handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1


Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
An overview of message handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Basic message queue communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
User and workstation message queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
Sending and displaying messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
Sending an inquiry message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
Displaying messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8
Sending break messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
Additional Message Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11
Message handling using IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
Sending messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
Additional message functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
View messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16
Copyright IBM Corp. 1997, 2012
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

TOC

Schema, libraries, and field reference files . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


SQL catalogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Native files and SQL objects coexist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IBM i and the DB2 family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

Create index GRADEPF99I (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-49


Assign permissions: Grant/Revoke authorities . . . . . . . . . . . . . . . . . . . . . . . . . . .12-50
Where are we? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-51
Using SQL to complete the case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-52
SELECT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-53
Case study requirement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-55
Executing the SQL SELECT statement (1 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-56
Executing the SQL SELECT statement (2 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-57
Executing the SQL SELECT statement (3 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-58
Executing the SQL SELECT statement (4 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-59
Executing the SQL SELECT statement (5 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-60
Case study requirement: Union of grades (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . .12-61
Case study requirement: Union of grades (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . .12-62
Case study requirement: Union of grades (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . .12-63
Case study requirement: Select data from related tables . . . . . . . . . . . . . . . . . . .12-64
Combining data from tables using JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-65
Case study JOIN (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-66
Case study JOIN (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-68
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-69
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-70
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-71
Unit 13. Defining database files using DDS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-2
Creating IBM i physical and logical files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-3
Physical files used in the school database case study . . . . . . . . . . . . . . . . . . . . . .13-4
Logical files used in the school database case study (1 of 2) . . . . . . . . . . . . . . . . .13-5
Logical files used in the school database case study (2 of 2) . . . . . . . . . . . . . . . . .13-6
Physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-7
DSPFD CLASSPF (1 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-8
DSPFD CLASSPF (2 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-9
DSPFD CLASSPF (3 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-10
DSPFD CLASSPF (4 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-11
DSPFD CLASSPF (5 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-12
DSPFD CLASSPF (6 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-13
DSPFD CLASSPF (7 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-14
DSPFD CLASSPF (8 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-15
DSPFD CLASSPF (9 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-16
DSPFD CLASSPF (10 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-17
DSPFFD CLASSPF (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-18
DSPFFD CLASSPF (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-19
DSPFFD CLASSPF (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-20
Multiple member physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-21
Source physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-22
Types of source in source physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-23
Naming convention for source PFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-24
Creating a source file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-25
Creating database files and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-26
x

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

TOC

Physical and logical file naming rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Coding for physical file CLASSPF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Coding for physical files GRADEPF98 and GRADEPF99 . . . . . . . . . . . . . . . . . .
Create source physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Create new source member . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Create CLASSPF *File object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Our library after GRADEPF99 is created . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating database files and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Relational database operations using logical files . . . . . . . . . . . . . . . . . . . . . . . .
Logical file: Selection and sequence (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical file: Selection and sequence (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical file: Selection and sequence (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (1 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (2 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (3 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (4 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (5 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (6 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (7 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFD GRADELF99 (8 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFFD GRADELF99 (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFFD GRADELF99 (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DSPFFD GRADELF99 (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using a field reference file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using a field reference file for our case study . . . . . . . . . . . . . . . . . . . . . . . . . . .
Properties of a field reference file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Field reference file for school database (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . .
Field reference file for school database (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . .
DDS for CLASSPF using SCHOOLREFFRF . . . . . . . . . . . . . . . . . . . . . . . . . . .
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF). . . . . . . . . . . . . . . . . . . . . . . . 14-1


Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2
Application Development ToolSet (ADTS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
Application Development ToolSet for IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
Programming Development Manager (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6
Programming Development Manager (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7
PDM options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-8
PDM work with members (1 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9
PDM work with members (2 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-10
PDM work with members (3 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-11
PDM work with members (4 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-21
Create new member (1 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-22
Create new member (2 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-23
Create new member (3 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-24
Copyright IBM Corp. 1997, 2012
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Contents

xi

Student Notebook

Create new member (4 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-33


Create new member (5 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-34
Create new member (6 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-35
Create new member (7 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-36
Compile DDS (1 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-37
Compile DDS (2 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-38
Compile DDS (3 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-39
Compile DDS (4 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-40
Compile DDS (5 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-41
Compile DDS (6 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-42
Compile DDS (7 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-43
Compile DDS (8 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-45
Browse/Copy options (1 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-46
Browse/Copy options (2 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-47
Browse/Copy Options (3 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-48
Browse/Copy options (4 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-49
Using basic SEU functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-50
Define a skeleton line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-51
Insert a skeleton line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-52
Skeleton line inserted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-53
Browse/Copy Options: Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-54
Browse/Copy options: Split screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-55
SEU Find/Change Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-56
Change SEU session defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-57
Change PDM session defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-58
PDM: Work with user-defined options (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . .14-65
PDM: Work with user-defined options (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . .14-66
PDM: Work with User-Defined Options (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . .14-67
Standard PDM options (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-68
Standard PDM options (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-69
Valid substitution variables for user-defined options (1 of 3) . . . . . . . . . . . . . . . .14-70
Valid substitution variables for user-defined options (2 of 3) . . . . . . . . . . . . . . . .14-71
Valid substitution variables for user-defined options (3 of 3) . . . . . . . . . . . . . . . .14-72
PDM: Create User-Defined Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-73
Summary of using PDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-74
File-related commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-75
FNDSTRPDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-76
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-77
Maintaining your DB2 database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-78
Database maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-79
Example: Enlarging a field size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-80
Example: Impacted objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-81
DSPFFD: Fields within file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-82
DSPPGMREF: Files used by programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-83
DSPDBR: Which LFs use which PFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-84
FNDSTRPDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-85
FNDSTRPDM parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-86
Example: Implement the field change (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . .14-87
xii

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

TOC

Example: Implement the field change (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-88


Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-89
CPYF (copy file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-90
Copy functions and commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-91
Copy function: From and to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-92
Selecting members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-93
Copy file: FROMMBR, TOMBR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-94
Copy file: CRTFILE, MBROPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-95
Copy file: FROMRCD, TORCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-96
Copy file: FROMKEY, TOKEY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-97
Copy file: NBRRCDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-98
Copy file: INCCHAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-99
Copy file: INCREL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-100
Copy file: FMTOPT(*DROP *MAP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-101
Copy file: FMTOPT(*NOCHK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-103
Creating test data using a DB copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-104
Print options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-105
Create a file not previously defined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-106
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-107
Additional database capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-108
Logical File: Union, projection, and sequence (1 of 2) . . . . . . . . . . . . . . . . . . . 14-109
Logical file: Union, projection, and sequence (2 of 2) . . . . . . . . . . . . . . . . . . . . 14-110
Multiformat logical file: Union, sequence (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . 14-111
Multiformat logical file: Union, sequence (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . 14-112
Logical file: Inner join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-113
Logical file DDS: Inner JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-114
Logical file: Left outer JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-115
Logical file DDS: Left outer JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-116
Creating logical file and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-117
School case study summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-118
Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-119
Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-120
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-121
Unit 15. Wrap-up and supplemental exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1
Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
Next step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-3
What can you do now? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
Programming courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-5
Database courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6
WDSC/RDP courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-7
Java anyone? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-8
Machine exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-9
Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-10
Appendix A. Checkpoint solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
Appendix X. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X-1
Copyright IBM Corp. 1997, 2012
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Contents

xiii

Student Notebook

xiv

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Adobe is either a registered trademark or a trademark of Adobe Systems Incorporated in


the United States, and/or other countries.
Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its
subsidiaries in the United States and other countries.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or
both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other
countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of
Oracle and/or its affiliates.
Other product and service names might be trademarks of IBM or other companies.

Copyright IBM Corp. 1997, 2012


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Trademarks

xv

Student Notebook

xvi

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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:

Navigate IBM i menus


Use common IBM i commands
Use IBM i Help and IBM i Information Center
Use a Windows-based PC and navigate PC menus and windows
Explain programming concepts
Write a simple program in any programming language

Copyright IBM Corp. 1997, 2012


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Course description

xvii

Student Notebook

Objectives
After completing this course, you should be able to:

Describe what application development tools are available


Identify platforms where tools are used
Describe the purpose and use of each tool
Create a user profile, library, output queue, and job description
Describe the key elements of Work Management, security, and
device files
Write a basic control language (CL) program to run application
programs
Define physical and logical files on the IBM i
Create physical and logical files
Use the basic features of the LPEX Editor to enter and maintain file
definitions
Use the basic features of the Screen/Report Designer to design,
create, and maintain displays and reports
Use Interactive SQL and IBM i Navigator to create schema, tables,
views, and indexes

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.

xviii IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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)

Copyright IBM Corp. 1997, 2012


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 1. Class administration and introduction


What this unit is about
In this unit, we will handle administrative matters and discuss the
course material. A description of local facilities and student
introductions are included in this unit. We will also discuss
prerequisites and course objectives. Finally, we will talk about the
agenda.

What you should be able to do


After completing this unit, you should be able to:
List the units to be presented in the course
Find and use the teaching locations facilities

Copyright IBM Corp. 1997, 2012

Unit 1. Class administration and introduction

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

1-1

Student Notebook

Prerequisites
IBM i

Before taking this course, students must be able to:


Navigate IBM i menus
Use common IBM i commands
Use IBM i Help and IBM i Information Center
Use a Windows-based PC and navigate PC menus and windows
Explain programming concepts
Write a simple program in any programming language
Copyright IBM Corporation 2012

Figure 1-1. Prerequisites

OL4912.1

Notes:
In order to optimize your learning experience, it is important that you meet all of the above
prerequisites.

1-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Course objectives
IBM i

After completing this course, you should be able to:


Describe what application development tools are available
Identify platforms where tools are used
Describe the purpose and use of each tool
Create a user profile, library, output queue, and job description
Describe the key elements of Work Management, security, and device
files
Write a basic Control Language (CL) program to run application
programs
Define physical and logical files on the IBM i
Create physical and logical files
Use the basic features of the LPEX Editor to enter and maintain file
definitions
Use the basic features of the Screen Designer and Report Designer to
design, create, and maintain displays and reports
Use Interactive SQL and IBM i Navigator to create schema, tables,
views, and indexes
Copyright IBM Corporation 2012

Figure 1-2. Course objectives

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.

Copyright IBM Corp. 1997, 2012

Unit 1. Class administration and introduction

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 1-3. Class administration

OL4912.1

Notes:

1-4

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Agenda (1 of 2)
IBM i

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 Access
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/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

Figure 1-4. Agenda (1 of 2)

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 1. Class administration and introduction

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

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)

Day 5

Machine exercise - Using the IBM i editors


Machine exercise - Code and create files: 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 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

Figure 1-5. Agenda (2 of 2)

OL4912.1

Notes:
Web sites:
http://publib.boulder.ibm.com/iseries/
http://www.ibm.com/servers/eserver/iseries/navigator

1-6

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Introductions
IBM i

Your name, city


Company/Organization name
Major uses of computer
Prior IBM i or other system experience
Prior programming experience

Copyright IBM Corporation 2012

Figure 1-6. Introductions

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 1. Class administration and introduction

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

1-7

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


List the units to be presented in the course
Find and use the teaching locations facilities

Copyright IBM Corporation 2012

Figure 1-7. Unit summary

OL4912.1

Notes:

1-8

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 2. IBM i application development tools


What this unit is about
This unit introduces the many tools available on the IBM i and the PC
Windows platform to assist you in performing your day to day
application development activities.

What you should be able to do


After completing this unit, you should be able to:
Name each of the tools
Identify the platforms on which each tool resides
For each tool, describe its purpose

How you will check your progress


Checkpoint questions

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Name each of the tools
Identify the platforms on which each tool resides
For each tool, describe its purpose

Copyright IBM Corporation 2012

Figure 2-1. Unit objectives

OL4912.1

Notes:

2-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i application development tools


IBM i

IBM i
application development tools
Copyright IBM Corporation 2012

Figure 2-2. IBM i application development tools

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Create test data


Compile programs
Test programs
Debug programs
Support applications
Copyright IBM Corporation 2012

Figure 2-3. Programming tasks

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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++

Feature: ILE Compilers


Option 31 ILE RPG
Option 35 ILE RPG *PRV Compiler
Option 41 ILE COBOL
Option 45 ILE COBOL *PRV Compiler
Option 51 ILE C
Option 52 ILE C++
Option 56 IXLC for C/C++

Feature: Heritage Compilers


Option 32 S/36 Compatible RPG II
Option 33 S/38 Compatible RPG II
Option 34 RPG/400 (RPG III)_
Option 42 S/36 Compatible COBOL
Option 43 S/38 Compatible COBOL
Option 44 OPM COBOL

RD for i for SOA


RDP, RBD, HATS
EGL, Web design

RAD
Java

Feature: ADTS
Option 21 ADTS

Copyright IBM Corporation 2012

Figure 2-4. RDS/RDP 8.0.3

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++

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-5

Student Notebook

Application Development Tool Set


-

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)

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

Rational Developer for i for SOA includes:


Rational Developer for Power Systems (RDP)
Rational Business Developer (RBD)
Rational HATS Toolkit
Rational Application Developer for WebSphere

Java development tools (with IBM i enhancements)


Web development tools (with IBM i enhancements)
Database development tools
Web services development tools
Server development tools
XML development tools
Test environments for WebSphere Application Server and WebSphere Portal products

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM Rational Developer for Power Systems


Software v8.0.3
IBM i

Comprehensive suite of compilers and tools for


IBM i development
Repackaging IBM i-based compilers in WebSphere
Development Studio (WDS) i 7.1: ILE Compilers, Heritage
Compilers, and ADTS offered as three separate components
Rebranding/enhancement of development tools
RDP
Includes LPEX, RSE, End to End Debugger
Screen Designer, Report Designer
RD for i for SOA
Includes Rational Business Developer (RBD) - EGL,
SOA.
Includes tooling for Web design
Web services from RPG/COBOL
Rational HATS Toolkit (webfacing)
Rational Application Developer (RAD)
Advanced Java Development (J2EE)
RDP plus RAD

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

Copyright IBM Corporation 2012

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:

Rational Business Developer (RBD)


EGL
Tools for Web design
Rational HATS Toolkit for Web facing

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Tool choices: Editors (1 of 2)


IBM i

Source Entry Utility (IBM i Server)


Create and maintain program source
members
Create and maintain database file
definition source
5250 'green screen' interface
Can invoke using STRSEU or from within
Program Development Manager PDM

Copyright IBM Corporation 2012

Figure 2-6. Tool choices: Editors (1 of 2)

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.

These source members can include the following:

ILE RPG
File Description (DDS)
Screen Display File source (DDS)
Report definition source (DDS)

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

2-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Tool choices: Editors (2 of 2)


IBM i

LPEX Editor (Windows PC)


Part of RDP set of client
tools
Can be connected to
IBM i or disconnected
GUI interface
Tokenizes source and
uses color to
differentiate tokens

Copyright IBM Corporation 2012

Figure 2-7. Tool choices: Editors (2 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-11

Student Notebook

Tool choices: Displays and reports (1 of 4)


IBM i

Screen Design Aid


Create and maintain displays and
menus
5250 'green screen' based
Can invoke using STRSDA or from
PDM

Copyright IBM Corporation 2012

Figure 2-8. Tool choices: Displays and reports (1 of 4)

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.

2-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Tool choices: Displays and reports (2 of 4)


IBM i

Screen Designer
Create and maintain displays and menus
Workstation based
Can design displays, view, and maintain
source

Copyright IBM Corporation 2012

Figure 2-9. Tool choices: Displays and reports (2 of 4)

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

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-13

Student Notebook

Tool choices: Displays and reports (3 of 4)


IBM i

Report Layout Utility

Copyright IBM Corporation 2012

Figure 2-10. Tool choices: Displays and reports (3 of 4)

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.

2-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Tool choices: Displays and reports (4 of 4)


IBM i

Report Designer

Copyright IBM Corporation 2012

Figure 2-11. Tool choices: Displays and reports (4 of 4)

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

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-15

Student Notebook

IBM DB2 Web Query for IBM i (1 of 2)


IBM i

IBM delivers a Web-based query and report writing product that


replaces IBM Query for i (Query/400).
Base product

Report and graphing assistants


Power Painter
Spreadsheet integration
Web-enable Query/400 reports

Additional IBM features

Active reports (disconnected)


Online analytical processing
Developer Workbench
Run-time user enablement
Spreadsheet client
SQL Server data adaptor
Software Development Kit (SDK)
Report Broker
JDE adaptors (***Beta Soon***)

For more details, refer to:


http://www.ibm.com/systems/i/software/db2/webquery

Copyright IBM Corporation 2012

Figure 2-12. IBM DB2 Web Query for IBM i (1 of 2)

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.

2-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-17

Student Notebook

IBM DB2 Web Query for IBM i (2 of 2)


IBM i

Additional add-ons available


Database/Cube/Mining connectors
Extract/Transformation/Load

IBM Query for i (Query/400)


evolution
Easy and intuitive
More powerful
More productive
Extensible
SQL data access

Web-based graphical user interface


Internet Explorer (IE) 6.0 or higher
Mozilla Firefox 1.5 or higher

Import of Query/400 definitions

Copyright IBM Corporation 2012

Figure 2-13. IBM DB2 Web Query for IBM i (2 of 2)

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.

2-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Preserve investment in Query/400


IBM i

Then modify
with Report
Assistant

Or rewrite as
new Web Query
to take
advantage of
SQE

Copyright IBM Corporation 2012

Figure 2-14. Preserve investment in Query/400

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.

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-19

Student Notebook

Product packaging
IBM i

The product has a modular structure.


Base product
Additional modules sold by IBM
Additional modules sold by Information Builders

Active
Report

Data
Adapter

OLAP

Report
Caster

Developer
Workbench

...

Base product
Report
Assistant

Graph
Assistant

Power
Painter

Query/400
Adapter

Copyright IBM Corporation 2012

Figure 2-15. Product packaging

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.

2-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

What do you need to buy?


IBM i

Base product

Base Product
Report
Assistant

Graph
Assista
nt

Power
Painter

Query/400
Adapter

Additional modules, if needed

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

Users working with existing active reports do not need licenses


Licenses allow you to use both the base product and additional
modules
A predefined number of user licenses is included in the base product
Copyright IBM Corporation 2012

Figure 2-16. What do you need to buy?

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.

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

2-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

How do you get 5733-QU2?


IBM i

Available on IBM i 5.4/6.1/7.1


Can query data on other systems/partitions not at
5.4/6.1/7.1
Customers at i 5.4 + software maintenance + 5722QU1
license
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
Maintenance not included, 90-day grace period
New 5733QU2 order
Base product + predefined number of users
One year of maintenance included with new purchase

SW groups

Included users

P05

P10

P20

P30

P40

10

P50

15

P60

20

Maintenance includes additional modules, if purchased


Extensible to 3 years

Includes license of product 5722QU1 for unlimited users,


not separately orderable at 5.4/6.1/7.1
Copyright IBM Corporation 2012

Figure 2-17. How do you get 5733-QU2?

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

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

2-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DB2 for i home page


IBM i

Your portal to everything DB2

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

New DB2 Web Query Web site:


http://www.ibm.com/systems/i/software/db2/webquery

Frequently asked questions


Detailed demonstration
Why IBM i for BI White Paper
Links to Information Builder add-on product information
Copyright IBM Corporation 2012

Figure 2-18. DB2 for i home page

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.

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-25

Student Notebook

Checkpoint
IBM i

1. Name two of the main development tools available for the


IBM i and where each of them run.
2. True or False: RPG and CL programs cannot be edited
interchangeably using the SEU or the LPEX editors.
3. True or False: Rational Development Studio is formerly
known as WebSphere Development Studio.

Copyright IBM Corporation 2012

Figure 2-19. Checkpoint

OL4912.1

Notes:

2-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit summary
IBM i

Having completed this unit, you should be able to:


Name each of the tools
Identify the platforms on which each tool resides
For each tool, describe its purpose

Copyright IBM Corporation 2012

Figure 2-20. Unit summary

OL4912.1

Notes:
You now have an appreciation of the tools that are available and where they can be used.

Copyright IBM Corp. 1997, 2012

Unit 2. IBM i application development tools

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-27

Student Notebook

2-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 3. IBM i concepts and overview


What this unit is about
In this unit, we will introduce some of the basic concepts of the IBM i
system including high-level machine, single-level storage, virtual
storage, objects, and libraries.

What you should be able to do


After completing this unit, you should be able to:
Describe the IBM i high-level machine interface
Describe single-level storage
Describe the components of an IBM i object
Define an IBM i library

How you will check your progress


Checkpoint questions

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe the IBM i high-level machine interface
Describe single-level storage
Describe the components of an IBM i object
Define an IBM i library

Copyright IBM Corporation 2012

Figure 3-1. Unit objectives

OL4912.1

Notes:

3-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Introducing the IBM i


IBM i

Introducing the IBM i


Copyright IBM Corporation 2012

Figure 3-2. Introducing the IBM i

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-3

Student Notebook

Early relationship of applications to hardware


IBM i

Application programs

Hardware

Copyright IBM Corporation 2012

Figure 3-3. Early relationship of applications to 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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Traditional system architecture


IBM i

User Program Area


COBOL
Security
RACF
Spooling
JES
Virtual Storage
Management MVS
Database Management
DB2
File Management
VSAM
Transaction Processor
CICS
Communications
VTAM

Machine Interface
370 Instruction Set

Supervisor
MVS

Licensed Internal Code


and Hardware
Copyright IBM Corporation 2012

Figure 3-4. Traditional system architecture

OL4912.1

Notes:
If you look at the architecture of many traditional systems, the software is layered, not
integrated.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-5

Student Notebook

IBM i high-level machine


IBM i

Software
User Program Area
Machine Interface (MI)

Security
Virtual Storage Management
Database Management
File Management
Communications
Supervisor

High-level
Machine

Internal Microprogramming Interface (IMI)

Licensed Internal Code


and Hardware
Copyright IBM Corporation 2012

Figure 3-5. IBM i 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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-7

Student Notebook

Architecture: Single-level storage


IBM i

Main Storage

All storage managed as


one container of objects

A
A

An object (file, program,


and so forth) is distributed
across multiple disk units

A
Drive 1

Drive 2

A
A

Drive 3

User not concerned with


designating location

A
Auxiliary Storage

Load balancing based on


performance and capacity
Copyright IBM Corporation 2012

Figure 3-6. Architecture: Single-level 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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Ability to spread data across disk arms in an ASP based on capacity.


- Spreads data across arms so each has an equal percentage of usage.
- Especially useful when disk arms are added.
Ability to move low-access data to slower, high-capacity disk arms within an ASP
(typically compressed disk).
- Identifies hot versus cold data and moves cold data to a slower disk.
- Can also specifically target data to a slower disk.
These functions can be controlled using CL commands.
Parallel load balancing is documented in the Backup and Recovery guide, and the CL
Reference.
Normally, after a new IBM i object, such as a database file (SQL table), is created, IBM i
writes the object content across multiple disks (DASD units, DASD devices) within the
same Auxiliary Storage Pool (ASP). The purpose is to spread the data as evenly as
possible on each disk present when the object is created. In the case of a database file, the
process takes place whenever data is written to the file. Generally, this delivers the best
system performance for accessing that object and makes the best use of DASD capacity
for all objects within the ASP.
There are conditions when the default spreading of data needs to be modified. The most
typical case is when new DASD devices are added to a system ASP or any ASP. At the
time the DASD is added there is no new data placed on the new DASD until the
subsequent normal creation of new objects or massive additions of new data. Then the
system places the new object/data on the DASD with the most available space. Over time,
the system will spread the data evenly across all DASD within the ASP.
In many cases of new DASD, the best performance can be achieved by spreading data
immediately across the new DASD. In releases previous to V4R1, the only straightforward
way to spread the data was to do a save and then a restore, which would spread the data
being restored. V4R3 contained a little known command - DSKBAL- that would spread
(balance) DASD data during IPL. DSKBAL was PTFed back to V4R1 and V4R2 during
1998.
As more enhancements were made to the AS/400, and then to the new System i, other
environmental conditions arose that call for different balancing of the DASD data. This is
specifically for certain performance environments where certain records/SQL rows are
accessed more frequently, or where a single ASP has a mixture of large capacity DASD
(such as 17.54 GB DASD) and smaller capacity DASD (such as 4.19 GB or 8.58 GB
DASD) all in the same ASP. Another consideration is where there is a mixture of
compressed and non-compressed DASD within the same ASP.
IBM i provides commands to give the authorized user the capability to control the balancing
of data within an ASP according to three options - Capacity, Usage, and Hierarchical
Storage Management (HSM).

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

3-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 3-7. Virtual storage

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 3-8. Single-level storage

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.

3-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i object types


IBM i

AUTL

Authorization List

LIB

CMD

Command
Definition

MSGQ Message Queue

DTAARA

Data Area

DEVD
FILE

Device
Description
File

FLR

Folder

JOBD

Library

OUTQ Output Queue


PGM

Program

QRYDFN

Query Definition

SBSD

Subsystem
Description

Job Description

USRPRF

User Profile

JOBQ

Job Queue

And many more

JRN

Journal

JRNRCV

Journal Receiver
Copyright IBM Corporation 2012

Figure 3-9. IBM i object types

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-13

Student Notebook

The IBM i object


IBM i

Object Description
Object Functional Part
Physical File Members
(Data Records)
Logical File Members
(Access Paths)
Program Code

Copyright IBM Corporation 2012

Figure 3-10. The IBM i object

OL4912.1

Notes:
Each object is made up of two components:
1. Object description
2. Functional part

3-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Libraries/objects
IBM i

FILEB
FILEA

FILEC

FILEA

PROGY
LIBA

PROGX

LIBZ
QUEUE1

PROG4
LIBB
FILEB

PROGY

Copyright IBM Corporation 2012

Figure 3-11. Libraries/objects

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 3-12. IBM i library

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.

3-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 3-13. Libraries

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-17

Student Notebook

Library/object structure
IBM i

QSYS

LIB A

PGM 1

Other library objects


User profiles
Configuration

LIB B

FILE 1

And so
forth

PGM 2

FILE 2

MEMBER 1

And so
forth
MEMBER A
MEMBER B

Copyright IBM Corporation 2012

Figure 3-14. Library/object structure

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.

3-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Cannot be deleted or renamed


Owned by the security officer
Should be on all library lists
Copyright IBM Corporation 2012

Figure 3-15. Supplied libraries (1 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Other libraries include:


QSPL Spooling library
QRECOVERY Recovery library for IBM use only
QDOC Document library
QUSRSYS System library containing some user objects

Licensed Program Libraries:


y QRPG/QRPGLE
y QCBL/QCBLLE
and many others
Copyright IBM Corporation 2012

Figure 3-16. Supplied libraries (2 of 2)

OL4912.1

Notes:
There are other libraries in your system, depending on the software products and the
applications installed in it.

3-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

User libraries
IBM i

These can be created to suit the environment:


Application
Department
User
Developer

Each user library has an attribute:


Production - The default
Test - Useful in a test environment

Copyright IBM Corporation 2012

Figure 3-17. User libraries

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-21

Student Notebook

File systems
IBM i

Users

Applications

Integrated
File
System
Application
Menus/Commands
Program Interface

Integrated File System Interface

QSYS.LIB
File
System

"Root"
File
System

QOpenSys
File
System

IBM i
File Server

QDLS
File
System

TCP/IP

Network
File System
(NFS)

Copyright IBM Corporation 2012

Figure 3-18. File systems

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.

3-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-23

Student Notebook

Checkpoint
IBM i

1. Many of the functions traditionally performed by system


control programs have been ________________
a.
b.
c.
d.

placed into subsystems.


integrated into the IBM i machine and hardware.
eliminated.
relegated to *MACHINE pool.

2. Which of the following are attributes of single level storage?


a.
b.
c.
d.

All storage is managed as one container.


Objects are distributed across multiple disks.
User does not need to designate location.
All of the above.

3. What object on the IBM i can organize other objects?


Copyright IBM Corporation 2012

Figure 3-19. Checkpoint

OL4912.1

Notes:

3-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe the IBM i high-level machine interface
Describe single-level storage
Describe the components of an IBM i object
Define an IBM i library

Copyright IBM Corporation 2012

Figure 3-20. Unit summary

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 3. IBM i concepts and overview

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-25

Student Notebook

3-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 4. IBM i Access and IBM i Navigator


What this unit is about
IBM i Access for Windows is the software that enables a
Windows-based PC client to interface with the IBM i and execute most
of the IBM i commands. IBM i Navigator is a powerful component of
Access.

What you should be able to do


After completing this unit, you should be able to:
Describe the purpose of IBM i Navigator
Describe the purpose of Management Central
Use IBM i Navigator help
Navigate IBM i Navigator menus

How you will check your progress


Checkpoint questions
Machine exercises

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe the purpose of IBM i Navigator
Describe the purpose of Management Central
Use IBM i Navigator help
Navigate IBM i Navigator menus

Copyright IBM Corporation 2012

Figure 4-1. Unit objectives

OL4912.1

Notes:

4-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i Access components


IBM i

Copyright IBM Corporation 2012

Figure 4-2. IBM i Access components

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

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-3

Student Notebook

IBM i Navigator
IBM i

IBM i Navigator
Copyright IBM Corporation 2012

Figure 4-3. IBM i Navigator

OL4912.1

Notes:

4-4

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

What is IBM i Navigator?


IBM i

Copyright IBM Corporation 2012

Figure 4-4. What is IBM i Navigator?

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

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-5

Student Notebook

Purpose of IBM i Navigator


IBM i

Copyright IBM Corporation 2012

Figure 4-5. Purpose of IBM i Navigator

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Simplified IBM i administration


IBM i

Leverages the user's Windows skills to administer IBM i


systems
Reduces need of learning IBM i command interface
Easier path to understanding terminology and concepts

Integrated into the Windows environment


Drag and drop
Explorer view
Property sheets
Context menus
Various views
Small icons
Large icons
List
Details

Copyright IBM Corporation 2012

Figure 4-6. Simplified IBM i administration

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)

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Management Central overview


IBM i

IBM i
Navigator

Copyright IBM Corporation 2012

Figure 4-7. Management Central overview

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

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

4-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

What is supported on an i? (1 of 2)
IBM i

Tailored view for each IBM i in the network


Based on available functions for IBM i level,
installed subcomponents, application
administration settings

Copyright IBM Corporation 2012

Figure 4-8. What is supported on an i? (1 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 4-9. What is supported on an i? (2 of 2)

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

4-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Management Central help


IBM i

Copyright IBM Corporation 2012

Figure 4-10. Management Central help

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.

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-13

Student Notebook

Machine exercise
IBM i

Navigating IBM i Navigator

Copyright IBM Corporation 2012

Figure 4-11. Machine exercise

OL4912.1

Notes:
At this point, we want to open IBM i Navigator and learn where some of the useful features
can be found.

4-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. What component of IBM i Access allows you to perform


administrative and system operations in a Windows
environment?
2. What component of IBM i Navigator allows you to perform
system management functions such as system monitoring,
PTF management, and so forth?
3. True or False: IBM i Navigator is able to support multiple IBM
i servers running different levels of IBM i.

Copyright IBM Corporation 2012

Figure 4-12. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 4. IBM i Access and IBM i Navigator

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-15

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe the purpose of IBM i Navigator
Describe the purpose of Management Central
Use IBM i Navigator help
Navigate IBM i Navigator menus

Copyright IBM Corporation 2012

Figure 4-13. Unit summary

OL4912.1

Notes:

4-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 5. Managing work flow on the IBM i


What this unit is about
This unit introduces IBM i Work Management. The following concepts
are presented:
IBM i job types - batch, interactive, and spooling
Creating and using job descriptions
Creating and using job queues and output queues
Creating subsystems and subsystem descriptions

What you should be able to do


After completing this unit, you should be able to:
Describe the characteristics of interactive and batch jobs
Start an interactive job, a batch job, and an alternate interactive
job
Describe how the job description and user profile contribute to a
job's attributes and its printed output
Work with spooled output files
Use IBM i Navigator to manage printed output
Implement unique job attributes by creating or modifying user
profiles and job descriptions and describe the concepts of IBM i
subsystems after learning the appropriate command syntax in a
subsequent unit

How you will check your progress


Checkpoint questions

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe the characteristics of interactive and batch jobs
Start an interactive job, a batch job, and an alternate
interactive job
Describe how the job description and user profile contribute to
a job's attributes and its printed output
Work with spooled output files
Use IBM i Navigator to manage printed output
Implement unique job attributes by creating or modifying user
profiles and job descriptions and describe the concepts of IBM
i subsystems after learning the appropriate command syntax in
a subsequent unit

Copyright IBM Corporation 2012

Figure 5-1. Unit objectives

OL4912.1

Notes:

5-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i jobs
IBM i

IBM i jobs

Copyright IBM Corporation 2012

Figure 5-2. 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

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Types of jobs
IBM i

System Jobs

User Jobs

Spooling

Interactive
Autostart
Batch
Communication

Copyright IBM Corporation 2012

Figure 5-3. Types of jobs

OL4912.1

Notes:
All jobs, regardless of type, are either:
1. Interactive
2. Batch

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-5

Student Notebook

User view of an interactive job


IBM i

Application
Program

Database

Reports

Payroll
1 Checks
2 Adjust

Copyright IBM Corporation 2012

Figure 5-4. User view of an interactive job

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

User view of a batch job


IBM i

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

Copyright IBM Corporation 2012

Figure 5-5. User view of a batch job

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-7

Student Notebook

Sign On display
IBM i

Copyright IBM Corporation 2012

Figure 5-6. Sign On display

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i Main Menu


IBM i

Copyright IBM Corporation 2012

Figure 5-7. IBM i Main Menu

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 5-8. Alternate job

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.

5-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

First job
IBM i

Copyright IBM Corporation 2012

Figure 5-9. First job

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-11

Student Notebook

System Request menu


IBM i

Copyright IBM Corporation 2012

Figure 5-10. System Request menu

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.

5-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Sign On to alternate job


IBM i

Copyright IBM Corporation 2012

Figure 5-11. Sign On to alternate job

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-13

Student Notebook

Alternate job
IBM i

Copyright IBM Corporation 2012

Figure 5-12. Alternate job

OL4912.1

Notes:
Both jobs have equal status.
Neither is a subordinate of the other.

5-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Toggling from alternate job


IBM i

Copyright IBM Corporation 2012

Figure 5-13. Toggling from alternate job

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-15

Student Notebook

IBM i job descriptions


IBM i

IBM i job descriptions

Copyright IBM Corporation 2012

Figure 5-14. IBM i job descriptions

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.

5-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

System view of an interactive job


IBM i

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

Copyright IBM Corporation 2012

Figure 5-15. System view of an interactive job

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-17

Student Notebook

System view of a batch job


IBM i

SBMJOB JOB(PAY) JOBD(PAYJOBD) CMD(CALL PAY01)

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

Figure 5-16. System view of a batch job

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.

5-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 5-17. Spooling intercept

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-19

Student Notebook

Printer device file


IBM i

PROGRAM
Writes to file QPRINT

Device file from CRTPRTF command


QPRINT
SPOOL
OUTQ
FORMTYPE
COPIES
SCHEDULE
SAVE
DEV

=
=
=
=
=
=
=

QPRINT

(*YES)
(*JOB)
(*STD)
(1)
(*FILEEND)
(*NO)
(*JOB)

T
OU

More . . .

Copyright IBM Corporation 2012

Figure 5-18. Printer device file

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.

5-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Printer queue and printer device file


IBM i

or

SPOOL(*NO) DEV(*JOB)

Determined at job initiation

Job Printer Device:

SPOOL(*YES) OUTQ(*JOB)

Job Output Queue:


OUTQ(*USRPRF)

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

Figure 5-19. Printer queue and printer device file

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

STRPRTWTR PRT01 PRT01


STRPRTWTR PRT06 FRED

WRKSPLF (DEFAULT PARMS)


OPTION 2 = CHANGE
OPTION 5 = DISPLAY
OPTION 4 = DELETE

CHGJOB OUTQ(PRTnn)

Copyright IBM Corporation 2012

Figure 5-20. Print output

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.

5-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Work with All Spooled Files: WRKSPLF


IBM i

Work with All Spooled Files


Type options, press Enter.
1=Send
2=Change
3=Hold
4=Delete
5=Display
8=Attributes
9=Work with printing status

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

Copyright IBM Corporation 2012

Figure 5-21. Work with All Spooled Files: WRKSPLF

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-23

Student Notebook

Display Spooled Files


IBM i

Display Spooled Files


File . . . .: OVERDUE
Page/Line 1/32
Control . . : _______
Columns
1 - 75
Find . . . .: 05/23
*...+....1....+....+....2....+....3....+....4....+....5....+....6....+....7...
The contents of a spooled file can be
displayed on the screen from any
of the Spooled Files list display

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

String found in position 63.


Copyright IBM Corporation 2012

Figure 5-22. Display Spooled Files

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.

5-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Change Spooled File Attributes


IBM i

Change Spooled File Attributes

2=Change

Spooled file. . . . . . >


Job Name. . . . . . . . >
User. . . . . . . . . >
Number. . . . . . . . >
Spooled file number . . >
Printer. . . . . . . . .
Print sequence . . . . .
Form type. . . . . . . .
Copies . . . . . . . . .
Restart printing . . . .

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_____

Copyright IBM Corporation 2012

Figure 5-23. Change Spooled File Attributes

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-25

Student Notebook

Changing multiple spooled members


IBM i

Work with All Spooled Files


Type options, press Enter.
1=Send
2=Change
3=Hold
4=Delete
5=Display
8=Attributes
9=Work with printing status

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

F22=Printers F24=More keys

Copyright IBM Corporation 2012

Figure 5-24. Changing multiple spooled members

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.

5-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Using IBM i Navigator to work with printed output


IBM i

Using IBM i Navigator


to work with printed output
Copyright IBM Corporation 2012

Figure 5-25. Using IBM i Navigator to work with printed output

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-27

Student Notebook

Printer output functions


IBM i

Manage printer output


Display the output
Display properties

Copyright IBM Corporation 2012

Figure 5-26. Printer output functions

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.

5-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Manage printer output


IBM i

Hold/Release
Send or move to another
printer/output queue
Delete
Reply to messages
Print next
Properties

Copyright IBM Corporation 2012

Figure 5-27. Manage printer output

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

5-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Viewing printed output using AFP Workbench


IBM i

Using AFP
Workbench Viewer
Full-function viewer
is included at no
charge

Copyright IBM Corporation 2012

Figure 5-28. Viewing printed output using AFP Workbench

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-31

Student Notebook

Printer output properties


IBM i

Display output properties


Change output properties, such as:
Printer/Queue
Number of copies
Priority
Form type

Copyright IBM Corporation 2012

Figure 5-29. Printer output properties

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

In addition to these changeable fields, there is additional information available on the


spooled file on these properties pages. For example, on the General tab the user finds
information about the Output name and the Status, on the Origin tab, the Time and Date as
well as the User, the Job, and the System the output was created on is displayed. The
Other 1 tab shows the Device requirements, such as AFP Resources and Bar codes. The
Other 2 and Other 3 tabs display additional attributes, such as Final Form text, Highlight,
Rotation, Subscript, Superscript, Variable characters per inch, Variable font, Variable
drawer, and many more.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-33

Student Notebook

Customizing the view of printer output


IBM i

Copyright IBM Corporation 2012

Figure 5-30. Customizing the view of printer output

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

5-34 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i subsystems
IBM i

IBM i subsystems

Copyright IBM Corporation 2012

Figure 5-31. IBM i subsystems

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-35

Student Notebook

What is a subsystem?
IBM i

Subsystem

Subsystem

Interactive
Processing

Batch
Processing

Spooling

Subsystem
Copyright IBM Corporation 2012

Figure 5-32. What is a subsystem?

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.

5-36 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Contents of subsystem description


IBM i

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

Defines the sources of the work for the subsystem


Autostart jobs
Work stations
Job queues
Communications

Copyright IBM Corporation 2012

Figure 5-33. Contents of subsystem description

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

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

5-38 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Subsystem configurations shipped by IBM


IBM i

IPL starts only the subsystem named in QCTLSBSD system value


Environment as shipped (Default) - QCTLSBSD = QBASE
Autostart Job

QBASE

QSPL

Console, Interactive, Batch,


Communications

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

Copyright IBM Corporation 2012

Figure 5-34. Subsystem configurations shipped by IBM

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

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-39

Student Notebook

The system value QCTLSBSD (Controlling subsystem) controls which subsystem


configuration will be used on a System i system.

5-40 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 5-35. Storage pool

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.

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-41

Student Notebook

Work management summary


IBM i

SBMJOB

JOBQ
BATCH
OUTQ
WRITER

PRINTER

CALL

INTERACTIVE

WRKJOBQ

WRKACTJOB

WRKOUTQ
WRKSPLF

WRKWTR

WRKUSRJOB
WRKSBMJOB
Copyright IBM Corporation 2012

Figure 5-36. Work management summary

OL4912.1

Notes:
There are a number of commands that enable you to perform work management activities:
WRKWTR

Work with spool writers

WRKOUTQ

Work with output queues

WRKSPLF

Work with spooled files

WRKACTJOB Work with active jobs


WRKJOBQ

Work with job queues

WRKUSRJOB Work with user jobs


WRKSBMJOB Work with submitted jobs

5-42 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. What are two common types of jobs on an IBM i system?


2. Where does printer output typically go on an IBM i system?
3. What command could you use to view spool files?
4. What command could you use to view your batch jobs?
5. What else could you use to view spool files?
6. What IBM i feature can be used to separate jobs into
different environments?
Copyright IBM Corporation 2012

Figure 5-37. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 5. Managing work flow on the IBM i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-43

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe the characteristics of interactive and batch jobs
Start an interactive job, a batch job, and an alternate
interactive job
Describe how the job description and user profile contribute to
a job's attributes and its printed output
Work with spooled output files
Use IBM i Navigator to manage printed output
Implement unique job attributes by creating or modifying user
profiles and job descriptions and describe the concepts of IBM
i subsystems after learning the appropriate command syntax in
a subsequent unit

Copyright IBM Corporation 2012

Figure 5-38. Unit summary

OL4912.1

Notes:

5-44 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 6. Commands, profiles, and libraries


What this unit is about
In this unit, we will describe some of the IBM i commands and how to
use them. Qualified objects are also described as well as the use of
library lists for unqualified objects. Creating and changing library list
attributes within a job is explained. More information is provided
regarding the user profile and job description within the context of the
commands that support their creation and modification.

What you should be able to do


After completing this unit, you should be able to:
Use IBM i commands in a job to manipulate both qualified and
unqualified objects
Describe the syntax of control language statements
Use the control language command Help
Use prompting to find and execute CL commands
Create and modify a user profile
Create and modify a job description
Explain the purpose of a library list
Use commands to modify a library list

How you will check your progress


Checkpoint questions
Machine exercises

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Use IBM i commands in a job to manipulate both qualified and
unqualified objects
Describe the syntax of control language statements
Use the control language command Help
Use prompting to find and execute CL commands
Create and modify a user profile
Create and modify a job description
Explain the purpose of a library list
Use commands to modify a library list

Copyright IBM Corporation 2012

Figure 6-1. Unit objectives

OL4912.1

Notes:

6-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Overview of using commands, user profiles, and


library lists
IBM i

Overview of using commands,


user profiles, and library lists

Copyright IBM Corporation 2012

Figure 6-2. Overview of using commands, user profiles, and library lists

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-3

Student Notebook

IBM i commands (1 of 2)
IBM i

Function:

Command and parameters:

Run a program

CALL HerProgram

Copy a file

CPYF HerFile HisFile

Delete a file

Dltf OldFile

Display a library

DSPLIB ourlib

Power off

Pwrdwnsys delay(120)

Reorganize a file

Rgzpfm disorgfile

Send a message

sndbrkmsg 'Please signoff' *ALLWS

Copyright IBM Corporation 2012

Figure 6-3. IBM i commands (1 of 2)

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Not all verb + items = a valid command!


HLDDTAARA
DLTPF
Many more commands!
Copyright IBM Corporation 2012

Figure 6-4. IBM i commands (2 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-5

Student Notebook

Command syntax (1 of 2)
IBM i

Command

DSPLIB
Action

Item
Abbrev.

Parameter

LIB(PAYLIB)
Keyword

Value

Copyright IBM Corporation 2012

Figure 6-5. Command syntax (1 of 2)

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Command syntax (2 of 2)
IBM i

CRTLIB LIB(MYLIB) TYPE(*TEST) TEXT('PROGRAM DEVELOPMENT LIBRARY')


OR
CRTLIB
MYLIB
*TEST
TEXT('PROGRAM DEVELOPMENT LIBRARY')
Job: B,I Pgm: B,I REXX: B,I Exec

(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

Figure 6-6. Command syntax (2 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Executing a command


IBM i

Copyright IBM Corporation 2012

Figure 6-7. Example: Executing a command

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-9

Student Notebook

Example: Prompting parameters


IBM i

Copyright IBM Corporation 2012

Figure 6-8. Example: Prompting parameters

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).

6-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Additional command parameters


IBM i

Copyright IBM Corporation 2012

Figure 6-9. Example: Additional command parameters

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-11

Student Notebook

Example: Parameter keyword view


IBM i

Copyright IBM Corporation 2012

Figure 6-10. Example: Parameter keyword view

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.

6-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Prompting for help


IBM i

Copyright IBM Corporation 2012

Figure 6-11. Example: Prompting for help

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-13

Student Notebook

Special characters and function keys


IBM i

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:

How to use this display

F14:

Command string

F15:

Error messages

F16:

Command complete

F24:

More keys

Copyright IBM Corporation 2012

Figure 6-12. Special characters and function 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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

6-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Using a menu


IBM i

Copyright IBM Corporation 2012

Figure 6-13. Example: Using a menu

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-17

Student Notebook

Example: The Major menu


IBM i

Copyright IBM Corporation 2012

Figure 6-14. Example: The Major menu

OL4912.1

Notes:
Commands are grouped by subject, verb, function, and so forth.

6-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Go command
IBM i

Copyright IBM Corporation 2012

Figure 6-15. Example: Go command

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-19

Student Notebook

QCMD command interface


IBM i

Copyright IBM Corporation 2012

Figure 6-16. QCMD command interface

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.

6-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

QCMD messages
IBM i

Copyright IBM Corporation 2012

Figure 6-17. QCMD messages

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-21

Student Notebook

QCMD detailed messages


IBM i

Copyright IBM Corporation 2012

Figure 6-18. QCMD detailed messages

OL4912.1

Notes:
From the QCMD display, pressing F10 expands the display vertically to include related
messages.

6-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create a user profile (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 6-19. Create a user profile (1 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-23

Student Notebook

Create a user profile (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 6-20. Create a user profile (2 of 2)

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.

6-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create user profile: IBM i Navigator


IBM i

Copyright IBM Corporation 2012

Figure 6-21. Create user profile: IBM i Navigator

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

6-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

User profile properties


IBM i

Copyright IBM Corporation 2012

Figure 6-22. User profile properties

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-27

Student Notebook

- Limit some capabilities (LMTCPB *PARTIAL). Administrator must have at least


*PARTIAL. Limit some capabilities means that the user is not able to change the
program and current library on the sign-on display, whereas the menu can be
changed and commands can be run from a command line. Also, the user can
change the initial menu value with the Change Profile (CHGPRF) command).
- Limit capabilities (LMTCPB *YES).
Assistance level (ASTLVL) - System value QASTLVL, Basic user, Intermediate user,
Advanced user.
Display sign-on information (DSPSGNINF) - System value QDSPSGNINF, Display
sign-on information, Do not display sign-on information.
Limit device sessions (LMTDEVSSN) - System value QLMTDEVSSN, Limit to one
session, Do not limit.
Keyboard buffering (KBDBUF) - System value QKBDBUF, Allow keyboard buffering,
Do not allow keyboard buffering, Allow except for attention key.
User options (USROPT) - No user options, Show CL keywords (*CLKWD), Expert
mode (*EXPERT), Full help display versus a window (*HLPFULL), Print messages
(*PRTMSG), Roll key reverse (*ROLLKEY), Status msg control (*NOSTSMSG or
*STSMSG).
On the General information page, the administrator can specify the Current library for a
user. The administrator can also set the Maximum allowed storage (No maximum or n
KBytes), the Highest schedule priority, the Accounting code, the Job description (Use
default job description or Specify library and name of a job description), and the Home
directory (if the home directory does not exist at sign-on, the user will get Root assigned
as his home directory).
The Output page allows the administrator to specify the:
Print device (Printer assigned to workstation, System value QPRTDEV or Printer name)
Output queue (Queue assigned to workstation, Queue assigned to printer, Name and
library of OUTQ)
Message queue (User name or Name and library of message queue)
Message delivery (Notify, Break, Hold, Default reply on messages)
Message severity (00 to 99 - used only if notify or break is specified - indicates that only
messages at this level or higher will notify or break) for a user

6-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Fred signs on
IBM i

Copyright IBM Corporation 2012

Figure 6-23. Fred signs on

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).

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-29

Student Notebook

Unqualified versus qualified name


IBM i

Example: Calling a program.

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

...

/*USE LIBRARY LIST


/*USE PAYSTLIB

*/
*/

Job's Library List


QSYS
QHLPSYS
QUSRSYS
QRPG
QCBL
PAYLIB
QGPL
QTEMP
PAYTSTLIB

...

Copyright IBM Corporation 2012

Figure 6-24. Unqualified versus qualified name

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.

6-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

How your library list is constructed at sign on


IBM i

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

The job description can override system value QUSRLIBL.

Value entered on Sign On panel overrides value in profile.


Copyright IBM Corporation 2012

Figure 6-25. How your library list is constructed at sign on

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-31

Student Notebook

How to change your library after sign on


IBM i

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

Copyright IBM Corporation 2012

Figure 6-26. How to change your library after sign on

OL4912.1

Notes:
The commands in the visual are used to change the values in a job's library list.

6-32 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

In which library is an object created?


IBM i

Unqualified name on create command: (object-name only)

Does

No

QGPL

Yes

job have a
current
library?

Current
library

Qualified name on create command: (library-name/object-name)


Place in specified library.

Exceptions:
QSYS is always the library for these object types:
*LIB
*CTLD
*USRPRF
*DEVD
*MODD
*AUTL
*LIND
*COSD
*EDTD
Copyright IBM Corporation 2012

Figure 6-27. In which library is an object created?

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-33

Student Notebook

Use libraries to organize


IBM i

By application
For security
By user
For backup
By object type: Programs or files
By use: Production or test

Copyright IBM Corporation 2012

Figure 6-28. Use libraries to organize

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.

6-34 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Library related commands


IBM i

Create a library

(CRTLIB)

Delete a library

(DLTLIB)

Display a library

(DSPLIB)

Clear a library

(CLRLIB)

Change a library

(CHGLIB)

Add library list entry

(ADDLIBLE)

Remove library list entry

(RMVLIBLE)

Edit library list

(EDTLIBL)

Change library list

(CHGLIBL)

Change current library

(CHGCURLIB)

Display library list


Change system part of library list

(DSPLIBL)
(CHGSYSLIBL)

Change system values QUSRLIBL QSYSLIBL

(CHGSYSVAL)

Copyright IBM Corporation 2012

Figure 6-29. Library related commands

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.

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-35

Student Notebook

Machine exercises
IBM i

Create library and work with library list


Modify profile/work with job description/alternate Job

Copyright IBM Corporation 2012

Figure 6-30. Machine exercises

OL4912.1

Notes:

6-36 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. What two types of parameter formats are used on CL


commands?
2. In a 5250 session, what are two of the handiest keys when
dealing with a command you are not familiar with?

3. If you do not qualify an object name with a library name,


where will the system generally look for that object?

Copyright IBM Corporation 2012

Figure 6-31. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 6. Commands, profiles, and libraries

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-37

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Use IBM i commands in a job to manipulate both qualified and
unqualified objects
Describe the syntax of control language statements
Use the control language command Help
Use prompting to find and execute CL commands
Create and modify a user profile
Create and modify a job description
Explain the purpose of a library list
Use commands to modify a library list

Copyright IBM Corporation 2012

Figure 6-32. Unit summary

OL4912.1

Notes:

6-38 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 7. Introduction to IBM i security


What this unit is about
This unit provides an overview of the major components of IBM i
security.

What you should be able to do


After completing this unit, you should be able to:
Describe how user profiles, group profiles, authorization lists, and
system values affect security
Describe special and specific authorities
Describe how the system determines the authority a user has to an
object

How you will check your progress


Checkpoint questions

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe how user profiles, group profiles, authorization lists,
and system values affect security
Describe special and specific authorities
Describe how the system determines the authority a user has
to an object

Copyright IBM Corporation 2012

Figure 7-1. Unit objectives

OL4912.1

Notes:

7-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i security concepts


IBM i

IBM i security concepts

Copyright IBM Corporation 2012

Figure 7-2. IBM i security concepts

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-3

Student Notebook

Security is always active


IBM i

Signon:
Mary

Menu

Authority

Payroll
menu

Authority

PAYEDIT
program

Authority

Data rights
Read
Update
Add
Delete

Payroll
data

Copyright IBM Corporation 2012

Figure 7-3. Security is always active

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 7-4. Layers of security

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-5

Student Notebook

QSECURITY system value


IBM i

Copyright IBM Corporation 2012

Figure 7-5. QSECURITY system value

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

The system requires a password to sign on. All users have


access to all system resources.

30

The system requires a password to sign on and the user must


have specific authority to access objects and system resources.

40

The system requires a password to sign on and users must


have authority to access objects and system resources.

7-6

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Programs fail if they try to access objects through interfaces


that are not supported.

Uempty
50

The system requires a password to sign on and users must


have authority to access objects and system resources.
Programs fail if they try to pass unsupported parameter values
to supported interfaces or if they try to access objects through
interfaces that are not supported.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-7

Student Notebook

Components of IBM i security


IBM i

People
(Users)

Objects
(Resources)

User
profiles

Individual
objects

Job
descriptions

Libraries

Group
profiles

Authorization
lists

System values

Copyright IBM Corporation 2012

Figure 7-6. Components of IBM i security

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 7-7. User profile

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-9

Student Notebook

User profiles shipped with IBM i


IBM i

Customer use

Service personnel 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

Figure 7-8. User profiles shipped with IBM i

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.

7-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 7-9. System authority

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

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-11

Student Notebook

Special Authorities span the entire system.


1. Specific Authority includes object authority and data authority. Both relate to a single
object.
a. Object Authority
- *OBJOPR (Operational) - Look at the object's attributes and use the object as
specified by the data authorities.
- *OBJMGT (Management) - Specify security, to move or rename the object, and to
add members if the object is a database file.
- *OBJEXIST (Existence) - Control the object's existence and ownership.
- *OBJALTER (Alter) - Change the attributes of an object, such as adding or removing
triggers for a database file.
- *OBJREF (Reference) - Specify the object as the first level in a referential
constraint.
- *EXCLUDE (Exclude) - A user with *EXCLUDE authority to an object is specifically
denied all access to that object.
a. Data Authority
- *READ (Read) - Access the contents of the object.
- *ADD (Add) - Add entries to the object.
- *UPD (Update) - Change the contents of existing entries in the object.
- *DLT (Delete) - Remove entries from the object.
- *EXECUTE (Execute) - Run a program or search a library or directory.

7-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

System-defined authority combinations

*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

The Public is excluded

*LIBCRTAUT

Refer to the library for public authority

Copyright IBM Corporation 2012

Figure 7-10. System-defined authority combinations

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

7-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Group profile example


IBM i

GRPMGRS
SPCAUT(*JOBCTL)

PGM1 *PGM *USE


FILE1 *FILE *CHANGE
FILE2 *FILE *ALL
MICHELLE
SPCAUT(*SPLCTL)

CHRIS

FILE2 *FILE *EXCLUDE

FILE2 *FILE *READ

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

Copyright IBM Corporation 2012

Figure 7-11. Group profile example

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-15

Student Notebook

How multiple group profiles work


IBM i

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

Object type: *FILE


Users
DEPTA
DEPTB

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

Figure 7-12. How multiple group profiles work

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.

7-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 7-13. Authorization lists

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-17

Student Notebook

Managing authorization lists using IBM i


Navigator
IBM i

Copyright IBM Corporation 2012

Figure 7-14. Managing authorization lists using IBM i Navigator

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

7-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-19

Student Notebook

Sign On display
IBM i

Copyright IBM Corporation 2012

Figure 7-15. Sign On display

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.

7-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 7-16. Sign on processing (1 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 7-17. Sign on processing (2 of 2)

OL4912.1

Notes:

7-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Authority search process


IBM i

*ALLOBJ
Private
authorization list

User profile - Stop when


any authority is found

None
found

*ALLOBJ
Primary group
private
authorization list

Group profiles - Like user profile,


repeats for each group profile and
accumulate, stops
when sufficient authority is
accumulated

None
found

*PUBLIC - Used when no


authority is found for user
or groups

Object
authorization list
Insufficient

Adopted profiles - Used


when authority is insufficient

Adopted
Copyright IBM Corporation 2012

Figure 7-18. Authority search process

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 7-19. Authorization flow (1 of 2)

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.

7-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 7-20. Authorization flow (2 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-25

Student Notebook

EDTOBJAUT command
IBM i

Edit Object Authority


Object . . . . . . . :
Library . . . . . :
Object type . . . . :

EMPLOYEE
PAYLIB
*FILE

Owner . . . . . . . :
Primary group . . . :

COMPANYA
*NONE

Type changes to current authorities, press Enter.


Object secured by authorization list . . . . . . .: *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

Copyright IBM Corporation 2012

Figure 7-21. EDTOBJAUT command

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

7-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Display object authorities


IBM i

Edit Object Authority


Object . . . . . . . :
Library . . . . . :
Object type . . . . :

EMPLOYEE
PAYLIB
*FILE

Owner . . . . . . . :
Primary group . . . :

COMPANYA
*NONE

Type changes to current authorities, press Enter.


Object secured by authorization list .
*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

F6=Add new users


F=12Cancel

F10=Grant with reference object


F17=Top
F18=Bottom

Copyright IBM Corporation 2012

Figure 7-22. Display object authorities

OL4912.1

Notes:
By pressing F11, you can display the data authorities for users attempting to operate on an
object.

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-27

Student Notebook

Managing security using IBM i Navigator


IBM i

Copyright IBM Corporation 2012

Figure 7-23. Managing security using IBM i Navigator

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.

7-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i Navigator Security Configuration Wizard


IBM i

Asks general security


questions about your
IBM i
Recommends security
level and system value
settings
Can change the security
to the recommended
settings
Do not need to know all
about IBM i security to
secure the IBM i

Copyright IBM Corporation 2012

Figure 7-24. IBM i Navigator Security Configuration Wizard

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

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

7-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. What are three methods of controlling access to IBM i


objects?

2. Can a user profile use multiple group profiles?

3. What are two methods you can use to manage profiles,


authorities and authorization lists?

Copyright IBM Corporation 2012

Figure 7-25. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 7. Introduction to IBM i security

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-31

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe how user profiles, group profiles, authorization lists,
and system values affect security
Describe special and specific authorities
Describe how the system determines the authority a user has
to an object

Copyright IBM Corporation 2012

Figure 7-26. Unit summary

OL4912.1

Notes:

7-32 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 8. Control language programming


What this unit is about
Control language programming (CLP) is a powerful job control
language that provides far more functionality than simply controlling
work flow.
This unit describes the basic functions and coding of CLPs.

What you should be able to do


After completing this unit, you should be able to:
Code, compile, and execute a simple CL program
Explain the structure of a CL program
Describe OPM and ILE CALLs
Use the IBM i LPEX Editor
Use the IBM i Source Entry Utility Editor

How you will check your progress


Checkpoint questions
Machine exercises

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Code, compile, and execute a simple CL program
Explain the structure of a CL program
Describe OPM and ILE CALLs
Use the IBM i LPEX Editor
Use the IBM i Source Entry Utility Editor

Copyright IBM Corporation 2012

Figure 8-1. Unit objectives

OL4912.1

Notes:

8-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Structure and rules


IBM i

Structure and rules

Copyright IBM Corporation 2012

Figure 8-2. Structure and rules

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-3

Student Notebook

Why use control language programs


IBM i

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

Copyright IBM Corporation 2012

Figure 8-3. Why use control language programs

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

CL programs perform the following functions:


Simplify operations.
Control the execution sequence of programs in an application.
Interpret errors and exceptions that occur during program execution and bypass or
correct that error.
Set up an environment that is customized for a particular job by changing library lists,
default output queue, job date, and so forth.
Control the running of application programs.
Perform front end tasks for application programs.
Process the output of a DSPxxx command as input, in order to perform a utility function
(user tool).
The main purpose of CL programs is to control the running of the high-level language
programs of your application.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-5

Student Notebook

Control language program


IBM i

A set of CL commands arranged in a logical sequence to


perform one or more tasks:

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

Edited using IBM i Source Entry Utility editor or LPEX PC


Editor
Compiled on IBM i server; can be created using LPEX
Can CALL other HLL programs
Can receive and pass parameters (variables)

Can create in legacy environment (OPM) or Integrated


Language Environment (ILE)
Copyright IBM Corporation 2012

Figure 8-4. Control language program

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 8-5. CL program structure

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-7

Student Notebook

Command format
IBM i

Parameter
LABEL:

CRTLIB

Command
label

Command
name

LIB(A)

Keyword

Value

Keyword / Positional

Copyright IBM Corporation 2012

Figure 8-6. Command format

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

CL command syntax (1 of 4)
IBM i

[?] [label-name:] [library-name/] command-name [parameter-set]


[]...

Optional

?...

Prompt, like F4, for commands within programs


Precedes label or command

label-name. . .

Identify statement for branching, breakpoints


and traces

library-name. . .

Usually omitted since IBM commands are in QSYS


keyword value

LABEL1:

DSPLIB LIB(PAYLIB)

delimiter for label

no space
blank

OUTPUT(*PRINT)

blank

Copyright IBM Corporation 2012

Figure 8-7. CL command syntax (1 of 4)

OL4912.1

Notes:
Labels are only used when the command is in a CL program.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

*PRINT

Combination format
DSPLIB

PAYLIB

OUTPUT(*PRINT)

Copyright IBM Corporation 2012

Figure 8-8. CL command syntax (2 of 4)

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.

8-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

CL command syntax (3 of 4)
IBM i

continuation
within a program

quoted character string

variables
start with
and

MSG('Today' 's balance is ' *CAT &BAL) +

SNDUSRMSG

MSGTYPE(*INFO) /* Show balance */


predefined values
start with *

comment

Copyright IBM Corporation 2012

Figure 8-9. CL command syntax (3 of 4)

OL4912.1

Notes:
Notice that a single quote is represented by double quotes.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-11

Student Notebook

CL command syntax (4 of 4)
IBM i

/*

This is a full-line comment

*/

SNDRCVF DEV(*FILE) RCDFMT(MENUFMT)


SNDRCVF RCDFMT(MENUFMT)
SNDRCVF
*N
MENUFMT
Take default for positional parameter
generic name

DSPOBJD

OBJ(PAYLIB/PAY*)

OBJTYPE(*PGM *FILE)

Connects parts
of a qualified
name

Blank to separate
list elements

Copyright IBM Corporation 2012

Figure 8-10. CL command syntax (4 of 4)

OL4912.1

Notes:
Defaults for positional parameters are designated with an *N. A blank is used to separate
list elements (values) of a parameter.

8-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 8-11. Coding rules (1 of 2)

OL4912.1

Notes:
The first character of every variable name must be an &.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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*

Plus(+) or Minus (-)


At the end of a line that continues on a next line

*N
Indicates the absence of a positional parameter
Copyright IBM Corporation 2012

Figure 8-12. Coding rules (2 of 2)

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.

8-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Information Center
IBM i

Copyright IBM Corporation 2012

Figure 8-13. Information Center

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

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-15

Student Notebook

Basic CL programming
IBM i

Basic CL programming

Copyright IBM Corporation 2012

Figure 8-14. Basic CL programming

OL4912.1

Notes:

8-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Control work flow


IBM i

PGM

/ * THIS IS CL PROG - MSTRCL

*/

CALL PGMA

/ * COBOL PROG - STEP 1

*/

CALL PGMB

/ * CL PROG - STEP 2

*/

CALL PGMC

/ * RPG PROG - STEP 3

*/

ENDPGM

Copyright IBM Corporation 2012

Figure 8-15. Control work flow

OL4912.1

Notes:
This is an example of a very simple CL program.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-17

Student Notebook

CL program structure
IBM i

Description
Start of program

Program statement
PGM (Optional)

Declare file and variables


Program-Level
Monitor messages

DCLF (maximum of one)


DCL
DCL
MONMSG
MONMSG
IF
ELSE

IBM Commands

COMMAND
MONMSG
MONMSG

Command-Level
Monitor Messages
and/or
User commands
End of program

ENDPGM (optional)
Copyright IBM Corporation 2012

Figure 8-16. CL program structure

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.

8-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Declare CL variable (DCL)


IBM i

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( )

default ( ' 0 ' )

Examples:
(1) DCL &A *LGL VALUE ( ' 1 ' )
(2) DCL &B *CHAR 5 ABCD
(3) DCL &C *DEC (6 2) 543.21

Copyright IBM Corporation 2012

Figure 8-17. Declare CL variable (DCL)

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

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 8-18. Conditional execution

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.

8-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Relational and logical expressions


IBM i

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

Less Than or Equal To

<

*NL

Not Less Than

>

*NG

Not Greater Than

>=

*GE

Greater Than or Equal To

*NE

Not Equal To

&

*AND

*OR

True if both operands are '1'


True if both or either operand is '1'

*NOT
Copyright IBM Corporation 2012

Figure 8-19. Relational and logical expressions

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-21

Student Notebook

IF examples
IBM i

1. IF COND(&RESP *EQ 5) THEN(CALL PGM(CUSINQ))


IF (&RESP *EQ 5) CALL CUSINQ
2. IF COND(&AMT *GT 10000) THEN(CALL PGMBIG) ELSE CMD(CALL
PGMSMALL)
3. IF (&A*NE &B) RETURN

IF (&A =&B) ELSE RETURN


4. IF &IN03 RETURN

Copyright IBM Corporation 2012

Figure 8-20. IF examples

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 ________________________________________________________

8-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DO group
IBM i

IF COND(&A *GT 100)

THEN(DO)
CALL PGM1
CALL PGM2
ENDDO

ELSE CMD(DO)
CALL PGM3
CALL PGM4
ENDDO
CALL PGM5

Copyright IBM Corporation 2012

Figure 8-21. DO group

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-23

Student Notebook

Nested IF statements
IBM i

T
&RESP=1

&A = 5

&B = N

CALL PGMA

Keyword form:

IF

Positional form:

IF (&RESP = 1) IF (&A = 5) IF (&B = N) CALL PGMA

DO, ENDDO 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 */

One IF with a compound condition


IF COND((&RESP = 1)

COND(&RESP = 1) THEN(IF COND(&A = 5) THEN(IF +


COND(&B = N) THEN(CALL PGM(PGMA))))

*AND (&A = 5)

#1
#2
#3

*/
*/
*/

*AND (&B = N)) THEN(CALL PGMA)

Copyright IBM Corporation 2012

Figure 8-22. Nested IF statements

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.

8-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PGMB and/or PGMC and/or PGMD


IBM i

&A=&B

PGMB

IF COND(&A=&B) THEN(CALL PGM(PGMB))


IF COND(&A=&C) THEN(CALL PGM(PGMC))

&A=&C

PGMC

IF COND(&A=&D) THEN(CALL PGM(PGMD))

&A=&D

PGMD

F
Copyright IBM Corporation 2012

Figure 8-23. PGMB and/or PGMC and/or PGMD

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-25

Student Notebook

PGMB or PGMC or PGMD


IBM i

&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

Figure 8-24. PGMB or PGMC or PGMD

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.

8-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Branching within a program: GOTO


IBM i

START:

END:

PGM
SNDRCVF RCDFMT(MENU)
.
.
.
IF (&OPTION = 12) GOTO CMDLBL(END)
.
.
.
.
.
GOTO START
ENDPGM

Statement labels must be unique.


Copyright IBM Corporation 2012

Figure 8-25. Branching within a program: GOTO

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-27

Student Notebook

Using the DOUNTIL and DOWHILE commands


IBM i

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

Figure 8-26. Using the DOUNTIL and DOWHILE commands

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.

8-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-29

Student Notebook

Using the SELECT command


IBM i

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

Figure 8-27. Using the SELECT command

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-31

Student Notebook

Branching outside a program: TFRCTL


IBM i

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

Figure 8-28. Branching outside a program: TFRCTL

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.

8-32 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Communicating data to a program with CALL


IBM i

*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
.
.
.

Copyright IBM Corporation 2012

Figure 8-29. Communicating data to a program with CALL

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

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-33

Student Notebook

To pass a number as a character value, enclose it in single quotes: '12345'


If the receiving parameter is shorter in length than the sending parameter, results are
unpredictable. Character parameters, in this case, are truncated.
Since a program executing a TFRCTL command is removed from the program stack,
only variables passed to the program are allowed on the PARM parameter of a
TFRCTL command.
Caution: Carefully match the type, length, and decimal positions (if numeric) of the sending
and receiving parameters.
Most Common call errors:
- In some cases, decimal numbers are converted to a constant and passed as
(15 5), so use this default when possible.
- If you pass a character variable that is longer than the declared length of the
receiving variable, the receiving program can not access the excess length because
it was truncated.

8-34 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

HLL and CL programs may call each other


IBM i

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.

Copyright IBM Corporation 2012

Figure 8-30. HLL and CL programs may call each other

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-35

Student Notebook

CHGVAR: Arithmetic calculations


IBM i

CHGVAR VAR(CL-variable) VALUE(operand

+
/
*

operand)

CHGVAR VAR(&AMT) VALUE(-37.2)


CHGVAR VALUE(&COUNT + 1) VAR(&COUNT)
CHGVAR &AMT ((&PRICE - &DISCOUNT) * &QTY)

Copyright IBM Corporation 2012

Figure 8-31. CHGVAR: Arithmetic calculations

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.

8-36 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

CHGVAR: Conversion between *CHAR and *DEC


data types
IBM i

CHGVAR VAR(&A)

VALUE(&B)

Character Variable &A

Decimal Variable &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

Decimal Variable &B


LEN

Converted Result

LEN

Specified Value

52
50
52

123.10
123
-123.00

10
10
10

'bb+123.1bb'
'bbb+123.00'
'-123bbbbbb'

Copyright IBM Corporation 2012

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.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-37

Student Notebook

Concatenation
IBM i

Combining two *CHAR Variables or Values


&FIRST
MARY

&LAST
*CAT

DAVIS

&NAME
MARY

DAVIS

(|| is equivalent to *CAT)


MARY

*TCAT

DAVIS

MARYDAVIS

(|< is equivalent to *TCAT)


MARY

*BCAT

DAVIS

MARY DAVIS

(|> is equivalent to *BCAT)


Example:
CHGVAR

VAR(&NAME) VALUE(&FIRST

|>

&LAST)

Copyright IBM Corporation 2012

Figure 8-33. Concatenation

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.

8-38 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Data type conversion and concatenation example


IBM i

&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)

The following variables exist at the start of the program:


VARIABLE
&NAME
&CUSNUM
&CUSNUMA
&DAYS
&DAYSA

TYPE
*CHAR
*DEC
*CHAR
*DEC
*CHAR

LENGTH
25
(5 0)
5
(3 0)
3

VALUE
XYZ CORPORATION
54321
30
Copyright IBM Corporation 2012

Figure 8-34. Data type conversion and concatenation example

OL4912.1

Notes:
Decimal variables must be converted to character variables before they can be used in
message text.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-39

Student Notebook

Summary of using PDM


IBM i

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

Copyright IBM Corporation 2012

Figure 8-35. Summary of using PDM

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.

8-40 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercise
IBM i

Write a Basic CL Program.

Copyright IBM Corporation 2012

Figure 8-36. Machine exercise

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-41

Student Notebook

ILE versus OPM


IBM i

ILE versus OPM

Copyright IBM Corporation 2012

Figure 8-37. ILE versus OPM

OL4912.1

Notes:

8-42 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

OPM versus ILE


IBM i

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

Figure 8-38. OPM versus ILE

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

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

8-44 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Dynamic program call


IBM i

*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

Copyright IBM Corporation 2012

Figure 8-39. Dynamic program call

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

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-45

Student Notebook

ILE static call: Bind by copy


IBM i

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

Figure 8-40. ILE static call: Bind by copy

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

8-46 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

objects, we can chose another development approach which implements superior


modularity and reusability.
1. Compile each routine/procedure into a separate non-executable module object. Each
module is written in the most appropriate ILE language for the job.
2. Bind copies of modules together into an executable program object, and specify the
name of the module to initially receive control.
3. At run time, control remains within a single program object, thus circumventing the
overhead impact of a dynamic program call.
Please note that each copy of a module within each program has a separate virtual
address. Thus, if many programs that are normally in memory at the same moment each
frequently call the same module, then many copies of that module will be in memory at the
same moment.
Because dynamic program call remains an option, transition to ILE can be as gradual as
necessary, but as we modularize, the potential number of calls will very likely grow, and
thus, so to will the importance of the static call.
Indeed, it is recommended that we not immediately convert all Dynamic Program Calls to
static calls, but rather, identify the most heavily executed CALL operations; these are ideal
candidates for the ILE Static Call. For example, a call to a procedure/routine one or more
times for each detail record processed in a large database file, would be a good place to
start, because of the sheer volume of dynamic calls that would be eliminated.

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-47

Student Notebook

ILE static call: Bind by reference


IBM i

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

Copyright IBM Corporation 2012

Figure 8-41. ILE static call: Bind by reference

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.

8-48 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. When editing a CL program in SEU, what can you use to help


you with the command parameters?

2. How is a variable denoted in a CL program?

3. Which IBM i programming model is generally used in a


complex environment?

Copyright IBM Corporation 2012

Figure 8-42. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 8. Control language programming

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-49

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Code, compile, and execute a simple CL program
Explain the structure of a CL program
Describe OPM and ILE CALLs
Use the IBM i LPEX Editor
Use the IBM i Source Entry Utility Editor

Copyright IBM Corporation 2012

Figure 8-43. Unit summary

OL4912.1

Notes:

8-50 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 9. Basic message handling


What this unit is about
Message handling on the IBM i is discussed, including how to use user
and workstation message queues, and how to send and display
messages.

What you should be able to do


After completing this unit, you should be able to:
Describe the message facilities that are available
Send and display messages

How you will check your progress


Checkpoint questions
Machine exercise

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe the message facilities that are available
Send and display messages

Copyright IBM Corporation 2012

Figure 9-1. Unit objectives

OL4912.1

Notes:

9-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

An overview of message handling


IBM i

An overview of message handling

Copyright IBM Corporation 2012

Figure 9-2. An overview of message handling

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-3

Student Notebook

Basic message queue communication


IBM i

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

Copyright IBM Corporation 2012

Figure 9-3. Basic message queue communication

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

User and workstation message queues


IBM i

NOTIFY

QU
EU
E

QU
EU
E

User

Workstation

At Sign on

At Sign off

Allocated to user's job

Deallocated

Notify delivery mode

Hold delivery mode

Old message reset to new


messages

Additional messages held in


queue

Attention light on
Audible alarm sound

Copyright IBM Corporation 2012

Figure 9-4. User and workstation message queues

OL4912.1

Notes:
The user message queue associated with a user is usually named the same as the user
profile.

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-5

Student Notebook

Sending and displaying messages


IBM i

SNDMSG

MSG('Employee updates are complete.')

TOUSR(DAVIS)

OR

TOMSGQ(DSP01)

DAVIS

DSP01
Qu
eu
e

Qu
e ue

DSPMSG
MSGQ(*WRKUSR)

OR

MSGQ(*WRKSTN)

Copyright IBM Corporation 2012

Figure 9-5. Sending and displaying messages

OL4912.1

Notes:
Messages can be sent to the user message queue or to the display station message
queue.

9-6

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Sending an inquiry message


IBM i

SNDMSG

MSG('What is the volume id for the payroll backup tape?')

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

Figure 9-6. Sending an inquiry message

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.

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-7

Student Notebook

Displaying messages
IBM i

DSPMSG

MSGQ(*WRKUSR)
Work with Messages
System:

Message for:

DSP07
Qu
eue

Type options below, then press Enter.


4=Remove
5=Display details and reply
Opt
__

__

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

Copyright IBM Corporation 2012

Figure 9-7. Displaying messages

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

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-9

Student Notebook

Sending break messages


IBM i

SNDBRKMSG

MSG('Power down in 5 minutes')

TOMSGQ(DSP07)
Display Messages
System:
Queue . . .:
Library . :
Severity . :

DSP07

DSP07
QSYS
00

Program . . :
Library. . :
Delivery. . :

ATLANTA
*DSPMSG
*NOTIFY

Type reply (if required), press Enter.

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

Copyright IBM Corporation 2012

Figure 9-8. Sending break messages

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.

9-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Additional Message Information


IBM i

Selection or command
===> SDPMSG_________________________
___Command SDPMSG, in library *LIBL not found.

Additional Message Information

HELP

Message ID . . :
Message type . :
Date sent . . .:

CPD0030
Severity . . . : 30
Diagnostic
09/07/98 Time Sent . . .: 19:32:33

Message . . . .: Command SDPMSG, in library *LIBL not found.


Cause . . . . .: If a library was not specified, the command
was not found in the libraries in the library list. If library
was specified, the command was not found there.
Recovery . . . : Change the command name or correct the library
name, and then try the command again.

Press Enter to continue.


F3=Exit
F6=Print
F9=Display message details
F10=Display messages in job log
F12=Cancel
F21=Select assistance level

Copyright IBM Corporation 2012

Figure 9-9. Additional Message Information

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.

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-11

Student Notebook

Message handling using IBM i Navigator


IBM i

Message handling using IBM i Navigator

Copyright IBM Corporation 2012

Figure 9-10. Message handling using IBM i Navigator

OL4912.1

Notes:

9-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Sending messages
IBM i

Copyright IBM Corporation 2012

Figure 9-11. Sending messages

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.

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-13

Student Notebook

Additional message functions


IBM i

Copyright IBM Corporation 2012

Figure 9-12. Additional message functions

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.

9-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

View messages
IBM i

Copyright IBM Corporation 2012

Figure 9-13. View messages

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.

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-15

Student Notebook

Machine exercise
IBM i

Using Messages

Copyright IBM Corporation 2012

Figure 9-14. Machine exercise

OL4912.1

Notes:

9-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. Where do messages get sent on an IBM i?

2. How many message queues are on an IBM i?

3. What could you use to send an important message to users


on an IBM i?

Copyright IBM Corporation 2012

Figure 9-15. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 9. Basic message handling

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

9-17

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe the message facilities that are available
Send and display messages

Copyright IBM Corporation 2012

Figure 9-16. Unit summary

OL4912.1

Notes:

9-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 10. Creating reports and displays


What this unit is about
This unit describes the Screen and Report Designer tools which are
used on a Windows PC to design displays and reports.
As well, the source code that is used by the IBM i to create the display
and printer file objects, known as Data Description Specifications
(DDS), will be introduced.

What you should be able to do


After completing this unit, you should be able to:
Describe the purpose of DDS
Recognize DDS coding
Describe the features of the Screen/Report Designer
Use the Screen Designer to create 5250 screen display files
Use the Report Designer to create printer files

How you will check your progress


Checkpoint questions
Machine exercises

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe the purpose of DDS
Recognize DDS coding
Describe the features of the Screen/Report Designer
Use the Screen Designer to create 5250 screen display files
Use the Report Designer to create printer files

Copyright IBM Corporation 2012

Figure 10-1. Unit objectives

OL4912.1

Notes:

10-2 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Introduction to data description specifications


IBM i

Introduction to data
description specifications
Copyright IBM Corporation 2012

Figure 10-2. Introduction to data description specifications

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-3

Student Notebook

What is DDS?
IBM i

Data definition specifications


Used to:
Define database files, records, and fields
Define report layouts
Define display screens

Native IBM i data definition language

Copyright IBM Corporation 2012

Figure 10-3. What is DDS?

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Levels of DDS definition


IBM i

FILE ............................. File-level keywords


apply to all fields in
all formats
FORMAT ..................... Format-level keywords
apply to all fields in
format
FIELD
FIELD
FIELD

FORMAT
FIELD .................. Field-level keywords
- constant (for example, Headings)
FIELD - variable (from program for example, CustNo)
- system (for example, System date)

FORMAT

Copyright IBM Corporation 2012

Figure 10-4. Levels of DDS definition

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).

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-5

Student Notebook

DDS report example (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 10-5. DDS report example (1 of 2)

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).

10-6 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-7

Student Notebook

DDS report example (2 of 2)


IBM i

Record format name

Reference DB file/field definition

Reference
Field name

Literal
Space after

This field is defined in this PRTF


Copyright IBM Corporation 2012

Figure 10-6. DDS report example (2 of 2)

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.

10-8 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DDS screen file example


IBM i

3
Copyright IBM Corporation 2012

Figure 10-7. DDS screen file example

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

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-9

Student Notebook

Designing reports and displays


IBM i

Designing reports and displays

Copyright IBM Corporation 2012

Figure 10-8. Designing reports and displays

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.

10-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Screen/Report Designer
IBM i

Use Open With > Screen


Designer to open designer
for DSPF.
Use Open With > Report
Designer to open designer
for PRTF.
Currently no built-in DDS
designer, but built-in source
editor (LPEX) does support
DDS.

Copyright IBM Corporation 2012

Figure 10-9. Screen/Report Designer

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-11

Student Notebook

What is Screen Designer?


IBM i

Copyright IBM Corporation 2012

Figure 10-10. What is Screen Designer?

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.

10-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

WYSIWYG screen and report design


IBM i

Graphical design tools for:


Display files screens (Screen Designer)
Printer files reports (Report Designer)
Physical files databases

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

Explorer-like browsing File/Record/Field hierarchy


Copyright IBM Corporation 2012

Figure 10-11. WYSIWYG screen and report design

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-13

Student Notebook

Screen Designer interface


IBM i

Copyright IBM Corporation 2012

Figure 10-12. Screen Designer interface

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.

10-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Displaying groups of records


IBM i

Displays are usually composed of one or more record formats:

Heading
Prompt (record key)
Results (output of record chain/select)
Format keys

A screen is a logical collection of one or more records that


make up a screen or a report .
Screen Designer concept
Created using the Screen Designer
Saved with your display and printer file source as comments in the
generated source

Screens (and reports) created outside the Screen/Report


Designer will not have this information stored in the source.
Copyright IBM Corporation 2012

Figure 10-13. Displaying groups of records

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-15

Student Notebook

Trees, workbooks, and notebooks


IBM i

Toolbar

Palette

DDS tree

Design page

Utility
notebook
Copyright IBM Corporation 2012

Figure 10-14. Trees, workbooks, and notebooks

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.

10-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-17

Student Notebook

Designing a display file


IBM i

Ruler
Design page

Palette use
mouse to drag
and drop.

Use mouse to select,


move and resize.
Ruler
DEL key works

Copyright IBM Corporation 2012

Figure 10-15. Designing a display file

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.

10-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Using the display file palette


IBM i

Copyright IBM Corporation 2012

Figure 10-16. Using the display file palette

OL4912.1

Notes:
This visual shows the different palette items which can be used to design records and fields
in a display file.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-19

Student Notebook

Using the Properties view


IBM i

Copyright IBM Corporation 2012

Figure 10-17. Using the Properties view

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.

10-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Designing a report
IBM i

Copyright IBM Corporation 2012

Figure 10-18. Designing a report

OL4912.1

Notes:
The design page for a printer file is very similar to that of a screen.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-21

Student Notebook

Using the printer file palette


IBM i

Copyright IBM Corporation 2012

Figure 10-19. Using the printer file palette

OL4912.1

Notes:
The printer file palette, while similar to that of a display file, has some noticeable
differences.

10-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Working with Screen Designer


IBM i

How do you use Screen Designer?


Drag and drop elements from the palette to the design page
Allows you to create records and create and position fields within the
record

Use the Properties notebook to modify the attributes of DDS


elements (size, type, position, and so forth)
Create report definitions that consist of one or more records

Copyright IBM Corporation 2012

Figure 10-20. Working with Screen Designer

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-23

Student Notebook

Verifying your design


IBM i

Error messages
Copyright IBM Corporation 2012

Figure 10-21. Verifying your design

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Summary of using Screen/Report Designer


IBM i

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

Copyright IBM Corporation 2012

Figure 10-22. Summary of using Screen/Report Designer

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.

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-25

Student Notebook

Machine exercises
IBM i

Editing display file source


Designing and creating display screens
Using Screen Designer to create reports

Copyright IBM Corporation 2012

Figure 10-23. Machine exercises

OL4912.1

Notes:

10-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Summary of Screen/Report Designer features


IBM i

Full graphical user interface


Screens/Reports organize records.
DDS tree shows a hierarchy of DDS elements.
Workbook shows design, source, and verify pages.
Source view opens a DDS editor.
Utilities notebook shows selected DDS, keywords, comments,
and error list pages.
Property notebook shows named fields and records.
Styles can be set for multiple objects.
Program Verify checks DDS syntax.
Checkpoints provide a snapshot of DDS source for backing up
to the previous design point.
Copyright IBM Corporation 2012

Figure 10-24. Summary of Screen/Report Designer features

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-27

Student Notebook

Checkpoint
IBM i

1. What can be defined using DDS on an IBM i?

2. What are the three hierarchical levels in a DDS file?

3. What tools can be used to create DDS?

Copyright IBM Corporation 2012

Figure 10-25. Checkpoint

OL4912.1

Notes:

10-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe the purpose of DDS
Recognize DDS coding
Describe the features of the Screen/Report Designer
Use the Screen Designer to create 5250 screen display files
Use the Report Designer to create printer files

Copyright IBM Corporation 2012

Figure 10-26. Unit summary

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 10. Creating reports and displays

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

10-29

Student Notebook

10-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 11. IBM DB2 for i


What this unit is about
The concepts of a relational database are introduced, followed by a
history of the IBM i database, from data description specifications to
SQL.
Externally-defined files are described and compared to the more
traditional structures of earlier systems. Physical files (tables), logical
files (views and indexes), members, field reference files, data
dictionaries, libraries, and schema are also discussed.
Creating and maintaining a database using DDS and CL commands
are contrasted to using SQL.

What you should be able to do


After completing this unit, you should be able to:
Describe the characteristics of a relational database
Describe physical and logical files
Describe SQL tables, views, and indexes
Differentiate libraries from schema
Define the purposes of system and SQL catalogs
List several relational database operations

How you will check your progress


Checkpoint questions

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Describe the characteristics of a relational database
Describe physical and logical files
Describe SQL tables, views, and indexes
Differentiate libraries from schema
Define the purposes of system and SQL catalogs
List several relational database operations

Copyright IBM Corporation 2012

Figure 11-1. Unit objectives

OL4912.1

Notes:

11-2 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Introduction to relational database


IBM i

Introduction to relational database

Copyright IBM Corporation 2012

Figure 11-2. Introduction to relational database

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-3

Student Notebook

IBM DB2 for i


IBM i

Optimizer

Lock manager

Integrity and recovery

11 12 1
10
2
3
9
4
8
7 6 5

Security

Logging

Continuous operation

Copyright IBM Corporation 2012

Figure 11-3. IBM DB2 for i

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

11-4 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Working with a relational DBMS


IBM i

Selection: Subsetting the records/rows of a file/table


Sequence: Of the records/rows
Projection: Subsetting the fields/columns of a file/table
Union: Two or more tables with identical arrangement of fields/columns
merged vertically. Conceptually, the resulting file/table is the same
width, but has more records/rows.
Join: Two or more files/tables with common fields/columns whose
records/rows are combined horizontally, based on the common
fields/columns, to make new rows, each of which are a combination of
the fields/columns of the files. Conceptually (in the simplest case), the
resulting file/table has the same number of records/rows, but is wider.

Copyright IBM Corporation 2012

Figure 11-4. Working with a relational DBMS

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.

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-5

Student Notebook

IBM DB2 for i relational database


IBM i

Fully integrated in IBM i since 1988


Database was named DB2 UDB beginning 1999
Includes SQL and IBM i native interfaces
Integrated database
Used by i functions as well as end-user applications
Applications developed on one IBM i can be restored and run
on another IBM i
A DB2 object is managed the same as other i objects
i includes security and transaction management components
used by DB2

Copyright IBM Corporation 2012

Figure 11-5. IBM DB2 for i relational database

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)

11-6 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-7

Student Notebook

IBM DB2 for i is integrated


IBM i

IBM i
DB2
Interactive
Multimedia
Systems Management
TIMI
Licensed Internal Code
IBM DB2 for i
Security
Communications
Transaction Management

IBM i Hardware

Copyright IBM Corporation 2012

Figure 11-6. IBM DB2 for i is integrated

OL4912.1

Notes:
This visual shows how the database is an integral part of the system.

11-8 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Traditional program data definition


IBM i

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

Changing a file's format requires changing


data definition in each program
Copyright IBM Corporation 2012

Figure 11-7. Traditional program data definition

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.

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-9

Student Notebook

Externally-described IBM i file


IBM i

Program 1
CRTxxxPGM

Data Definition

Data
Definition

Data
Records

Program 2
Data Definition

Database File
CLASSPF

Program 3
Data Definition

Copyright IBM Corporation 2012

Figure 11-8. Externally-described IBM i file

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.

11-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Externally-described file example


IBM i

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

Copyright IBM Corporation 2012

Figure 11-9. Externally-described file example

OL4912.1

Notes:
At program creation (compilation) time, the data definition is copied into the program
object, that is, the executable program.

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-11

Student Notebook

Externally-described file components


IBM i

Object type: *FILE


Type of file: Physical

File Name: CLASSPF


Column Heading
Crs Code
Course Title
Ins No
Instr Name

L001:1 L103:2 L211:3 L214:4 L303:5

L001
L103
L211
L214
L303

ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE

001
002
003
004
005

DANTE
HIGGINS
PICASSO
HOMER
TSUNG

Access path (optional)


not available
with SQL

Data

Member CLASSPF

Record Format: CLASSREC


Field
Data Type Field Length
CRSCODE
CHAR
4
CRSTITLE
CHAR
7
INSTNO
CHAR
3
INSTLNAME CHAR
7

File Description

Copyright IBM Corporation 2012

Figure 11-10. Externally-described file components

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.

11-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Relational database operations


IBM i

Selection: Subset rows of a table.


Sequence: Sequence the rows of a table.
Projection: Subset columns of a table.
Union: Create a set of two or more tables with identical
arrangement of columns merged vertically.
Join: Create a set of two or more files/tables with common
columns whose rows are combined horizontally, based on the
common columns.
Copyright IBM Corporation 2012

Figure 11-11. Relational database operations

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.

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-13

Student Notebook

IBM i logical file


IBM i

Physical file

Logical file

Description

Description

Access path

Access path

Data

yObject = *FILE file


yType: Logical
ySQL views and indexes are also logical files

Copyright IBM Corporation 2012

Figure 11-12. IBM i logical file

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.

11-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Legacy coding to define database file CLASSPF


IBM i

Copyright IBM Corporation 2012

Figure 11-13. Legacy coding to define database file CLASSPF

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.

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-15

Student Notebook

SQL versus native IBM i DB object terminology


IBM i

Physical file
SQL: Table

L001
L103
L211
L214
L303

Object type: *FILE


File type: (Native) Physical file

ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE

001
002
003
004
005

DANTE
HIGGINS
PICASSO
HOMER
TSUNG

Native: Records
SQL: Rows

Native: Fields
SQL: Columns

Copyright IBM Corporation 2012

Figure 11-14. SQL versus native IBM i DB object terminology

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.

11-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

More terminology
IBM i

TABLE

Native IBM i term


FILE

ROW

RECORD

COLUMN

FIELD

VIEW

LOGICAL FILE

INDEX

KEYED LOGICAL FILE

COLLECTION

LIBRARY

Industry terms

DB2 for i terms

SCHEMA

SCHEMA

LOG

JOURNAL

ISOLATION LEVEL

COMMITMENT CONTROL
LEVEL

SQL term

Copyright IBM Corporation 2012

Figure 11-15. More terminology

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.

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-17

Student Notebook

IBM DB2 for i offers flexibility


IBM i

Access using SQL or native tools


Create tables/files using SQL or native DDS

Copyright IBM Corporation 2012

Figure 11-16. IBM DB2 for i offers flexibility

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)

11-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

3. Access data using different interfaces.


a. Interactive SQL on IBM i
b. IBM i Navigator Run SQL Scripts
c. Query for IBM i

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-19

Student Notebook

Schema, libraries, and field reference files


IBM i

Library

Created using CRTLIB


Object type: *LIB
Contains PF, LF, source code
Can be accessed using native or SQL

Schema

Created using SQL CREATE SCHEMA


Includes journal, journal receiver, SQL Catalog
Object type: *LIB
Contains tables, views, indexes, source code
Can be accessed using native or SQL

Field Reference File

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

Copyright IBM Corporation 2012

Figure 11-17. Schema, libraries, and field reference files

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.

11-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

SQL catalogs
IBM i

Copyright IBM Corporation 2012

Figure 11-18. SQL catalogs

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

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-21

Student Notebook

Native files and SQL objects coexist


IBM i

Tables, views, and programs can be created, copied, or restored


to any IBM i *LIB (CRTLIB or CREATE SCHEMA).
Placing a *FILE PF in an SQL SCHEMA results in addition to
SQL catalogs.
Placing an SQL table in a regular IBM i *LIB results in no
change; no SQL catalogs are created.

Copyright IBM Corporation 2012

Figure 11-19. Native files and SQL objects coexist

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.

11-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

IBM i and the DB2 family


IBM i

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

Figure 11-20. IBM i and the DB2 family

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/

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-23

Student Notebook

Checkpoint
IBM i

1. What are the five main operations that are performed on


relational data?

2. Describe the primary difference between tables/physical files


and views/logical files.

3. Are files created using DDS and SQL compatible on the IBM
i?

Copyright IBM Corporation 2012

Figure 11-21. Checkpoint

OL4912.1

Notes:

11-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit summary
IBM i

Having completed this unit, you should be able to:


Describe the characteristics of a relational database
Describe physical and logical files
Describe SQL tables, views, and indexes
Differentiate libraries from schema
Define the purposes of system and SQL catalogs
List several relational database operations

Copyright IBM Corporation 2012

Figure 11-22. Unit summary

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 11. IBM DB2 for i

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

11-25

Student Notebook

11-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 12. Accessing the IBM i database using SQL


and IBM i Navigator
What this unit is about
This unit shows how to define and create a database case study using
SQL and IBM i Navigator.

What you should be able to do


After completing this unit, you should be able to:
Define the meaning of key relational database (SQL) terms
Use SQL and IBM i Navigator to create schema, tables, views, and
indexes
Use Run SQL Scripts to create simple SQL statements

How you will check your progress


Checkpoint questions
Machine exercise

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

After completing this unit, you should be able to:


Define the meaning of key relational database (SQL) terms
Use SQL and IBM i Navigator to create schema, tables, views,
and indexes
Use Run SQL Scripts to create simple SQL statements

Copyright IBM Corporation 2012

Figure 12-1. Unit objectives

OL4912.1

Notes:

12-2 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

An introduction to SQL
IBM i

An introduction to SQL

Copyright IBM Corporation 2012

Figure 12-2. 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

Developed originally by IBM


De facto industry standard
Define and maintain database
Create and maintain data
Query the database reports
Embedded in high-level language

Introducing SQL,
Structured Query Language
Copyright IBM Corporation 2012

Figure 12-3. Introducing SQL

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

12-4 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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 provides run-time support for existing SQL applications.


Query Management (not an end-user tool)
Call-level interface
APIs
RUNSQLSTM to run SQL statements in source members

DB2 Query Manager and SQL Development Kit


For SQL application development
Query Manager (end-user tool)
HLL precompilers
Interactive SQL

IBM i Navigator
GUI interface
Run SQL scripts
Copyright IBM Corporation 2012

Figure 12-4. Using SQL

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).

12-6 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Types of SQL statements


IBM i

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

Copyright IBM Corporation 2012

Figure 12-5. Types of SQL statements

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

The IBM i supports the following statements:


- GRANT PACKAGE
- GRANT PROCEDURE
- GRANT TABLE
- REVOKE PACKAGE
- REVOKE PROCEDURE
- REVOKE TABLE
DYNAMIC - SQL can be dynamically prepared in order to improve execution.
The IBM i supports the following DYNAMIC statements:
- DESCRIBE
- EXECUTE
- EXECUTE IMMEDIATE
- PREPARE
MISCELLANEOUS - these statements allow access to databases.
The IBM i supports the following as MISCELLANEOUS statements:
- BEGIN DECLARE SECTION
- CALL
- CONNECT
- DECLARE PROCEDURE
- DECLARE STATEMENT
- DECLARE VARIABLE
- DESCRIBE TABLE
- DISCONNECT
- END DECLARE SECTION
- INCLUDE
- RELEASE
- SET CONNECTION
- SET OPTION
- SET RESULT SETS
- SET TRANSACTION
- WHENEVER

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

5250 interactive SQL interface


IBM i

Component of SQL Development Kit


Interactive and immediate execution of SQL statements
SQL entered from 5250 interactive command interface
Statements prepared and executed dynamically
Results displayed to user

Invoked using STRSQL command


Similar to QCMD command entry
Prompting (F4) and help available
Can save session statements to source for use as RUNSQLSTM script

Also invoked using the STRQM (Start Query Manager) command


Query/400-like interface
Can generate SQL
Can save and manage queries
Copyright IBM Corporation 2012

Figure 12-6. 5250 interactive SQL interface

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.

12-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example SQL query using STRSQL (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-7. Example SQL query using STRSQL (1 of 2)

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.

12-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example SQL query using STRSQL (2 of 2)


IBM i

Result set

Copyright IBM Corporation 2012

Figure 12-8. Example SQL query using STRSQL (2 of 2)

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

Closing an interactive SQL session


IBM i

Copyright IBM Corporation 2012

Figure 12-9. Closing an interactive SQL session

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.

12-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

SQL source member


IBM i

Copyright IBM Corporation 2012

Figure 12-10. SQL source member

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

Other useful SQL statements


IBM i

INSERT, CREATE, UPDATE - Rows in a table


insert into OL38V3COL.EMP_ACT values(
'000010', 'AD3100', 10, 0.50, '1982-01-01', '1982-07-01');

DROP - Schema, table, view


drop table OL38V3COL.DEPARTMENT;

ALTER - Add, change, or delete a column definition


alter table equipment
alter column equip-desc
set data type varchar(60)

Copyright IBM Corporation 2012

Figure 12-11. Other useful SQL statements

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Database case study


IBM i

Database case study

Copyright IBM Corporation 2012

Figure 12-12. Database case study

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

Tables used in the school database case study


IBM i

CLASSPF - classes available in which students have enrolled


Column
CRSCODE
CRSTITLE
INSTNO
INSTLNAME

Data Type
CHAR
CHAR
CHAR
CHAR

Length
4
7
3
7

Description
Course Code
Course Title
Instructor Number
Instructor Last Name

Create an index over the CLASSPF table using the CRSCODE


column
GRADEPF98 - grades recorded for each student in each class
GRADEPF99 - grades recorded for each student in each class
Column
CRSCODE
CLSYR
CLSQTR
STUDNO
STUDLNAME
GRADE

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

Copyright IBM Corporation 2012

Figure 12-13. Tables used in the school database case study

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.

12-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Required case study results


IBM i

1. Result set of grades for one course, ordered in ascending


sequence by student number
2. Result set of all grades for the two years available
3. Result set of course grades for each student ordered by
grade descending within student including columns from
CLASSPF and the 1999 GRADE tables
4. Create indexes:
Over the CLASSPF table using the CRSCODE column
Over the GRADEPF98 table using the STUDNO column
Over the GRADEPF99 table using the STUDNO column
Copyright IBM Corporation 2012

Figure 12-14. Required case study results

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

CREATE SCHEMA FACSLIB2


Repository
Tables
Views
Indexes

Created as an IBM i Library


Also created automatically in Schema
SQL Catalog
Journal
Journal Receiver

Copyright IBM Corporation 2012

Figure 12-15. Creating a schema

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.

12-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Creating a schema using IBM i Navigator


(1 of 2)
IBM i

Copyright IBM Corporation 2012

Figure 12-16. Creating a schema using IBM i Navigator (1 of 2)

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

Creating a schema using IBM i Navigator


(2 of 2)
IBM i

Copyright IBM Corporation 2012

Figure 12-17. Creating a schema using IBM i Navigator (2 of 2)

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).

12-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Objects in schema
IBM i

Copyright IBM Corporation 2012

Figure 12-18. Objects in schema

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

Create CLASSPF table (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-19. Create CLASSPF table (1 of 2)

OL4912.1

Notes:
To create a new table in the FACSLIB2 schema:
1. Right-click FACSLIB2.
2. Click New > Table > Table.

12-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create CLASSPF table (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-20. Create CLASSPF table (2 of 2)

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

Copyright IBM Corporation 2012

Figure 12-21. Define columns (1 of 2)

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.

12-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Define columns (2 of 2)
IBM i

Copyright IBM Corporation 2012

Figure 12-22. Define columns (2 of 2)

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.

12-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Column naming rules


IBM i

First character of column name must be A through Z,#,@,$.


Subsequent characters can be A-Z,#,@,$,-,0-9.
Column name is maximum 30 characters in length.
Names are upper case.
Cannot:
Use any reserved words
Begin names (first two characters) with:
SQ
RDI
DSN
Copyright IBM Corporation 2012

Figure 12-23. Column naming rules

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

Adding column headings


IBM i

Copyright IBM Corporation 2012

Figure 12-24. Adding column headings

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.

12-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Run SQL Scripts


IBM i

Copyright IBM Corporation 2012

Figure 12-25. Run SQL Scripts

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

Resulting SQL: LABEL ON statement


IBM i

Copyright IBM Corporation 2012

Figure 12-26. Resulting SQL: LABEL ON statement

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.

12-32 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create index for CLASSPF on column CRSCODE


(1 of 2)
IBM i

Copyright IBM Corporation 2012

Figure 12-27. Create index for CLASSPF on column CRSCODE (1 of 2)

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.

12-34 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create index for CLASSPF on column CRSCODE


(2 of 2)
IBM i

Copyright IBM Corporation 2012

Figure 12-28. Create index for CLASSPF on column CRSCODE (2 of 2)

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

Create table GRADEPF99 (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-29. Create table GRADEPF99 (1 of 2)

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.

12-36 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create table GRADEPF99 (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-30. Create table GRADEPF99 (2 of 2)

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.

12-38 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create table GRADEPF98 (1 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 12-31. Create table GRADEPF98 (1 of 3)

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

Create table GRADEPF98 (2 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 12-32. Create table GRADEPF98 (2 of 3)

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.

12-40 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create table GRADEPF98 (3 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 12-33. Create table GRADEPF98 (3 of 3)

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

New Table: GRADEPF98 final review


IBM i

Copyright IBM Corporation 2012

Figure 12-34. New Table: GRADEPF98 final review

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.

12-42 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

GRADEPF98 in FACSLIB2
IBM i

Copyright IBM Corporation 2012

Figure 12-35. GRADEPF98 in FACSLIB2

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

Review the newly created table GRADEPF98


IBM i

Copyright IBM Corporation 2012

Figure 12-36. Review the newly created table GRADEPF98

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.

12-44 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Display table data: GRADEPF99


IBM i

Copyright IBM Corporation 2012

Figure 12-37. Display table data: GRADEPF99

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

Insert new rows in table GRADEPF99


IBM i

Copyright IBM Corporation 2012

Figure 12-38. Insert new rows in table GRADEPF99

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.

12-46 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create index for table GRADEPF99


IBM i

Copyright IBM Corporation 2012

Figure 12-39. Create index for table GRADEPF99

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

Create index GRADEPF99I (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-40. Create index GRADEPF99I (1 of 2)

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.

12-48 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create index GRADEPF99I (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-41. Create index GRADEPF99I (2 of 2)

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

Assign permissions: Grant/Revoke authorities


IBM i

Copyright IBM Corporation 2012

Figure 12-42. Assign permissions: Grant/Revoke authorities

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.

12-50 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Where are we?


IBM i

Created tables and indexes:

Copyright IBM Corporation 2012

Figure 12-43. Where are we?

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

Using SQL to complete the case study


IBM i

Using SQL to complete


the case study

Copyright IBM Corporation 2012

Figure 12-44. Using SQL to complete the case study

OL4912.1

Notes:

12-52 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

SELECT statement
IBM i

SELECT

....
FROM ....
WHERE ....
GROUP BY ....
HAVING ....
ORDER BY ....

Fine
William
Goes
Home
Often

Clauses must be used in this order.

Output of SELECT = Result Set.

Copyright IBM Corporation 2012

Figure 12-45. SELECT statement

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.

12-54 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Case study requirement


IBM i

Produce a result set of grades for one course, ordered in


ascending sequence by student number.
Course desired is L0001.
How should we construct the SELECT statement?

Copyright IBM Corporation 2012

Figure 12-46. Case study requirement

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

Executing the SQL SELECT statement (1 of 5)


IBM i

Copyright IBM Corporation 2012

Figure 12-47. Executing the SQL SELECT statement (1 of 5)

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.

12-56 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Executing the SQL SELECT statement (2 of 5)


IBM i

Copyright IBM Corporation 2012

Figure 12-48. Executing the SQL SELECT statement (2 of 5)

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

Executing the SQL SELECT statement (3 of 5)


IBM i

Copyright IBM Corporation 2012

Figure 12-49. Executing the SQL SELECT statement (3 of 5)

OL4912.1

Notes:
We enter our SQL statement.

12-58 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Executing the SQL SELECT statement (4 of 5)


IBM i

Copyright IBM Corporation 2012

Figure 12-50. Executing the SQL SELECT statement (4 of 5)

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

Executing the SQL SELECT statement (5 of 5)


IBM i

Copyright IBM Corporation 2012

Figure 12-51. Executing the SQL SELECT statement (5 of 5)

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.

12-60 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Case study requirement: Union of grades (1 of 3)


IBM i

Result set of all grades for the two years available


GRADEPF98 and GRADEPF99
Need a UNION of both

Copyright IBM Corporation 2012

Figure 12-52. Case study requirement: Union of grades (1 of 3)

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

Case study requirement: Union of grades (2 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 12-53. Case study requirement: Union of grades (2 of 3)

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.

12-62 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Case study requirement: Union of grades (3 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 12-54. Case study requirement: Union of grades (3 of 3)

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

Case study requirement: Select data from related


tables
IBM i

Requirement

Result set of course grades for each student ordered by course within
student including columns from CLASSPF and the 1999 GRADE table

What does this mean?

Result set derived from two tables


CRSCODE is common column (match on CRSCODE)
Answer is to code an SQL JOIN!
Copyright IBM Corporation 2012

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

12-64 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Combining data from tables using JOIN


IBM i

Employee table and department table have common column


Can use common column to JOIN tables and extract data from both
Creates a single result set
EMPLOYEE
Lastname
Workdept
Haas
A00
Thompson
B01
Kwan
C01
Geyer
E01
Stern
D11
Pulaski
D21
Henderson
E11
Spenser
E21
Lucchesi
A00
Haas
Lucchesi
O Connell
Thompson
Kwan
Quintana
Nicholls
Stern
Adamson
Pianka
Yoshimura
Scoutten

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

SPIFFY Computer Service Div.


SPIFFY Computer Service Div.
SPIFFY Computer Service Div.
Planning
Information Center
Information Center
Information Center
Manufacturing Systems
Manufacturing Systems
Manufacturing Systems
Manufacturing Systems
Manufacturing Systems

Copyright IBM Corporation 2012

Figure 12-56. Combining data from tables using JOIN

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

Case study JOIN (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-57. Case study JOIN (1 of 2)

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? __________________________
_____________________________________________________________________

12-66 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Which columns are extracted from the GRADEPF99 table:?_______________________


_____________________________________________________________________
What is the column that is used as the common column in both tables?________________
Why must it be qualified?__________________________________________________

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

Case study JOIN (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 12-58. Case study JOIN (2 of 2)

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.

12-68 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercise
IBM i

Working with the database using IBM i Navigator

Copyright IBM Corporation 2012

Figure 12-59. Machine exercise

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?

3. What SQL statement can you use to retrieve data (result


sets) from tables?

Copyright IBM Corporation 2012

Figure 12-60. Checkpoint

OL4912.1

Notes:

12-70 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit summary
IBM i

Having completed this unit, you should be able to:


Define the meaning of key relational database (SQL) terms
Use SQL and IBM i Navigator to create schema, tables, views,
and indexes
Use Run SQL Scripts to create simple SQL statements

Copyright IBM Corporation 2012

Figure 12-61. Unit summary

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

12-72 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 13. Defining database files using DDS


What this unit is about
In this unit, the school case study is explored further. Rather than
using SQL and IBM i Navigator, the native IBM i features are used.
Coding DDS for physical and logical files as well as a field reference
file is covered.

What you should be able to do


After completing this unit, you should be able to:
Code DDS for physical and logical files
Use a field reference file to define a physical file

How you will check your progress


Checkpoint questions
Desk exercise

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Code DDS for physical and logical files
Use a field reference file to define a physical file

Copyright IBM Corporation 2012

Figure 13-1. Unit objectives

OL4912.1

Notes:

13-2 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Creating IBM i physical and logical files


IBM i

Creating IBM i physical


and logical files

Copyright IBM Corporation 2012

Figure 13-2. Creating IBM i physical and logical files

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-3

Student Notebook

Physical files used in the school database case


study
IBM i

CLASSPF - classes available in which students have enrolled


Column
******
CRSCODE
CRSTITLE
INSTNO
INSTLNAME

Data Type
*********
CHAR
CHAR
CHAR
CHAR

Length
******
4
7
3
7

Description
***********
Course Code
Course Title
Instructor Number
Instructor Last Name

CRSCODE column is the key


Record format CLASSREC
GRADEPF98 - grades recorded for each student in each class and GRADEPF99
Column
******
CRSCODE
CLSYR
CLSQTR
STUDNO
STUDLNAME
GRADE

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

Record format GRADEREC


Copyright IBM Corporation 2012

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.

13-4 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Logical files used in the school database case


study (1 of 2)
IBM i

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-5

Student Notebook

Logical files used in the school database case


study (2 of 2)
IBM i

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.

13-6 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corporation 2012

Figure 13-6. Physical file

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-7

Student Notebook

DSPFD CLASSPF (1 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-7. DSPFD CLASSPF (1 of 10)

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.

13-8 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD CLASSPF (2 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-8. DSPFD CLASSPF (2 of 10)

OL4912.1

Notes:
Note that the maximum number of members for a physical file is one.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-9

Student Notebook

DSPFD CLASSPF (3 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-9. DSPFD CLASSPF (3 of 10)

OL4912.1

Notes:

13-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD CLASSPF (4 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-10. DSPFD CLASSPF (4 of 10)

OL4912.1

Notes:
Remember that our school database study required that we have a record key. It is noted in
this visual.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-11

Student Notebook

DSPFD CLASSPF (5 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-11. DSPFD CLASSPF (5 of 10)

OL4912.1

Notes:
Note that the member name is the same as the name of the physical file.

13-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD CLASSPF (6 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-12. DSPFD CLASSPF (6 of 10)

OL4912.1

Notes:
There are five records currently in the file.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-13

Student Notebook

DSPFD CLASSPF (7 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-13. DSPFD CLASSPF (7 of 10)

OL4912.1

Notes:

13-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD CLASSPF (8 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-14. DSPFD CLASSPF (8 of 10)

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-15

Student Notebook

DSPFD CLASSPF (9 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-15. DSPFD CLASSPF (9 of 10)

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.

13-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD CLASSPF (10 of 10)


IBM i

Copyright IBM Corporation 2012

Figure 13-16. DSPFD CLASSPF (10 of 10)

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-17

Student Notebook

DSPFFD CLASSPF (1 of 3)
IBM i

Copyright IBM Corporation 2012

Figure 13-17. DSPFFD CLASSPF (1 of 3)

OL4912.1

Notes:
Some of the same information provided by DSPFFD is repeated by this command.

13-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFFD CLASSPF (2 of 3)
IBM i

Copyright IBM Corporation 2012

Figure 13-18. DSPFFD CLASSPF (2 of 3)

OL4912.1

Notes:
Note the field definitions here and continued on next visual.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-19

Student Notebook

DSPFFD CLASSPF (3 of 3)
IBM i

Copyright IBM Corporation 2012

Figure 13-19. DSPFFD CLASSPF (3 of 3)

OL4912.1

Notes:
This visual shows the last of the defined fields.

13-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Multiple member physical file


IBM i

File name: CLASSPF


R

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

Figure 13-20. Multiple member physical file

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-21

Student Notebook

Source physical file


IBM i

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

Figure 13-21. Source physical file

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.

13-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Types of source in source physical file


IBM i

Commands
Database files
Display files
Report (Printer) files
Menus
Programs (COBOL, RPG, C, and so forth)

Source
Physical File

Copyright IBM Corporation 2012

Figure 13-22. Types of source in 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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-23

Student Notebook

Naming convention for source PFs


IBM i

IBM Suggested Names:


QCBLSRC/QLBLSRC
QCBLLESRC

COBOL
ILE COBOL

QCLSRC

CONTROL LANGUAGE

QCMDSRC

COMMAND DEFINITION

QDDSSRC

DATA DESCRIPTION SPECIFICATIONS

QMNUSRC

MENUS

QRPGLESRC
QRPGSRC

ILE RPG (RPG IV syntax)


RPG (RPG III syntax)

Copyright IBM Corporation 2012

Figure 13-23. Naming convention for source PFs

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.

13-24 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Creating a source file


IBM i

CRTSRCPF FILE(FACxx/QDDSSRC)
RCDLEN(92)
MBR(*NONE)
TEXT('DDS Source File for FACnn')

Copyright IBM Corporation 2012

Figure 13-24. Creating a source file

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

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-25

Student Notebook

Creating database files and entering data


IBM i

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

Copyright IBM Corporation 2012

Figure 13-25. Creating database files and entering data

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.

13-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Physical and logical file naming rules


IBM i

Rules apply to:


File names
Record format names
Field names

First character alphabetic (A - Z, @, $, #)


Remaining characters (A - Z, @, $, # plus _, 0-9)
No hyphens anywhere:
MyFile = OK
My_File = OK
My-File = Invalid
Copyright IBM Corporation 2012

Figure 13-26. Physical and logical file naming rules

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-27

Student Notebook

Coding for physical file CLASSPF


IBM i

Copyright IBM Corporation 2012

Figure 13-27. Coding for physical file CLASSPF

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.

13-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Coding for physical files GRADEPF98 and


GRADEPF99
IBM i

Copyright IBM Corporation 2012

Figure 13-28. Coding for physical files GRADEPF98 and GRADEPF99

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-29

Student Notebook

Create source physical file


IBM i

CRTSRCPF QDDSSRC
FACOUTQxx

Library
FACxx
FACOUTQx
x
PAYROLxx
FACJOBDxx
ODDSSRC

PAYROLxx

FACJOBDxx

QDDSSRC
SRCSEQ
SRCDAT
SRCDTA

Copyright IBM Corporation 2012

Figure 13-29. Create source physical file

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.

13-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create new source member


IBM i

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

Copyright IBM Corporation 2012

Figure 13-30. Create new source member

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-31

Student Notebook

Create CLASSPF *File object


IBM i

PDM OPT 14 = COMPILE MEMBER

FACOUTQxx

PAYROLxx

When the file


is initially created,
there are no records
in the data member

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

Copyright IBM Corporation 2012

Figure 13-31. Create CLASSPF *File object

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.

13-32 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Our library after GRADEPF99 is created


IBM i

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

Copyright IBM Corporation 2012

Figure 13-32. Our library after GRADEPF99 is created

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-33

Student Notebook

Creating database files and entering data


IBM i

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

Copyright IBM Corporation 2012

Figure 13-33. Creating database files and entering data

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.

13-34 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Logical files
IBM i

Based on one or more physical files


Can perform DB relational operations on logical files
Can be an implementation of DB security
HLL programs treat logicals as just another file
Normally contain access paths to physical files

Copyright IBM Corporation 2012

Figure 13-34. Logical files

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-35

Student Notebook

Relational database operations using logical files


IBM i

Projection: Use a subset of a physical file's fields


Union: Merging (sequencing is required also) the records of
two or more physical file members
Selection: Including only a subset of a physical file's records
Sequencing: Sorting a physical file's records
Joining: Combining physical files by matching records from one
physical file to those of another physical file based on common
fields to form a file of combined (joined) records
Copyright IBM Corporation 2012

Figure 13-35. Relational database operations using logical files

OL4912.1

Notes:
You can perform the relational operations above on logical files.

13-36 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Logical file: Selection and sequence (1 of 3)


IBM i

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

Copyright IBM Corporation 2012

Figure 13-36. Logical file: Selection and sequence (1 of 3)

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).

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-37

Student Notebook

Logical file: Selection and sequence (2 of 3)


IBM i

DDS Coding for GRADELF99 Logical File:


GRADELF99
T.Name++++++.Len++TDpB......Functions+++++++++++++++++++
R GRADEREC
PFILE(GRADEPF99)
2
K STUDNO
S CRSCODE
CMP(EQ 'L001')
PDM Option 14=Compile or CRTLF

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

Copyright IBM Corporation 2012

Figure 13-37. Logical file: Selection and sequence (2 of 3)

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.

13-38 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-39

Student Notebook

Logical file: Selection and sequence (3 of 3)


IBM i

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
-

GRADELF99's view of GRADEPF99


102-1
103-2
105-8
107-9

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
-

Copyright IBM Corporation 2012

Figure 13-38. Logical file: Selection and sequence (3 of 3)

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.

13-40 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD GRADELF99 (1 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-39. DSPFD GRADELF99 (1 of 8)

OL4912.1

Notes:
Notice that GRADELF99 is a logical file.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-41

Student Notebook

DSPFD GRADELF99 (2 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-40. DSPFD GRADELF99 (2 of 8)

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.

13-42 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD GRADELF99 (3 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-41. DSPFD GRADELF99 (3 of 8)

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-43

Student Notebook

DSPFD GRADELF99 (4 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-42. DSPFD GRADELF99 (4 of 8)

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).

13-44 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD GRADELF99 (5 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-43. DSPFD GRADELF99 (5 of 8)

OL4912.1

Notes:
We are only interested in course code L001.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-45

Student Notebook

DSPFD GRADELF99 (6 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-44. DSPFD GRADELF99 (6 of 8)

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.

13-46 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFD GRADELF99 (7 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-45. DSPFD GRADELF99 (7 of 8)

OL4912.1

Notes:
Notice the record format list is the same as it was for the physical file, GRADEPF99.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-47

Student Notebook

DSPFD GRADELF99 (8 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 13-46. DSPFD GRADELF99 (8 of 8)

OL4912.1

Notes:
This last display from the DSPFD command example is shown for completeness.

13-48 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFFD GRADELF99 (1 of 3)
IBM i

Copyright IBM Corporation 2012

Figure 13-47. DSPFFD GRADELF99 (1 of 3)

OL4912.1

Notes:
This visual is the first of three resulting from the DSPFFD command for the GRADELF99
logical file.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-49

Student Notebook

DSPFFD GRADELF99 (2 of 3)
IBM i

Copyright IBM Corporation 2012

Figure 13-48. DSPFFD GRADELF99 (2 of 3)

OL4912.1

Notes:
The fields in the DSPFFD for the logical are the same as the physical file.

13-50 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPFFD GRADELF99 (3 of 3)
IBM i

Copyright IBM Corporation 2012

Figure 13-49. DSPFFD GRADELF99 (3 of 3)

OL4912.1

Notes:
This visual shows the last of the fields included in the GRADELF99 logical file.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-51

Student Notebook

Using a field reference file


IBM i

Using a field reference file

Copyright IBM Corporation 2012

Figure 13-50. Using a field reference file

OL4912.1

Notes:

13-52 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Using a field reference file for our case study


IBM i

Defined to the system


Definition of:

Fields for GRADEPF


CRSCODE

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(.

.
.
.
.
.
.
.
.

.
.
.
.

Copyright IBM Corporation 2012

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.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-53

Student Notebook

Properties of a field reference file


IBM i

Physical file
SCHOOLREF
R SCHOOLFMT

Format

CRSCODE

CRSTITLE

INSTNO

TEXT(. . .
COLHDG(. . .
TEXT(. . .
COLHDG(. . .
TEXT(. . .
COLHDG(. . .

Access path
NO KEY FIELD

Data

NO DATA RECORDS

Copyright IBM Corporation 2012

Figure 13-52. Properties of a field reference file

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.

13-54 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Field reference file for school database (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 13-53. Field reference file for school database (1 of 2)

OL4912.1

Notes:
If we moved all the definitions for our physical files into a single FRF, the FRF would look
like this.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-55

Student Notebook

Field reference file for school database (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 13-54. Field reference file for school database (2 of 2)

OL4912.1

Notes:
Notice how the fields have been organized by record format name by using comment lines
within the DDS.

13-56 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DDS for CLASSPF using SCHOOLREFFRF


IBM i

Copyright IBM Corporation 2012

Figure 13-55. DDS for CLASSPF using SCHOOLREFFRF

OL4912.1

Notes:
This is an example of the DDS coding of the CLASSPF physical file using the field
reference file technique.

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-57

Student Notebook

Machine exercise
IBM i

Code a physical and a logical file.

Copyright IBM Corporation 2012

Figure 13-56. Machine exercise

OL4912.1

Notes:

13-58 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Checkpoint
IBM i

1. Where is the information (record formats, field definitions, and


so forth) that describes a physical file stored?

2. What are two of the commands that you could use to display
that information?

3. On the IBM i a physical file may contain multiple groups of


data that are accessed separately, what are these called?

Copyright IBM Corporation 2012

Figure 13-57. Checkpoint

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 13. Defining database files using DDS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

13-59

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Code DDS for physical and logical files
Use a field reference file to define a physical file

Copyright IBM Corporation 2012

Figure 13-58. Unit summary

OL4912.1

Notes:

13-60 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)


What this unit is about
In this unit, the 5250-based Source Entry Utility and Program
Development Manager to enter source DDS and create files are
explored. The use of CPYF to populate files with data is also
examined. Finally, assessing the impact of making a change to a
physical file and how to implement such a change is shown.

What you should be able to do


After completing this unit, you should be able to:
Use Source Entry Utility (SEU) to enter and update source DDS
statements
Use the facilities of the Program Development Manager (PDM)
Use the CPYF command to copy physical file records
Implement a field change in an existing physical file

How you will check your progress


Checkpoint questions
Machine exercises

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Use Source Entry Utility (SEU) to enter and update source
DDS statements
Use the facilities of the Program Development Manager (PDM)
Use the CPYF command to copy physical file records
Implement a field change in an existing physical file

Copyright IBM Corporation 2012

Figure 14-1. Unit objectives

OL4912.1

Notes:

14-2 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Application Development ToolSet (ADTS)


IBM i

Application Development
ToolSet (ADTS)

Copyright IBM Corporation 2012

Figure 14-2. 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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-3

Student Notebook

Application Development ToolSet for IBM i


IBM i

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)

Copyright IBM Corporation 2012

Figure 14-3. Application Development ToolSet for IBM i

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).

14-4 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-5

Student Notebook

Programming Development Manager (1 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 14-4. Programming Development Manager (1 of 2)

OL4912.1

Notes:
To use the PDM, type strpdm from an IBM i command line and press Enter.

14-6 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Programming Development Manager (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 14-5. Programming Development Manager (2 of 2)

OL4912.1

Notes:
Options 1 through 3 are the most frequently used functions of PDM.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-7

Student Notebook

PDM options
IBM i

Copyright IBM Corporation 2012

Figure 14-6. PDM options

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.

14-8 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PDM work with members (1 of 4)


IBM i

Copyright IBM Corporation 2012

Figure 14-7. PDM work with members (1 of 4)

OL4912.1

Notes:
To work with the members of a source file, you first type 3.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-9

Student Notebook

PDM work with members (2 of 4)


IBM i

Copyright IBM Corporation 2012

Figure 14-8. PDM work with members (2 of 4)

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.

14-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PDM work with members (3 of 4)


IBM i

Copyright IBM Corporation 2012

Figure 14-9. PDM work with members (3 of 4)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-13

Student Notebook

Type 9 to save a member on diskette or tape.


13=Change text
Type 13 to change some of the attributes of one or more members.
14=Compile
Type 14 to compile one or more members. The system creates an object based on the
number being compiled. The member is compiled interactively or in batch mode,
depending on what you have specified on the Change Defaults display.
The following member types can be compiled: BAS, BAS36, BAS38, C, CBL, CBLLE,
CBL36, CBL38, CICSC, CICSCBL, CICSMAP, CICSSQLCBL, CLD, CLLE, CLP,
CLP38, DSPF, DSPF36, DSPF38, FTN, ICFF, LF, LF38, MENU, PAS, PF, PF38, PLI,
PLI38, PNLGRP, PRFT, PRFT38, QRY38, RMC, RPG, RPGLE, RPG36, RPG38, RPT,
RPT36, RPT38, SPADCT, SQLC, SQLCBL, SQLCBLLE, SQLCLE, SQLFTN, SQLPLI,
SQLRPG, SQLRPGLE, and TBL.
When the PDM compiles a program using the necessary create commands, the object
name to create is always specified as the source member name. You may change the
object name parameter to another object name by prompting the option or typing the
correct parameter on the command line. The PDM will check if the object name already
exists. If the name already exists, the Confirm Compile of Member display appears.
This display gives you the option of deleting the existing object.
Note: This display does not appear if the Replace object prompt on the Change Defaults
display is set to Y (Yes).
If you have changed the object name parameter to a special value, the programming
development manager will not check to see if the object exists. For example, if you
compile an RPG* program and change the Program prompt to *CTLSPEC, the PDM
will not check to see if the object exists.
15=Create module
Type 15 to create a module object for an ILE source type.
16=Run procedure
Type 16 to run a source member with a member type of REXX, OCL36, BASP, or
BASP38. If you try to run a member with a type that cannot be run, you receive an error
message. To run an OCL36 procedure, the file name must be QS36PRC. You can have
the member run in batch mode or interactively depending on what you specified in the
Run in batch prompt on the Change Defaults display.
17=Change using SDA
Type 17 to use Screen Design Aid (SDA) to work with the chosen members.
If the member type is DSPF, or DSPF38, SDA is called to work with the display.
If the member type is MNU, MNUDDS or MNUCMD, SDA is called to work with a menu.
If the member type is DSPF36 or MNU36, the System 36 SDA main menu is displayed.
14-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Basic Native Procedure

BASP38

Basic System/38 Native Procedure

C Language

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-15

Student Notebook

CBL

COBOL

CBLLE

Integrated Language Environment COBOL for IBM i

CBL36

COBOL System/36

CBL38

COBOL System/38

CICSC

CICS C

CICSCBL

CICS COBOL

CICSMAP

CICS Map

CICSSQLCBL

CICS DB2/400 Query Manager COBOL

CLD

C Locale Description

CLLE

Control Language Integrated Language Environment

CLP

Control Language

CLP38

System/38 Control Language

CMD

Command

CMD38

Command System/38

DSPF

Display File

DSPF36

Display File System/36

DSPF38

Display File System/38

FTN

FORTRAN/400

ICFF

Inter-System Communication Function File

LF

Logical File

LF38

Logical File System/38

MENU

UIM Menu

MNU

Menu

MNUCMD

Menu Command

MNUDDS

Menu Data Description Specifications

MNU36

Message File For System/36

MSGF36

Message File For System/36

OCL36

System/36 Operator Control Language

PAS

Pascal

PF

Physical File

PF38

Physical File System/38

PLI

PL/I

14-16 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PLI38

PL/I System/38

PNLGRP

Panel Group

PRTF

Printer File

PRTF38

Printer File System/38

QRY38

System/38 QUERY

REXX

Restructured Extended Executor Language

RMC

RM/COBOL-85**

RPG

RPG

RPGLE

Integrated Language Environment

RPG36

RPG System/36

RPG38

RPG System/38

RPT

RPG Auto Report

RPT36

RPG Auto Report System/36

RPT38

RPG Auto Report System/38

SPADCT

Spelling Aid Dictionary

SQLC

DB2/400 Query Manager C

SQLCBL

DB2/400 Query Manager COBOL

SQLCBLLE

DB2/400 Query Manager COBOL/400 Integrated Language Environment

SQLFTN

DB2/400 Query Manager FORTRAN

SQLPLI

DB2/400 Query Manager PL/I

SQLRPG

DB2/400 Query Manager RPG

SQLRPGLE

DB2/400 Query Manager RPG/400 Integrated Language Environment

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-18 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

F11=Display names and types


Press F11 to see the options, names, and attributes of the objects and of libraries in a
library list in multiple column format.
F12=Cancel
Press F12 to cancel processing of any options or changes that you have made to the
current display, and go back to the previous display.
F13=Repeat
Press F13 to repeat any valid programming development manager option, or
user-defined option, from a particular item downward to the end of the list in the Opt
column. Options next to preceding items in the list, ahead of that item, are left alone.
If you type only one option, or two or more of the same options on consecutive items,
F13 repeats that option regardless of the cursor position.
You can repeat a blank option in the same manner as any other valid option. Type a
blank in the Option field using the space bar. When a non-blank option for an item in
the list is encountered, a confirmation message is sent before the value is overwritten.
The cursor position is important when there are two or more non-consecutive or
different options in the list. If the cursor is on an option when you press F13 and the
other options in the list are all the same, the repeat is performed. If the other options in
the list are different, you receive a message telling you that there are other options in
the list, and to press F13 again to perform the repeat. If the cursor is not on an option,
you receive a message telling you to place the cursor on an option and press F13
again. The cursor is placed on the first option on the displayed page.
F14=Display date
Press F14 to display the dates on which the members in the list were last changed.
F15=Sort date
Press F15 to display the list sorted by the date the member was last changed.
F16=User options
Press F16 to work with the current user-defined options. The user-defined options file
that contains the active user-defined options is shown in the Change Defaults display.
The Work with User-Defined Options display appears.
F17=Subset
Press F17 to create a subset of a list. You can specify criteria to display certain items
you want to work with.
F18=Change defaults
Press F18 to display the Change Defaults display. From here you can assign defaults to
be used for system commands associated with an option.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-20 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PDM work with members (4 of 4)


IBM i

Copyright IBM Corporation 2012

Figure 14-10. PDM work with members (4 of 4)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-21

Student Notebook

Create new member (1 of 7)


IBM i

Copyright IBM Corporation 2012

Figure 14-11. Create new member (1 of 7)

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.

14-22 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create new member (2 of 7)


IBM i

A* Field Reference File


A*****************************************************************
A
R ORDREFFILE
TEXT('Field Reference File'
A
ACTIVE
1 0
COLHDG('Rcd' 'Sts' 'Cd')
A
RANGE(0 2)
A
TEXT('Record Status Code')
A
ALTDES
30
COLHDG('Alt. Item Descr.')
A
TEXT('Alternate Item Descri
A
BALANC
7 2
EDTCDE(K) COLHDG('Bal')
A
TEXT('Account Balance')
A
BALANT
9 2
COLHDG('Balances' 'Total')
A
EDTCDE(K)
A
CARBAL
9 2
COLHDG('Cur' 'A/R Bal')
A
TEXT('Current A/R Value')

Copyright IBM Corporation 2012

Figure 14-12. Create new member (2 of 7)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-23

Student Notebook

Create new member (3 of 7)


IBM i

Copyright IBM Corporation 2012

Figure 14-13. Create new member (3 of 7)

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-25

Student Notebook

Choose from the following:


A=After
Type A in the Sequence number prompt to move or copy records after this record.
An=After with a repeat n times
Type An in the Sequence number prompt to move or copy records after this record and
repeat these records n times.
B=Before
Type B in the Sequence number prompt to move or copy records before this record.
Bn=Before with repeat n times
Type Bn in the Sequence number prompt to move or copy records before this record and
repeat these records n times.
C=Copy a line
Type C to copy this line to a specified target.
Cn=Copy n lines
Type Cn to copy this line plus the next n-1 lines to the specified target.
CC=Block Copy
Type CC to copy all lines between the boundaries formed by the two CC commands.
CR=Copy records and retain command
Type CR to copy this record to the specified targets and keep this command on the display.
CRn=Copy n records and retain command
Type CRn to copy records to the specified targets and keep this command on the display.
CCR=Copy block records and retain command
Type CCR to copy the block of records defined by a pair of CCR commands to the
specified targets and keep this command on the display.
COLS=Column
Type COLS to make a free-form format line appear just before the line the command was
entered on.
D=Delete a line
Type D to delete this line.
Dn=Delete n lines
Type Dn to delete this line and the next n-1 lines.
DD=Block Delete
Type DD to delete all lines between the two DD boundaries.
14-26 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

F=Display format line


Type F to display a format line.
Fxx=Display the xx format line
Type Fxx to display the xx format line.
F?=Show the Select Format display
Type F? to show the Select Format display. From this display choose the format to use.
I=Insert a line
Type I to insert a blank line after this record.
In=Insert n lines
Type In to insert n blank lines after this record.
IF=Insert line and display format
Type IF to insert a blank line and display the current format before the first new line.
IFn=Insert n lines and display format
Type IFn to insert n blank lines and display the current format before the first new line.
IFxx=Insert a blank line and display xx format
Type IFxx to insert a line and display the xx format before this new line.
IFxxn=Insert n blank lines and display xx format
Type IFxxn to insert n lines and display the xx format before these new lines.
IF?=Show the Select Format display
Type IF? to show the Select Format display and insert a line with a format selected from
that display before this new line.
IF?n=Show the Select Format display and insert lines
Type IF?n to show the Select Format display and insert n lines with a format selected from
that display before this new line.
IP=Insert line and prompt
Type IP to insert a blank line and display the line in a prompt. The format of the previous
record determines the type of prompt to display.
IPxx=Insert line with an xx prompt
Type IPxx to insert a line and display the line in the xx prompt, where xx is the name
associated with an IBM-supplied or user-defined prompt.
IP?=Show Select Prompt Display
Type IP? to show the Select prompt Display. An insert line will be shown in the prompt
selected from this display.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-27

Student Notebook

IS=Insert skeleton line


Type IS to insert a line and initialize it to the data saved as the skeleton line.
ISn=Insert n skeleton lines
Type ISn to insert n lines and initialize them to the data saved as the skeleton lines.
L=Shift data 1 char left
Type L to shift data in this record one character position to the left. If there is any data in the
first column, the record will only shift up to the start of the data.
Ln=Shift data n chars left
Type Ln to shift data in this record n character positions to the left. If there is any data in the
first n columns, the record will only shift up to the start of the data.
LL=Shift block 1 char to the left
Type LL to shift the data that is defined by the boundaries between and including the two
LL line commands one character position to the left. If there is any data in the first column,
the record will only shift up to the start of the data.
LLn=Shift block n chars to the left
Type LLn to shift the data that is defined by the boundary between and including the LLn
and LL line commands n character positions to the left. If there is any data in the first n
columns, the record will only shift up to the start of the data.
LP=Line Print a line
Type LP to print this line.
LPn=Line Print n lines
Type LPn to print this line plus the next n-1 lines.
LLP=Block Line Print
Type LLP to print all lines between the boundaries formed by the two LLP commands.
LT=Shift data 1 char left with truncate
Type LT to shift data in this record one character position to the left. Any data that
appeared in the first column will be removed.
LTn-Shift data n chars left with truncate
Type LTn to shift data in this record n character positions to the left. Any data that
appeared in the first column through the nth column will be removed.
LLT=Shift block left with truncate
Type LLT to shift the data that is defined by the boundary between and including the two
LLT line commands one position to the left. Any data that appeared in the first column will
be removed.

14-28 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

LLTn=Shift block n chars left with truncate


Type LLTn to shift the data that is defined by the boundary between and including the LLTn
and LLT line commands n positions to the left. Any data that appeared in the first column
through the nth column will be removed.
M=Move a line
Type M to move a line to a specified target.
Mn=Move n lines
Type Mn to move this line and the following n-1 lines to a specified target.
MM=Block Move
Type MM to move all records between and including the boundaries defined by the MM line
commands to a specified target.
O=Overlay
Type O to overlay this line with the first line defined by the move, copy, or copy repeated
line command.
On=Overlay n lines
Type On to overlay this line and the following n-1 lines with the first n lines defined by the
move, copy, or copy repeated line command.
OO=Block overlay
Type OO to overlay all the records between and including the boundaries defined by two
OO line commands with the lines defined by the move, copy, or copy repeated line
command.
P=Display prompt
Type P to display this line in a prompt.
Pxx=Display xx prompt
Type Pxx to display this line in the xx prompt, where xx is the name associated with an
IBM-supplied or user-defined prompt.
P?=Show the Select Prompt display
Type P? to show the Select Prompt display and look at the line in the prompt chosen from
this display.
R=Shift data 1 char right
Type R to shift the data in this record one character position to the right. If there is any data
in the last column, the record will only shift up to the end of the data.
Rn=Shift data n chars right
Type Rn to shift the data in this record n character positions to the right. If there is any data
in the last n columns, the record will only shift up to the end of the data.
Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-29

Student Notebook

RR=Block shift 1 char to the right


Type RR to shift the data that is defined by the boundary between and including the two RR
line commands one character position to the right. If there is any data in the last column,
the record will only shift up to the end of the data.
RRn=Block shift n chars to the right
Type RRn to shift the data that is defined by the boundary between and including the RRn
and RR line commands n character positions to the right. If there is any data in the last n
columns, the record will only shift up to the end of the data.
RRT=Shift block right with truncate
Type RRT to shift the data that is defined by the boundary between and including the two
RRT line commands n positions to the right. Any data that appeared in the last column will
be removed.
RRTn=Shift block n chars right with truncate
Type RRTn to shift the data that is defined by the boundary between and including the
RRTn and RRT line commands n positions to the right. Any data that appeared in the last
column through the nth column will be removed.
RT=Shift data 1 char right with truncate
Type RT to shift the data in this record one character position to the right. Any data in the
last column will be removed.
RTn=Shift data chars n right with truncate
Type RTn to shift the data in this record n character positions to the right. Any data in the
last column through the nth column will be removed.
RP=Repeat line
Type RP to repeat this line once before the following line.
RPn=Repeat line n times
Type RPn to repeat this line n times before the following line.
RPP=Block repeat
Type RPP to repeat all lines defined by the boundary between the two RRP line
commands.
RPPn=Block repeat n times
Type RPPn to repeat all lines defined by the boundary between the two RRP line
commands n times.
S=Skeleton line
Type S to define this data line as the skeleton line.

14-30 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

SF=Show first record


Type SF to show the first record of the exclude group.
SFn=Show first n records
Type SFn to show the first n records of the exclude group.
SL=Show last record
Type SL to show the last record of the exclude group.
SLn=Show last n records
Type SLn to show the last n records of the exclude group.
TABS=Display tabs record
Type TABS to set and show the tabs for the display. Before you can use the tabs you set,
you must specify Y (Yes) for the Tabs on prompt on the Change Session Defaults display.
W=Display member from column 1
Type W to display the member beginning in column 1.
Wn=Display member from column n
Type Wn to display the member beginning in column n.
X=Exclude a line
Type an X next to the record to exclude it from the display.
Xn=Exclude n lines
Type Xn to exclude this record and the next n-1 records.
XX=Block exclude
Type XX to exclude all lines between the boundaries formed by the two XX line commands.
+ (plus sign)=Roll member forward 1 line
Type + to roll the member forward one line.
+n=Roll member forward n lines
Type +n to roll the member forward n lines.
- (minus sign)=Roll member backward 1 line
Type - to roll the member backward one line.
-n=Roll member backward n lines
Type -n to roll the member backward n lines.
n=Absolute Positioning
Type a sequence number in to position the line identified by that value as the first record on
the display.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-32 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create new member (4 of 7)


IBM i

Copyright IBM Corporation 2012

Figure 14-14. Create new member (4 of 7)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-33

Student Notebook

Create new member (5 of 7)


IBM i

Copyright IBM Corporation 2012

Figure 14-15. Create new member (5 of 7)

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.

14-34 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Create new member (6 of 7)


IBM i

Copyright IBM Corporation 2012

Figure 14-16. Create new member (6 of 7)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-35

Student Notebook

Create new member (7 of 7)


IBM i

Copyright IBM Corporation 2012

Figure 14-17. Create new member (7 of 7)

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.

14-36 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Compile DDS (1 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-18. Compile DDS (1 of 8)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-37

Student Notebook

Compile DDS (2 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-19. Compile DDS (2 of 8)

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.

14-38 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Compile DDS (3 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-20. Compile DDS (3 of 8)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-39

Student Notebook

Compile DDS (4 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-21. Compile DDS (4 of 8)

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.

14-40 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Compile DDS (5 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-22. Compile DDS (5 of 8)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-41

Student Notebook

Compile DDS (6 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-23. Compile DDS (6 of 8)

OL4912.1

Notes:
Type option 5 to display the compile listing.

14-42 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Compile DDS (7 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-24. Compile DDS (7 of 8)

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:

Relative Paging - P+/-n


Absolute Paging - Pn
Relative Rolling - +/-n
Absolute Rolling - n
Relative Windowing - W+/-n
Absolute Windowing - Wn
Displaying Bottom of file - B or *BOT
Displaying Top of file - T or *TOP

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-44 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Compile DDS (8 of 8)
IBM i

Copyright IBM Corporation 2012

Figure 14-25. Compile DDS (8 of 8)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-45

Student Notebook

Browse/Copy options (1 of 4)
IBM i

Copyright IBM Corporation 2012

Figure 14-26. Browse/Copy options (1 of 4)

OL4912.1

Notes:
Type option 2 to edit the source member.

14-46 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Browse/Copy options (2 of 4)
IBM i

Copyright IBM Corporation 2012

Figure 14-27. Browse/Copy options (2 of 4)

OL4912.1

Notes:
Press F15 = Browse/Copy options.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-47

Student Notebook

Browse/Copy Options (3 of 4)
IBM i

Copyright IBM Corporation 2012

Figure 14-28. Browse/Copy Options (3 of 4)

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.

14-48 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Browse/Copy options (4 of 4)
IBM i

Copyright IBM Corporation 2012

Figure 14-29. Browse/Copy options (4 of 4)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-49

Student Notebook

Using basic SEU functions


IBM i
Assume you are editing these records:
0007.00
0008.00
0009.00
0010.00
0011.00
0012.00
0013.00
0014.00
0015.00
0016.00

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

COLHDG('ALT. ITEM DESCR.')


TEXT('ALTERNATE ITEM DESCRI
COLHDG('BAL')
TEXT('Current A/R Value')
EDTCDE(K)
COLHDG('Customer Name')
RANGE(1 4)
RANGE(1 4)
COLHDG('City')
COLHDG('Credit' 'Limit')

And you enter the following functions:


0007.00
00D8.00
0009.00
0010.00
0C11.00
0012.00
0013.00
0014.00
0015.00
0A16.00

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

COLHDG('ALT. ITEM DESCR.')


TEXT('ALTERNATE ITEM DESCRI
COLHDG('BAL')
TEXT('Current A/R Value')
EDTCDE(K)
COLHDG('Customer Name')
RANGE(1 4)
RANGE(1 4)
COLHDG('City')
COLHDG('Credit' 'Limit')

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

COLHDG('ALT. ITEM DESCR.')


COLHDG('BAL')
TEXT('Current A/R Value')
EDTCDE(K)
COLHDG('Customer Name')
RANGE(1 4)
RANGE(1 4)
COLHDG('City')
COLHDG('Credit' 'Limit')
EDTCDE(K)

Copyright IBM Corporation 2012

Figure 14-30. Using basic SEU functions

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.

14-50 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Define a skeleton line


IBM i

Copyright IBM Corporation 2012

Figure 14-31. Define a skeleton line

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-51

Student Notebook

Insert a skeleton line


IBM i

Copyright IBM Corporation 2012

Figure 14-32. Insert a skeleton line

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.

14-52 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Skeleton line inserted


IBM i

Copyright IBM Corporation 2012

Figure 14-33. Skeleton line inserted

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-53

Student Notebook

Browse/Copy Options: Copy


IBM i

Copyright IBM Corporation 2012

Figure 14-34. Browse/Copy Options: Copy

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.

14-54 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Browse/Copy options: Split screen


IBM i

To
here

From
here

Copyright IBM Corporation 2012

Figure 14-35. Browse/Copy options: Split screen

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-55

Student Notebook

SEU Find/Change Options


IBM i

Copyright IBM Corporation 2012

Figure 14-36. SEU Find/Change Options

OL4912.1

Notes:
SEU offers the ability to find a string and replace it with something else, if needed.

14-56 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Change SEU session defaults


IBM i

Copyright IBM Corporation 2012

Figure 14-37. Change SEU session defaults

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-57

Student Notebook

Change PDM session defaults


IBM i

Copyright IBM Corporation 2012

Figure 14-38. Change PDM session defaults

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-59

Student Notebook

Save session defaults


Use this prompt to choose whether to save the PDM default values for the current session
only, or to save them permanently in your user profile.
Note: If you want batch jobs submitted through PDM to use the same default values as
your current session, the Save session defaults value must be set to Y before the job is
submitted to batch, and these batch jobs must also run under the same user profile as the
one that submitted it.
Choose from the following:
Y=Yes
Type Y if you want changes to the default values to be saved permanently in your user
profile.
N=No
Type N if you do not want changes to the default values to be saved permanently in
your user profile. Any changes are effective in your current session only.
Save/restore option
Use this prompt to choose whether to save or restore objects and members individually or
with one command.
Choose from the following:
1=Single
Type 1 if you want to save or restore the selected objects or members individually, each
with its own separate command.
2=All
Type 2 if you want to save or restore the selected objects or members all at the same
time with one command.
Job description
Use this prompt to specify the name of the job description for submitting a job in batch
mode. The job description is an object which defines how a job is to be processed. Choose
from the following options:
Name
The name of a job description. Press F4 to go to a selection list of the job descriptions in
the specified library. You can create a subset of the selection list by typing one of the
following before pressing F4:
*ALL
Type *ALL to display a list of all job descriptions. Displays a list of all items ending with
ABC. For example, ABC, DABC, or TESTABC.
*B*
14-60 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-64 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PDM: Work with user-defined options (1 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 14-39. PDM: Work with user-defined options (1 of 3)

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).

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-65

Student Notebook

PDM: Work with user-defined options (2 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 14-40. PDM: Work with user-defined options (2 of 3)

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.

14-66 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PDM: Work with User-Defined Options (3 of 3)


IBM i

Copyright IBM Corporation 2012

Figure 14-41. PDM: Work with User-Defined Options (3 of 3)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-67

Student Notebook

Standard PDM options (1 of 2)


IBM i

Member: QAUOOPT File: QAUOOPT Library: QGPL


Option
Name

Command Called

CALL &O/&N

Allows you to run a program on the Work with Members


Using PDM display

CC

CHGCURLIB
CURLIB(&L)

Changes the library on the Work with Objects Using


PDM display or the Work with Members Using PDM
display to the current library in the library list

CD

STRDFU OPTION(2)

Allows you to create a DFU program

CHGCURLIB
CURLIB(&N)
STRSDA OPTION(2)
SRCFILE(&L/&F)
??SRCMBR( )

Changes selected library on the Work with Libraries


Using PDM display to the current library in the library list

CL
CM

CS
DM
EA

STRSDA OPTION(1)
SRCFILE(&L/&F)
??SRCMBR()
DSPMSG
EDTOBJAUT
OBJ(&L/&N)
OBJTYPE(&T)

Explanation

Allows you to create a member (menu) using SDA

Allows you to create a member (display) using SDA


Allows you to display messages
Allows you to edit the authority to an object on the Work
with Objects Using PDM display
Copyright IBM Corporation 2012

Figure 14-42. Standard PDM options (1 of 2)

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.

14-68 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Standard PDM options (2 of 2)


IBM i

Option
Name
GO

Command Called
GO &L/ &N

Explanation
Allows you to display the menu for a menu object

JL

DSPJOBLOG

Allows you to display the job log

SL

SBMJOB ??CMD
(SAVLIB LIB(&N))

Save library in batch on the Work with Libraries


Using PDM display

SBMJOB ??CMD(SAVOBJ
OBJ(&F) LIB(&L)
OBJTYPE (*FILE)
FILEMBR ((&F(&N))))

Save member in batch on the Work with Members


Using PDM display

SM

SO

SBMJOB ??CMD(SAVOBJ
OBJ(&N) LIB(&L))

Save object in batch on the Work with Objects


Using PDM display. This option is an example using
conditional prompting. This means that the prompt for
the SBMJOB command comes up automatically when
the user-defined option is used. This is specified by
the ?? at the beginning of the CMD parameter.

SP

WRKSPLF

Allows you to work with spooled files

WS

WRKSBMJOB

Allows you to work with jobs submitted to batch


Copyright IBM Corporation 2012

Figure 14-43. Standard PDM options (2 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-69

Student Notebook

Valid substitution variables for user-defined


options (1 of 3)
IBM i

Parm

Meaning

Description

&A

Object attribute

If you are working with objects, &A is replaced by the object


attribute from the list. If you are working with libraries or
members, &A is replaced by *NULL.

&B

List type

If you are working with a library list (*LIBL, *USRLIBL), &B


is replaced by X. If you are working with a list of libraries
(*ALL, *ALLUSR), &B is replaced by L. If you are working
with a list of objects, &B is replaced by O. If you are
working with a list of members, &B is replaced by M.

&C

Option

&C is replaced by the user-defined option code.

&D

Member change date

&E

Run in batch

&F

File name

If you are working with members, &D is replaced by the


date the member was last changed. The value returned is
the system format with separator characters. Otherwise,
&D is replaced by *NULL. You must use this variable in
single quotation marks (that is, '&D') because the date may
contain a slash (/), which is used as an operator.
&E is replaced by *YES if Y is specified in the Run in batch
prompt on the Change Defaults display and *NO if N is
specified.
If you are working with members, &F is replaced by the
name of the file that contains these members. For all other
conditions, &F is replaced by *NULL.
Copyright IBM Corporation 2012

Figure 14-44. Valid substitution variables for user-defined options (1 of 3)

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.

14-70 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Valid substitution variables for user-defined


options (2 of 3)
IBM i

Parm

Meaning

Description

&G

Job description
library

&G is replaced by the job description library value from


the Change Defaults display.

&H

Job description
name

&H is replaced by the job description value from the


Change Defaults display.

&J

Job description

&J is replaced by the job description value from the


Change Defaults display in the format library/job
description.

&L

Library name

If you are working with libraries, &L is replaced by QSYS.


If you are working with objects or members, &L is replaced
by the name of the library that contains the objects or
members.

&N

Item name

&N is replaced by the name of the item in the list


beside which the option was typed.

&O

Object library

If you are working with libraries, objects, or members, &O is


replaced by the object library from the Change Defaults
display.

&P

Compile in batch

&P is replaced by *YES if Y is specified in the


Compile in batch prompt on the Change Defaults
display and *NO if N is specified.
Copyright IBM Corporation 2012

Figure 14-45. Valid substitution variables for user-defined options (2 of 3)

OL4912.1

Notes:
Here is page two of three showing more substitution variables for user-defined options.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-71

Student Notebook

Valid substitution variables for user-defined


options (3 of 3)
IBM i

Parm
&R

&S

Meaning

Description

Replace object

&R is replaced by *YES if Y is specified in the Replace


object prompt on the Change Defaults display and *NO if
N is specified.

Item type without

If you are working with libraries, &S is replaced by LIB. If


you are working with objects, &S is replaced by the
object type without the asterisk '*'. If you are working
with members, &S is replaced by the member type as is.
If you are working with libraries, &T is replaced by *LIB.
If you are working with objects or members, &T is
replaced by the object or member type as is.

'*'

&T

Item type with

'*'

&U

User-Defined Option
File

&U is replaced by the user-defined option file name from


the Change Defaults display.

&V

User-Defined
Option Library

&V is replaced by the user-defined option library


name from the Change Defaults display.

&W

User-Defined Option
File Member

&W is replaced by the user-defined option file member


name from the Change Defaults display.

Item text

&X is replaced by the text (in single quotation marks) of the


item beside which the option is typed.

&X

Copyright IBM Corporation 2012

Figure 14-46. Valid substitution variables for user-defined options (3 of 3)

OL4912.1

Notes:
Here is the last page of substitution variables for user-defined options.

14-72 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

PDM: Create User-Defined Option


IBM i

Copyright IBM Corporation 2012

Figure 14-47. PDM: Create User-Defined Option

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-73

Student Notebook

Summary of using PDM


IBM i

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

Copyright IBM Corporation 2012

Figure 14-48. Summary of using PDM

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.

14-74 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

File relationships and dependencies

Copyright IBM Corporation 2012

Figure 14-49. File-related commands

OL4912.1

Notes:
There are many useful commands and these are the ones that are the most-commonly
used.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-75

Student Notebook

FNDSTRPDM
IBM i

Character String Search (PDM option 25)


Source physical file
Physical database file
Single, multiple, *ALL members
Supports character/hex searches
Optionally case sensitive
Supports all PDM options

Edit/Browse
Compile
Print
Copy
Delete
Reverse
User-defined options
Copyright IBM Corporation 2012

Figure 14-50. FNDSTRPDM

OL4912.1

Notes:
This command allows you to search for character or hex strings in source physical files or
physical files (that contain data).

14-76 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercise
IBM i

Using IBM i Editors

Copyright IBM Corporation 2012

Figure 14-51. Machine exercise

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-77

Student Notebook

Maintaining your DB2 database


IBM i

Maintaining your
DB2 database

Copyright IBM Corporation 2012

Figure 14-52. Maintaining your DB2 database

OL4912.1

Notes:

14-78 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Database maintenance
IBM i

What objects are impacted?


What actions are required?

Add, change, or delete a field.


Copyright IBM Corporation 2012

Figure 14-53. Database maintenance

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-79

Student Notebook

Example: Enlarging a field size


IBM i

File - PF
Field Reference File

Copyright IBM Corporation 2012

Figure 14-54. Example: Enlarging a field size

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.

14-80 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Impacted objects


IBM i

*File - PF
Field Reference File

*File - PF

*File - PRTF
*File - LF

*File - DSPF

*PGM

Copyright IBM Corporation 2012

Figure 14-55. Example: Impacted objects

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-81

Student Notebook

DSPFFD: Fields within file


IBM i

*File - PF
Field Reference File
*File - PF

*File - PRTF

*File - LF
DSPFFD

*File - DSPF

*PGM
Copyright IBM Corporation 2012

Figure 14-56. DSPFFD: Fields within file

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

14-82 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

DSPPGMREF: Files used by programs


IBM i

*File - PF
Field Reference File

*File - PF
*File - PRTF
*File - LF

*File - DSPF

*PGM

DSPPGMREF
Copyright IBM Corporation 2012

Figure 14-57. DSPPGMREF: Files used by programs

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

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-83

Student Notebook

DSPDBR: Which LFs use which PFs


IBM i

*File - PF
Field Reference File

*File - PF

*File - PRTF
*File - LF

*File - DSPF

*PGM

Copyright IBM Corporation 2012

Figure 14-58. DSPDBR: Which LFs use which PFs

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.

14-84 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

FNDSTRPDM
IBM i

Can be used instead of DSPFFD, DSPDBR, and


DSPPGMREF
Used with QDDSSRC, QCLSRC, QRPGLESRC, and so forth
Look for file and field names in the source members
Used in PDM - Option 25

Copyright IBM Corporation 2012

Figure 14-59. FNDSTRPDM

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Figure 14-60. FNDSTRPDM parameters

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.

14-86 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Example: Implement the field change (1 of 2)


IBM i

1.

Change Field Reference File source and re-create.

2.

Find affected PFs using:

DSPFFD
or DSPFFD ... OUTPUT(*OUTFILE) and SQL or QUERY
or FNDSTRPDM

3.

Optional, but highly recommended:

4.

Save the affected physical files.

For each physical file:

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.

Modify and recompile impacted display and printer files.


Copyright IBM Corporation 2012

Figure 14-61. Example: Implement the field change (1 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-87

Student Notebook

Example: Implement the field change (2 of 2)


IBM i

7. Find affected programs.


DSPFFD... OUTFILE(W)

DSPPGMREF... OUTFILE(Y)

FILEA FORMATX FIELDA


''

PGMX

FILEA

''

FILEB

FIELDB

''

PGMY
''

FIELDC

''

''

FILEC
FILED

Select "W" records with changed field.


Join W and Y on file name using
Join logical file
Query/400
8. Change program source if necessary.
9. Recreate programs.
Copyright IBM Corporation 2012

Figure 14-62. Example: Implement the field change (2 of 2)

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.

14-88 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercise
IBM i

Code and create files and use file-related commands.

Copyright IBM Corporation 2012

Figure 14-63. Machine exercise

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-89

Student Notebook

CPYF (copy file)


IBM i

CPYF (copy file)

Copyright IBM Corporation 2012

Figure 14-64. CPYF (copy file)

OL4912.1

Notes:

14-90 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Copy functions and commands


IBM i

CPYF

Copy file

CPYSRCF

Copy source file

CPYFRMDKT

Copy from diskette

Copy to diskette

CPYTODKT

CPYFRMTAP
CPYTOTAP

Copy from tape

Copy to tape

DUPDKT

Duplicate diskette

DUPTAP

Duplicate tape

Create duplicate object

CRTDUPOBJ

Copyright IBM Corporation 2012

Figure 14-65. Copy functions and commands

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-91

Student Notebook

Copy function: From and to


IBM i

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

Copyright IBM Corporation 2012

Figure 14-66. Copy function: From and to

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.

14-92 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Selecting members
IBM i

CPYF FROMFILE( ) TOFILE ( ) FROMMBR( ) TOMBR( )...


Data Base
FROMMBR(

member name
generic name
*ALL
*FIRST
TOMBR(

)
member name
*FROMMBR
*FIRST

If TOMBR does not exist it is added to the database file.


Copyright IBM Corporation 2012

Figure 14-67. Selecting members

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-93

Student Notebook

Copy file: FROMMBR, TOMBR


IBM i

Default
FROMMBR

*FIRST

MBR3

*ALL

*ALL

TOMBR

*FIRST

*FIRST

*FIRST

*FROMMBR

MBR1

MBR1

MBR2

MBR2

MBR3

MBR3

FROMFILE

MBR1
TOFILE

MBR2

MBR1

MBR3

MBR3

Copyright IBM Corporation 2012

Figure 14-68. Copy file: FROMMBR, TOMBR

OL4912.1

Notes:
The member names represent the content of the respective members.

14-94 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Copy file: CRTFILE, MBROPT


IBM i

TOFILE
Before

After

NONE
CRTFILE (*YES)
FROMFILE

MBROPT (*ADD)

MBROPT (*REPLACE)

Copyright IBM Corporation 2012

Figure 14-69. Copy file: CRTFILE, MBROPT

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-95

Student Notebook

Copy file: FROMRCD, TORCD


IBM i

102
103

106

105
103

108

105
108
FROMRCD(3)
TORCD(5)

Copyright IBM Corporation 2012

Figure 14-70. Copy file: FROMRCD, TORCD

OL4912.1

Notes:
These two parameters are used to selectively copy based on relative record position within
the file.

14-96 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Copy file: FROMKEY, TOKEY


IBM i

102
106

103

103

105
106

105
108
FROMKEY(103)
TOKEY(106)

Copyright IBM Corporation 2012

Figure 14-71. Copy file: FROMKEY, TOKEY

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-97

Student Notebook

Copy file: NBRRCDS


IBM i

NBRRCDS(50)
/*

Number of Records to Cop

*/

Instead of
TORCD
-orTOKEY

Copyright IBM Corporation 2012

Figure 14-72. Copy file: NBRRCDS

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.

14-98 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Copy file: INCCHAR


IBM i

102 SMITH
106 DAVIS

106 DAVIS

105 ST. DAVIDS

103 SAMPSON

108 DAVIDSON

105 ST. DAVIDS


108 DAVIDSON
INCCHAR(NAME 1 *CT DAV)

Copyright IBM Corporation 2012

Figure 14-73. Copy file: INCCHAR

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF)

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

14-99

Student Notebook

Copy file: INCREL


IBM i

102

59

106

160

103

175

105

23

108

132

106

160

103

175

INCREL((*IF AMT *GT 150))

Copyright IBM Corporation 2012

Figure 14-74. Copy file: INCREL

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.

14-100 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Copy file: FMTOPT(*DROP *MAP)


IBM i

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

Copyright IBM Corporation 2012

Figure 14-75. Copy file: FMTOPT(*DROP *MAP)

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

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-101

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

14-102 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Copy file: FMTOPT(*NOCHK)


IBM i

FROM
TO

Copyright IBM Corporation 2012

Figure 14-76. Copy file: FMTOPT(*NOCHK)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-103

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Creating test data using a DB copy


IBM i

CPYF

FROMFILE(PAYLIB/EMP1)
TOFILE(TESTLIB/EMP1T)
FROMMBR(*FIRST)
TOMBR(*FIRST)
MBROPT(*REPLACE)

Required keywords for database to database copy.


FROMFILE - TOFILE - MBROPT

Copyright IBM Corporation 2012

Figure 14-77. Creating test data using a DB copy

OL4912.1

Notes:
In the space provided below, write down what you think this example is doing:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

14-104 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Print options
IBM i

TOFILE(

*PRINT
SEU type listing for CPYSRCF

Printer device filename

OUTFMT(

*CHAR
*HEX

PRINT(

*COPIED
*EXCLUDED

Copyright IBM Corporation 2012

Figure 14-78. Print options

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-105

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Create a file not previously defined


IBM i

CPYF

FROMFILE(BILL/CUSTOMER)
TOFILE(QGPL/CUSTOMER)
CRTFILE(*YES)
INCREL((*IF CRDLMT *GE 10000))

Copyright IBM Corporation 2012

Figure 14-79. Create a file not previously defined

OL4912.1

Notes:
Example of CRTFILE(*YES).

14-106 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercise
IBM i

Copy file

Copyright IBM Corporation 2012

Figure 14-80. Machine exercise

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-107

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Additional database capabilities


IBM i

Additional database
capabilities
Copyright IBM Corporation 2012

Figure 14-81. Additional database capabilities

OL4912.1

Notes:
We will continue to use our case study school database to illustrate some additional
features, implementing JOINs and UNIONs in DDS.

14-108 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Logical File GRADE9899U


Union: GRADEPF98 and GRADEPF99
Sequence by student number
Do not need student number

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

Copyright IBM Corporation 2012

Figure 14-82. Logical File: Union, projection, and sequence (1 of 2)

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-109

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Logical file:
Union, projection, and sequence (2 of 2)
IBM i

Copyright IBM Corporation 2012

Figure 14-83. Logical file: Union, projection, and sequence (2 of 2)

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.

14-110 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Multiformat logical file: Union, sequence (1 of 2)


IBM i

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
-

Copyright IBM Corporation 2012

Figure 14-84. Multiformat logical file: Union, sequence (1 of 2)

OL4912.1

Notes:
The records from CLASSPF and GRADEPF99 are presented as though they had been
sorted and merged by logical file ROSTERLF.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-111

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Multiformat logical file: Union, sequence (2 of 2)


IBM i

Copyright IBM Corporation 2012

Figure 14-85. Multiformat logical file: Union, sequence (2 of 2)

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.

14-112 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Logical file: Inner join


IBM i

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

CLASSPF (Primary) Inner Joined to


GRADEPF99 (Secondary) on Course Code.
Sequence duplicates by student lastname.
Crs
Code
L001
L001
L001
L001
L001
L103
L214
L303

Course
Title
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ENGLISH
GREEK
CHINESE

Copyright IBM Corporation 2012

Instr
Name
DANTE
DANTE
DANTE
DANTE
DANTE
HIGGINS
HOMER
TSUNG

CLSGRDIJ99

Figure 14-86. Logical file: Inner join

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.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-113

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Logical file DDS: Inner JOIN


IBM i

Copyright IBM Corporation 2012

Figure 14-87. Logical file DDS: Inner JOIN

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).

14-114 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Logical file: Left outer JOIN


IBM i

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

CLASSPF (Primary) Left Outer Joined to


GRADEPF99 (Secondary) on Course Code.
Sequence duplicates by student's last name.
Crs
Code
L001
L001
L001
L001
L001
L103
L211
L214
L303

Course
Title
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ITALIAN
ENGLISH
SPANISH
GREEK
CHINESE

Copyright IBM Corporation 2012

Instr
Name
DANTE
DANTE
DANTE
DANTE
DANTE
HIGGINS
PICASSO
HOMER
TSUNG

NELSON
STING

CLSGRDOJ99

Figure 14-88. Logical file: Left outer JOIN

OL4912.1

Notes:
A left outer join supplies default values for missing secondary records.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-115

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Logical file DDS: Left outer JOIN


IBM i

Copyright IBM Corporation 2012

Figure 14-89. Logical file DDS: Left outer JOIN

OL4912.1

Notes:
Specifying the JDFTVAL keyword makes this a left outer join.

14-116 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Creating logical file and entering data


IBM i

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

Figure 14-90. Creating logical file and entering data

OL4912.1

Notes:
Creating a logical file DDS source follows the same steps as creating a physical file.

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-117

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

School case study summary


IBM i

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

Copyright IBM Corporation 2012

Figure 14-91. School case study summary

OL4912.1

Notes:
This visual summarizes all the objects that we have described and created in the lecture.

14-118 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercise
IBM i

Using the IBM i Editors


Code and create files: Use file-related commands
Copy file
Additional physical and logical files

Copyright IBM Corporation 2012

Figure 14-92. Machine exercise

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-119

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

Checkpoint
IBM i

1. What are some of the commands that could be used to


access the SEU editor?

2. What command could you use to find the occurrences of a


particular string in source files?

3. What does a join do in a logical file?

Copyright IBM Corporation 2012

Figure 14-93. Checkpoint

OL4912.1

Notes:

14-120 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit summary
IBM i

Having completed this unit, you should be able to:


Use Source Entry Utility (SEU) to enter and update source
DDS statements
Use the facilities of the Program Development Manager (PDM)
Use the CPYF command to copy physical file records
Implement a field change in an existing physical file

Copyright IBM Corporation 2012

Figure 14-94. Unit summary

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-121

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Student Notebook

14-122 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Unit 15. Wrap-up and supplemental exercises


What this unit is about
In this unit, we will wrap up the course by suggesting some other
classes that you should consider attending in order to enhance your
skills.
There are a series of machine exercises that you should complete
prior to your departure from the class. There is no lecture associated
with these exercises. They cover the use of more IBM i native tools
including the Screen Design Aid (SDA - create menus and displays),
Data File Utility (DFU - create test data) and Query (an end-user query
tool).

What you should be able to do


After completing this unit, you should be able to:
Identify courses that you should attend
Use SDA, DFU, and Query

How you will check your progress


Machine exercises

Copyright IBM Corp. 1997, 2012

Unit 15. Wrap-up and supplemental exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

15-1

Student Notebook

Unit objectives
IBM i

After completing this unit, you should be able to:


Identify courses that you should attend
Use SDA, DFU, and Query

Copyright IBM Corporation 2012

Figure 15-1. Unit objectives

OL4912.1

Notes:

15-2 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Next step
IBM i

Next step

Copyright IBM Corporation 2012

Figure 15-2. Next step

OL4912.1

Notes:

Copyright IBM Corp. 1997, 2012

Unit 15. Wrap-up and supplemental exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

15-3

Student Notebook

What can you do now?


IBM i

Use basic features of RDP to:


Edit DDS
Design displays and reports

Use IBM i Navigator to:


Create libraries, schema, and file objects
Browse files
Insert data into files
Run SQL Scripts

Use SEU to edit DDS.


Use CPYF utility.
Use basic IBM i commands.
Copyright IBM Corporation 2012

Figure 15-3. What can you do now?

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!

15-4 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

Control language programming:


OL20/OL201 Control Language Programming Workshop for IBM i

Copyright IBM Corporation 2012

Figure 15-4. Programming courses

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

Copyright IBM Corp. 1997, 2012

Unit 15. Wrap-up and supplemental exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

15-5

Student Notebook

Database courses
IBM i

OL62/OV620 - DB2 for IBM i Database Coding and


Implementation Using DDS and CL Commands
OD47/OD470 - IBM i DB2 and SQL School
OL37/OV370 - Accessing the IBM i Database Using SQL
OL38/OL380 - Developing IBM i Applications Using SQL
OL39/OV390 - DB2 for IBM i SQL Advanced Programming

Copyright IBM Corporation 2012

Figure 15-5. Database courses

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).

15-6 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

WDSC/RDP courses
IBM i

RN500 - IBM i RPG Development with IBM Rational Developer


for Power Systems Software V8
AS96 - Advanced WebFacing Functions using WebSphere
Development Studio Client AEV6 WDSC
OW87 - IBM i Application Development using WDSC Version
7.0
AS94 - IBM WebSphere Application Server V7.0 for IBM i
Administration
OW80 - WAS V7.0 Performance for IBM i
Copyright IBM Corporation 2012

Figure 15-6. WDSC/RDP courses

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

Copyright IBM Corp. 1997, 2012

Unit 15. Wrap-up and supplemental exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

15-7

Student Notebook

Java anyone?
IBM i

AS08 - Java for RPG Programmers

Copyright IBM Corporation 2012

Figure 15-7. Java anyone?

OL4912.1

Notes:
RPG IV programmers can get a better feel for Java with this course.

15-8 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

Uempty

Machine exercises
IBM i

Build display file and HLL program


Build a menu display format with DDS
Screen Design aid for menus
SDA for display formats
Overrides
Data File utility
Query for IBM i

Copyright IBM Corporation 2012

Figure 15-8. Machine exercises

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.

Copyright IBM Corp. 1997, 2012

Unit 15. Wrap-up and supplemental exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

15-9

Student Notebook

Unit summary
IBM i

Having completed this unit, you should be able to:


Identify courses that you should attend
Use SDA, DFU, and Query

Copyright IBM Corporation 2012

Figure 15-9. Unit summary

OL4912.1

Notes:

15-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

AP

Appendix A. Checkpoint solutions


Unit 1, "Class administration and introduction"
No checkpoint solutions in this unit.

Unit 2, "IBM i application development tools"


Solutions for Figure 2-19, "Checkpoint," on page 2-26

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:

Rational Developer for Power Systems Software (RDP) workstation


Screen Designer (part of RDP) - workstation
Report Designer (part of RDP) - workstation
LPEX editor (part of RDP) - workstation
SEU, SDA, RLU - IBM i
DB2 Web Query workstation

2. True or False: RPG and CL programs cannot be edited


interchangeably using the SEU or the LPEX editors.
The answer is False.

3. True or False: Rational Development Studio is formerly known as


WebSphere Development Studio.
The answer is True.
Copyright IBM Corporation 2012

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-1

Student Notebook

Unit 3, "IBM i concepts and overview"


Solutions for Figure 3-19, "Checkpoint," on page 3-24

Checkpoint solutions
IBM i

1. Many of the functions traditionally performed by system control


programs have been _______________
a.
b.
c.
d.

placed into subsystems.


integrated into the IBM i machine and hardware.
eliminated.
relegated to *MACHINE pool.
The answer is integrated into the IBM i machine and hardware.

2. Which of the following are attributes of single level storage?


a.
b.
c.
d.

All storage is managed as one container.


Objects are distributed across multiple disks.
User does not need to designate location.
All of the above.
The answer is All of the above.

3. What object on the IBM i can organize other objects?


The answer is Library.
Copyright IBM Corporation 2012

A-2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

AP

Unit 4, "IBM i Access and IBM i Navigator"


Solutions for Figure 4-12, "Checkpoint," on page 4-15

Checkpoint solutions
IBM i

1. What component of IBM i Access allows you to perform


administrative and system operations in a Windows
environment?
The answer is IBM i Navigator.

2. What component of IBM i Navigator allows you to perform


system management functions such as system monitoring,
PTF management, and so forth?
The answer is Management Central.

3. True or False: IBM i Navigator is able to support multiple IBM


i servers running different levels of IBM i.
The answer is true.
Copyright IBM Corporation 2012

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-3

Student Notebook

Unit 5, "Managing work flow on the IBM i"


Solutions for Figure 5-37, "Checkpoint," on page 5-43

Checkpoint solutions
IBM i

1. What are two common types of jobs on an IBM i system?


The answer is Batch and interactive.

2. Where does printer output typically go on an IBM i system?


The answer is Spool files (which are stored using output queues).

3. What command could you use to view spool files?


The answer is WRKSPLF.

4.

What command could you use to view your batch jobs?


The answer is WRKSBMJOB.

5. What else could you use to view spool files?


The answer is IBM i Navigator.

6. What IBM i feature can be used to separate jobs into different


environments?
The answer is Subsystems.
Copyright IBM Corporation 2012

A-4

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

AP

Unit 6, "Commands, profiles, and libraries"


Solutions for Figure 6-31, "Checkpoint," on page 6-37

Checkpoint solutions
IBM i

1. What two types of parameter formats are used on CL


commands?
The answers are Keyword and Positional.

2. In a 5250 session, what are two of the handiest keys when


dealing with a command you are not familiar with?
The answers are F1 (Help) and F4 (Prompt).

3. If you do not qualify an object name with a library name,


where will the system generally look for that object?
The answer is In the Library List (*LIBL).

Copyright IBM Corporation 2012

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-5

Student Notebook

Unit 7, "Introduction to IBM i security"


Solutions for Figure 7-25, "Checkpoint," on page 7-31

Checkpoint solutions
IBM i

1. What are three methods of controlling access to IBM i


objects?
The answers are:
User profiles
Group profiles
Authority lists

2. Can a user profile use multiple group profiles?


The answer is yes, a group profile and up to 15 supplemental group
profiles may be specified in a user profile.

3. What are two methods you can use to manage profiles,


authorities and authorization lists?
The answers are CL commands (WRKUSRPRF, EDTOBJAUT,
CHGAUTLE, ) and IBM i Navigator.
Copyright IBM Corporation 2012

A-6

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

AP

Unit 8, "Control language programming"


Solutions for Figure 8-42, "Checkpoint," on page 8-49

Checkpoint solutions
IBM i

1. When editing a CL program in SEU, what can you use to help


you with the command parameters?
The answer is F4, just like on the command line.

2. How is a variable denoted in a CL program?


The answer is it starts with an ampersand (&).

3. Which IBM i programming model is generally used in a


complex environment?
The answer is ILE.

Copyright IBM Corporation 2012

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-7

Student Notebook

Unit 9, "Basic message handling"


Solutions for Figure 9-15, "Checkpoint," on page 9-17

Checkpoint solutions
IBM i

1. Where do messages get sent on an IBM i?


The answer is to a message queue.

2. How many message queues are on an IBM i?


The answer is most likely many. There are system defined queues
such as QSYSOPR and every user generally has at least one
message queue.

3. What could you use to send an important message to users


on an IBM i?
The answers are SNDBRKMSG and IBM i Navigator.

Copyright IBM Corporation 2012

A-8

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

AP

Unit 10, "Creating reports and displays"


Solutions for Figure 10-25, "Checkpoint," on page 10-28

Checkpoint solutions
IBM i

1. What can be defined using DDS on an IBM i?


The answers are:
physical files
logical files
display screens
reports

2. What are the three hierarchical levels in a DDS file?


The answers are:
File level
Record format level
Field level

3. What tools can be used to create DDS?


The answers are:
SEU
RDP (LPEX/Screen Designer/Report Designer)
Copyright IBM Corporation 2012

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-9

Student Notebook

Unit 11, "IBM DB2 for i"


Solutions for Figure 11-21, "Checkpoint," on page 11-24

Checkpoint solutions
IBM i

1. What are the five main operations that are performed on


relational data?
The answers are Selection, Projection, Sequence/ordering, Union,
and Join.

2. Describe the primary difference between tables/physical files


and views/logical files.
The answer is data is actually stored in a physical file/table. A view
or logical file does not generally contain any data, but points to the
physical data stored in a table or physical file.

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

A-10 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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.

Copyright IBM Corporation 2012

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-11

Student Notebook

Unit 13, "Defining database files using DDS"


Solutions for Figure 13-57, "Checkpoint," on page 13-59

Checkpoint solutions
IBM i

1. Where is the information (record formats, field definitions, and


so forth) that describes a physical file stored?
The answer is as part of the file itself. This is called an externally
described file as that information does not need to be coded into
every program you write that accessed the file.

2. What are two of the commands that you could use to display
that information?
The answer is DSPFD and DSPFFD.

3. On the IBM i a physical file may contain multiple groups of


data that are accessed separately, what are these called?
The answer is Member.
Copyright IBM Corporation 2012

A-12 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0
Student Notebook

AP

Unit 14, "Using the Legacy toolset (PDM/SEU/CPYF)"


Solutions for Figure 14-93, "Checkpoint," on page 14-120

Checkpoint solutions
IBM i

1. What are some of the commands that could be used to


access the SEU editor?
The answers are:
STRSEU
STRPDM
WRKMBRPDM

2. What command could you use to find the occurrences of a


particular string in source files?
The answer is FNDSTRPDM.

3. What does a join do in a logical file?


The answer is connects the records from two files based on a
common key field.
Copyright IBM Corporation 2012

Unit 15, "Wrap-up and supplemental exercises"


No checkpoint solutions in this unit.

Copyright IBM Corp. 1997, 2012

Appendix A. Checkpoint solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-13

Student Notebook

A-14 IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

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

IBM i Information Center


IBM Redbooks IBM i Collection

Advanced Functions and Administration on DB2 Universal


Database for System i
Stored Procedures and Triggers on DB2 Universal Database for
System i
Who Knew You Could do that with RPGIV?

Copyright IBM Corp. 1997, 2012

Appendix X. Bibliography

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

X1

Student Notebook

X2

IBM i Programming Facilities

Copyright IBM Corp. 1997, 2012

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V7.0

backpg

Back page

You might also like