CL Programing

  • View
    120

  • Download
    7

Embed Size (px)

DESCRIPTION

CL Programing For AS400

Text of CL Programing

ERserveriSeries

CL ProgrammingVersion 5SC41-5721-05

ERserveriSeries

CL ProgrammingVersion 5SC41-5721-05

Note Before using this information and the product it supports, be sure to read the information in Appendix E, Notices on page 443.

Sixth Edition (September 2002) This edition replaces SC41-5721-04. This edition applies only to reduced instruction set computer (RISC) systems. Copyright International Business Machines Corporation 1997, 2002. All rights reserved. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

ContentsFigures . . . . . . . . . . . . . . vii About CL Programming (SC41-5721) . . ixWho should read this book . . . . . . . . . ix Prerequisite and related information . . . . . . ix iSeries Navigator. . . . . . . . . . . . ix How to send your comments . . . . . . . . . x Using the %SUBSTRING Built-In Function . . Using the %SWITCH Built-In Function . . . Using the Monitor Message (MONMSG) Command . . . . . . . . . . . . . Values That Can Be Used as Variables . . . . Retrieving System Values . . . . . . . . Retrieving Configuration Source . . . . . Retrieving Configuration Status . . . . . Retrieving Network Attributes . . . . . . Retrieving Job Attributes . . . . . . . . Retrieving Object Descriptions . . . . . . Retrieving User Profile Attributes . . . . . Retrieving Member Description Information . Working with CL Procedures . . . . . . . Logging CL Procedure Commands . . . . CL Module Compiler Listings . . . . . . Errors Encountered during Compilation . . . Obtaining a Procedure Dump . . . . . . Displaying Module Attributes . . . . . . Displaying Program Attributes . . . . . . Return Code Summary . . . . . . . . Compiling Source Programs for a Previous Release Previous-Release (*PRV) Libraries . . . . . Installing CL Compiler Support for a Previous Release . . . . . . . . . . . . . . . 43 . 45 . . . . . . . . . . . . . . . . . . 46 48 48 51 51 51 52 53 53 54 55 55 56 58 59 60 60 61 62 . 62

Chapter 1. Introduction . . . . . . . . 1Control Language . . Procedure . . . . Module . . . . . Program . . . . . Service Program . . Command Syntax. . CL Procedures . . . . Command Definition . Menus . . . . . . Objects and Libraries . Objects . . . . . Libraries . . . . . Messages . . . . . Message Descriptions Message Queues . . Testing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1 2 2 2 2 4 4 4 5 5 7 8 8 8

. 63

Chapter 2. CL Programming. . . . . . 11Creating a CL Program . . . . . . . . . Interactive Entry. . . . . . . . . . . Batch Entry . . . . . . . . . . . . Parts of a CL Procedure . . . . . . . . Example of a Simple CL Program . . . . . Commands Used in CL Procedures . . . . . Commands Entered on the RQSDTA and CMD Parameters . . . . . . . . . . . . CL Commands . . . . . . . . . . . Using CL Procedures . . . . . . . . . . Working with Variables . . . . . . . . . Declaring a Variable . . . . . . . . . Using Variables to Specify a List or Qualified Name . . . . . . . . . . . . . . Lowercase Characters in Variables . . . . . Variables Replacing Reserved or Numeric Parameter Values . . . . . . . . . . Changing the Value of a Variable . . . . . Trailing Blanks on Command Parameters . . Writing Comments in CL Procedures . . . . Controlling Processing within a CL Procedure . . Using the GOTO Command and Labels . . . Using the IF Command . . . . . . . . Using the DO Command and DO Groups . . Using the ELSE Command . . . . . . . Using Embedded IF Commands . . . . . Using the *AND, *OR, and *NOT Operators . Using the %BINARY Built-In Function . . . Copyright IBM Corp. 1997, 2002

. . . . . . . . . . .

13 13 13 14 15 17 17 17 18 22 24

Chapter 3. Controlling Flow and Communicating between Programs and Procedures . . . . . . . . . . . . . 65CALL Command . . . . . . . . . . . . CALLPRC Command . . . . . . . . . . . RETURN Command . . . . . . . . . . . Passing Parameters between Programs and Procedures . . . . . . . . . . . . . . Using the CALL Command . . . . . . . . Common Errors When Calling Programs and Procedures . . . . . . . . . . . . . Using Data Queues to Communicate between Programs and Procedures . . . . . . . . . Remote Data Queues . . . . . . . . . . Comparisons with Using Database Files as Queues . . . . . . . . . . . . . . . Similarities to Message Queues . . . . . . . Prerequisites for Using Data Queues . . . . . Managing the Storage Used by a Data Queue . . Allocating Data Queues . . . . . . . . . Examples Using a Data Queue . . . . . . . Creating Data Queues Associated with an Output Queue . . . . . . . . . . . . . . . Sample Data Queue Entry . . . . . . . . Using Data Areas to Communicate between Procedures and Programs . . . . . . . . . Local Data Area . . . . . . . . . . . . Group Data Area . . . . . . . . . . . Program Initialization Parameter (PIP) Data Area 65 66 68 68 71 74 78 81 82 82 83 83 83 84 88 88 89 90 90 91

