ILE COBOL Programmer's Guide
Compiling, Running, and Debugging ILE COBOL Programs
Introduction
Integrated Language Environment
Major Steps in Creating a Runnable ILE COBOL Program Object
Designing Your ILE COBOL Source Program
Entering Source Statements into a Source Member
Compiling a Source Program into Module Objects
Creating a Program Object
Running a Program Object
Debugging a Program
Other Application Development Tools
WebSphere Development Studio
WebSphere Development Studio Client for iSeries
Entering Source Statements into a Source Member
Creating a Library and Source Physical File
Entering Source Statements Using the Source Entry Utility
COBOL Source File Format
Starting SEU
Using the COBOL Syntax Checker in SEU
Example of Entering Source Statements into a Source Member
Using Coded Character Set Identifiers
Assigning a CCSID to a Source Physical File
Including Copy Members with Different CCSIDs in Your Source File
Setting the CCSID for the COBOL Syntax Checker in SEU
Assigning a CCSID to a Locale
Runtime CCSID Considerations
Handling Different CCSIDs with the ILE Source Debugger
Compiling Source Programs into Module Objects
Definition of a Module Object
Using the Create COBOL Module (CRTCBLMOD) Command
Using Prompt Displays with the CRTCBLMOD Command
Syntax for the CRTCBLMOD Command
Parameters of the CRTCBLMOD Command
Example of Compiling a Source Program into a Module Object
Specifying a Different Target Release
Specifying National Language Sort Sequence in CRTCBLMOD
Collecting Profiling Data
Specifying Date, Time, and Timestamp Data Types
Using the PROCESS Statement to Specify Compiler Options
PROCESS Statement Options
Compiling Multiple Source Programs
Using COPY within the PROCESS Statement
Understanding Compiler Output
Specifying the Format of Your Listing
Browsing Your Compiler Listing Using SEU
A Sample Program and Listing
Creating a Program Object
Definition of a Program Object
The Binding Process
Using the Create Program (CRTPGM) Command
Example of Binding Multiple Modules to Create a Program Object
Using the Create Bound COBOL (CRTBNDCBL) Command
Using Prompt Displays with the CRTBNDCBL Command
Syntax for the CRTBNDCBL Command
Parameters of the CRTBNDCBL Command
Invoking CRTPGM Implicitly from CRTBNDCBL
Example of Binding One Module Object to Create a Program Object
Specifying National Language Sort Sequence in CRTBNDCBL
Reading a Binder Listing
A Sample Binder Listing
Modifying a Module Object and Binding the Program Object Again
Changing the ILE COBOL Source Program
Changing the Optimization Levels
Removing Module Observability
Enabling Performance Collection
Collection Levels
Procedures
Creating a Service Program
Definition of a Service Program
Using Service Programs
Writing the Binder Language Commands for an ILE COBOL Service Program
Using the Create Service Program (CRTSRVPGM) Command
Example of Creating a Service Program
Using the Retrieve Binder Source (RTVBNDSRC) Command as Input
Calling Exported ILE Procedures in Service Programs
Sharing Data with Service Programs
Canceling an ILE COBOL Program in a Service Program
Running an ILE COBOL Program
Running a COBOL Program Using the CL CALL Command
Passing Parameters to an ILE COBOL Program Through the CL CALL Command
Running an ILE COBOL Program Using a HLL CALL Statement
Running an ILE COBOL Program From a Menu-Driven Application
Running an ILE COBOL Program Using a User Created Command
Ending an ILE COBOL Program
Replying to Run Time Inquiry Messages
Debugging a Program
The ILE Source Debugger
Debug Commands
Preparing a Program Object for a Debug Session
Using a Listing View
Using a Source View
Using a Statement View
Starting the ILE Source Debugger
STRDBG Example
Setting Debug Options
Running a Program Object in a Debug Session
Adding Program Objects and Service Programs to a Debug Session
Removing Program Objects or Service Programs from a Debug Session
Viewing the Program Source
Changing the Module Object that is Shown
Changing the View of the Module Object that is Shown
Setting and Removing Breakpoints
Setting and Removing Unconditional Job Breakpoints
Setting and Removing Unconditional Thread Breakpoints
Setting and Removing Conditional Job Breakpoints
Setting and Removing Conditional Thread Breakpoints
Removing All Breakpoints
Setting and Removing Watch Conditions
Characteristics of Watches
Setting Watch Conditions
Displaying Active Watches
Removing Watch Conditions
Example of Setting a Watch Condition
Running a Program Object or ILE Procedure After a Breakpoint
Resuming a Program Object or ILE Procedure
Stepping Through the Program Object or ILE Procedure
Displaying Variables, Constant-names, Expressions, Records, Group Items, and Arrays
Displaying Variables and Expressions
Displaying Records, Group Items, and Arrays
Changing the Value of Variables
Equating a Name with a Variable, Expression, or Command
National Language Support for the ILE Source Debugger
Changing and Displaying Locale-Based Variables
Support for User-Defined Data Types
ILE COBOL Programming Considerations
Working with Data Items
General ILE COBOL View of Numbers (PICTURE Clause)
Defining Numeric Items
Separate Sign Position (For Portability)
Extra Positions for Displayable Symbols (Numeric Editing)
Computational Data Representation (USAGE Clause)
External Decimal (USAGE DISPLAY) Items
Internal Decimal (USAGE PACKED-DECIMAL or COMP-3)
Binary (USAGE BINARY or COMP-4) Items
Internal Floating-Point (USAGE COMP-1 and COMP-2) Items
External Floating-Point (USAGE DISPLAY) Items
Creating User-Defined Data Types
Data Format Conversions
What Conversion Means
Conversion Takes Time
Conversions and Precision
Sign Representation and Processing
With the *CHGPOSSN Compiler Option
Checking for Incompatible Data (Numeric Class Test)
How to Do a Numeric Class Test
Performing Arithmetic
COMPUTE and Other Arithmetic Statements
Arithmetic Expressions
Numeric Intrinsic Functions
Converting Data Items (Intrinsic Functions)
Evaluating Data Items (Intrinsic Functions)
Formatting Dates and Times Based On Locales (LOCALE-DATE, LOCALE-TIME)
Fixed-Point versus Floating-Point Arithmetic
Floating-Point Evaluations
Fixed-Point Evaluations
Arithmetic Comparisons (Relation Conditions)
Examples of Fixed-Point and Floating-Point Evaluations
Processing Table Items
Processing Multiple Table Items (ALL Subscript)
What is the Year 2000 Problem?
Long-Term Solution
Short-Term Solution
Working with Date-Time Data Types
MOVE Considerations for Date-Time Data Items
Working With Locales
Creating Locales on the iSeries
Setting a Current Locale for Your Application
Identification and Scope of Locales
LC_MONETARY Locale Category
LC_TIME Category
LC_TOD Category
Calling and Sharing Data Between ILE COBOL Programs
Run Time Concepts
Activation and Activation Groups
COBOL Run Unit
Control Boundaries
Main Programs and Subprograms
Initialization of Storage
Transferring Control to Another Program
Calling an ILE COBOL Program
Identifying the Linkage Type of Called Programs and Procedures
Calling Nested Programs
Using Static Procedure Calls and Dynamic Program Calls
Using CALL identifier
Using CALL procedure-pointer
Using Recursive Calls
Returning from an ILE COBOL Program
Returning from a Main Program
Returning from a Subprogram
Maintaining OPM COBOL/400 Run Unit Defined STOP RUN Semantics
Examples of Returning from an ILE COBOL Program
Passing Return Code Information (RETURN-CODE Special Register)
Passing and Sharing Data Between Programs
Comparing Local and Global Data
Passing Data Using CALL...BY REFERENCE, BY VALUE, or BY CONTENT
Sharing EXTERNAL Data
Sharing EXTERNAL Files
Passing Data Using Pointers
Passing Data Using Data Areas
Effect of EXIT PROGRAM, STOP RUN, GOBACK, and CANCEL on Internal Files
Canceling an ILE COBOL Program
Canceling from Another ILE COBOL Program
Canceling from Another Language
COBOL and the eBusiness World
COBOL and XML
COBOL and MQSeries, V5.2
COBOL and Java Programs
System Requirements
COBOL and PCML
COBOL and JNI
Calling Java Methods from a COBOL Program
COBOL and Java Data Types
JNI Copy Members for COBOL
Processing XML Documents
XML parser in COBOL
Accessing XML documents
Parsing XML documents
Processing XML events
Writing procedures to process XML
Understanding XML document encoding
Specifying the code page
Parsing documents in other code pages
Handling errors in XML documents
Unhandled exceptions
Handling exceptions
Terminating the parse
CCSID conflict exception
Calling and Sharing Data with Other Languages
Calling ILE C and VisualAge C++ Programs and Procedures
Passing Data to an ILE C Program or Procedure
Sharing External Data with an ILE C Program or Procedure
Returning Control from an ILE C Program or Procedure
Examples of an ILE C Procedure Call from an ILE COBOL Program
Sample Code for ILE C Procedure Call Example 1
Sample Code for ILE C Procedure Call Example 2
Creating and Running the ILE C Procedure Call Examples
Example of an ILE C Program Call from an ILE COBOL Program
Sample Code for ILE C Program Call Example
Creating and Running the ILE C Program Call Example
Calling ILE RPG Programs and Procedures
Passing Data to an ILE RPG Program or Procedure
Returning Control from an ILE RPG Program or Procedure
Calling ILE CL Programs and Procedures
Passing Data to an ILE CL Program or Procedure
Returning Control from an ILE CL Program or Procedure
Calling OPM Languages
Calling OPM COBOL/400 Programs
Calling EPM Languages
Issuing a CL Command from an ILE COBOL Program
Including Structured Query Language (SQL) Statements in Your ILE COBOL Program
Calling an ILE API to Retrieve Current Century
Using Intrinsic Functions or the ACCEPT Statement to Retrieve Current Century
Calling IFS API
Using Pointers in an ILE COBOL Program
Defining Pointers
Pointer Alignment
Writing the File Section and Working-Storage Section for Pointer Alignment
Redefining Pointers
Initializing Pointers Using the NULL Figurative Constant
Reading and Writing Pointers
Using the LENGTH OF Special Register with Pointers
Setting the Address of Linkage Section Items
Using ADDRESS OF and the ADDRESS OF Special Register
Using Pointers in a MOVE Statement
Using Pointers in a CALL Statement
Adjusting the Value of Pointers
Accessing User Spaces Using Pointers and APIs
Processing a Chained List Using Pointers
Passing Pointers between Programs and Procedures
Check for the End of the Chained List
Processing the Next Record
Incrementing Addresses Received from Another Program
Passing Entry Point Addresses with Procedure-Pointers
Preparing ILE COBOL Programs for Multithreading
How Language Elements Are Interpreted in a Multithreaded Environment
Working with Run-Unit Scoped Elements
Working with Program Invocation Instance Scoped Elements
Choosing THREAD for Multithreading Support
Language Restrictions under THREAD
Control Transfer within a Multithreaded Environment
Limitations on ILE COBOL in a Multithreaded Environment
Example of Using ILE COBOL in a Multithreaded Environment
Sample Code for the Multithreading Example
Creating and Running the Multithreading Example
ILE COBOL Error and Exception Handling
ILE Condition Handling
Ending an ILE COBOL Program
Using Error Handling Bindable Application Programming Interfaces (APIs)
Initiating Deliberate Dumps
Program Status Structure
Handling Errors in String Operations
Handling Errors in Arithmetic Operations
The ON SIZE ERROR Phrase
Handling Errors in Floating-Point Computations
Handling Errors in Input-Output Operations
Processing of Input-Output Verbs
Detecting End-of-File Conditions (AT END Phrase)
Detecting Invalid Key Conditions (INVALID KEY Phrase)
Using EXCEPTION/ERROR Declarative Procedures (USE Statement)
Determining the Type of Error Through the File Status Key
Handling Errors in Sort/Merge Operations
Handling Exceptions on the CALL Statement
User-Written Error Handling Routines
Common Exceptions and Some of Their Causes
Recovery After a Failure
Recovery of Files with Commitment Control
TRANSACTION File Recovery
Handling Errors in Operations Using Null-Capable Fields
Handling Errors in Locale Operations
ILE COBOL Input-Output Considerations
Defining Files
Types of File Descriptions
Defining Program-Described Files
Defining Externally Described Files
Describing Files Using Data Description Specifications (DDS)
Processing Files
Associating Files with Input-Output Devices
Specifying Input and Output Spooling
Input Spooling
Output Spooling
Overriding File Attributes
Redirecting File Input and Output
Locking and Releasing Files
Locking and Releasing Records
Sharing an Open Data Path to Access a File
Unblocking Input Records and Blocking Output Records
Using File Status and Feedback Areas
FILE STATUS
OPEN-FEEDBACK Area
I-O-FEEDBACK Area
Using Commitment Control
Commitment Control Scoping
Example of Using Commitment Control
Sorting and Merging Files
Describing the Files
Sorting Files
Merging Files
Specifying the Sort Criteria
Writing the Input Procedure
Writing the Output Procedure
Restrictions on the Input Procedures and Output Procedures
Determining Whether the Sort or Merge Was Successful
Premature Ending of a Sort or Merge Operation
Sorting Variable Length Records
Example of Sorting and Merging Files
Declaring Data Items Using SAA Data Types
Variable-length Fields
Date, Time, and Timestamp Fields
Null-Capable Fields
DBCS-Graphic Fields
Variable-length DBCS-graphic Fields
Floating-point Fields
Accessing Externally Attached Devices
Types of Device Files
Accessing Printer Devices
Naming Printer Files
Describing Printer Files
Writing to Printer Files
Example of Using FORMATFILE Files in an ILE COBOL Program
Accessing Files Stored on Tape Devices
Naming Files Stored on Tape Devices
Describing Files Stored on Tape Devices
Reading and Writing Files Stored on Tape Devices
Accessing Files Stored on Diskette Devices
Naming Files Stored on Diskette Devices
Describing Files Stored on Diskette Devices
Reading and Writing Files Stored on Diskette Devices
Accessing Display Devices and ICF Files
Using DISK and DATABASE Files
Differences between DISK and DATABASE Files
File Organization and iSeries File Access Paths
File Processing Methods for DISK and DATABASE Files
Processing Sequential Files
Processing Relative Files
Processing Indexed Files
Processing Files with Descending Key Sequences
Processing Files with Variable Length Records
Examples of Processing DISK and DATABASE Files
Sequential File Creation
Sequential File Updating and Extension
Relative File Creation
Relative File Updating
Relative File Retrieval
Indexed File Creation
Indexed File Updating
OS/400 System Files
Distributed Data Management (DDM) Files
Using DDM Files with Non-OS/400 Systems
DDM Programming Considerations
DDM Direct (Relative) File Support
Distributed Files
Open Considerations for Data Processing
When Distributed Data Processing is Overridden
When Distributed Data Processing is NOT Overridden
Input/Output Considerations for Distributed Files
SQL Statement Additions for Distributed Data Files
Examples of Processing Distributed Files
Processing Files with Constraints
Restrictions
Adding, Modifying and Removing Constraints
Checking that Constraints Have Been Successfully Added or Removed
Order of Operations
Handling Null Fields with Check Constraints
Handling Constraint Violations
Database Features that Support Referential or Check Constraints
Using Transaction Files
Defining Transaction Files Using Data Description Specifications
Processing an Externally Described Transaction File
Writing Programs That Use Transaction Files
Naming a Transaction File
Describing a Transaction File
Processing a Transaction File
Example of a Basic Inquiry Program Using Transaction Files
Using Indicators with Transaction Files
Passing Indicators in a Separate Indicator Area
Passing Indicators in the Record Area
Examples of Using Indicators in ILE COBOL Programs
Using Subfile Transaction Files
Defining a Subfile Using Data Description Specifications
Using Subfiles for a Display File
Accessing Single Device Files and Multiple Device Files
Writing Programs That Use Subfile Transaction Files
Naming a Subfile Transaction File
Describing a Subfile Transaction File
Processing a Subfile Transaction File
Example of Using WRITE SUBFILE in an Order Inquiry Program
Example of Using READ SUBFILE...NEXT MODIFIED and REWRITE SUBFILE in a Payment Update Program
Appendixes
Appendix A. Level of Language Support
COBOL Standard
ILE COBOL Level of Language Support
System Application Architecture(R) (SAA(R)) Common Programming Interface (CPI) Support
Appendix B. The Federal Information Processing Standard (FIPS) Flagger
Appendix C. ILE COBOL Messages
COBOL Message Descriptions
Severity Levels
Compilation Messages
Program Listings
Interactive Messages
Responding to Messages
Appendix D. Supporting International Languages with Double-Byte Character Sets
Using DBCS Characters in Literals
How to Specify Literals Containing DBCS Characters
How the COBOL Compiler Checks DBCS Characters
How to Continue Mixed Literals on a New Line
Syntax-Checker Considerations
Where You Can Use DBCS Characters in a COBOL Program
How to Write Comments
Identification Division
Environment Division
Configuration Section
Input-Output Section
File Control Paragraph
Data Division
File Section
Working-Storage Section
Procedure Division
Intrinsic Functions
Conditional Expressions
Input/Output Statements
Data Manipulation Statements
Procedure Branching Statements
Table Handling--SEARCH Statement
SORT/MERGE
Compiler-Directing Statements
COPY Statement
REPLACE Statement
TITLE Statement
Communications between Programs
FIPS Flagger
COBOL Program Listings
Intrinsic Functions with Collating Sequence Sensitivity
Appendix E. Example of a COBOL Formatted Dump
Appendix F. XML reference material
XML exceptions that allow continuation
XML exceptions that do not allow continuation
XML conformance
Appendix G. Migration and Compatibility Considerations between OPM COBOL/400 and ILE COBOL
Migration Strategy
Compatibility Considerations
General Considerations
CL Commands
Compiler-Directing Statements
Environment Division
Data Division
Procedure Division
Application Programming Interfaces (APIs)
Run Time
Appendix H. Glossary of Abbreviations
Appendix I. ILE COBOL Documentation
Online Information
Hardcopy Information
Bibliography
Index
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.