Top Banner
IBM i Programming Facilities Workshop (Course code OL49) Student Notebook ERC 12.1 V7.0 cover
618

RXZ5E_ol49studentnotebook

Dec 23, 2015

Download

Documents

Información plataforma IBM i
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: RXZ5E_ol49studentnotebook

V7.0

cover

Front cover

IBM i Programming Facilities Workshop (Course code OL49)

Student NotebookERC 12.1

Page 2: RXZ5E_ol49studentnotebook

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:

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.

AS/400® CICS® Clementine®COBOL/400® DB™ DB2 Universal Database™DB2® Integrated Language

Environment®iSeries®

i5/OS™ i5/OS® Language Environment®Lotus Notes® Lotus® Notes®Power Systems™ Power Systems Software™ Power®Rational® Redbooks® RPG/400®SPSS® System i® WebSphere®xSeries® 400®

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 customer’s ability to evaluate and integrate them into the customer’s 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.

Page 3: RXZ5E_ol49studentnotebook

Student NotebookV7.0

TOC

Contents

Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Course description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

Agenda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Unit 1. Class administration and introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2Course objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3Class administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4Agenda (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5Agenda (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6Introductions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8

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

Unit 3. IBM i concepts and overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2Introducing the IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3Early relationship of applications to hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4Traditional system architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5IBM i high-level machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6Architecture: Single-level storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8

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

© Copyright IBM Corp. 1997, 2012 Contents iii

Page 4: RXZ5E_ol49studentnotebook

Student Notebook

Virtual storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-11Single-level storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-12IBM i object types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-13The IBM i object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-14Libraries/objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-15IBM i library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-16Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-17Library/object structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-18Supplied libraries (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-19Supplied libraries (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-20User libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-21File systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-22Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-24Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-25

Unit 4. IBM i Access and IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-2IBM i Access components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4What is IBM i Navigator? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-5Purpose of IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6Simplified IBM i administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7Management Central overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-9What is supported on an i? (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-11What is supported on an i? (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-12Management Central help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-13Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-14Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-15Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-16

Unit 5. Managing work flow on the IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2IBM i jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3Types of jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-5User view of an interactive job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-6User view of a batch job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-7Sign On display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-8IBM i Main Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-9Alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-10First job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11System Request menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-12Sign On to alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-13Alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-14Toggling from alternate job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-15IBM i job descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-16System view of an interactive job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-17System view of a batch job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-18Spooling intercept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-19

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

iv IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 5: RXZ5E_ol49studentnotebook

Student NotebookV7.0

TOC

Printer device file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20Printer queue and printer device file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21Print output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22Work with All Spooled Files: WRKSPLF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23Display Spooled Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24Change Spooled File Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25Changing multiple spooled members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26Using IBM i Navigator to work with printed output . . . . . . . . . . . . . . . . . . . . . . . . . 5-27Printer output functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28Manage printer output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29Viewing printed output using AFP Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31Printer output properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32Customizing the view of printer output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-34IBM i subsystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-35What is a subsystem? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-36Contents of subsystem description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-37Subsystem configurations shipped by IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-39Storage pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41Work management summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-42Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-44

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

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

© Copyright IBM Corp. 1997, 2012 Contents v

Page 6: RXZ5E_ol49studentnotebook

Student Notebook

How to change your library after sign on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-32In which library is an object created? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-33Use libraries to organize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-34Library related commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-35Machine exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-36Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-37Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-38

Unit 7. Introduction to IBM i security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-2IBM i security concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3Security is always active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4Layers of security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5QSECURITY system value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-6Components of IBM i security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8User profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-9User profiles shipped with IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-10System authority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-11System-defined authority combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-13Group profile example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-15How multiple group profiles work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-16Authorization lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-17Managing authorization lists using IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . .7-18Sign On display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20Sign on processing (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21Sign on processing (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-22Authority search process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-23Authorization flow (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-24Authorization flow (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-25EDTOBJAUT command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-26Display object authorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-27Managing security using IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-28IBM i Navigator Security Configuration Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-29Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-31Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-32

Unit 8. Control language programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-2Structure and rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-3Why use control language programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-4Control language program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6CL program structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7Command format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8CL command syntax (1 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-9CL command syntax (2 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-10CL command syntax (3 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-11CL command syntax (4 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-12Coding rules (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-13

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

vi IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 7: RXZ5E_ol49studentnotebook

Student NotebookV7.0

TOC

Coding rules (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14Information Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15Basic CL programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16Control work flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17CL program structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18Declare CL variable (DCL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19Conditional execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20Relational and logical expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-21IF examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22DO group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23Nested IF statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24PGMB and/or PGMC and/or PGMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-25PGMB or PGMC or PGMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26Branching within a program: GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-27Using the DOUNTIL and DOWHILE commands . . . . . . . . . . . . . . . . . . . . . . . . . . 8-28Using the SELECT command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30Branching outside a program: TFRCTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-32Communicating data to a program with CALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33HLL and CL programs may call each other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-35CHGVAR: Arithmetic calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-36CHGVAR: Conversion between *CHAR and *DEC data types . . . . . . . . . . . . . . . 8-37Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-38Data type conversion and concatenation example . . . . . . . . . . . . . . . . . . . . . . . . 8-39Summary of using PDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-40Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-41ILE versus OPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-42OPM versus ILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-43Dynamic program call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-45ILE static call: Bind by copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-46ILE static call: Bind by reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-48Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-49Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-50

Unit 9. Basic message handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2An overview of message handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3Basic message queue communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4User and workstation message queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5Sending and displaying messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6Sending an inquiry message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7Displaying messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8Sending break messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10Additional Message Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11Message handling using IBM i Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12Sending messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13Additional message functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14View messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16

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

© Copyright IBM Corp. 1997, 2012 Contents vii

Page 8: RXZ5E_ol49studentnotebook

Student Notebook

Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-17Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-18

Unit 10. Creating reports and displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-2Introduction to data description specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-3What is DDS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-4Levels of DDS definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-5DDS report example (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-6DDS report example (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-8DDS screen file example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-9Designing reports and displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-10Screen/Report Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-11What is Screen Designer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-12WYSIWYG screen and report design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-13Screen Designer interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-14Displaying groups of records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-15Trees, workbooks, and notebooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-16Designing a display file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-18Using the display file palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-19Using the Properties view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-20Designing a report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-21Using the printer file palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-22Working with Screen Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-23Verifying your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-24Summary of using Screen/Report Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-25Machine exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-26Summary of Screen/Report Designer features . . . . . . . . . . . . . . . . . . . . . . . . . . .10-27Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-28Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-29

Unit 11. IBM DB2 for i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-2Introduction to relational database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-3IBM DB2 for i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-4Working with a relational DBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-5IBM DB2 for i relational database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-6IBM DB2 for i is integrated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-8Traditional program data definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-9Externally-described IBM i file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-10Externally-described file example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-11Externally-described file components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-12Relational database operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-13IBM i logical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-14Legacy coding to define database file CLASSPF . . . . . . . . . . . . . . . . . . . . . . . . .11-15SQL versus native IBM i DB object terminology . . . . . . . . . . . . . . . . . . . . . . . . . .11-16More terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-17IBM DB2 for i offers flexibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-18

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

viii IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 9: RXZ5E_ol49studentnotebook

Student NotebookV7.0

TOC

Schema, libraries, and field reference files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20SQL catalogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21Native files and SQL objects coexist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22IBM i and the DB2 family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-24Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25

Unit 12. Accessing the IBM i database using SQL and IBM i Navigator . . . . . . . . 12-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2An introduction to SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3Introducing SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4Using SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6Types of SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-75250 interactive SQL interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-10Example SQL query using STRSQL (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-11Example SQL query using STRSQL (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13Closing an interactive SQL session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-14SQL source member . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15Other useful SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-16Database case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17Tables used in the school database case study . . . . . . . . . . . . . . . . . . . . . . . . . 12-18Required case study results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-19Creating a schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-20Creating a schema using IBM i Navigator (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . 12-21Creating a schema using IBM i Navigator (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . 12-22Objects in schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-23Create CLASSPF table (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-24Create CLASSPF table (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-25Define columns (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-26Define columns (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27Column naming rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-29Adding column headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-30Run SQL Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-31Resulting SQL: LABEL ON statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-32Create index for CLASSPF on column CRSCODE (1 of 2) . . . . . . . . . . . . . . . . 12-33Create index for CLASSPF on column CRSCODE (2 of 2) . . . . . . . . . . . . . . . . 12-35Create table GRADEPF99 (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-36Create table GRADEPF99 (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-37Create table GRADEPF98 (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-39Create table GRADEPF98 (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-40Create table GRADEPF98 (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-41New Table: GRADEPF98 final review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-42GRADEPF98 in FACSLIB2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-43Review the newly created table GRADEPF98 . . . . . . . . . . . . . . . . . . . . . . . . . . 12-44Display table data: GRADEPF99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-45Insert new rows in table GRADEPF99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-46Create index for table GRADEPF99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-47Create index GRADEPF99I (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-48

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

© Copyright IBM Corp. 1997, 2012 Contents ix

Page 10: RXZ5E_ol49studentnotebook

Student Notebook

Create index GRADEPF99I (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-49Assign permissions: Grant/Revoke authorities . . . . . . . . . . . . . . . . . . . . . . . . . . .12-50Where are we? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-51Using SQL to complete the case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-52SELECT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-53Case study requirement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-55Executing the SQL SELECT statement (1 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-56Executing the SQL SELECT statement (2 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-57Executing the SQL SELECT statement (3 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-58Executing the SQL SELECT statement (4 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-59Executing the SQL SELECT statement (5 of 5) . . . . . . . . . . . . . . . . . . . . . . . . . .12-60Case study requirement: Union of grades (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . .12-61Case study requirement: Union of grades (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . .12-62Case study requirement: Union of grades (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . .12-63Case study requirement: Select data from related tables . . . . . . . . . . . . . . . . . . .12-64Combining data from tables using JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-65Case study JOIN (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-66Case study JOIN (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-68Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-69Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-70Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-71

Unit 13. Defining database files using DDS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-2Creating IBM i physical and logical files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-3Physical files used in the school database case study . . . . . . . . . . . . . . . . . . . . . .13-4Logical files used in the school database case study (1 of 2) . . . . . . . . . . . . . . . . .13-5Logical files used in the school database case study (2 of 2) . . . . . . . . . . . . . . . . .13-6Physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-7DSPFD CLASSPF (1 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-8DSPFD CLASSPF (2 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-9DSPFD CLASSPF (3 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-10DSPFD CLASSPF (4 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-11DSPFD CLASSPF (5 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-12DSPFD CLASSPF (6 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-13DSPFD CLASSPF (7 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-14DSPFD CLASSPF (8 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-15DSPFD CLASSPF (9 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-16DSPFD CLASSPF (10 of 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-17DSPFFD CLASSPF (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-18DSPFFD CLASSPF (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-19DSPFFD CLASSPF (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-20Multiple member physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-21Source physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-22Types of source in source physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-23Naming convention for source PFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-24Creating a source file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-25Creating database files and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-26

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

x IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 11: RXZ5E_ol49studentnotebook

Student NotebookV7.0

TOC

Physical and logical file naming rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-27Coding for physical file CLASSPF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-28Coding for physical files GRADEPF98 and GRADEPF99 . . . . . . . . . . . . . . . . . . 13-29Create source physical file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-30Create new source member . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-31Create CLASSPF *File object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-32Our library after GRADEPF99 is created . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-33Creating database files and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-34Logical files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-35Relational database operations using logical files . . . . . . . . . . . . . . . . . . . . . . . . 13-36Logical file: Selection and sequence (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-37Logical file: Selection and sequence (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-38Logical file: Selection and sequence (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-40DSPFD GRADELF99 (1 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-41DSPFD GRADELF99 (2 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-42DSPFD GRADELF99 (3 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-43DSPFD GRADELF99 (4 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-44DSPFD GRADELF99 (5 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-45DSPFD GRADELF99 (6 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-46DSPFD GRADELF99 (7 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-47DSPFD GRADELF99 (8 of 8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-48DSPFFD GRADELF99 (1 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-49DSPFFD GRADELF99 (2 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-50DSPFFD GRADELF99 (3 of 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-51Using a field reference file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-52Using a field reference file for our case study . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-53Properties of a field reference file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-54Field reference file for school database (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . 13-55Field reference file for school database (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . 13-56DDS for CLASSPF using SCHOOLREFFRF . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-57Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-58Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-59Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-60

Unit 14. Using the Legacy toolset (PDM/SEU/CPYF). . . . . . . . . . . . . . . . . . . . . . . . 14-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2Application Development ToolSet (ADTS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3Application Development ToolSet for IBM i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4Programming Development Manager (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6Programming Development Manager (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7PDM options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-8PDM work with members (1 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9PDM work with members (2 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-10PDM work with members (3 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-11PDM work with members (4 of 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-21Create new member (1 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-22Create new member (2 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-23Create new member (3 of 7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-24

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

© Copyright IBM Corp. 1997, 2012 Contents xi

Page 12: RXZ5E_ol49studentnotebook

Student Notebook

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

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

xii IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 13: RXZ5E_ol49studentnotebook

Student NotebookV7.0

TOC

Example: Implement the field change (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-88Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-89CPYF (copy file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-90Copy functions and commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-91Copy function: From and to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-92Selecting members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-93Copy file: FROMMBR, TOMBR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-94Copy file: CRTFILE, MBROPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-95Copy file: FROMRCD, TORCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-96Copy file: FROMKEY, TOKEY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-97Copy file: NBRRCDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-98Copy file: INCCHAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-99Copy file: INCREL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-100Copy file: FMTOPT(*DROP *MAP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-101Copy file: FMTOPT(*NOCHK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-103Creating test data using a DB copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-104Print options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-105Create a file not previously defined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-106Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-107Additional database capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-108Logical File: Union, projection, and sequence (1 of 2) . . . . . . . . . . . . . . . . . . . 14-109Logical file: Union, projection, and sequence (2 of 2) . . . . . . . . . . . . . . . . . . . . 14-110Multiformat logical file: Union, sequence (1 of 2) . . . . . . . . . . . . . . . . . . . . . . . 14-111Multiformat logical file: Union, sequence (2 of 2) . . . . . . . . . . . . . . . . . . . . . . . 14-112Logical file: Inner join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-113Logical file DDS: Inner JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-114Logical file: Left outer JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-115Logical file DDS: Left outer JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-116Creating logical file and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-117School case study summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-118Machine exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-119Checkpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-120Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-121

Unit 15. Wrap-up and supplemental exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1Unit objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2Next step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-3What can you do now? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4Programming courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-5Database courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6WDSC/RDP courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-7Java anyone? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-8Machine exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-9Unit summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-10

Appendix A. Checkpoint solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1

Appendix X. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X-1

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

© Copyright IBM Corp. 1997, 2012 Contents xiii

Page 14: RXZ5E_ol49studentnotebook

Student Notebook

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

xiv IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 15: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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:

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.

AS/400® CICS® Clementine®COBOL/400® DB™ DB2 Universal Database™DB2® Integrated Language

Environment®iSeries®

i5/OS™ i5/OS® Language Environment®Lotus Notes® Lotus® Notes®Power Systems™ Power Systems Software™ Power®Rational® Redbooks® RPG/400®SPSS® System i® WebSphere®xSeries® 400®

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

© Copyright IBM Corp. 1997, 2012 Trademarks xv

Page 16: RXZ5E_ol49studentnotebook

Student Notebook

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

xvi IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 17: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Course description xvii

Page 18: RXZ5E_ol49studentnotebook

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.

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

xviii IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 19: RXZ5E_ol49studentnotebook

Student NotebookV7.0

pref

Agenda

Day 1

Unit 1 - Class administration and introductionUnit 2 - IBM i application development toolsUnit 3 - IBM i concepts and overviewUnit 4 - IBM i Access and IBM i NavigatorMachine Exercise - Navigating IBM i NavigatorUnit 5 - Managing work flow on the IBM iUnit 6 - Commands, profiles, and libraries

Day 2

Machine exercise - Create library and work with library listMachine exercise - Modify profile, work with job description and alternate JobUnit 7 - Introduction to IBM i securityUnit 8 - Control language programming Machine exercise - Write a basic CL programUnit 9 - Basic message handlingMachine exercise - Using messages

Day 3

Unit 10 - Creating reports and displaysMachine exercise - Editing display file sourceMachine exercise - Designing and creating display screensMachine exercise - Designing and creating reportsUnit 11 - IBM DB2 for iUnit 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 (cont’d)Machine exercise - Working with the database using IBM i NavigatorUnit 13 - Defining database files using DDSDesk exercise - Code a physical and a logical fileUnit 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.

© Copyright IBM Corp. 1997, 2012 Agenda xix

Page 20: RXZ5E_ol49studentnotebook

Student Notebook

Day 5

Machine exercise - Using the IBM i EditorsMachine exercise - Code and create files and use file-related commandsMachine exercise - Copy fileMachine exercise - Additional physical and logical filesUnit 15 - Wrap up and supplemental exercisesMachine exercise - Build display file and HLL programMachine exercise - Build a menu display format with DDSMachine exercise - Build a menu using Screen Design AidMachine exercise - SDA for screen formatsMachine exercise - OverridesMachine exercise - Data File Utility (DFU)Machine exercise - Query for IBM i

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

xx IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 21: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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 location’s facilities

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

© Copyright IBM Corp. 1997, 2012 Unit 1. Class administration and introduction 1-1

Page 22: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

PrerequisitesBefore 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

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

1-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 23: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Course objectivesAfter 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

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

© Copyright IBM Corp. 1997, 2012 Unit 1. Class administration and introduction 1-3

Page 24: RXZ5E_ol49studentnotebook

Student Notebook

Figure 1-3. Class administration OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

FACILITIES

CLASS

HOURS

BADGES

PHONES

FOOD

QUESTIONSMAPS

Class administration

� Student information� Badges/security� Phones and messages� Facilities� Class hours� Local restaurants� Maps - area and building

� Questions� Introductions

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

1-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 25: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 1-4. Agenda (1 of 2) OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Agenda (1 of 2)� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 1. Class administration and introduction 1-5

Page 26: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Agenda (2 of 2)� 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

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

1-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 27: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 1-6. Introductions OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Introductions

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

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

© Copyright IBM Corp. 1997, 2012 Unit 1. Class administration and introduction 1-7

Page 28: RXZ5E_ol49studentnotebook

Student Notebook

Figure 1-7. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

Having completed this unit, you should be able to:� List the units to be presented in the course� Find and use the teaching location�s facilities

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

1-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 29: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-1

Page 30: RXZ5E_ol49studentnotebook

Student Notebook

Figure 2-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectivesAfter 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

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

2-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 31: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 2-2. IBM i application development tools OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

IBM i application development tools

IBM iIBM iapplication development toolsapplication development tools

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-3

Page 32: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Programming tasks

� 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

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

2-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 33: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

RDS/RDP 8.0.3

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

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

5770WDSi V7.1

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

Feature: ADTS� Option 21 ADTS

COBOL, RPG, C/C++

RDP

RD for i for SOARDP, RBD, HATS

JavaRAD

i V5.45722WDS

EGL, Web design

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-5

Page 34: RXZ5E_ol49studentnotebook

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.

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

2-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 35: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM Rational Developer for Power Systems Software v8.0.3

� 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

Thread 1: X=X + 1Thread 2: OPENFile(customer)

Thread 3: Write record ds

PGM 1

PGM 2

File parameter

12

6

39

Comprehensive suite of compilers and tools for IBM i development

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-7

Page 36: RXZ5E_ol49studentnotebook

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

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

2-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 37: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Tool choices: Editors (1 of 2)

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-9

Page 38: RXZ5E_ol49studentnotebook

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.

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

2-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 39: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Tool choices: Editors (2 of 2)

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-11

Page 40: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Tool choices: Displays and reports (1 of 4)

� Screen Design Aid� Create and maintain displays and

menus� 5250 'green screen' based� Can invoke using STRSDA or from

PDM

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

2-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 41: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Tool choices: Displays and reports (2 of 4)

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

source

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-13

Page 42: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Tool choices: Displays and reports (3 of 4)

� Report Layout Utility

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

2-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 43: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Tool choices: Displays and reports (4 of 4)

� Report Designer

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-15

Page 44: RXZ5E_ol49studentnotebook

Student Notebook

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 Developer’s Workbench to build more customized reports or enhance a meta data layer.

© Copyright IBM Corporation 2012

IBM i

For more details, refer to: http://www.ibm.com/systems/i/software/db2/webquery

IBM DB2 Web Query for IBM i (1 of 2) � 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***)

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

2-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 45: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

This product is an OEM agreement with Information Builder’s Web FOCUS product. Add additional components from Information Builders such as ERP or other database adapters (to query Oracle, for instance, you’d add an Oracle Adapter). Grow into more complete BI solutions leveraging the product’s 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.

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-17

Page 46: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

IBM DB2 Web Query for IBM i (2 of 2)� 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

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

2-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 47: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Preserve investment in Query/400

Then modify with Report Assistant

Or rewrite as new Web Query to take advantage of SQE

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-19

Page 48: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Product packaging� The product has a modular structure.

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

Base product

ReportAssistant

GraphAssistant

PowerPainter

Query/400Adapter

ActiveReport

OLAP

DeveloperWorkbench

DataAdapter

ReportCaster

. . .

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

2-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 49: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

What do you need to buy?

� Base product

� Additional modules, if needed

� 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

Base Product

ReportAssistant

GraphAssista

nt

PowerPainter

Query/400Adapter

ActiveReport

OLAP

DeveloperWorkbench

DataAdapter

ReportCaster

. . .

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-21

Page 50: RXZ5E_ol49studentnotebook

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 don’t 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.

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

2-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 51: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 it’s 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 Corporation 2012

IBM i

How do you get 5733-QU2?� 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

� 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

SW groups Included users

P05 2

P10 4P20 6

P30 8

P40 10

P50 15

P60 20

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-23

Page 52: RXZ5E_ol49studentnotebook

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

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

2-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 53: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DB2 for i home page� Your portal to everything DB2

� General information� See it in action demos� What�s 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

ibm.com/systems/i/software/db2

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-25

Page 54: RXZ5E_ol49studentnotebook

Student Notebook

Figure 2-19. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

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

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

2-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 55: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Unit summary

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

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

© Copyright IBM Corp. 1997, 2012 Unit 2. IBM i application development tools 2-27

Page 56: RXZ5E_ol49studentnotebook

Student Notebook

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

2-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 57: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-1

Page 58: RXZ5E_ol49studentnotebook

Student Notebook

Figure 3-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

3-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 59: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 3-2. Introducing the IBM i OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Introducing the IBM i

Introducing the IBM i

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-3

Page 60: RXZ5E_ol49studentnotebook

Student Notebook

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 system’s 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.

© Copyright IBM Corporation 2012

IBM i

Application programs

Hardware

Early relationship of applications to hardware

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

3-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 61: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SupervisorMVS

CommunicationsVTAM

Transaction ProcessorCICS

File ManagementVSAM

Database ManagementDB2

Virtual StorageManagement MVS

SpoolingJES

SecurityRACF

User Program AreaCOBOL

Licensed Internal Codeand Hardware

Machine Interface370 Instruction Set

Traditional system architecture

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-5

Page 62: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

User Program Area

SecurityVirtual Storage ManagementDatabase ManagementFile ManagementCommunicationsSupervisor

Machine Interface (MI)

Internal Microprogramming Interface (IMI)

Licensed Internal Codeand Hardware

Software

High-levelMachine

IBM i high-level machine

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

3-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 63: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-7

Page 64: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

A

A

A

A

Main Storage

A

A A

A

Drive 1 Drive 2 Drive 3

Auxiliary Storage

Architecture: Single-level storage

� All storage managed as one container of objects

� An object (file, program, and so forth) is distributed across multiple disk units

� User not concerned with designating location

� Load balancing based on performance and capacity

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

3-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 65: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-9

Page 66: RXZ5E_ol49studentnotebook

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.

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

3-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 67: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Swapping is done with an entire job structure.Paging is done with a portion of a job structure.

Main Storage Auxiliary Storage

Virtual storage

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-11

Page 68: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Data Program

Data Data

Program Data Data Program Data Program

Data Program Program Data Data

Data Data DataProgram Program

Job Queue

Output Queue

User Profile

Library

Program

Main Storage

Auxiliary Storage

Single-level storage

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

3-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 69: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM i object types� AUTL Authorization List

� CMD Command Definition

� DTAARA Data Area

� DEVD Device Description

� FILE File

� FLR Folder

� JOBD Job Description

� JOBQ Job Queue

� JRN Journal

� JRNRCV Journal Receiver

� LIB Library

� MSGQ Message Queue

� OUTQ Output Queue

� PGM Program

� QRYDFN Query Definition

� SBSD Subsystem Description

� USRPRF User Profile

� And many more

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-13

Page 70: RXZ5E_ol49studentnotebook

Student Notebook

Figure 3-10. The IBM i object OL4912.1

Notes:

Each object is made up of two components:

1. Object description

2. Functional part

© Copyright IBM Corporation 2012

IBM i

Object Description

Object Functional Part

Physical File Members(Data Records)

Logical File Members(Access Paths)

Program Code

The IBM i object

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

3-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 71: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

LIBA

FILEA

FILEB

PROGY

FILEC

LIBZ

PROGX

FILEB

LIBB

FILEA

PROGY

QUEUE1 PROG4

Libraries/objects

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-15

Page 72: RXZ5E_ol49studentnotebook

Student Notebook

Figure 3-12. IBM i library OL4912.1

Notes:

For each object in a specific library, the library contains the object’s 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.

© Copyright IBM Corporation 2012

IBM i

MYDSPFMYPROG MYPF

IBM i libraryMYLIB

NAME TYPE ADDRESS

MYPROG *PGM ADDRESSMYDSPF *FILE ADDRESSMYPF *FILE ADDRESSMYLF *FILE ADDRESS

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

3-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 73: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

LIBA

FILEA

FILEB

PROGYFILEC

PROGX

FILEB

QUEUE1

PROG4

PROGY

LIBB

LIBZQSYS

SINGLE STORAGELEVEL

Libraries

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-17

Page 74: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

PGM 1

Other library objectsUser profilesConfiguration

LIB A

QSYS

LIB B

And so forth

And soforth

PGM 2FILE 1

MEMBER 1 MEMBER A

MEMBER B

FILE 2

Library/object structure

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

3-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 75: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

QSYSContains many IBM-supplied programs, data, and libraries

QGPLgeneral purpose library

Contains spool queues, source files, and so forth

Supplied libraries (1 of 2)

� Cannot be deleted or renamed� Owned by the security officer� Should be on all library lists

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-19

Page 76: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Other libraries include:QSPL Spooling libraryQRECOVERY Recovery library for IBM use onlyQDOC Document libraryQUSRSYS System library containing some user objects

Licensed Program Libraries:� QRPG/QRPGLE� QCBL/QCBLLEand many others

Supplied libraries (2 of 2)

QTEMP� Automatically created for each job on the system� Lasts only for the duration of the job� Useful place for storing temporary objects

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

3-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 77: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

User libraries

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-21

Page 78: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

QSYS.LIBFile

System

"Root"File

System

QOpenSysFile

System

QDLSFile

System

NetworkFile System

(NFS)

Integrated File System Interface

IntegratedFile System

Menus/Commands

Applications

ApplicationProgram Interface

Users

IBM iFile Server TCP/IP

File systems

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

3-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 79: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-23

Page 80: RXZ5E_ol49studentnotebook

Student Notebook

Figure 3-19. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. Many of the functions traditionally performed by system

control programs have been ________________a. placed into subsystems.b. integrated into the IBM i machine and hardware.c. eliminated.d. relegated to *MACHINE pool.

2. Which of the following are attributes of single level storage?a. All storage is managed as one container.b. Objects are distributed across multiple disks.c. User does not need to designate location.d. All of the above.

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

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

3-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 81: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 3-20. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

© Copyright IBM Corp. 1997, 2012 Unit 3. IBM i concepts and overview 3-25

Page 82: RXZ5E_ol49studentnotebook

Student Notebook

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

3-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 83: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-1

Page 84: RXZ5E_ol49studentnotebook

Student Notebook

Figure 4-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

4-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 85: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM i Access components

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-3

Page 86: RXZ5E_ol49studentnotebook

Student Notebook

Figure 4-3. IBM i Navigator OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

IBM i Navigator

IBM i Navigator

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

4-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 87: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

What is IBM i Navigator?

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-5

Page 88: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Purpose of IBM i Navigator

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

4-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 89: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Simplified IBM i administration

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-7

Page 90: RXZ5E_ol49studentnotebook

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.

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

4-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 91: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM iNavigator

Management Central overview

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-9

Page 92: RXZ5E_ol49studentnotebook

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.

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

4-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 93: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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

� Tailored view for each IBM i in the network� Based on available functions for IBM i level,

installed subcomponents, application administration settings

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-11

Page 94: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Go to: http://publib.boulder.ibm.com/infocenter/systems/scope/i5os/index.jsp

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

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

4-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 95: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Management Central help

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-13

Page 96: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Navigating IBM i Navigator

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

4-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 97: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 4-12. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

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

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

© Copyright IBM Corp. 1997, 2012 Unit 4. IBM i Access and IBM i Navigator 4-15

Page 98: RXZ5E_ol49studentnotebook

Student Notebook

Figure 4-13. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

4-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 99: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-1

Page 100: RXZ5E_ol49studentnotebook

Student Notebook

Figure 5-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

5-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 101: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM i jobs IBM i jobs

IBM i jobsIBM i jobs

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-3

Page 102: RXZ5E_ol49studentnotebook

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.

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

5-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 103: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 5-3. Types of jobs OL4912.1

Notes:

All jobs, regardless of type, are either:

1. Interactive

2. Batch

© Copyright IBM Corporation 2012

IBM i

Spooling Interactive

Autostart

Batch

Communication

System Jobs User Jobs

Types of jobs

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-5

Page 104: RXZ5E_ol49studentnotebook

Student Notebook

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 job’s output queue).

© Copyright IBM Corporation 2012

IBM i

Payroll

1 Checks2 Adjust

i

ApplicationProgram Database

Reports

User view of an interactive job

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

5-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 105: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SpooledFiles

Report Data

Report Data

Job Queue

Main Storage

Pay

Output Queue

Pay 01

DatabaseFile

Data

Pay

User view of a batch jobPayroll

1 Checks2 Adjust

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-7

Page 106: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Sign On display

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

5-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 107: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM i Main Menu

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-9

Page 108: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

JOB A JOB B

Sign-onProcessSystem Request, Opt 1or TFRSECJOB

2

ResumeProcessingSign-off

4

Sign-on ProcessSystem Requestor TFRSECJOB

1

ResumeProcessingSystem Request, Opt 1or TFRSECJOB

3

ResumeProcessingSign-off

5

Alternate job

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

5-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 109: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

First job

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-11

Page 110: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

System Request menu

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

5-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 111: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Sign On to alternate job

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-13

Page 112: RXZ5E_ol49studentnotebook

Student Notebook

Figure 5-12. Alternate job OL4912.1

Notes:

• Both jobs have equal status.

• Neither is a subordinate of the other.

© Copyright IBM Corporation 2012

IBM i

Alternate job

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

5-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 113: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Toggling from alternate job

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-15

Page 114: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

IBM i job descriptionsIBM i job descriptions

IBM i job descriptionsIBM i job descriptions

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

5-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 115: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

i

FREDPAYLIBOUTQAQDFTJOBD

Database

Reports

Payroll

1 Checks2 Adjust

*USRPRF

QDFTJOBDDATE *SYSVALSWITCH 00000000

LIBRARY LIST*SYSVAL______________

*JOBD

System ValuesQUSRLIBLQSYSLIBLQDATEQ . . .

PAYLIB

*LIB

OUTQA

*OUTQ

System view of an interactive job

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-17

Page 116: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

SpooledFiles

Report Data

Report Data

Job Queue

Payroll

1 Checks2 Adjust

Main Storage

PAY

PAY01

DatabaseFile

Data

PAY

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

System view of a batch job

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

5-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 117: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

QPRINT

SPOOL(*YES) DataManagement

SpoolingIntercept

Device File

PROGRAM

OUTQ

QPRINTPrintDataSpooled

File

Spooling intercept

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-19

Page 118: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

QPRINT

SPOOL = (*YES)OUTQ = (*JOB)FORMTYPE = (*STD)COPIES = (1)SCHEDULE = (*FILEEND)SAVE = (*NO)DEV = (*JOB)

More . . .

PROGRAMWrites to file QPRINT

OUTQ

QPRINT

Printer device file

Device file from CRTPRTF command

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

5-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 119: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SPOOL(*YES) OUTQ(*JOB) SPOOL(*NO) DEV(*JOB)

Job Output Queue: Determined at job initiation Job Printer Device:

OUTQ(*USRPRF) Job description PRTDEV(*USRPRF)

OUTQ(*WRKSTN) User profile PRTDEV(*WRKSTN)

OUTQ(*DEV)Device description

PRTDEV(*SYSVAL)

System valueQPRTDEV(PRT01)

At job initiation, the first named output queue and printer device found are used as the defaults for the job.

or

Printer queue and printer device file

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-21

Page 120: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

FRED OUTQ(FREDQ)

FRED*USRPRF

USRIDPASSWORD

JOBD QDFTJOBD

OUTQ FREDQ

QDFTJOBD*JOBD

OUTQ *USRPRF

INLLIBL *SYSVAL

PRT01*OUTQ

SPLF

PRT01*DEVD

SPOOLWTRPROG

FRED*OUTQ

SPLF

SPLF SPLF

STRPRTWTR PRT01 PRT01STRPRTWTR PRT06 FRED

WRKSPLF (DEFAULT PARMS)

OPTION 2 = CHANGEOPTION 5 = DISPLAYOPTION 4 = DELETECHGJOB OUTQ(PRTnn)

Print outputCRTUSRPRFCHGUSRPRFCHGPRF

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

5-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 121: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Work with All Spooled Files

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

Device or Total CurOpt File ser Queue User Data Sts Pages Page Copy___ PROG1 OPR07 PRT03 WTR 3 1 1_5_ OVRDUE OPR07 PRT03 RDY 3 1___ DROP OPR07 PRT03 RDY 6 1___ QPJOBLOG OPR07 JOBLOGS DROP RDY 10 1___ SAVEOPRLIB OPR07 PRT02 WTR 3 1 1___ SCREENS OPR07 PRT02 RDY 9 1___ QSYSPRT OPR07 PRT03 RDY 7 1

BottomParameters for options 1, 2, 3 or command===>_______________________________________________________________________

F3=Exit F10=View 3 F11=View 2 F12=Cancel F22=Printers F24=More keys

Work with All Spooled Files: WRKSPLF

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-23

Page 122: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Press F16

The contents of a spooled file can be displayed on the screen from any

of the Spooled Files list display

Display Spooled FilesFile . . . .: OVERDUE Page/Line 1/32Control . . : _______ Columns 1 - 75Find . . . .: 05/23 *...+....1....+....+....2....+....3....+....4....+....5....+....6....+....7...

ACCOUNT OPRLIB ACCOUNTDATE . . . . . . . . . 05/23/08TIME . . . . . . . . . 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 CODESMITH,JEFFREY 414 3347085 53095 WEST BEND, WI 4838 SOUTH STMUELLER,JANET 507 4452658 52685 ROCHESTER, MI 1478 14TH STWEST,CINDY 507 4438987 52369 ROCHESTER, MI 2578 16TH STSTARK,JAME 312 6458963 60621 CHICAGO, IL 2114 HALL STWENZEL,KIM 312 6489214 60125 SKOKIE, IL 840 GRAND STHAMMER,GAIL 305 6425584 33125 MIAMI, FL 18 FLAG AVEFISCHER,BRIAN 954 9452874 33084 DAVIE, FL 121 WEST STBRANDT,TONY 404 2314825 30305 ATLANTA, GA 18 ANDREWS DR

Confidential* * * * * * E N D O F L I S T I N G * * * * * * * *

BottomF3=Exit F12=Cancel F19=Left F20=Right F24=More keys

String found in position 63.

Display Spooled Files

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

5-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 123: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Change Spooled File Attributes

Spooled file. . . . . . > OVRDUE

Job Name. . . . . . . . > QDFTJOBD

User. . . . . . . . . > OPR07

Number. . . . . . . . > 020874

Spooled file number . . > 5

Printer. . . . . . . . . PRT03___

Print sequence . . . . . *SAME___

Form type. . . . . . . . *STD____

Copies . . . . . . . . . 1_______

Restart printing . . . . *STRPAGE

Additional Parameters

Output queue . . . . . . *DEV____

Library . . . . . . . ________

File separators . . . . _0______

Page range to print:

Starting page. . . . . _1______

Ending page. . . . . . _*END____

File becomes available . _*FILEEND

Save file. . . . . . . . _*NO_____

2=Change

Change Spooled File Attributes

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-25

Page 124: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Changing multiple spooled membersWork with All Spooled Files

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

Device or Total CurOpt File User Queue User Data Sts Pages Page Copy___ PROG1 OPR07 PRT03 WTR 3 1 1 _2_ OVRDUE OPR07 PRT03 RDY 3 1_2_ DROP OPR07 PRT03 RDY 6 1___ QPJOBLOG OPR07 JOBLOGS DROP RDY 10 1___ SAVEOPRLIB OPR07 PRT02 WTR 3 1 1___ SCREENS OPR07 PRT02 RDY 9 1_2_ QSYSPRT OPR07 PRT03 RDY 7 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

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

5-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 125: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

© Copyright IBM Corporation 2012

IBM i

Using IBM i NavigatorUsing IBM i Navigatorto work with printed outputto work with printed output

Using IBM i Navigator to work with printed outputUsing IBM i Navigator to work with printed output

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-27

Page 126: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Printer output functions� Manage printer output� Display the output� Display properties

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

5-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 127: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Manage printer output� Hold/Release� Send or move to another

printer/output queue� Delete� Reply to messages� Print next� Properties

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-29

Page 128: RXZ5E_ol49studentnotebook

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.

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

5-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 129: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Viewing printed output using AFP Workbench

� Using AFP Workbench Viewer

� Full-function viewer is included at no charge

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-31

Page 130: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Printer output properties

� Display output properties� Change output properties, such as:

� Printer/Queue� Number of copies� Priority� Form type

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

5-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 131: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-33

Page 132: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Customizing the view of printer output

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

5-34 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 133: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 5-31. IBM i subsystems OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

IBM i subsystemsIBM i subsystems

IBM i subsystemsIBM i subsystems

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-35

Page 134: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Subsystem

Interactive Processing

Subsystem

Batch Processing

Subsystem

Spooling

What is a subsystem?

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

5-36 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 135: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Contents of subsystem description

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-37

Page 136: RXZ5E_ol49studentnotebook

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.

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

5-38 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 137: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

QBASE QSPL SpoolingAutostart Job

QSYSWRK System Functions

QSERVER File Server

QCTL

QBATCH

Autostart Job

QSPL

QCMN

Batch

Spooling

Communications

Console

QSYSWRK

File Server

QINTER Interactive

QSERVER

System Functions

Subsystem configurations shipped by IBM� IPL starts only the subsystem named in QCTLSBSD system value� Environment as shipped (Default) - QCTLSBSD = QBASE

� Console, Interactive, Batch, Communications

� Complex environment �QCTLSBSD = QCTL

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-39

Page 138: RXZ5E_ol49studentnotebook

Student Notebook

The system value QCTLSBSD (Controlling subsystem) controls which subsystem configuration will be used on a System i system.

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

5-40 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 139: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Storage pool

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

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-41

Page 140: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

JOBQ

INTERACTIVE

BATCH

OUTQ

WRITER PRINTER

SBMJOB

CALL

WRKJOBQ WRKACTJOB WRKOUTQWRKSPLF

WRKUSRJOBWRKSBMJOB

WRKWTR

Work management summary

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

5-42 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 141: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 5-37. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

© Copyright IBM Corp. 1997, 2012 Unit 5. Managing work flow on the IBM i 5-43

Page 142: RXZ5E_ol49studentnotebook

Student Notebook

Figure 5-38. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

5-44 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 143: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-1

Page 144: RXZ5E_ol49studentnotebook

Student Notebook

Figure 6-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

6-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 145: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

© Copyright IBM Corporation 2012

IBM i

Overview of using commands, Overview of using commands, user profiles, and library listsuser profiles, and library lists

Overview of using commands, user profiles, and Overview of using commands, user profiles, and library listslibrary lists

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-3

Page 146: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

IBM i commands (1 of 2)Command and parameters:

CALL HerProgram

CPYF HerFile HisFile

Dltf OldFile

DSPLIB ourlib

Pwrdwnsys delay(120)

Rgzpfm disorgfile

sndbrkmsg 'Please signoff' *ALLWS

Function:

Run a program

Copy a file

Delete a file

Display a library

Power off

Reorganize a file

Send a message

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

6-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 147: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Verb + Item = Command

Create Physical File CRTPFCreate Logical File CRTLFCreate Display File CRTDSPFCreate ILE RPG Module CRTRPGMODCreate Bound RPG Program CRTBNDRPGCreate CL Program CRTCLPGMCreate Bound COBOL Program CRTBNDCBLCreate Library CRTLIB

Delete Program DLTPGMDelete File DLTFDelete Library DLTLIB

Change Command CHGCMDDisplay Data area DSPDTAARAHold Output queue HLDOUTQRelease Spooled file RLSSPLF

Work with User profile WRKUSRPRF

Not all verb + items = a valid command!

HLDDTAARADLTPF

Many more commands!

IBM i commands (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-5

Page 148: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Command Parameter

DSPLIB LIB(PAYLIB)Action Item

Abbrev.Keyword Value

Command syntax (1 of 2)

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

6-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 149: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Job: B,I Pgm: B,I REXX: B,I Exec

*SYSVAL*NONE*USRPRF*CHANGE*ALL

*LIBCRTAUT*CHANGE*ALL*USE*EXCLUDEauthorization-list-name

*SYSVAL*CHANGE*ALL*USE*EXCLUDEauthorization-list-name

CRTAUT

*PROD*TESTTYPE( )

asp-identifier 'description'ASP-- ( TEXT--(

CRTOBJAUD

(P)CRTLIB-LIB(-library-name-)

)

NOTE:P All parameters preceding this point can be specified positionallyF4=Prompt

AUT( )

( ) ( )

)

1 *BLANK

Command syntax (2 of 2)CRTLIB LIB(MYLIB) TYPE(*TEST) TEXT('PROGRAM DEVELOPMENT LIBRARY')

ORCRTLIB MYLIB *TEST TEXT('PROGRAM DEVELOPMENT LIBRARY')

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-7

Page 150: RXZ5E_ol49studentnotebook

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.

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

6-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 151: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Example: Executing a command

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-9

Page 152: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Example: Prompting parameters

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

6-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 153: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Example: Additional command parameters

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-11

Page 154: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Example: Parameter keyword view

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

6-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 155: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Example: Prompting for help

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-13

Page 156: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Special characters and function keysSpecial Characters

& Increase length

+ Add after

> Insert

< Delete

Function Keys

F1: Help

F3: Exit

F4: Prompt

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

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

6-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 157: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-15

Page 158: RXZ5E_ol49studentnotebook

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.

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

6-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 159: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Example: Using a menu

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-17

Page 160: RXZ5E_ol49studentnotebook

Student Notebook

Figure 6-14. Example: The Major menu OL4912.1

Notes:

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

© Copyright IBM Corporation 2012

IBM i

Example: The Major menu

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

6-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 161: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Example: Go command

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-19

Page 162: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

QCMD command interface

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

6-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 163: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

QCMD messages

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-21

Page 164: RXZ5E_ol49studentnotebook

Student Notebook

Figure 6-18. QCMD detailed messages OL4912.1

Notes:

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

© Copyright IBM Corporation 2012

IBM i

QCMD detailed messages

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

6-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 165: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 user’s 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 Corporation 2012

IBM i

Create a user profile (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-23

Page 166: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create a user profile (2 of 2)

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

6-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 167: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create user profile: IBM i Navigator

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-25

Page 168: RXZ5E_ol49studentnotebook

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.

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

6-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 169: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

User profile properties

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-27

Page 170: RXZ5E_ol49studentnotebook

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

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

6-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 171: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Fred signs on

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-29

Page 172: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Example: Calling a program.

Unqualified: CALL PAY02 /*USE LIBRARY LIST */ Qualified: CALL PAYTSTLIB/PAY02 /*USE PAYSTLIB */

QSYS

QCVVV

QCZZZ

QCXXX

QCYYY

PAY77

PAY99

AP60

AP55

INQLIB

PAYTSTLIB

AP55

PAY01PAY02

AP05

PAYLIB

PAY01

PAY02

PAY04

PAY05

Job's Library List

QSYSQHLPSYSQUSRSYSQRPGQCBLPAYLIBQGPLQTEMPPAYTSTLIB

. . .

. . .

Unqualified versus qualified name

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

6-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 173: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

QUSRLIBLQGPLQTEMP

Job Descr INLLIBLQGPLQTEMPPAYLIB

SystemPart

ProgramProductPart

CurrentLibrary

User Part

QSYSQHLPSYSQUSRSYS

FREDLIB

QGPLQTEMPPAYLIB

USER PROFILECURLIB(FREDLIB)

SIGN ON

CURRENT LIBRARY FREDLIB

The job description can override system value QUSRLIBL.

Value entered on Sign On panel overrides value in profile.

1

2

1

2

How your library list is constructed at sign onQSYSLIBL

QSYSQHLPSYSQUSRSYS

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-31

Page 174: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

CHGSYSLIBLSystemPart

ProgramProductPart

CurrentLibrary

User Part

QSYSQHLPSYSQUSRSYS

FREDLIB

QGPLQTEMPPAYLIB

CHGLIBL

*CURLIB *USRLIBL

*LIBL

CHGCURLIB

ADDLIBLERMVLIBLEEDTLIBL

How to change your library after sign on

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

6-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 175: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

QGPLCurrentlibrary

Doesjob have a

currentlibrary?

YesNo

In which library is an object created?� Unqualified name on create command: (object-name only)

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-33

Page 176: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Use libraries to organize

� By application

� For security

� By user

� For backup

� By object type: Programs or files

� By use: Production or test

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

6-34 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 177: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

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 (DSPLIBL)Change system part of library list (CHGSYSLIBL)Change system values QUSRLIBL QSYSLIBL (CHGSYSVAL)

Library related commands

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-35

Page 178: RXZ5E_ol49studentnotebook

Student Notebook

Figure 6-30. Machine exercises OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercises

� Create library and work with library list

� Modify profile/work with job description/alternate Job

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

6-36 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 179: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 6-31. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

© Copyright IBM Corp. 1997, 2012 Unit 6. Commands, profiles, and libraries 6-37

Page 180: RXZ5E_ol49studentnotebook

Student Notebook

Figure 6-32. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

6-38 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 181: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-1

Page 182: RXZ5E_ol49studentnotebook

Student Notebook

Figure 7-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

7-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 183: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 7-2. IBM i security concepts OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

IBM i security conceptsIBM i security concepts

IBM i security conceptsIBM i security concepts

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-3

Page 184: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Menu

Payrollmenu

PAYEDITprogram

Payrolldata

Data rightsRead

UpdateAdd

Delete

Authority

Authority

Authority

Signon:Mary

Security is always active

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

7-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 185: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Physical

Resource

User profile

User USER7Password JON8S

DSP07

Integrity

Specialcases

Physical Logical

*FILE: PAYMAST

*FILE: PAYLFSelected recordsSelected fields

*LIB: PAYLIB*PGM: PAY01

*LIB: QSYS

*USRPRFUSER7

*DEVDDSP07

Layers of security

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-5

Page 186: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

QSECURITY system value

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

7-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 187: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Programs fail if they try to access objects through interfaces that are not supported.

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-7

Page 188: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Userprofiles

Individualobjects

Job descriptions

Groupprofiles

Libraries

Authorizationlists

People(Users)

Objects(Resources)

System values

Components of IBM i security

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

7-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 189: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 7-7. User profile OL4912.1

Notes:

A user profile contains more than the user’s 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 Corporation 2012

IBM i

Information about the user

List ofobjects owned

Specificobject

authorizations

CRT...CHGOBJOWN

GRTOBJAUTRVKOBJAUT

User profile

User profile

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-9

Page 190: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Customer use Service personnel use

Fullservice

functions

Basicservice

functions

Testrequest

functions

Securityofficer

ProgrammerSystemoperator

User

Defaultowner

QUSER (*NONE)

QDFTOWN (*NONE)

QSECOFR (QSECOFR)

QPGMR (*NONE) QSYSOPR(*NONE)

. . . and more

QSRV(*NONE)

QSRVBAS(*NONE)

QTSTRQS(*NONE)

User profiles shipped with IBM i

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

7-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 191: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

System authority

Specialauthority

Specificauthority

*SPLCTL Object authority Data authority

*SERVICE *OBJOPR *READ

*JOBCTL *OBJMGT *ADD

*SAVSYS *OBJEXIST *UPD

*SECADM *OBJREF *DLT

*ALLOBJ *OBJALTER *EXECUTE

*AUDIT *EXCLUDE

*IOSYSCFG

System authority

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-11

Page 192: RXZ5E_ol49studentnotebook

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.

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

7-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 193: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

*ALL X X X X X X X X X X

*CHANGE X X X X X X

*USE X X X

*EXCLUDE The Public is excluded

*LIBCRTAUT Refer to the library for public authority

*OBJMGT

*OBJEXIST

*OBJREF

*OBJALTER

*OBJOPR

*EXECUTE

*READ

*ADD

*UPD

*DLT

System

defined

authority

combinations

System-defined authority combinations

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-13

Page 194: RXZ5E_ol49studentnotebook

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.

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

7-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 195: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

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 Source Chris' authorities*JOBCTL Group *JOBCTL*SPLCTL SelfPGM1 *USE Group PGM1 *USEFILE1 *CHANGE Group FILE1 *CHANGEFILE2 *EXCLUDE Self FILE2 *READ

Group profile example

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-15

Page 196: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Object: CUSTOMER Object type: *FILE

Users

Authority DEPTOWN DEPTA DEPTB *PUBLIC

Object Authorities

*OBJOPR X X X

*OBJMGT X

*OBJEXIST X

*OBJALTER X

*OBJREF

Data Authorities

*READ X X X

*ADD X X

*UPD X X

*DLT X X

*EXECUTE X X X

*EXCLUDE X

Q: Will Gregory be allowed to read, add, update and delete records in the CUSTOMER file?

How multiple group profiles workUser : GREGORYGroup: DEPTASupplemental group: DEPTB

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

7-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 197: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

LIBA LFILEB

PFILEC PROGD

CRTAUTLEDTAUTLWRKAUTL

CRT...GRTOBJAUT

AUT(AUT-LIST-NAME)AUTL( )

Authorization lists

Name: AUTL1Owner: USER3

Authorities:

USER3 *ALL*AUTLMGT

USER1 *USEUSER2 *CHANGEUSER4 *ALL*PUBLIC *EXCLUDE

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-17

Page 198: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Managing authorization lists using IBM i Navigator

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

7-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 199: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-19

Page 200: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Sign On display

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

7-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 201: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Programkeyed?

Call keyedprogram

Error message

Call INLPGM

Error message

Error message

A

No

No

No

Yes

No

No

Yes

Yes

Yes

INLPGM in profile?

Valid User/Password?

Authorized to device?

Program/Menu/Libexceed capability?

Yes

Sign on processing (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-21

Page 202: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

© Copyright IBM Corporation 2012

IBM i

A

Menu keyed?

Displaykeyed menu

Signoff user

Displayprofile menu

INLMNU(*SIGNOFF)?

No

Yes

Yes

No

Sign on processing (2 of 2)

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

7-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 203: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 7-18. Authority search process OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Object authorization list

Adopted

User profile - Stop whenany authority is found

Group profiles - Like user profile, repeats for each group profile and accumulate, stopswhen sufficient authority is accumulated

*PUBLIC - Used when no authority is found for user or groups

Adopted profiles - Usedwhen authority is insufficient

Nonefound

Nonefound

Insufficient

*ALLOBJPrimary group

privateauthorization list

Authority search process

*ALLOBJPrivateauthorization list

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-23

Page 204: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

USER GROUPs PUBLICSTART

*ALLOBJSpecial

authority?

*ALLOBJSpecial

authority?

Group

specificauthorities

?

Userspecific

authorities

User onauthorization

list?

Publicspecific

authorities?

Group onauthorization

list?

Use *PUBLICauthority fromauthorization list

No

No

No

Yes

Yes

Yes

Yes

Yes

No

No

Yes

No

A

No

Authorization flow (1 of 2)

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

7-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 205: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Adequateauthority

?

Allow access

Access denied

Allow accessto object

Access denied

Adoptedauthoritysufficient

?

No

Yes

NoNoYes

Yes

A

Anyadoptedauthority

?

Authorization flow (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-25

Page 206: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Edit Object Authority

Object . . . . . . . : EMPLOYEE Owner . . . . . . . : COMPANYA

Library . . . . . : PAYLIB Primary group . . . : *NONE

Object type . . . . : *FILE

Type changes to current authorities, press Enter.

Object secured by authorization list . . . . . . .: *NONE ____

Object -------------------Object----------------

User Group Authority Opr Mgt Exist Alter Ref

COMPANYA *ALL X X X X X

DEPTA *USE X _ _ _ _

DAVISW USER DEF X X _ _ _

*PUBLIC *CHANGE 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

EDTOBJAUT command

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

7-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 207: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Edit Object Authority

Object . . . . . . . : EMPLOYEE Owner . . . . . . . : COMPANYA

Library . . . . . : PAYLIB Primary group . . . : *NONE

Object type . . . . : *FILE

Type changes to current authorities, press Enter.

Object secured by authorization list . . . . . . . . ..

*NONE

Object -------------------Data-----------------

User Group Authority Read Add Update Delete Execute

COMPANYA *ALL X X X X X

DEPTA *USE X _ _ _ X

DAVISW USER DEF X X X X X

*PUBLIC *CHANGE X X X X X

Bottom

F3=Exit F5=Refresh F6=Add new users F10=Grant with reference object

F11=Display object authorities F=12Cancel F17=Top F18=Bottom

Display object authorities

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-27

Page 208: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Managing security using IBM i Navigator

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

7-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 209: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM i Navigator Security Configuration Wizard

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-29

Page 210: RXZ5E_ol49studentnotebook

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.

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

7-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 211: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 7-25. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

© Copyright IBM Corp. 1997, 2012 Unit 7. Introduction to IBM i security 7-31

Page 212: RXZ5E_ol49studentnotebook

Student Notebook

Figure 7-26. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

7-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 213: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-1

Page 214: RXZ5E_ol49studentnotebook

Student Notebook

Figure 8-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

8-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 215: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 8-2. Structure and rules OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Structure and rulesStructure and rules

Structure and rulesStructure and rules

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-3

Page 216: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

UsersOperatorsProgrammers

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

Con

trol L

angu

age

Why use control language programs

CL Commands:� Consistent interface� Prompting and Help

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

8-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 217: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-5

Page 218: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Control language program

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

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

8-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 219: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

PGM

DeclarationDCLDCLF

Program functionSNDRCVFCHGVARDSPMSGIFELSE

Passing controlCALLSIGNOFFRETURNTFRCTL

ENDPGM

. . .

Most CL commands

are allowed inCL programs

CL program structure

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-7

Page 220: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

LABEL: CRTLIB LIB(A)

Commandlabel

Commandname

Keyword Value

Parameter

Keyword / Positional

Command format

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

8-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 221: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

LABEL1: DSPLIB LIB(PAYLIB) OUTPUT(*PRINT)

keyword value

delimiter for labelblank

no spaceblank

CL command syntax (1 of 4)[?] [label-name:] [library-name/] command-name [parameter-set]

[ ] . . . Optional

? . . . Prompt, like F4, for commands within programsPrecedes label or command

label-name. . . Identify statement for branching, breakpointsand traces

library-name. . . Usually omitted since IBM commands are in QSYS

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-9

Page 222: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

CL command syntax (2 of 4)

� Keyword format� DSPLIB LIB(PAYLIB) OUTPUT(*PRINT)� DSPLIB OUTPUT(*PRINT) LIB(PAYLIB)

� Positional format� DSPLIB PAYLIB *PRINT

� Combination format� DSPLIB PAYLIB OUTPUT(*PRINT)

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

8-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 223: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

Notice that a single quote is represented by double quotes.

© Copyright IBM Corporation 2012

IBM i

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

MSGTYPE(*INFO) /* Show balance */

quoted character string

continuationwithin a program

variablesstart with and

predefined valuesstart with *

comment

CL command syntax (3 of 4)

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-11

Page 224: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

/* This is a full-line comment */SNDRCVF DEV(*FILE) RCDFMT(MENUFMT)SNDRCVF RCDFMT(MENUFMT)SNDRCVF *N MENUFMT

generic name

Take default for positional parameter

DSPOBJD OBJ(PAYLIB/PAY*) OBJTYPE(*PGM *FILE)

Connects partsof a qualified

name

Blank to separatelist elements

CL command syntax (4 of 4)

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

8-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 225: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

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

© Copyright IBM Corporation 2012

IBM i

Coding rules (1 of 2)� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-13

Page 226: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Coding rules (2 of 2)

� /* 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

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

8-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 227: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Information Center

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-15

Page 228: RXZ5E_ol49studentnotebook

Student Notebook

Figure 8-14. Basic CL programming OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Basic CL programmingBasic CL programming

Basic CL programmingBasic CL programming

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

8-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 229: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 8-15. Control work flow OL4912.1

Notes:

This is an example of a very simple CL program.

© Copyright IBM Corporation 2012

IBM i

Control work flow

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

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-17

Page 230: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Start of program PGM (Optional)

Declare file and variables DCLF (maximum of one)DCLDCL

Program-LevelMonitor messages

MONMSGMONMSG

IBM Commands

and/orUser commands

IFELSE

End of program ENDPGM (optional)

Command-LevelMonitor Messages

MONMSGMONMSG

COMMAND

Description Program statement

CL program structure

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

8-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 231: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DCL VAR(&NAME) TYPE( ) LEN( ) VALUE( )

TYPE ( ) LEN( ) VALUE( )*DEC default (15 5)

max. (15 9)default ( 0 )

*CHAR default (32)max. (9999)

default ( b )

*LGL 1 default ( ' 0 ' )

Examples:

(1) DCL &A *LGL VALUE ( ' 1 ' )

(2) DCL &B *CHAR 5 ABCD

(3) DCL &C *DEC (6 2) 543.21

Declare CL variable (DCL)

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-19

Page 232: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

IF COND

ELSE CMD(command)

( )relationalor logical

expression

THEN (command)

THEN parameter or ELSE command is optional.

IF THEN

ELSE

TRUE

FALSE

Conditional execution

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

8-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 233: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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 True if both operands are '1'

| *OR True if both or either operand is '1'

*NOT

Relational and logical expressionsExpression: (Operand Operator Operand)Result of a relational or logical expression: '1' True or '0' FalseOperands: Constant, Variable, Another Expression

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-21

Page 234: RXZ5E_ol49studentnotebook

Student Notebook

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 ________________________________________________________

© Copyright IBM Corporation 2012

IBM i

IF examples1. 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

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

8-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 235: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IF COND(&A *GT 100) THEN(DO)CALL PGM1CALL PGM2ENDDO

ELSE CMD(DO)CALL PGM3CALL PGM4ENDDO

CALL PGM5

DO group

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-23

Page 236: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Keyword form: IF COND(&RESP = 1) THEN(IF COND(&A = 5) THEN(IF +COND(&B = N) THEN(CALL PGM(PGMA))))

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

DO, ENDDO form: IF COND(&RESP = 1) THEN(DO) /* #1 */IF COND(&A = 5) THEN(DO) /* #2 */IF COND(&B = N) THEN(DO) /* #3 */CALL PGMAENDDO /* #3 */ENDDO /* #2 */ENDDO /* #1 */

One IF with a compound conditionIF COND((&RESP = 1) *AND (&A = 5) *AND (&B = N)) THEN(CALL PGMA)

&RESP=1 &A = 5 &B = N CALL PGMA

T TT

FF F

Nested IF statements

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

8-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 237: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

&A=&B TPGMB

F

&A=&C TPGMC

F

&A=&D T PGMD

F

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

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

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

PGMB and/or PGMC and/or PGMD

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-25

Page 238: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

&A=&B TPGMB

F

&A=&CT PGMC

F

&A=&DT

PGMD

F

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

PGMB or PGMC or PGMD

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

8-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 239: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

PGMSNDRCVF RCDFMT(MENU)...IF (&OPTION = 12) GOTO CMDLBL(END).....GOTO STARTENDPGM

Statement labels must be unique.

Branching within a program: GOTO

START:

END:

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-27

Page 240: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DOWHILE (&LGL)...IF (&INT *EQ 2) (CHGVAR &LGL '0')

ENDDO

Using the DOUNTIL and DOWHILE commands

DOUNTIL (&LGL)...CHGVAR &INT (&INT + 1)IF (&INT *GT 5) (CHGVAR &LGL '1')

ENDDO

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

8-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 241: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-29

Page 242: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

SELECTWHEN (&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

Using the SELECT command

SELECTWHEN (condition-1) THEN(command-1)...WHEN (condition-n) THEN(command-n)OTHERWISE command-x

ENDSELECT

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

8-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 243: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-31

Page 244: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

PGM..CALL PGMB. . . . . . . . . . ....

PGM..CALL PGMC. . . . . . . . . . .... TFRCTL PGMD...

PGM...ENDPGM

PGM...RETURN

PGMD

BottomLevel n+2

PGMC

TopLevel nPGMA

Program StackLevel n+1

PGMB

Branching outside a program: TFRCTL

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

8-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 245: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Job's processaccess group

Variables for A &COUNTA 005

Variables for B &IN99&COUNTB&X&CO

.

.

.

*PGM: B

PGM PARM(&IN99 &COUNTB &X &CO)DCL &IN99 *LGLDCL &COUNTB *DEC (3 0)DCL &X *DEC (15 5)DCL &CO *CHAR (20)

.

.

.CHGVAR VAR(&COUNTB) VALUE(&COUNTB + 1)

.

.

.

PGMDCL VAR(&COUNTA) TYPE(*DEC) LEN(3 0)

.

.

.CALL PGM(B) +

PARM( '0' &COUNTA 100 'ABC Co.')...

*PGM: A

006*CHAR

(32)

*DEC(15 5)

*CHAR(32)

Communicating data to a program with CALL

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-33

Page 246: RXZ5E_ol49studentnotebook

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.

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

8-34 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 247: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

CL

RPG IV COBOL

DCL VAR(&IN98) TYPE(*LGL)DCL VAR(&CUSTZ) TYPE(*DEC) LEN(5 0)

CALL PGM( ) PARM(&CUSTZ &IN98)

Linkage Section.01 Customer PIC S99999 COMP-3.01 IN98 PIC 1.

Procedure Division

Using Customer, IN98.

D Customer PR D CustZ 5 0 D Indic N

HLL and CL programs may call each other

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-35

Page 248: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

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)

CHGVAR: Arithmetic calculations

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

8-36 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 249: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Character Variable &A

LEN Converted Result

777

0023.00-003.90-123.67

Decimal Variable &B

Converted Result

5 25 05 2

123.10123

-123.00

Character Variable &A

Specified Value

101010

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

Decimal Variable &B

Specified Value

5 25 25 2

23.00 or +23-3.9-123.67

CHGVAR VAR(&A) VALUE(&B)

CHGVAR VAR(&B) VALUE(&A)

LEN

LEN

LEN

CHGVAR: Conversion between *CHAR and *DEC data types

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-37

Page 250: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Combining two *CHAR Variables or Values

&FIRST &LAST &NAME

MARY *CAT DAVIS MARY DAVIS

MARY *TCAT DAVIS MARYDAVIS

MARY *BCAT DAVIS MARY DAVIS

Example:

CHGVAR VAR(&NAME) VALUE(&FIRST |> &LAST)

(|| is equivalent to *CAT)

(|< is equivalent to *TCAT)

(|> is equivalent to *BCAT)

Concatenation

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

8-38 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 251: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Resulting message:Customer XYZ CORPORATION, account number 54321,

is overdue by 030 days.

&DAYSA

&NAME &CUSNUMA

The following variables exist at the start of the program:

VARIABLE TYPE LENGTH VALUE&NAME *CHAR 25 XYZ CORPORATION&CUSNUM *DEC (5 0) 54321&CUSNUMA *CHAR 5 &DAYS *DEC (3 0) 30&DAYSA *CHAR 3

CHGVAR VAR(&DAYSA) VALUE(&DAYS)CHGVAR VAR(&CUSNUMA) VALUE(&CUSNUM)SNDMSG MSG('Customer' *BCAT &NAME *TCAT ', account +

number' *BCAT &CUSNUMA *CAT ', is overdue +by' *BCAT &DAYSA *BCAT 'days.') TOMSGQ(ARDEPT)

Data type conversion and concatenation example

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-39

Page 252: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Source file

Member X

Member Y

Member Z

CodeCL

source

CL programobject

EnterCL

source

Create CL program (compile

CLP source)

CallCL

program

Syntaxchecking

QCLSRC1 2

3

4

Compile listing and

errors

Summary of using PDM

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

8-40 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 253: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 8-36. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Write a Basic CL Program.

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-41

Page 254: RXZ5E_ol49studentnotebook

Student Notebook

Figure 8-37. ILE versus OPM OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

ILE versus OPMILE versus OPM

ILE versus OPMILE versus OPM

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

8-42 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 255: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Single language

focus

Language-specific

error handling

Compilation results

in a runningprogram

Compile, run

Mixed language

focus

Common error handling

+Language-specific

error handling

Compilation results

*MODULE or*PGM

Compile, bind, run

OPM ILE

OPM versus ILE

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-43

Page 256: RXZ5E_ol49studentnotebook

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.

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

8-44 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 257: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

*PGM B1START

CALL DATEEND

*PGM DATE

START

STANDARDDATEPROCESSING

END

*PGM MAIN

*PGM B2START

. . .CALL DATE. . .

END

*PGM B2ASTART

CALL DATE. . .IF TOTAL >7CALL UPDTOT

END?

STARTCALL B1CALL B2CALL B2A

END

Dynamic program call

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-45

Page 258: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

QCLSRC MAIN

QCBLLESRC B1

QRPGLESRC B2

QCLSRC B2A

QCSRC DATE

*MODULE MAIN

*MODULE B1

*MODULE B2

*MODULE B2A

*MODULE DATE

1

CRTxxxMOD

2 CRTPGM PGM(MAIN)MODULE(MAIN B1 B2 B2A DATE)ENTMOD(MAIN)

*PGM MAIN===> MAIN

B1B2

B2ADATE

3 CALL MAIN

ILE static call: Bind by copy

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

8-46 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 259: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-47

Page 260: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

QCLSRC MAIN

QCBLLESRC B1

QRPGLESRC B2

QCLSRC B2A

QCSRC DATE

*MODULE MAIN

*MODULE B1

*MODULE B2

*MODULE B2A

1

CRTxxxMOD

2 CRTSRVPGM SRVPGM(MYUTIL)MODULE(DATE TAX)

*PGM MAIN===> MAIN

B1B2B2ADATE

4 CALL MAIN

QCSRC TAX

3 CRTPGM PGM(MAIN)MODULE(MAIN B1 B2 B2A)BNDSRVPGM(MYUTIL)ENTMOD(MAIN)

*MODULE DATE*MODULE TAX

*SRVPGM MYUTILDATETAX

ILE static call: Bind by reference

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

8-48 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 261: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 8-42. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint

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?

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

© Copyright IBM Corp. 1997, 2012 Unit 8. Control language programming 8-49

Page 262: RXZ5E_ol49studentnotebook

Student Notebook

Figure 8-43. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

8-50 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 263: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-1

Page 264: RXZ5E_ol49studentnotebook

Student Notebook

Figure 9-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

9-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 265: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 9-2. An overview of message handling OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

An overview of message handlingAn overview of message handling

An overview of message handlingAn overview of message handling

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-3

Page 266: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSP01*MSGQ

DAVIS*MSGQ

ARDEPT*MSGQ

QSYSOPR*MSGQ

JOB

Usermessagequeue

System operatormessagequeue

Workstationmessage

queue

Usermessage

queue

CRTMSGQ System supplied

CRTDEVDSP CRTUSRPRF

DSP01*DEVD

DAVIS*USRPRF

Basic message queue communication

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

9-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 267: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

At Sign off

� Deallocated

� Hold delivery mode

� Additional messages held in queue

User Workstation

NOTIFY

QUEUEQUEUE

At Sign on

� Allocated to user's job

� Notify delivery mode

� Old message reset to new messages

� Attention light on� Audible alarm sound

User and workstation message queues

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-5

Page 268: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

SNDMSG MSG('Employee updates are complete.')

TOUSR(DAVIS) TOMSGQ(DSP01)

DSPMSGMSGQ(*WRKUSR)

MSGQ(*WRKSTN)

OR

OR

DAVIS

Queue

DSP01

Queue

Sending and displaying messages

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

9-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 269: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Queue

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

MSGTYPE(*INQ)

TOMSGQ(QSYSOPR) RPYMSGQ(*WRKSTN)

Queue

What is thevolume ID for the payrollbackuptape? ________

The volume

ID isPAYBKP

Sending an inquiry message

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-7

Page 270: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Work with MessagesSystem: ATLANTA

Message for: FAC01

Type options below, then press Enter.4=Remove 5=Display details and reply

Opt MessageMessages 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

BottomF1=Help F3=Exit F5=Refresh F6=Display system operator messagesF16=Remove messages not needing a reply F17=Top F24=More keys

Queue

DSP07

Queue

FAC01

DSPMSG MSGQ(*WRKUSR)

Displaying messages

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

9-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 271: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-9

Page 272: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Display MessagesSystem: ATLANTA

Queue . . .: DSP07 Program . . : *DSPMSGLibrary . : QSYS Library. . : Severity . : 00 Delivery. . : *NOTIFY

Type reply (if required), press Enter.

FROM . . : QSECOFR 02/26/98 10:09:48Power down in 5 minutes

Bottom

F3=Exit F11=Remove a message F12=CancelF13=Remove all F16=Remove all except unanswered F24=More keys

Queue

Queue

DSP07

FAC01

Sending break messagesSNDBRKMSG MSG('Power down in 5 minutes')

TOMSGQ(DSP07)

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

9-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 273: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Additional Message Information

Message ID . . : CPD0030 Severity . . . : 30

Message type . : Diagnostic

Date sent . . .: 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

HELP

Additional Message Information

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

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-11

Page 274: RXZ5E_ol49studentnotebook

Student Notebook

Figure 9-10. Message handling using IBM i Navigator OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Message handling using IBM i NavigatorMessage handling using IBM i Navigator

Message handling using IBM i NavigatorMessage handling using IBM i Navigator

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

9-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 275: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Sending messages

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-13

Page 276: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Additional message functions

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

9-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 277: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

View messages

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-15

Page 278: RXZ5E_ol49studentnotebook

Student Notebook

Figure 9-14. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Using Messages

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

9-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 279: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 9-15. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

© Copyright IBM Corp. 1997, 2012 Unit 9. Basic message handling 9-17

Page 280: RXZ5E_ol49studentnotebook

Student Notebook

Figure 9-16. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

9-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 281: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-1

Page 282: RXZ5E_ol49studentnotebook

Student Notebook

Figure 10-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

10-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 283: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 10-2. Introduction to data description specifications OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Introduction to dataIntroduction to datadescription specificationsdescription specifications

Introduction to data description specificationsIntroduction to data description specifications

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-3

Page 284: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

What is DDS?

� Data definition specifications

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

� Native IBM i data definition language

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

10-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 285: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

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

Levels of DDS definition

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-5

Page 286: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

DDS report example (1 of 2)

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

10-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 287: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-7

Page 288: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

�Record format name �Reference DB file/field definition

�Space after

�Reference

�Field name

�This field is defined in this PRTF

DDS report example (2 of 2)

�Literal

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

10-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 289: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

2

5

1 4

3

DDS screen file example

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-9

Page 290: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i Designing reports and displaysDesigning reports and displays

Designing reports and displaysDesigning reports and displays

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

10-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 291: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Screen/Report Designer

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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-11

Page 292: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

What is Screen Designer?

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

10-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 293: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

WYSIWYG screen and report design� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-13

Page 294: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Screen Designer interface

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

10-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 295: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Displaying groups of records

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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-15

Page 296: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Trees, workbooks, and notebooks

DDS tree

Utility notebook

Toolbar

Palette

Design page

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

10-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 297: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-17

Page 298: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Designing a display file

Design page

DEL key works

Ruler

Use mouse to select, move and resize.

Palette � use mouse to drag and drop.

Ruler

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

10-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 299: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Using the display file palette

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-19

Page 300: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Using the Properties view

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

10-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 301: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Designing a report

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-21

Page 302: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Using the printer file palette

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

10-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 303: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Working with Screen Designer

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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-23

Page 304: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Verifying your design

Error messages

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

10-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 305: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Source file

Member X

Member Y

Member Z

Design Display

or Printer File

Display or Printer

File

Screen Designer produces

DDS

Screen Designer compiles

DDS Source

Write a PGM using Display or Printer File

Optional DDS edit and

validity checks

QDDSSRC1 2

3

4

Summary of using Screen/Report Designer

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-25

Page 306: RXZ5E_ol49studentnotebook

Student Notebook

Figure 10-23. Machine exercises OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercises

� Editing display file source� Designing and creating display screens� Using Screen Designer to create reports

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

10-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 307: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

© Copyright IBM Corporation 2012

IBM i

Summary of Screen/Report Designer features

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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-27

Page 308: RXZ5E_ol49studentnotebook

Student Notebook

Figure 10-25. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

10-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 309: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 10-26. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

© Copyright IBM Corp. 1997, 2012 Unit 10. Creating reports and displays 10-29

Page 310: RXZ5E_ol49studentnotebook

Student Notebook

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

10-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 311: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-1

Page 312: RXZ5E_ol49studentnotebook

Student Notebook

Figure 11-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

11-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 313: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 11-2. Introduction to relational database OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Introduction to relational databaseIntroduction to relational database

Introduction to relational databaseIntroduction to relational database

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-3

Page 314: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Optimizer Lock manager

Security

Integrity and recovery

Continuous operation Logging

12234

567891011 1

IBM DB2 for i

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

11-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 315: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Working with a relational DBMS� 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.

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-5

Page 316: RXZ5E_ol49studentnotebook

Student Notebook

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)

© Copyright IBM Corporation 2012

IBM i

IBM DB2 for i relational database

� 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

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

11-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 317: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.135–4: 1996, Database Language SQL - Part 4: Persistent Stored Modules (SQL/PSM)

• ANSI (American National Standards Institute) X3.135-1999, Database Language SQL - Core

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-7

Page 318: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Licensed Internal CodeIBM DB2 for i SecurityCommunicationsTransaction Management

IBM i Hardware

TIMI

DB2InteractiveMultimediaSystems Management

IBM i

IBM DB2 for i is integrated

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

11-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 319: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Program 4

Program 3

Program 2

Program 1

COBOLDATA (DEFINITION)DIVISION

RPGINPUT SPECIFICATIONS

Changing a file's format requires changing data definition in each program

Class File

L001L103L211L214L303

ITALIANENGLISHSPANISHGREEKCHINESE

001002003004005

DANTEHIGGINSPICASSOHOMERTSUNG

Traditional program data definition

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-9

Page 320: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Program 1

Data Definition

Program 2

Data Definition

Program 3

Data Definition

DataDefinition

DataRecords

Database FileCLASSPF

CRTxxxPGM

Externally-described IBM i file

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

11-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 321: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

CLASSPFField

CRSCODE

CRSTITLE

INSTNO

INSTLNAME

CHAR

CHAR

CHAR

CHAR

4

7

3

7

Column Heading

Crs Code

CourseTitle

InsNo

Instr Name

L001L103L211L214L303

ITALIANENGLISHSPANISHGREEKCHINESE

001002003004005

DANTEHIGGINSPICASSOHOMERTSUNG

DataType

FieldLength

DataDefinition

Data

Externally-described file example

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-11

Page 322: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Object type: *FILEType of file: Physical

FieldCRSCODECRSTITLEINSTNOINSTLNAME

Data TypeCHARCHARCHARCHAR

Field Length4737

Column HeadingCrs CodeCourse TitleIns NoInstr Name

File Name: CLASSPF

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

L001L103L211L214L303

ITALIANENGLISHSPANISHGREEKCHINESE

001002003004005

DANTEHIGGINSPICASSOHOMERTSUNG

File Description

Record Format: CLASSREC

Access path (optional)not availablewith SQL

Data

Mem

ber C

LAS

SP

F

Externally-described file components

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

11-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 323: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Relational database operations

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

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-13

Page 324: RXZ5E_ol49studentnotebook

Student Notebook

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 table’s 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.

© Copyright IBM Corporation 2012

IBM i

�Object = *FILE file�Type: Logical�SQL views and indexes are also logical files

Physical file

Description

Data

Logical file

Description

Access pathAccess path

IBM i logical file

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

11-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 325: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Legacy coding to define database file CLASSPF

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-15

Page 326: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

L001L103L211L214L303

ITALIANENGLISHSPANISHGREEKCHINESE

001002003004005

DANTEHIGGINSPICASSOHOMERTSUNG

Native: FieldsSQL: Columns

Native: RecordsSQL: Rows

Physical fileSQL: Table

Object type: *FILEFile type: (Native) Physical file

SQL versus native IBM i DB object terminology

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

11-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 327: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SQL term Native IBM i termTABLE FILEROW RECORD

COLUMN FIELDVIEW LOGICAL FILEINDEX KEYED LOGICAL FILE

COLLECTION LIBRARY

Industry terms DB2 for i termsSCHEMA SCHEMA

LOG JOURNAL

ISOLATION LEVEL COMMITMENT CONTROL LEVEL

More terminology

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-17

Page 328: RXZ5E_ol49studentnotebook

Student Notebook

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)

© Copyright IBM Corporation 2012

IBM i

IBM DB2 for i offers flexibility� Access using SQL or native tools� Create tables/files using SQL or native DDS

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

11-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 329: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-19

Page 330: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Schema, libraries, and field reference files� 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

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

11-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 331: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SQL catalogs

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-21

Page 332: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Native files and SQL objects coexist

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.

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

11-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 333: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

IBM i and the DB2 family

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-23

Page 334: RXZ5E_ol49studentnotebook

Student Notebook

Figure 11-21. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

11-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 335: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 11-22. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

© Copyright IBM Corp. 1997, 2012 Unit 11. IBM DB2 for i 11-25

Page 336: RXZ5E_ol49studentnotebook

Student Notebook

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

11-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 337: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-1

Page 338: RXZ5E_ol49studentnotebook

Student Notebook

Figure 12-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

12-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 339: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

An introduction to SQLAn introduction to SQL

An introduction to SQLAn introduction to SQL

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-3

Page 340: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Introducing SQL,Introducing SQL,SStructured tructured QQuery uery LLanguageanguage

Introducing SQL

� 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

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

12-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 341: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-5

Page 342: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Using SQL� 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

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

12-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 343: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Dynamic

DESCRIBEEXECUTEPREPARE

SQLStructured Query

LanguageGRANTREVOKE

Security

Miscellaneous

CONNECTDECLARECALL WHENEVER

INSERTUPDATEDELETE

SELECT

Datamanipulation

and so on

CREATEDROPALTER

Data definition

and so on

Types of SQL statements

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-7

Page 344: RXZ5E_ol49studentnotebook

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.

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

12-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 345: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-9

Page 346: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

5250 interactive SQL interface� 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

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

12-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 347: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 session’s 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 Corporation 2012

IBM i

Example SQL query using STRSQL (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-11

Page 348: RXZ5E_ol49studentnotebook

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.

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

12-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 349: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Result set

Example SQL query using STRSQL (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-13

Page 350: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Closing an interactive SQL session

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

12-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 351: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SQL source member

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-15

Page 352: RXZ5E_ol49studentnotebook

Student Notebook

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 Navigator’s Run SQL Scripts provides templates that can be used to build SQL statements.

© Copyright IBM Corporation 2012

IBM i

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

drop table OL38V3COL.DEPARTMENT;

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

Other useful SQL statements

� INSERT, CREATE, UPDATE - Rows in a table

� DROP - Schema, table, view

� ALTER - Add, change, or delete a column definition

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

12-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 353: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Database case studyDatabase case study

Database case studyDatabase case study

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-17

Page 354: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Column Data Type Length DescriptionCRSCODE CHAR 4 Course Code CRSTITLE CHAR 7 Course TitleINSTNO CHAR 3 Instructor NumberINSTLNAME CHAR 7 Instructor Last Name

Column Data Type Length DescriptionCRSCODE CHAR 4 Course CodeCLSYR CHAR 4 Class YearCLSQTR PACKED 1,0 Class QuarterSTUDNO CHAR 3 Student NumberSTUDLNAME CHAR 7 Student Last NameGRADE PACKED 3,0 Grade

Tables used in the school database case study

� CLASSPF - classes available in which students have enrolled

� 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

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

12-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 355: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Required case study results

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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-19

Page 356: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Creating a schema

CREATE SCHEMA FACSLIB2

Repository

� Tables� Views� Indexes

Created as an IBM i Library

Also created automatically in Schema� SQL Catalog� Journal � Journal Receiver

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

12-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 357: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Creating a schema using IBM i Navigator (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-21

Page 358: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Creating a schema using IBM i Navigator (2 of 2)

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

12-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 359: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Objects in schema

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-23

Page 360: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create CLASSPF table (1 of 2)

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

12-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 361: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create CLASSPF table (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-25

Page 362: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Define columns (1 of 2)

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

12-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 363: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Define columns (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-27

Page 364: RXZ5E_ol49studentnotebook

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.

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

12-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 365: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Column naming rules

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-29

Page 366: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Adding column headings

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

12-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 367: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Run SQL Scripts

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-31

Page 368: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Resulting SQL: LABEL ON statement

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

12-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 369: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create index for CLASSPF on column CRSCODE (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-33

Page 370: RXZ5E_ol49studentnotebook

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.

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

12-34 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 371: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create index for CLASSPF on column CRSCODE (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-35

Page 372: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create table GRADEPF99 (1 of 2)

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

12-36 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 373: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create table GRADEPF99 (2 of 2)

1

2

3

1

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-37

Page 374: RXZ5E_ol49studentnotebook

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.

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

12-38 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 375: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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, let’s 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 Corporation 2012

IBM i

Create table GRADEPF98 (1 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-39

Page 376: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create table GRADEPF98 (2 of 3)

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

12-40 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 377: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create table GRADEPF98 (3 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-41

Page 378: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

New Table: GRADEPF98 final review

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

12-42 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 379: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

GRADEPF98 in FACSLIB2

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-43

Page 380: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Review the newly created table GRADEPF98

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

12-44 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 381: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Display table data: GRADEPF99

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-45

Page 382: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Insert new rows in table GRADEPF99

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

12-46 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 383: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 12-39. Create index for table GRADEPF99 OL4912.1

Notes:

1. Right-click the file, GRADEPF99.

2. Click New > Index.

© Copyright IBM Corporation 2012

IBM i

Create index for table GRADEPF99

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-47

Page 384: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create index GRADEPF99I (1 of 2)

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

12-48 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 385: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create index GRADEPF99I (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-49

Page 386: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Assign permissions: Grant/Revoke authorities

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

12-50 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 387: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Where are we?

� Created tables and indexes:

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-51

Page 388: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

© Copyright IBM Corporation 2012

IBM i

Using SQL to completeUsing SQL to completethe case studythe case study

Using SQL to complete the case studyUsing SQL to complete the case study

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

12-52 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 389: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

� Clauses must be used in this order.

� Output of SELECT = Result Set.

SELECT ....

FROM ....

WHERE ....

GROUP BY ....

HAVING ....

ORDER BY ....

Fine

William

Goes

Home

Often

SELECT statement

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-53

Page 390: RXZ5E_ol49studentnotebook

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.

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

12-54 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 391: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 12-46. Case study requirement OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Case study requirement

� 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?

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-55

Page 392: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Executing the SQL SELECT statement (1 of 5)

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

12-56 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 393: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Executing the SQL SELECT statement (2 of 5)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-57

Page 394: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

We enter our SQL statement.

© Copyright IBM Corporation 2012

IBM i

Executing the SQL SELECT statement (3 of 5)

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

12-58 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 395: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Executing the SQL SELECT statement (4 of 5)

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-59

Page 396: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Executing the SQL SELECT statement (5 of 5)

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

12-60 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 397: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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

Result set of all grades for the two years available

� GRADEPF98 and GRADEPF99

� Need a UNION of both

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-61

Page 398: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

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

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

12-62 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 399: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-63

Page 400: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

� Result set derived from two tables� CRSCODE is common column (match on CRSCODE)

Answer is to code an SQL JOIN!

Requirement

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

What does this mean?

Case study requirement: Select data from related tables

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

12-64 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 401: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Haas A00 SPIFFY Computer Service Div.Lucchesi A00 SPIFFY Computer Service Div.O Connell A00 SPIFFY Computer Service Div.Thompson B01 PlanningKwan C01 Information CenterQuintana C01 Information CenterNicholls C01 Information CenterStern D11 Manufacturing SystemsAdamson D11 Manufacturing SystemsPianka D11 Manufacturing SystemsYoshimura D11 Manufacturing SystemsScoutten D11 Manufacturing Systems

Deptno DeptnameA00 SPIFFY Computer Service Div.B01 PlanningC01 Information CenterD01 Development CenterD11 Manufacturing SystemsD21 Administration SystemsE01 Support ServicesE11 OperationsE21 Software Support

Lastname WorkdeptHaas A00Thompson B01Kwan C01Geyer E01Stern D11Pulaski D21Henderson E11Spenser E21Lucchesi A00

EMPLOYEE DEPARTMENT

Combining data from tables using JOIN� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-65

Page 402: RXZ5E_ol49studentnotebook

Student Notebook

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, instlnamefrom facslib2/classpf ainner join facslib2/gradepf99 bon a.crscode = b.crscodeorder by studlname, grade desc;

What do you notice about the columns to be displayed? ___________________________

Which columns are extracted from the CLASSPF table? __________________________

_____________________________________________________________________

© Copyright IBM Corporation 2012

IBM i

Case study JOIN (1 of 2)

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

12-66 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 403: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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?__________________________________________________

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-67

Page 404: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Case study JOIN (2 of 2)

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

12-68 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 405: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 12-59. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Working with the database using IBM i Navigator

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-69

Page 406: RXZ5E_ol49studentnotebook

Student Notebook

Figure 12-60. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

12-70 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 407: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 12-61. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

© Copyright IBM Corp. 1997, 2012 Unit 12. Accessing the IBM i database using SQL and IBM i Navigator 12-71

Page 408: RXZ5E_ol49studentnotebook

Student Notebook

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

12-72 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 409: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-1

Page 410: RXZ5E_ol49studentnotebook

Student Notebook

Figure 13-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

13-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 411: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Creating IBM i physicalCreating IBM i physicaland logical files and logical files

Creating IBM i physical and logical filesCreating IBM i physical and logical files

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-3

Page 412: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Physical files used in the school database case study

� CLASSPF - classes available in which students have enrolled

� CRSCODE column is the key� Record format CLASSREC � GRADEPF98 - grades recorded for each student in each class and GRADEPF99

� Record format GRADEREC

Column Data Type Length Description****** ********* ****** ***********CRSCODE CHAR 4 Course Code CRSTITLE CHAR 7 Course TitleINSTNO CHAR 3 Instructor NumberINSTLNAME CHAR 7 Instructor Last Name

Column Data Type Length Description****** ********* ****** ***********CRSCODE CHAR 4 Course CodeCLSYR CHAR 4 Class YearCLSQTR PACKED 1,0 Class QuarterSTUDNO CHAR 3 Student NumberSTUDLNAME CHAR 7 Student Last NameGRADE PACKED 3,0 Grade

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

13-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 413: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Logical files used in the school database case study (1 of 2)� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-5

Page 414: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Logical files used in the school database case study (2 of 2)

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

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

13-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 415: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

CLASSPFFile description

attributesaccess path descriptionmember namesrecord format nametriggersconstraints

Record format:CLASSRECField descriptions

Data recordsL001 ITALLIAN 001 DANTEL103 ENGLISH 002 HIGGINSL211 SPANISH 003 PICASSOL214 GREEK 004 HOMERL303 CHINESE 005 TSUNG

Access pathL001-1 L103-2 L211-3L214-4 L303-5

DSPFFD

DSPFD

MemberCLASSPF

Physical file

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-7

Page 416: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (1 of 10)

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

13-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 417: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFD CLASSPF (2 of 10)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-9

Page 418: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (3 of 10)

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

13-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 419: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFD CLASSPF (4 of 10)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-11

Page 420: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (5 of 10)

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

13-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 421: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

There are five records currently in the file.

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (6 of 10)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-13

Page 422: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (7 of 10)

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

13-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 423: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFD CLASSPF (8 of 10)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-15

Page 424: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (9 of 10)

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

13-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 425: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

© Copyright IBM Corporation 2012

IBM i

DSPFD CLASSPF (10 of 10)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-17

Page 426: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

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

© Copyright IBM Corporation 2012

IBM i

DSPFFD CLASSPF (1 of 3)

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

13-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 427: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

Note the field definitions here and continued on next visual.

© Copyright IBM Corporation 2012

IBM i

DSPFFD CLASSPF (2 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-19

Page 428: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

This visual shows the last of the defined fields.

© Copyright IBM Corporation 2012

IBM i

DSPFFD CLASSPF (3 of 3)

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

13-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 429: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

R CLASSRECCRSCODE 4CRSTITLE 7INSTNO 3INSTLNAME 7

K CRSCODE

Key is CRSCODE

DATA RECORDS

Format

Key is CRSCODE

DATA RECORDS

Key is CRSCODE

DATA RECORDS

SCHOOLA

SCHOOLB

SCHOOLC

Members

File name: CLASSPF

Multiple member physical file

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-21

Page 430: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DATA RECORDS

DATA RECORDS

DATA RECORDS

SRCSEQ 6 2SRCDAT 6 0SRCDTA 80

Format

PROGA

Access path

PROGB

PROGC

Members Data records(Source statements)

Key is

Source physical file

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

13-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 431: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SourcePhysical File

Types of source in source physical file

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

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-23

Page 432: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Naming convention for source PFsIBM Suggested Names:

QCBLSRC/QLBLSRC COBOL

QCBLLESRC ILE COBOL

QCLSRC CONTROL LANGUAGE

QCMDSRC COMMAND DEFINITION

QDDSSRC DATA DESCRIPTION SPECIFICATIONS

QMNUSRC MENUS

QRPGLESRC ILE RPG (RPG IV syntax)

QRPGSRC RPG (RPG III syntax)

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

13-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 433: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Creating a source file

CRTSRCPF FILE(FACxx/QDDSSRC)

RCDLEN(92)

MBR(*NONE)

TEXT('DDS Source File for FACnn')

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-25

Page 434: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

SOURCE FILE

MEMBER XSYNTAX

CHECKING

CODE

DDSSOURCE

QDDSSRC1

CREATEDATABASE

FILE(COMPILE

DDS SOURCE)

ENTER DDS SOURCE

2

3

DFU or

RPGor

COBOL

4

LISTING OFSOURCE

DESCRIPTIONAND ERRORS

FILEDESCRIPTION

MEMBER

X

Data PathUser Steps

Creating database files and entering data

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

13-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 435: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Physical and logical file naming rules

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-27

Page 436: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Coding for physical file CLASSPF

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

13-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 437: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Coding for physical files GRADEPF98 and GRADEPF99

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-29

Page 438: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

SRCSEQSRCDATSRCDTA

QDDSSRC

FACOUTQxx PAYROLxx FACJOBDxx

LibraryFACxx

FACOUTQxxPAYROLxxFACJOBDxxODDSSRC

CRTSRCPF QDDSSRC

Create source physical file

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

13-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 439: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SRCSEQSRCDATSRCDTA

QDDSSRC

FACOUTQxx PAYROLxx FACJOBDxxLibraryFACxx

FACOUTQxxPAYROLxxFACJOBDxxODDSSRC

CLASSPF

PDM / SEUF6 = CREATE NEW MEMBER (NAMED CLASSPF)

R CLASSRECCRSCODE 4 ...CRSTITLE 7 ...INSTNO 3 ...INSTLNAME 7 ...

K CRSCODE

Create new source member

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-31

Page 440: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

FACOUTQxx PAYROLxx FACJOBDxxLibraryFACxx

FACOUTQxxPAYROLxxFACJOBDxxODDSSRCCLASSPF

PDM OPT 14 = COMPILE MEMBER

CLASSPFR CLASSREC

CRSCODE 4 ...CRSTITLE 7 ...INSTNO 3 ...INSTLNAME 7 ...

K CRSCODE

Access PathKey is CRSCODE

DATA

MemberCLASSPF

MemberCLASSPF

SRCSEQSRCDATSRCDTA

QDDSSRC

R CLASSRECCRSCODE 4 ...CRSTITLE 7 ...INSTNO 3 ...INSTLNAME 7 ...

K CRSCODE

When the fileis initially created,

there are no records in the data member

Create CLASSPF *File object

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

13-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 441: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

SRCSEQSRCDATSRCDTA

QDDSSRC

Member CLASSPFSource DDS

Member GRADEPFSource DDS

CLASSPF

GRADEPF99

Description

Format

Access path

Data records

Description

Format

Access path

Data records

LibraryFACxx

FACOUTQxxPAYROLxxFACJOBDxxQDDSSRCCLASSPFGRADEPF99

FACOUTQxx PAYROLxx FACJOBDxx

Our library after GRADEPF99 is created

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-33

Page 442: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

SOURCE FILE

MEMBER X

SYNTAXCHECKING

CODE

DDSSOURCE

QDDSSRC1

CREATEDATABASE

FILE(COMPILE

DDS SOURCE)

ENTER DDS SOURCE

2

3

DFU or

RPGor

COBOL

4

LISTING OFSOURCE

DESCRIPTIONAND ERRORS

FILEDESCRIPTION

MEMBER

X

Data pathUser steps

Creating database files and entering data

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

13-34 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 443: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Logical files

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-35

Page 444: RXZ5E_ol49studentnotebook

Student Notebook

Figure 13-35. Relational database operations using logical files OL4912.1

Notes:

You can perform the relational operations above on logical files.

© Copyright IBM Corporation 2012

IBM i

Relational database operations using logical files

� 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

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

13-36 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 445: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

GRADEPF99Physical File

R GRADERECCRSCODE 4 CLSYR 4CLSQTR 1 0STUDNO 3STUDLNAME 7GRADE 3 0

K CRSCODEK STUDNO

Access Path

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdLOO1 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 1 101 BOWIE 93L103 1999 1 101 BOWIE 62L214 1999 2 108 NELSON 97L410 1999 1 106 HOLIDAY 75L303 1999 3 107 STING 86L001 1999 2 105 MADONNA -L001 1999 2 107 STING -

Logical filerequirements:

�Same format�Only L001 records�Sequence bystudent number

MemberGRADEPF99

Logical file: Selection and sequence (1 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-37

Page 446: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

GRADEPF99

Access path

Data

Fmt: GRADEREC

GRADELF99

Fmt: GRADEREC

Access path

101-3 102-1 103-2

107-9105-8

Mem

berG

RA

DE

LF99DDS Coding for GRADELF99 Logical File:

GRADELF99T.Name++++++.Len++TDpB......Functions+++++++++++++++++++R GRADEREC PFILE(GRADEPF99)K STUDNOS CRSCODE CMP(EQ 'L001')

PDM Option 14=Compile or CRTLF

31

2

Based on

Logical file: Selection and sequence (2 of 3)

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

13-38 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 447: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-39

Page 448: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 1 101 BOWIE 93L103 1999 1 101 BOWIE 62L214 1999 2 108 NELSON 97L410 1999 1 106 HOLIDAY 75L303 1999 3 107 STING 86L001 1999 2 105 MADONNA -L001 1999 3 107 STING -

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1999 1 101 BOWIE 93L001 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 2 105 MADONNA -L001 1999 3 107 STING -

101-3 102-1 103-2 107-9105-8

GRADELF99's view of GRADEPF99

GRADEPF99 records

Logical file: Selection and sequence (3 of 3)

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

13-40 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 449: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

Notice that GRADELF99 is a logical file.

© Copyright IBM Corporation 2012

IBM i

DSPFD GRADELF99 (1 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-41

Page 450: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSPFD GRADELF99 (2 of 8)

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

13-42 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 451: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFD GRADELF99 (3 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-43

Page 452: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

DSPFD GRADELF99 (4 of 8)

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

13-44 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 453: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

We are only interested in course code L001.

© Copyright IBM Corporation 2012

IBM i

DSPFD GRADELF99 (5 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-45

Page 454: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSPFD GRADELF99 (6 of 8)

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

13-46 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 455: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFD GRADELF99 (7 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-47

Page 456: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

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

© Copyright IBM Corporation 2012

IBM i

DSPFD GRADELF99 (8 of 8)

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

13-48 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 457: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFFD GRADELF99 (1 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-49

Page 458: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

DSPFFD GRADELF99 (2 of 3)

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

13-50 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 459: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DSPFFD GRADELF99 (3 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-51

Page 460: RXZ5E_ol49studentnotebook

Student Notebook

Figure 13-50. Using a field reference file OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Using a field reference fileUsing a field reference file

Using a field reference fileUsing a field reference file

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

13-52 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 461: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Using a field reference file for our case study� Defined to the system� Definition of:

� File by name� Record by name� Fields by name� Access arrival/keyed sequence

� Fields for GRADEPF� CRSCODE

� CLSYR 4 TEXT('Class Year') � COLHDG('Cls' 'Yr')� CLSQTR 1 0 TEXT('Class Quarter')

CLASSPF SCHOOLREF

R CLASSREC

CRSCODE R

CRSTITLE R

INSTNO R

INSTLNAME R

L001 ITALLIAN 001 DANTE

L103 ENGLISH 002 HIGGINS

L211 SPANISH 003 PICASSO

L214 GREEK 004 HOMER

L303 CHINESE 005 TSUNG

R SCHOOLFMT

*FIELDS FOR CLASSPF

CRSCODE 4 TEXT(. . .

COLHDG(. . .

CRSTITLE 7 TEXT(. . .

COLHDG(. . .

INSTNO 3 TEXT(. . .

COLHDG(. . .

INSTLNAME 7 TEXT(. . .

COLHDG(. . .

REF(SCHOOLREF)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-53

Page 462: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

R SCHOOLFMT

CRSCODE 4 TEXT(. . .COLHDG(. . .

CRSTITLE 7 TEXT(. . .COLHDG(. . .

INSTNO 3 TEXT(. . .COLHDG(. . .

Data

Format

Access path

Physical file

NO KEY FIELD

NO DATA RECORDS

SCHOOLREF

Properties of a field reference file

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

13-54 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 463: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Field reference file for school database (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-55

Page 464: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Field reference file for school database (2 of 2)

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

13-56 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 465: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

DDS for CLASSPF using SCHOOLREFFRF

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-57

Page 466: RXZ5E_ol49studentnotebook

Student Notebook

Figure 13-56. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Code a physical and a logical file.

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

13-58 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 467: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 13-57. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

© Copyright IBM Corp. 1997, 2012 Unit 13. Defining database files using DDS 13-59

Page 468: RXZ5E_ol49studentnotebook

Student Notebook

Figure 13-58. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

13-60 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 469: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-1

Page 470: RXZ5E_ol49studentnotebook

Student Notebook

Figure 14-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

14-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 471: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Application DevelopmentApplication DevelopmentToolSet (ADTS) ToolSet (ADTS)

Application Development ToolSet (ADTS)Application Development ToolSet (ADTS)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-3

Page 472: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Application Development ToolSet for 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)

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

14-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 473: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-5

Page 474: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Programming Development Manager (1 of 2)

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

14-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 475: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Programming Development Manager (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-7

Page 476: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

PDM options

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

14-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 477: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

PDM work with members (1 of 4)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-9

Page 478: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

PDM work with members (2 of 4)

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

14-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 479: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

PDM work with members (3 of 4)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-11

Page 480: RXZ5E_ol49studentnotebook

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.

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

14-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 481: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-13

Page 482: RXZ5E_ol49studentnotebook

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.

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

14-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 483: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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 C Language

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-15

Page 484: RXZ5E_ol49studentnotebook

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

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

14-16 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 485: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-17

Page 486: RXZ5E_ol49studentnotebook

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.

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

14-18 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 487: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-19

Page 488: RXZ5E_ol49studentnotebook

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.

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

14-20 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 489: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

PDM work with members (4 of 4)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-21

Page 490: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create new member (1 of 7)

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

14-22 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 491: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

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

Create new member (2 of 7)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-23

Page 492: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Create new member (3 of 7)

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

14-24 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 493: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-25

Page 494: RXZ5E_ol49studentnotebook

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.

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

14-26 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 495: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-27

Page 496: RXZ5E_ol49studentnotebook

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.

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

14-28 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 497: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-29

Page 498: RXZ5E_ol49studentnotebook

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.

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

14-30 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 499: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-31

Page 500: RXZ5E_ol49studentnotebook

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.

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

14-32 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 501: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create new member (4 of 7)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-33

Page 502: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create new member (5 of 7)

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

14-34 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 503: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Create new member (6 of 7)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-35

Page 504: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Create new member (7 of 7)

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

14-36 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 505: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Compile DDS (1 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-37

Page 506: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Compile DDS (2 of 8)

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

14-38 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 507: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Compile DDS (3 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-39

Page 508: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Compile DDS (4 of 8)

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

14-40 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 509: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Compile DDS (5 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-41

Page 510: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

Type option 5 to display the compile listing.

© Copyright IBM Corporation 2012

IBM i

Compile DDS (6 of 8)

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

14-42 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 511: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Compile DDS (7 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-43

Page 512: RXZ5E_ol49studentnotebook

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.

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

14-44 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 513: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Compile DDS (8 of 8)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-45

Page 514: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

Type option 2 to edit the source member.

© Copyright IBM Corporation 2012

IBM i

Browse/Copy options (1 of 4)

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

14-46 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 515: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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

Notes:

Press F15 = Browse/Copy options.

© Copyright IBM Corporation 2012

IBM i

Browse/Copy options (2 of 4)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-47

Page 516: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Browse/Copy Options (3 of 4)

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

14-48 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 517: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Browse/Copy options (4 of 4)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-49

Page 518: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Using basic SEU functions

Assume you are editing these records:

0007.00 A ALTDES 30 COLHDG('ALT. ITEM DESCR.') 0008.00 A TEXT('ALTERNATE ITEM DESCRI 0009.00 A BALANC 7 2 COLHDG('BAL') 0010.00 A TEXT('Current A/R Value') 0011.00 A EDTCDE(K) 0012.00 A CNAME 25 COLHDG('Customer Name') 0013.00 A COMSTS 1 0 RANGE(1 4) 0014.00 A COMSTT 1 0 RANGE(1 4) 0015.00 A CCITY 25 COLHDG('City') 0016.00 A CRLIM 5 2 COLHDG('Credit' 'Limit')

And you enter the following functions:

0007.00 A ALTDES 30 COLHDG('ALT. ITEM DESCR.') 00D8.00 A TEXT('ALTERNATE ITEM DESCRI 0009.00 A BALANC 7 2 COLHDG('BAL') 0010.00 A TEXT('Current A/R Value') 0C11.00 A EDTCDE(K) 0012.00 A CNAME 25 COLHDG('Customer Name') 0013.00 A COMSTS 1 0 RANGE(1 4) 0014.00 A COMSTT 1 0 RANGE(1 4) 0015.00 A CCITY 25 COLHDG('City') 0A16.00 A CRLIM 5 2 COLHDG('Credit' 'Limit')

Results in:

0007.00 A ALTDES 30 COLHDG('ALT. ITEM DESCR.') 0009.00 A BALANC 7 2 COLHDG('BAL') 0010.00 A TEXT('Current A/R Value') 0011.00 A EDTCDE(K) 0012.00 A CNAME 25 COLHDG('Customer Name') 0013.00 A COMSTS 1 0 RANGE(1 4) 0014.00 A COMSTT 1 0 RANGE(1 4) 0015.00 A CCITY 25 COLHDG('City') 0016.00 A CRLIM 5 2 COLHDG('Credit' 'Limit') 0016.01 A EDTCDE(K)

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

14-50 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 519: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Define a skeleton line

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-51

Page 520: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Insert a skeleton line

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

14-52 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 521: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Skeleton line inserted

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-53

Page 522: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Browse/Copy Options: Copy

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

14-54 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 523: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Browse/Copy options: Split screen

Tohere

Fromhere

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-55

Page 524: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

SEU Find/Change Options

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

14-56 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 525: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Change SEU session defaults

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-57

Page 526: RXZ5E_ol49studentnotebook

Student Notebook

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:

© Copyright IBM Corporation 2012

IBM i

Change PDM session defaults

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

14-58 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 527: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-59

Page 528: RXZ5E_ol49studentnotebook

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*

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

14-60 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 529: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-61

Page 530: RXZ5E_ol49studentnotebook

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.

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

14-62 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 531: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-63

Page 532: RXZ5E_ol49studentnotebook

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.

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

14-64 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 533: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-65

Page 534: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

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

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

14-66 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 535: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-67

Page 536: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Option Name

ExplanationCommand Called

C CALL &O/&NAllows you to run a program on the Work with Members Using PDM display

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 listCC

CHGCURLIBCURLIB(&L)

STRDFU OPTION(2) Allows you to create a DFU program

EA

DM

CS

CM

CL

CD

EDTOBJAUTOBJ(&L/&N)OBJTYPE(&T)

DSPMSG

STRSDA OPTION(1)SRCFILE(&L/&F)??SRCMBR()

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

CHGCURLIBCURLIB(&N)

Changes selected library on the Work with Libraries Using PDM display to the current library in the library list

Allows you to edit the authority to an object on the Work with Objects Using PDM display

Allows you to create a member (menu) using SDA

Allows you to create a member (display) using SDA

Allows you to display messages

Member: QAUOOPT File: QAUOOPT Library: QGPL

Standard PDM options (1 of 2)

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

14-68 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 537: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Option Name

ExplanationCommand Called

GO GO &L/ &N Allows you to display the menu for a menu object

Allows you to display the job logJL DSPJOBLOG

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

Save library in batch on the Work with Libraries Using PDM display

WS

SP

SO

SM

SL

WRKSBMJOB

WRKSPLF

SBMJOB ??CMD(SAVOBJOBJ(&N) LIB(&L))

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

Save member in batch on the Work with Members Using PDM display

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.

Allows you to work with spooled files

Allows you to work with jobs submitted to batch

Standard PDM options (2 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-69

Page 538: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Parm DescriptionMeaning&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.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.

&B List type

&F

&E

&D

&C

File name

Run in batch

Member change date

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

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.

Valid substitution variables for user-defined options (1 of 3)

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

14-70 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 539: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Parm DescriptionMeaning&G Job description

library&G is replaced by the job description library value from the Change Defaults display.

&H is replaced by the job description value from the Change Defaults display.

&H Job description name

&O

&N

&L

&J

Object library

Item name

Library name

Job description &J is replaced by the job description value from the Change Defaults display in the format library/job description.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 is replaced by the name of the item in the list beside which the option was typed.

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.

Valid substitution variables for user-defined options (2 of 3)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-71

Page 540: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Parm DescriptionMeaning&R 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.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.

&S Item type without '*'

&V

&U

&T

User-Defined Option Library

User-Defined Option File

Item type with '*'

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.

&U is replaced by the user-defined option file name from the Change Defaults display.

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

&X Item text &X is replaced by the text (in single quotation marks) of the item beside which the option is typed.

Valid substitution variables for user-defined options (3 of 3)

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

14-72 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 541: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

PDM: Create User-Defined Option

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-73

Page 542: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Data pathUser steps

MEMBER XOPTIONALSYNTAX

CHECKING

CODE

DDSSOURCE

QDDSSRC1

CREATEDATABASE

FILE(COMPILE

DDS SOURCE)

ENTER DDS SOURCE

2

3

DFU or

RPGor

COBOL

4

LISTING OFSOURCE

DESCRIPTIONAND ERRORS

FILEDESCRIPTION

MEMBER

Z

MEMBER Z

MEMBER Y

SOURCE FILE

Summary of using PDM

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

14-74 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 543: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Command (Parameter) Provides

DSPLIB library-name ExistenceContents

DSPFD file-nameSizeMembers# records# deleted records

DSPFFD file-name Record formatsFields

DSPPFM file-name (Member-name) Data

DLTF file-name Delete

DSPMBR file-name File relationships and dependencies

File-related commands

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-75

Page 544: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

FNDSTRPDM

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

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

14-76 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 545: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 14-51. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Using IBM i Editors

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-77

Page 546: RXZ5E_ol49studentnotebook

Student Notebook

Figure 14-52. Maintaining your DB2 database OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Maintaining yourMaintaining yourDB2 databaseDB2 database

Maintaining your DB2 databaseMaintaining your DB2 database

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

14-78 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 547: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

� What objects are impacted?� What actions are required?

Add, change, or delete a field.

Database maintenance

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-79

Page 548: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

File - PF

Field Reference File

Example: Enlarging a field size

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

14-80 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 549: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

*File - PF

Field Reference File

*File - PF

*PGM

*File - DSPF*File - LF

*File - PRTF

Example: Impacted objects

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-81

Page 550: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

DSPFFD

*File - PF

Field Reference File

*File - PF

*PGM

*File - DSPF

*File - LF *File - PRTF

DSPFFD: Fields within file

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

14-82 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 551: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

*File - PRTF

*File - DSPF

*File - PF

Field Reference File

DSPPGMREF

*File - PF

*File - LF

*PGM

DSPPGMREF: Files used by programs

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-83

Page 552: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

*PGM

*File - PRTF

*File - DSPF

*File - PF

Field Reference File

*File - LF

*File - PF

DSPDBR: Which LFs use which PFs

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

14-84 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 553: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

FNDSTRPDM

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-85

Page 554: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

STRING

FILE

MBR

OPTION

PROMPT

PRTMBRLIST

MARK

PRTRCDS

'string'

library/QxxxSRC

*ALL

*EDIT *RNM *SDA *COPY *DSPD *RLU*DLT *SAVE *DSP *CHGT *PRT *CMPL

*NONPROMPT *PROMPT

*NO *YES

*MARK *NOMARK

*NONE *CHAR *MARK *FOLD *ALL *HEX*NOMARK *TRUNCATE number *ALTHEX

( )( )( )( )

( )( )( )( )

FNDSTRPDM parameters

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

14-86 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 555: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Example: Implement the field change (1 of 2)

1. Change Field Reference File source and re-create.

2. Find affected PFs using:� DSPFFD

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

3. Optional, but highly recommended:� Save the affected physical files.

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-87

Page 556: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

8. Change program source if necessary.9. Recreate programs.

7. Find affected programs.

FILEA FORMATX FIELDA

FIELDB

FIELDC

' ' ' '

' ' ' '

FILEAPGMX

FILEB

FILEC

FILED

PGMY

' '

' '

DSPFFD... OUTFILE(W) DSPPGMREF... OUTFILE(Y)

�Select "W" records with changed field.�Join W and Y on file name using�Join logical file�Query/400

W Y

Example: Implement the field change (2 of 2)

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

14-88 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 557: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 14-63. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Code and create files and use file-related commands.

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-89

Page 558: RXZ5E_ol49studentnotebook

Student Notebook

Figure 14-64. CPYF (copy file) OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

CPYF (copy file)CPYF (copy file)

CPYF (copy file)CPYF (copy file)

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

14-90 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 559: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Copy functions and commands

CPYF

CPYSRCF

CPYFRMDKT

CPYTODKT

CPYFRMTAP

CPYTOTAP

DUPDKT

DUPTAP

CRTDUPOBJ

-

-

-

-

-

-

-

-

-

-

Copy file

Copy source file

Copy from diskette

Copy to diskette

Copy from tape

Copy to tape

Duplicate diskette

Duplicate tape

Create duplicate object

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-91

Page 560: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Fromfile

To filePhysical

XXXXX

Undefined

XX

Printer

XXXXX

Tape

XXXXX

Diskette

XX

XX

PhysicalLogicalDisketteTapeInline Data

Copy function: From and to

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

14-92 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 561: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

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

FROMMBR( )

member namegeneric name*ALL*FIRST

TOMBR( )

member name*FROMMBR*FIRST

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

Selecting members

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-93

Page 562: RXZ5E_ol49studentnotebook

Student Notebook

Figure 14-68. Copy file: FROMMBR, TOMBR OL4912.1

Notes:

The member names represent the content of the respective members.

© Copyright IBM Corporation 2012

IBM i

MBR1

MBR2

MBR3

FROMFILE

FROMMBR *FIRST MBR3 *ALL *ALL

TOMBR *FIRST *FIRST *FIRST *FROMMBR

TOFILEMBR1

MBR2

MBR3

MBR1 MBR3MBR1

MBR2

MBR3

Default

Copy file: FROMMBR, TOMBR

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

14-94 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 563: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

FROMFILE

NONE

CRTFILE (*YES)

MBROPT (*ADD)

MBROPT (*REPLACE)

Before AfterTOFILE

Copy file: CRTFILE, MBROPT

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-95

Page 564: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

102

106

103

105

108

FROMRCD(3)TORCD(5)

103

105

108

Copy file: FROMRCD, TORCD

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

14-96 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 565: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

102

106

103

105

108

FROMKEY(103)TOKEY(106)

103

105

106

Copy file: FROMKEY, TOKEY

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-97

Page 566: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

NBRRCDS(50)

/* Number of Records to Cop */

Instead of

TORCD

-or-

TOKEY

Copy file: NBRRCDS

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

14-98 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 567: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

102

106

103

105

108

INCCHAR(NAME 1 *CT DAV)

106

105

108

SMITH

DAVIS

SAMPSON

ST. DAVIDS

DAVIDSON

ST. DAVIDS

DAVIDSON

DAVIS

Copy file: INCCHAR

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-99

Page 568: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

INCREL((*IF AMT *GT 150))

102

106

103

105

108

59

160

175

23

132

106

103

160

175

Copy file: INCREL

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

14-100 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 569: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

FLDA FLDB FLDC FLDD

FLDA FLDB FLDC FLDD

7 10 12 5

51587

FLDA FLDB FLDC FLDD

FLDA FLDC FLDD

FROM

TO

TO

FROM

FMTOPT(*MAP)

FMTOPT(*DROP)

Copy file: FMTOPT(*DROP *MAP)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-101

Page 570: RXZ5E_ol49studentnotebook

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.

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

14-102 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 571: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

FROM

TO

Copy file: FMTOPT(*NOCHK)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-103

Page 572: RXZ5E_ol49studentnotebook

Student Notebook

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:

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

© Copyright IBM Corporation 2012

IBM i

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

Creating test data using a DB copyCPYF FROMFILE(PAYLIB/EMP1)

Required keywords for database to database copy.

FROMFILE - TOFILE - MBROPT

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

14-104 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 573: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Print options

� TOFILE( )� *PRINT

� SEU type listing for CPYSRCF� Printer device filename

� OUTFMT( )� *CHAR� *HEX

� PRINT( )� *COPIED� *EXCLUDED

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-105

Page 574: RXZ5E_ol49studentnotebook

Student Notebook

Figure 14-79. Create a file not previously defined OL4912.1

Notes:

Example of CRTFILE(*YES).

© Copyright IBM Corporation 2012

IBM i

CPYF FROMFILE(BILL/CUSTOMER)

TOFILE(QGPL/CUSTOMER)

CRTFILE(*YES)

INCREL((*IF CRDLMT *GE 10000))

Create a file not previously defined

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

14-106 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 575: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 14-80. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise

� Copy file

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-107

Page 576: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Additional databaseAdditional databasecapabilitiescapabilities

Additional database capabilitiesAdditional database capabilities

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

14-108 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 577: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 1 101 BOWIE 93L103 1999 1 101 BOWIE 62L214 1999 2 108 NELSON 97L410 1999 1 106 HOLIDAY 75L303 1999 3 107 STING 86L001 1999 2 105 MADONNA -L001 1999 3 107 STING -

Crs Cls Cls Stu StuCode Yr Qtr No GrdL001 1999 1 101 93L103 1999 1 101 62L001 1999 1 102 72L001 1999 1 103 79L001 1999 2 105 -L410 1999 1 106 75L303 1999 3 107 86L001 1999 3 107 -L214 1999 2 108 97L001 1998 3 110 93L001 1998 3 113 86L001 1998 3 115 96L001 1998 4 117 81L001 1998 4 118 90

Logical File GRADE9899UUnion: GRADEPF98 and GRADEPF99Sequence by student numberDo not need student number

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1998 3 110 PARKER 93L001 1998 3 113 TORME 86L001 1998 3 115 KENTON 96L001 1998 4 117 DAVIS 81L001 1998 4 118 BRUBECK 90

GRADEPF98

GRADEPF99

Logical File: Union, projection, and sequence (1 of 2)

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-109

Page 578: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

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

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

14-110 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 579: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Crs Course Ins InstrCode Title No NameL001 ITALIAN 001 DANTEL103 ENGLISH 002 HIGGINSL211 SPANISH 003 PICASSOL214 GREEK 004 HOMERL303 CHINESE 005 TSUNG

CLASSPF GRADEPF99

L001 ITALLIAN 001 DANTEL001 101 1999 1 BOWIE 93L001 102 1999 1 LAUPER 72L001 103 1999 1 TURNER 79L001 105 1999 2 MADONNA -L001 107 1999 3 STING -

L103 ENGLISH 002 HIGGINSL103 101 1999 1 BOWIE 62

L211 SPANISH 003 PICASSOL214 GREEK 004 HOMER

L214 108 1999 2 NELSON 97L303 CHINESE 005 TSUNG

L303 107 1999 3 STING 86L410 106 1999 1 HOLIDAY 75

ROSTERLF

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 1 101 BOWIE 93L103 1999 1 101 BOWIE 62L214 1999 2 108 NELSON 97L410 1999 1 106 HOLIDAY 75L303 1999 3 107 STING 86L001 1999 2 105 MADONNA -L001 1999 3 107 STING -

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-111

Page 580: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

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

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

14-112 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 581: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

CLSGRDIJ99

Crs Course InstrCode Title NameL001 ITALIAN DANTEL001 ITALIAN DANTEL001 ITALIAN DANTEL001 ITALIAN DANTEL001 ITALIAN DANTEL103 ENGLISH HIGGINSL214 GREEK HOMERL303 CHINESE TSUNG

Student StuName GrdBOWIE 93LAUPER 72MADONNA -STING -TURNER 79BOWIE 62NELSON 97STING 86

CLASSPF (Primary) Inner Joined toGRADEPF99 (Secondary) on Course Code.Sequence duplicates by student lastname.

CLASSPF GRADEPF99Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 1 101 BOWIE 93L103 1999 1 101 BOWIE 62L214 1999 2 108 NELSON 97L410 1999 1 106 HOLIDAY 75L303 1999 3 107 STING 86L001 1999 2 105 MADONNA -L001 1999 3 107 STING -

Crs Course Ins InstrCode Title No NameL001 ITALIAN 001 DANTEL103 ENGLISH 002 HIGGINSL211 SPANISH 003 PICASSOL214 GREEK 004 HOMERL303 CHINESE 005 TSUNG

Logical file: Inner join

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-113

Page 582: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Logical file DDS: Inner JOIN

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

14-114 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 583: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 14-88. Logical file: Left outer JOIN OL4912.1

Notes:

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

© Copyright IBM Corporation 2012

IBM i

Crs Course InstrCode Title NameL001 ITALIAN DANTEL001 ITALIAN DANTEL001 ITALIAN DANTEL001 ITALIAN DANTEL001 ITALIAN DANTEL103 ENGLISH HIGGINSL211 SPANISH PICASSOL214 GREEK HOMERL303 CHINESE TSUNG

Student StuName GrdBOWIE 93LAUPER 72MADONNA -STING -TURNER 79BOWIE 62

-NELSON 97STING 86

GRADEPF99

CLSGRDOJ99

CLASSPF (Primary) Left Outer Joined toGRADEPF99 (Secondary) on Course Code.

Sequence duplicates by student's last name.

CLASSPFCrs Course Ins InstrCode Title No NameL001 ITALLIAN 001 DANTEL103 ENGLISH 002 HIGGINSL211 SPANISH 003 PICASSOL214 GREEK 004 HOMERL303 CHINESE 005 TSUNG

Crs Cls Cls Stu Student StuCode Yr Qtr No Name GrdL001 1999 1 102 LAUPER 72L001 1999 1 103 TURNER 79L001 1999 1 101 BOWIE 93L103 1999 1 101 BOWIE 62L214 1999 2 108 NELSON 97L410 1999 1 106 HOLIDAY 75L303 1999 3 107 STING 86L001 1999 2 105 MADONNA -L001 1999 3 107 STING -

Logical file: Left outer JOIN

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-115

Page 584: RXZ5E_ol49studentnotebook

Student Notebook

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

Notes:

Specifying the JDFTVAL keyword makes this a left outer join.

© Copyright IBM Corporation 2012

IBM i

Logical file DDS: Left outer JOIN

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

14-116 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 585: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

MEMBER Y

MEMBER X

SOURCE FILECODE

DDSSOURCE

QDDSSRC1

CREATEDATABASE

FILE(COMPILE

DDS SOURCE)

ENTER DDS SOURCE

2

3

DFU or

RPGor

COBOL

4

LOGICAL FILEY Data path

User steps

OPTIONALSYNTAX

CHECKING

DATA

PHYSICALFILE X

LISTING OFSOURCE

DESCRIPTIONAND ERRORS

Creating logical file and entering data

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-117

Page 586: RXZ5E_ol49studentnotebook

Student Notebook

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.

© Copyright IBM Corporation 2012

IBM i

Access Path

Data

CLASSPF

Access Path

Data

GRADEPF99

Access Path

Data

GRADEPF98

*LIB: FACxx

FACOUTQxxPAYROLxxFACJOBDxxQDDSSRCCLASSPFGRADEPF98GRADEPF99GRADELF99ROSTERLFGRADE9899UGRADEIJ99GRADEOJ99

GRADE9899U

GRADELF99

ROSTERLF

CLSGRDOJ99

CLSGRDIJ99

Access Path

Access Path

Access Path

Access Path

Access Path

FACOUTQxx PAYROLxx FACJOBDxxQDDSSRC

Mbr: CLASSPFDDS

Mbr: GRADEPFDDS

Mbr: GRADELF99DDS

Mbr: ROSTERLFDDS

Mbr: GRADE9899UDDS

Mbr: GRADEIJ99DDS

Mbr: GRADEOJ99DDS

School case study summary

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

14-118 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 587: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 14-92. Machine exercise OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Machine exercise� Using the IBM i Editors

� Code and create files: Use file-related commands

� Copy file

� Additional physical and logical files

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-119

Page 588: RXZ5E_ol49studentnotebook

Student Notebook

Figure 14-93. Checkpoint OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Checkpoint1. 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?

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

14-120 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 589: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 14-94. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

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

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

© Copyright IBM Corp. 1997, 2012 Unit 14. Using the Legacy toolset (PDM/SEU/CPYF) 14-121

Page 590: RXZ5E_ol49studentnotebook

Student Notebook

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

14-122 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 591: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

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

© Copyright IBM Corp. 1997, 2012 Unit 15. Wrap-up and supplemental exercises 15-1

Page 592: RXZ5E_ol49studentnotebook

Student Notebook

Figure 15-1. Unit objectives OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit objectives

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

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

15-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 593: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

Figure 15-2. Next step OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Next stepNext step

Next stepNext step

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

© Copyright IBM Corp. 1997, 2012 Unit 15. Wrap-up and supplemental exercises 15-3

Page 594: RXZ5E_ol49studentnotebook

Student Notebook

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!

© Copyright IBM Corporation 2012

IBM i

What can you do now?� 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.

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

15-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 595: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Programming courses

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 15. Wrap-up and supplemental exercises 15-5

Page 596: RXZ5E_ol49studentnotebook

Student Notebook

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

© Copyright IBM Corporation 2012

IBM i

Database courses

� 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

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

15-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 597: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

WDSC/RDP courses

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 15. Wrap-up and supplemental exercises 15-7

Page 598: RXZ5E_ol49studentnotebook

Student Notebook

Figure 15-7. Java anyone? OL4912.1

Notes:

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

© Copyright IBM Corporation 2012

IBM i

Java anyone?

� AS08 - Java for RPG Programmers

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

15-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 599: RXZ5E_ol49studentnotebook

Student NotebookV7.0

Uempty

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 Corporation 2012

IBM i

Machine exercises

� 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

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

© Copyright IBM Corp. 1997, 2012 Unit 15. Wrap-up and supplemental exercises 15-9

Page 600: RXZ5E_ol49studentnotebook

Student Notebook

Figure 15-9. Unit summary OL4912.1

Notes:

© Copyright IBM Corporation 2012

IBM i

Unit summary

Having completed this unit, you should be able to:� Identify courses that you should attend� Use SDA, DFU, and Query

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

15-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 601: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-1

Page 602: RXZ5E_ol49studentnotebook

Student Notebook

Unit 3, "IBM i concepts and overview"

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. Many of the functions traditionally performed by system control

programs have been _______________a. placed into subsystems.b. integrated into the IBM i machine and hardware.c. eliminated.d. 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. All storage is managed as one container.b. Objects are distributed across multiple disks.c. User does not need to designate location.d. 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.

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

A-2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 603: RXZ5E_ol49studentnotebook

Student NotebookV7.0

AP

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

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-3

Page 604: RXZ5E_ol49studentnotebook

Student Notebook

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

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

A-4 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 605: RXZ5E_ol49studentnotebook

Student NotebookV7.0

AP

Unit 6, "Commands, profiles, and libraries"

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

© Copyright IBM Corporation 2012

IBM i

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

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-5

Page 606: RXZ5E_ol49studentnotebook

Student Notebook

Unit 7, "Introduction to IBM i security"

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. What are three methods of controlling access to IBM i

objects?The answers are:

User profilesGroup profilesAuthority 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.

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

A-6 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 607: RXZ5E_ol49studentnotebook

Student NotebookV7.0

AP

Unit 8, "Control language programming"

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-7

Page 608: RXZ5E_ol49studentnotebook

Student Notebook

Unit 9, "Basic message handling"

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

A-8 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 609: RXZ5E_ol49studentnotebook

Student NotebookV7.0

AP

Unit 10, "Creating reports and displays"

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

© Copyright IBM Corporation 2012

IBM i

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

The answers are:physical fileslogical filesdisplay screensreports

2. What are the three hierarchical levels in a DDS file?The answers are:File levelRecord format levelField level

3. What tools can be used to create DDS?The answers are:SEURDP (LPEX/Screen Designer/Report Designer)

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-9

Page 610: RXZ5E_ol49studentnotebook

Student Notebook

Unit 11, "IBM DB2 for i"

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

A-10 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 611: RXZ5E_ol49studentnotebook

Student NotebookV7.0

AP

Unit 12, "Accessing the IBM i database using SQL and IBM i Navigator"

Solutions for Figure 12-60, "Checkpoint," on page 12-70

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. List three methods that you could use to run SQL statements on an

IBM i.The answers are:Interactive SQL (STRSQL)RUNSQLSTMIBM i Navigator (Run SQL Scripts)A HLL program with embedded SQLCall-level interfaces such as CLI, ODBC, JDBCWeb 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.

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-11

Page 612: RXZ5E_ol49studentnotebook

Student Notebook

Unit 13, "Defining database files using DDS"

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

© Copyright IBM Corporation 2012

IBM i

Checkpoint solutions1. 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.

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

A-12 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 613: RXZ5E_ol49studentnotebook

Student NotebookV7.0

AP

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

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

Unit 15, "Wrap-up and supplemental exercises"

No checkpoint solutions in this unit.

© Copyright IBM Corporation 2012

IBM i

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

access the SEU editor?The answers are:STRSEUSTRPDMWRKMBRPDM

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.

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

© Copyright IBM Corp. 1997, 2012 Appendix A. Checkpoint solutions A-13

Page 614: RXZ5E_ol49studentnotebook

Student Notebook

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

A-14 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 615: RXZ5E_ol49studentnotebook

Student NotebookV7.0

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 Newshttp://www.iprodeveloper.com/ System i Network Website http://www.midrange.com/ Midrange Website http://www.ibmsystemsmag.com/ IBM Systems Magazinehttp://www.mcpressonline.com/ MC Press

• CD-ROMs: SK3T-4091 IBM i Information Center SK2T-2849 IBM Redbooks IBM i Collection

• Redbooks: SG24-4249 Advanced Functions and Administration on DB2 Universal

Database for System i SG24-6503 Stored Procedures and Triggers on DB2 Universal Database for

System i SG24-5402 Who Knew You Could do that with RPGIV?

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

© Copyright IBM Corp. 1997, 2012 Appendix X. Bibliography X1

Page 616: RXZ5E_ol49studentnotebook

Student Notebook

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

X2 IBM i Programming Facilities © Copyright IBM Corp. 1997, 2012

Page 617: RXZ5E_ol49studentnotebook

V7.0

backpg

Back page
Page 618: RXZ5E_ol49studentnotebook