Table of Contents at a Glance

Similar documents
562 Control Language Programming for IBM i

About the Authors. Preface

V5R3 CL Enhancements. Larry Bolhuis Arbor Solutions, Inc.

CL The Story Continues

Contents. Acknowledgments Introduction

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

INDEX. *AND (See logical variables)

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

PROBLEM SOLVING WITH FORTRAN 90

A Web-Based Introduction

Index. B Bachman diagram defined, 216 illustrated, 216, 380 Based-on logical files, information, 310

C# Programming: From Problem Analysis to Program Design. Fourth Edition

"Charting the Course... Java Programming Language. Course Summary

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Contents. Preface. Introduction. Introduction to C Programming

Practical C++ Programming

Fundamentals of the Java Programming Language

BASIC OPERATORS AND FUNCTIONS

Beginning Perl. Third Edition. Apress. JAMES LEE with SIMON COZENS

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

CONTENTS. ... vii. ... xv The Old Standard xvi The New Standard xvi A Whole New Ball Game xvii e-rpg xviii INTRODUCTION

Verilog HDL. A Guide to Digital Design and Synthesis. Samir Palnitkar. SunSoft Press A Prentice Hall Title

It has always been a pain to call IBM APIs from CL programs

Computer Programming C++ (wg) CCOs

Excel Programming with VBA (Macro Programming) 24 hours Getting Started

INDEX. Note: boldface numbers indicate illustrations; (t) indicates a table. 257

The Designer's Guide to VHDL Second Edition

Acknowledgments Introduction. Chapter 1: Introduction to Access 2007 VBA 1. The Visual Basic Editor 18. Testing Phase 24

Preface to the Second Edition... xi A Note About Source Entry... xi

(CL Compiler Enhancements from V5R3 to now)

CITY UNIVERSITY OF NEW YORK. i. Visit:

Microsoft. Microsoft Visual C# Step by Step. John Sharp

1 Chapter Plan...1 Exercise - Simple Program...2

Python Scripting for Computational Science

CHAPTER 1: INTRODUCING C# 3

CONTENTS. INTRODUCTION xvii

SOME ASSEMBLY REQUIRED

Contents. part 1: ILE Basics...7. Acknowledgments...iv

CITY UNIVERSITY OF NEW YORK. Creating a New Project in IRBNet. i. After logging in, click Create New Project on left side of the page.

Introduction PL/1 Programming

С and the Programming for Multitasking. Thomas W. Schultz. Purdue University West Lafayette, Indiana

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS

Contents. 2 Introduction to C++ Programming,

Absolute C++ Walter Savitch

[CHAPTER] 1 INTRODUCTION 1

Advanced R. V!aylor & Francis Group. Hadley Wickham. ~ CRC Press

Pointers in C. A Hands on Approach. Naveen Toppo. Hrishikesh Dewan

Installing and Administering a Satellite Environment

Contents. 1 Introduction to Computers, the Internet and the World Wide Web 1. 2 Introduction to C Programming 26

Rational Developer for i: What's New in 9.0.1

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

Acknowledgments Introduction. Part I: Programming Access Applications 1. Chapter 1: Overview of Programming for Access 3

Index. user profile and, 7 Work with Objects Using PDM (WRKOBJPDM) and, 446

C Programming for Electronic Engineers

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

SAP' ABAP. Handbook. Kogent Learning Solutions, Inc. Sudbury, Massachusetts JONES AND BARTLETT PUBLISHERS BOSTON TORONTO LONDON SINUAPORI:

Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi

Learn Windows PowerShell 3 in a Month of Lunches

CERTIFICATE IN WEB PROGRAMMING

Oracle BPM 10g R3 Programming 1 Essentials

IBM. TSO/E REXX User's Guide. z/os. Version 2 Release 3 SA

Introduction. Assessment Test. Part I The Programmer s Exam 1

Understanding the Concepts and Features of Macro Programming 1

1 OBJECT-ORIENTED PROGRAMMING 1

Scenario Manager User Guide. Release September 2013

C for Electronic Engineering

Preface. The Purpose of this Book and Its Audience. Coverage and Approach

INDEX. A Absolute Value of Expression (%ABS), 26, 27 activation groups for database triggers, 257, 267, 279

System Administration of PTC Windchill 11.0

Python Scripting for Computational Science

foreword to the first edition preface xxi acknowledgments xxiii about this book xxv about the cover illustration

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Contents. Acknowledgments