. 24 . 25 . . . . . . . . . . . . 26 27 28 29 30 31 31 33 34 36 37 41

iii

Remote Data Areas . . . . . . . . . . Creating a Data Area . . . . . . . . . Data Area Locking and Allocation . . . . . Displaying a Data Area . . . . . . . . Changing a Data Area . . . . . . . . . Retrieving a Data Area . . . . . . . . Retrieve Data Area Examples . . . . . . Changing and Retrieving a Data Area Example

. . . . . . .

91 92 92 93 93 93 93 94

Writing a CL Program to Control a Menu . . . Overriding Display Files in a CL Procedure . . Working with Multiple Device Display Files . . Receiving Data from a Database File . . . . Overriding Database Files in a CL Procedure or Program . . . . . . . . . . . . . . Referring to Output Files from Display Commands . . . . . . . . . . . . .

152 154 155 158 158 159

Chapter 4. Objects and Libraries

. . . 97

Object Types and Common Attributes . . . . . 97 Functions Performed on Objects . . . . . . . 97 Functions the System Performs Automatically . . 97 Functions You Can Perform Using Commands. . 98 Libraries . . . . . . . . . . . . . . . 98 Library Lists . . . . . . . . . . . . . 99 Displaying a Library List . . . . . . . . 107 Using Generic Object Names . . . . . . . 107 Searching for Multiple Objects or a Single Object 108 Using Libraries . . . . . . . . . . . . . 108 Creating a Library . . . . . . . . . . . 109 Specifying Authority for Libraries . . . . . 109 Security Considerations for Objects . . . . . 111 Default Public Authority for Newly Created Objects . . . . . . . . . . . . . . 111 Default Auditing Attribute for Newly Created Objects . . . . . . . . . . . . . . 113 Placing Objects in Libraries . . . . . . . . 113 Deleting and Clearing Libraries . . . . . . 113 Displaying Library Names and Contents . . . 114 Displaying and Retrieving Library Descriptions 115 OS/400 Globalization. . . . . . . . . . . 115 Describing Objects . . . . . . . . . . . . 117 Displaying Object Descriptions . . . . . . . 117 Retrieving Object Descriptions. . . . . . . . 121 RTVOBJD Example . . . . . . . . . . 123 Creation Information for Objects . . . . . . . 123 Detecting Unused Objects on the System . . . . 123 Moving Objects from One Library to Another . . 129 Creating Duplicate Objects . . . . . . . . . 131 Renaming Objects . . . . . . . . . . . . 133 Compressing or Decompressing Objects . . . . 135 Compression of Objects . . . . . . . . . 135 Temporarily Decompressed Objects . . . . . 136 Automatic Decompression of Objects . . . . 136 Deleting Objects . . . . . . . . . . . . 137 Allocating Resources . . . . . . . . . . . 138 Displaying the Lock States for Objects . . . . 141

Chapter 6. Advanced Programming Topics . . . . . . . . . . . . . . 161Using the QCAPCMD Program . . . . . . . Using the QCMDEXC Program . . . . . . . Using the QCMDEXC Program with DBCS Data Using the QCMDCHK Program . . . . . . . Using Message Subfiles in a CL Program or Procedure . . . . . . . . . . . . . . Allowing User Changes to CL Commands at Run Time . . . . . . . . . . . . . . . . Using the Prompter within a CL Procedure or Program . . . . . . . . . . . . . . Selective Prompting for CL Commands. . . . QCMDEXC with Prompting in CL Procedures and Programs . . . . . . . . . . . . Using the Programmer Menu . . . . . . . . Uses of the Start Programmer Menu (STRPGMMNU) Command. . . . . . . . Command Analyzer Exit Points . . . . . . . Application Programming for DBCS Data . . . . Designing DBCS Application Programs . . . . Converting Alphanumeric Programs to Process DBCS Data . . . . . . . . . . . . . Using DBCS Data in a CL Program . . . . . . Sample CL Programs . . . . . . . . . . . Initial Program for Setup (Programmer) . . . Moving an Object from a Test Library to a Production Library (Programmer) . . . . . Saving Specific Objects in an Application (System Operator) . . . . . . . . . . . Recovery from Abnormal End (System Operator). . . . . . . . . . . . . . Submitting a Job (System Operator) . . . . . Timing Out While Waiting for Input from a Device Display . . . . . . . . . . . . Retrieving Program Attributes . . . . . . . Loading and Running an Application from Tapes or Diskettes . . . . . . . . . . . . . . Responsibilities of the Application Writer . . . 161 161 164 165 166 167 167 168 171 172 172 173 173 174 174 174 175 175 176 176 177 177 177 178 179 179

Chapter 5. Working with Objects in CL Procedures and Programs . . . . . . 143Accessing Objects in CL Programs . . . . . . Exceptions: Accessing Command Definitions, Files, and Procedures . . . . . . . . . . Checking for the Existence of an Object . . . Working with Files in CL Procedure