Chapters and Appendix F are PDF documents posted online at the book s Companion Website (located at

"Charting the Course... SharePoint 2007 Hands-On Labs Course Summary

Contents Introduction 1

Contents Chapter 1 Introduction to Programming and the Java Language

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Maintain an ILE RPG application using Remote System Explorer

JAVA CONCEPTS Early Objects

A Fast Review of C Essentials Part I

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

PYTHON. p ykos vtawynivis. Second eciitiovl. CO Ve, WESLEY J. CHUN

ILE Essentials, Part 1 Static Binding and Service Programs

Introduction to PTC Windchill ProjectLink 11.0

ERserver. ILE Concepts. iseries. Version 5 Release 3 SC

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6

Murach s Beginning Java with Eclipse

Introduction to Programming Using Java (98-388)

Contents. Illustrations. 1 Introduction to Computers, the Internet, the Web and C# 1

Scanner Logic Programmer Manual

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

UNIX Shell Programming

Table of Contents. Preface... xxi

Tentative Teaching Plan Department of Software Engineering Name of Teacher Dr. Naeem Ahmed Mahoto Course Name Computer Programming

Chapters are PDF documents posted online at the book s Companion Website (located at

Transcription:

Table of Contents at a Glance Preface... xix Chapter 1 What Is CL?... 1 Chapter 2 Control Language Command Names... 7 Chapter 3 Command Parameters... 13 Chapter 4 The IBM i User Interface... 25 Chapter 5 Creating CL Programs... 49 Chapter 6 The Structure of a CL Program... 77 Chapter 7 Declaring Program Variables... 93 Chapter 8 Manipulating Variables with the CHGVAR Command... 113 Chapter 9 CL Control Structures... 133 Chapter 10 Expressions... 155 Chapter 11 Controlling Workflow... 173 Chapter 12 Basic Error Handling... 193 Chapter 13 Passing Parameters... 215 Chapter 14 Retrieving and Changing External Attributes... 237 Chapter 15 Files and Data Areas... 257 Chapter 16 Advanced Message Handling... 289 Chapter 17 Advanced File Techniques... 319 Chapter 18 Advanced Command Prompting... 341 Chapter 19 Using IBM-Supplied APIs... 351 Chapter 20 Displaying and Changing Command Properties... 367 Chapter 21 Understanding the Job Log... 377 Chapter 22 Understanding the Integrated Language Environment... 387 Chapter 23 User-Defined Commands... 403 Chapter 24 Command Processing Programs... 425 Chapter 25 Advanced Command Facilities... 439 Appendix A The Most-Often-Used CL Commands... 457 Appendix B Program Development Tools... 531 Appendix C Program Testing and Debugging...551

vii Table of Contents [Italic type indicates a sidebar.] Preface...?? INTRODUCTION TO CONTROL LANGUAGE Chapter 1 What Is CL?...1 Chapter Overview... 1 What CL Is... 1 What CL Is Not... Controlling Workflow with CL... 3 CL Execution Environment and Restrictions... 3 An Introductory Program... 3 Chapter Summary... 4 Key Terms... 4 Review Questions... 5 Chapter 2 Control Language Command Names...7 Chapter Overview... 7 Verbs and Subjects... 7 Modifiers and Subject Phrases... 9 Command Aliases...11 Chapter Summary... 11 Key Terms... 11 Review Questions... 12 Chapter 3 Command Parameters...13 Chapter Overview... 13 Command Parameters... 13 Required and Optional Parameters... 13 Entering Parameters with Keyword Notation... 15 Entering Parameters with Positional Notation... 15 The Order of Parameters... 16 Positional Keyword Limits... 17 Using *N... 18 Mixing Keyword and Positional Notation... 18 Types of Command Parameters... 19 Parameter Special Values... 19 Qualified Values... 20 Value Lists...20 Complex Lists... 21 Chapter Summary... 21

viii Programming in RPG IV, Fourth Edition Key Terms... 22 Review Questions... 22 Exercises...22 Chapter 4 The IBM i User Interface...25 Chapter Overview... 25 The IBM i Menu System... 25 Command-Line Operations... 27 Command-Line Function Keys... 27 The Prompt Facility... 28 The Command Prompt Display... 29 Determining Allowable Values... 30 Command-Prompt Function Keys... 32 Additional Parameters... 35 Prompt Special Characters... 37 Finding the Right CL Command... 41 Using the CMD Menus... 45 Chapter Summary... 46 Key Terms... 46 Review Questions... 47 Exercises...47 BASIC CL PROGRAMMING Chapter 5 Creating CL Programs...49 Chapter Overview... 49 The Capabilities of CL Programs... 49 Using a Source Physical File... 50 How to Create a CL Program... 51 Adding a Source Member... 52 Using WDSc to Add a Source Member... 53 Using PDM to Add a Source Member... 53 Entering CL Commands into a Source Member... 54 Compiling the CL Source... 56 Using the CL Compiler... 56 CL Compiler Options... 58 CL Compiler Reports... 60 Analyzing Compiler Reports... 63 Diagnosing Compile-Time Errors... 64 Diagnosing Errors with WDSc... 67 Binding a Program... 68 Using a Shortcut... 69 CL and the Original Program Model...70 Chapter Summary... 71 Key Terms... 71

Contents ix Review Questions... 72 Programming Assignments... 73 Chapter 6 The Structure of a CL Program...77 Chapter Overview... 77 Entering CL Source Statements... 77 Free-Format Statement Entry... 77 Upper and Lower Case... 78 Blank Lines... 78 Keyword and Positional Notation... 79 Entering Program Comments... 79 Command Continuation (+ and )... 79 Using Labels... 82 The Sections of a CL Source Member... 82 Program Information Section... 83 Program Linkage Section... 83 Declarations Section... 84 Procedure Section... 85 Putting It All Together... 87 Chapter Summary... 89 Key Terms... 89 Review Questions... 90 Programming Assignments... 90 Chapter 7 Declaring Program Variables...93 Chapter Overview... 93 What Is a Program Variable?... 93 How to Declare a Variable... 93 The DCL Command... 93 Naming Variables... 94 Specifying the Data Type... 94 Specifying the Variable Size... 94 Coding in Style...96 Initializing the Value of a Variable... 96 Assigning Values to *CHAR Variables... 97 Assigning Values to *LGL Variables... 98 Assigning Values to Numeric Variables... 98 Miscellaneous Rules for Initial Values... 99 Using DCL with Pointers...100 Declaring Based Variables... 100 Declaring Defined Variables... 101 More DCL Examples...102 The DCLF Command...103 DCLF Examples...104

x Programming in RPG IV, Fourth Edition Chapter Summary...105 Key Terms...105 Review Questions...106 Exercises...106 Programming Assignments... 109 Chapter 8 Manipulating Variables with the CHGVAR Command... 113 Chapter Overview...113 The CHGVAR (Change Variable) Command... 113 Using CHGVAR with Character Variables... 114 Using CHGVAR with Numeric Variables... 115 Using CHGVAR with Logical Variables... 116 Performing Data Conversion with CHGVAR... 116 Converting Numeric Data to Character Data... 116 Converting Character Data to Numeric Data... 117 Using a Variable to Specify VALUE... 118 Using an Arithmetic Expression to Specify VALUE... 118 Using a Character String Expression to Specify VALUE... 119 Using Built-In Functions...120 Using %SUBSTRING...120 Using %BINARY...121 Using Built-In Functions in the Receiver Variable... 121 The DMPCLPGM Command...122 Using Functions with Pointers... 123 Chapter Summary...124 Key Terms...125 Review Questions...125 Exercises...126 Programming Assignments... 127 Chapter 9 CL Control Structures... 133 Chapter Overview...133 CL and Structured Programming... 133 The GOTO Command...135 IF/ELSE Structure...136 Nested IF Structures...136 Using the ELSE Command... 137 Nested IF/THEN/ELSE Structures... 138 DO Groups...139 SELECT/WHEN/OTHERWISE Structure... 140 Program Looping and Iteration... 141 DOWHILE Command... 141 DOUNTIL Command...142 DOFOR Command...142 Loops and Early Exits...143

Contents xi Using Subroutines...145 The CALLSUBR Command... 146 Leaving a Subroutine...147 Using a Return Value...147 The DCLPRCOPT Command... 147 Chapter Summary...148 Key Terms...149 Review Questions...150 Exercises...150 Programming Assignments... 152 Chapter 10 Expressions...155 Chapter Overview...155 What Is an Expression?...155 Using Arithmetic Expressions... 156 Arithmetic Order of Operations... 157 Using the %BIN Function... 157 Using Character String Expressions... 158 Using the %SST Function... 159 Using Relational Expressions... 160 Relational Operators...161 Character Operands of Different Lengths... 162 Using Relational Expressions with the CHGVAR Command... 162 Using Logical Expressions...162 Evaluating Logical Relationships... 163 Using Logical Variables and Logical Constants... 164 Using More Than Two Operands... 165 Expression Order of Evaluation... 166 Chapter Summary...166 Key Terms...167 Review Questions...167 Exercises...167 Programming Assignments... 169 Chapter 11 Controlling Workflow... 173 Chapter Overview...173 Work Management Overview... 173 What Is a Job?...173 What Is a Job Description?... 174 What Is a Job Queue?...174 What Is a Library List?...174 Executing Programs with the CALL Command... 175 ILE Considerations...177 The Call Stack...178

xii Programming in RPG IV, Fourth Edition Executing Programs with the TFRCTL Command... 179 The RETURN Command...181 High-Level Language Considerations... 182 Executing Commands in Batch Using SBMJOB... 182 The CMD Parameter of the SBMJOB Command... 182 Other SBMJOB Parameters... 183 Job Definition Parameters for SBMJOB... 184 Library List Parameters for SBMJOB... 184 SBMJOB Output Parameters... 184 Scheduling Parameters for SBMJOB... 185 The Self-Submitting Program... 185 Chapter Summary...187 Key Terms...188 Review Questions...188 Exercises...189 Programming Assignments... 190 Chapter 12 Basic Error Handling... 193 Chapter Overview...193 Types of Errors...193 Error Messages...193 Message Files...194 The CHKOBJ Command...196 The MONMSG Command...197 Command-Level MONMSG... 198 Program-Level MONMSG... 199 Mixing Command- and Program-Level MONMSGs... 201 Monitoring for Generic Messages... 202 Specifying Multiple MONMSG Commands... 203 Errors Within a MONMSG... 203 The Interactive Job Log...204 Ignoring Error Messages... 205 Receiving Escape Message Text... 205 Chapter Summary...207 Key Terms...207 Review Questions...208 Exercises...209 Programming Assignments... 210 INPUT/OUTPUT IN A CL PROGRAM Chapter 13 Passing Parameters...215 Chapter Overview...215 What Are Parameters?...215 Defining Parameters in a Called Program... 216

Contents xiii Passing Constants to a Called Program... 217 Passing Character Constants... 217 Passing Logical Constants... 220 Passing Decimal Constants... 221 Passing Variables to a Called Program... 221 The Mechanics of Passing Variables... 222 Passing Parameters Using the TFRCTL Command... 224 Passing Parameters Using the SBMJOB Command... 225 Using Hexadecimal Notation...227 Chapter Summary...228 Key Terms...228 Review Questions...229 Exercises...230 Programming Assignments... 231 Chapter 14 Retrieving and Changing External Attributes... 237 Chapter Overview...237 Return Variables...237 The RTVJOBA Command... 238 The CHGJOB Command... 239 System Values...241 The RTVSYSVAL Command... 241 The CHGSYSVAL Command... 242 Categories of System Values... 242 Date/Time System Values... 243 System Control System Values245 Library List System Value... 246 Other System Values...247 The RTVUSRPRF Command... 247 The CHGUSRPRF Command... 248 Other RTV Commands...248 Date Conversion Using the CVTDAT Command... 249 Chapter Summary...251 Key Terms...252 Review Questions...252 Exercises...254 Programming Assignments... 254 Chapter 15 Files and Data Areas...257 Chapter Overview...257 Working with Files...257 Database Files...257 Display Files...259 CL and SQL...259

xiv Programming in RPG IV, Fourth Edition File Existence Requirements for CL... 259 Data Description Specifications... 260 DDS for Physical Files...261 DDS for Logical Files...263 DDS for Display Files...264 Files Without DDS...266 CL File Processing...267 The DCLF Command...267 The SNDRCVF Command... 268 The SNDF Command...269 The RCVF Command...270 The WAIT and ENDRCV Commands... 271 CL OUTFILE Support...271 Data Areas...273 Creating and Deleting a Data Area... 274 Displaying a Data Area s Contents... 275 Retrieving the Contents of a Data Area... 275 Changing the Contents of a Data Area... 276 The Local Data Area...277 Chapter Summary...277 Data Queues...278 Key Terms...282 Review Questions...282 Exercises...284 Programming Assignments... 285 ADVANCED CL PROGRAMMING Chapter 16 Advanced Message Handling... 289 Chapter Overview...289 Messages...289 What Is a Message?...289 Message Queues...289 Types of Messages...290 Commands Used to Send Messages... 291 The SNDMSG Command... 292 The SNDBRKMSG Command... 293 The SNDPGMMSG Command... 293 The SNDUSRMSG Command... 295 Receiving Messages...297 The TOPGMQ Parameter...298 RCVMSG Examples...304 Removing Messages...305 RMVMSG Examples...306 Standard Error-Handling Routines... 306

Contents xv Chapter Summary...312 Key Terms...313 Review Questions...313 Exercises...314 Programming Assignments... 316 Chapter 17 Advanced File Techniques... 319 Chapter Overview...319 Using Files in a CL Program... 319 Using File Overrides...319 Using the OVRDBF Command... 320 Using the DLTOVR Command... 323 Using the OVRPRTF Command... 323 Positioning Database Files...326 Preopening Database Files... 326 Using OPNQRYF...328 Using CPYFRMQRYF...331 Chapter Summary...333 Key Terms...334 Review Questions...334 Exercises...335 Programming Assignments... 336 Chapter 18 Advanced Command Prompting... 341 Chapter Overview...341 Reviewing the Prompt Facility... 341 Simple Command Prompting... 341 Selective Prompting...344 Chapter Summary...346 Key Terms...346 Review Questions...347 Exercises...347 Programming Assignments... 348 Chapter 19 Using IBM-Supplied APIs... 351 Chapter Overview...351 Introduction to APIs...351 Using QCMD...352 Using QUSCMDLN...354 Using QCMDCHK...355 Prompting with QCMDCHK... 355 Using QCMDEXC...356 QCMDEXC and Call Levels... 358 Other APIs...358

xvi Programming in RPG IV, Fourth Edition ILE Bindable APIs...359 Chapter Summary...361 Key Terms...362 Review Questions...362 Exercises...363 Programming Assignments... 363 Chapter 20 Displaying and Changing Command Properties... 367 Chapter Overview...367 Displaying the Properties of a CL Command... 367 Changing the Properties of a CL Command... 370 Changing Parameter Default Values... 372 Changing IBM-Supplied Commands... 372 Chapter Summary...374 Key Terms...374 Review Questions...374 Exercises...375 Chapter 21 Understanding the Job Log... 377 Chapter Overview...377 What Is a Job Log?...377 The LOG Attribute...379 Logging CL Commands...380 Analyzing the Job Log...381 Keeping a Lean Job Log...384 Chapter Summary...384 Key Terms...384 Review Questions...385 Exercises...385 Programming Assignments... 386 Chapter 22 Understanding the Integrated Language Environment... 387 Chapter Overview...387 What Is ILE?...387 What Is a Procedure?...387 What Is a Module?...388 What Is a Program?...388 Creating ILE Modules and Programs... 388 One-Step Program Creation... 389 Multiple-Module Programs... 389 Updating ILE Programs...390 Adding Modules...391 Calling ILE Programs and Procedures... 391 Calling ILE Procedures Using a Static Call... 391

Contents xvii Using Service Programs...392 Understanding Activation Groups... 393 Default Activation Group... 394 User-Named Activation Group... 394 System-Named Activation Group... 394 *CALLER Activation Group Option... 395 *ENTMOD Activation Group Option... 395 Activation Groups Made Easy... 395 Activation Groups and File Overrides... 395 Call Stack Level Scoping... 396 Activation Group Scoping... 396 Job Scoping...396 ILE Error Handling...396 ILE Error-Handling Tips... 397 Chapter Summary...397 Key Terms...398 Review Questions...399 Exercises...399 Programming Assignments... 400 CREATING YOUR OWN COMMANDS Chapter 23 User-Defined Commands... 403 Chapter Overview...403 Why Commands?...403 The Components of a Command... 404 Command Definition Statements... 404 The CMD Statement...406 The PARM Statement...407 The QUAL Statement...410 Other Command Definition Statements... 412 The CRTCMD Command...413 Chapter Summary...414 Key Terms...414 Review Questions...415 Exercises...416 Programming Assignments... 418 Chapter 24 Command Processing Programs... 425 Chapter Overview...425 Writing a Command Processing Program... 425 Parameters in the CPP...425 Analyzing the CPP...430 Processing List Parameters in the CPP... 432 Using QCMDEXC as a CPP... 434

xviii Control Language Programming for IBM i, Third Edition Chapter Summary...435 Key Terms...436 Review Questions...436 Exercises...436 Programming Assignments... 437 Chapter 25 Advanced Command Facilities... 439 Chapter Overview...439 Adding Help to Your Commands... 439 Using the GENCMDDOC Command... 440 UIM Tag Language...440 Associating a Panel Group with a Command... 445 Validity Checking Programs... 446 Other Advanced Command Topics... 448 Chapter Summary...449 Key Terms...450 Review Questions...450 Exercises...451 Programming Assignments... 452 APPENDICES Appendix A The Most-Often-Used CL Commands... 457 Appendix B Program Development Tools... 531 Appendix C Program Testing and Debugging... 551 INDEX...561