IBM - VisualAge Cobol for Windows Programming Guide
634 pág.

IBM - VisualAge Cobol for Windows Programming Guide


DisciplinaCobol25 materiais167 seguidores
Pré-visualização50 páginas
/LINENUMBERS, /NOLINENUMBERS . . . . 210
/LOGO, /NOLOGO . . . . . . . . . . . 211
/MAP, /NOMAP . . . . . . . . . . . . 211
/OUT . . . . . . . . . . . . . . . . 212
/PMTYPE . . . . . . . . . . . . . . 212
/SECTION . . . . . . . . . . . . . . 212
/SEGMENTS . . . . . . . . . . . . . 213
/STACK . . . . . . . . . . . . . . . 214
/STUB . . . . . . . . . . . . . . . 214
/SUBSYSTEM . . . . . . . . . . . . . 214
/VERBOSE . . . . . . . . . . . . . . 215
/VERSION . . . . . . . . . . . . . . 215
Chapter 13. Run-time options . . . . 217
CHECK . . . . . . . . . . . . . . . 217
DEBUG . . . . . . . . . . . . . . . 218
ERRCOUNT. . . . . . . . . . . . . . 218
FILESYS . . . . . . . . . . . . . . . 218
TRAP . . . . . . . . . . . . . . . . 219
UPSI . . . . . . . . . . . . . . . . 219
Chapter 14. Debugging . . . . . . . 221
Debugging with source language . . . . . . . 221
Tracing program logic . . . . . . . . . 222
Finding and handling input-output errors . . . 223
Validating data . . . . . . . . . . . . 223
Finding uninitialized data . . . . . . . . 223
Contents v
Generating information about procedures . . . 223
Debugging using compiler options . . . . . . 225
Finding coding errors . . . . . . . . . 226
Finding line sequence problems . . . . . . 227
Checking for valid ranges . . . . . . . . 227
Selecting the level of error to be diagnosed . . 228
Finding program entity definitions and
references . . . . . . . . . . . . . 230
Listing data items . . . . . . . . . . . 230
Preparing to use the debugger. . . . . . . 231
Getting listings . . . . . . . . . . . . . 231
Example: short listing . . . . . . . . . 232
Example: SOURCE and NUMBER output . . . 234
Example: MAP output . . . . . . . . . 235
Example: XREF output - data-name
cross-references. . . . . . . . . . . . 237
Example: VBREF compiler output . . . . . 240
Debugging user exits . . . . . . . . . . . 240
Debugging assembler routines. . . . . . . . 241
Part 3. Accessing databases . . . 243
Chapter 15. Programming for a DB2
environment . . . . . . . . . . . . 245
DB2 coprocessor . . . . . . . . . . . . 245
Coding SQL statements . . . . . . . . . . 245
Using SQL INCLUDE . . . . . . . . . 246
Using binary items . . . . . . . . . . 246
Determining the success of SQL statements . . 246
Starting DB2 before compiling . . . . . . . . 246
Compiling with the SQL option . . . . . . . 247
Separating SQL suboptions . . . . . . . . 247
Using package and bind file names . . . . . 247
Ignored options . . . . . . . . . . . 248
Chapter 16. Developing COBOL
programs for CICS . . . . . . . . . 249
Coding COBOL applications to run under CICS 250
Coding for ASCII-EBCDIC differences . . . . 251
Getting the system date under CICS. . . . . 251
Making dynamic calls under CICS . . . . . 251
Calling between COBOL and C/C++ under
CICS . . . . . . . . . . . . . . . 253
Compiling and running CICS programs . . . . 253
EBCDIC-enabled COBOL programs under CICS 253
Selecting run-time options . . . . . . . . 254
Debugging CICS programs . . . . . . . . . 254
Chapter 17. Open Database
Connectivity (ODBC) . . . . . . . . 255
Comparison of ODBC and embedded SQL . . . 255
Background . . . . . . . . . . . . . . 256
Installing and configuring software for ODBC . . 256
Coding ODBC calls from COBOL: overview . . . 256
Using data types appropriate for ODBC . . . 256
Passing pointers as arguments in ODBC calls 257
Accessing function return values in ODBC calls 259
Testing bits in ODBC calls . . . . . . . . 259
Using COBOL copybooks for ODBC APIs . . . . 260
Example: sample program using ODBC
copybooks . . . . . . . . . . . . . 261
Example: copybook for ODBC procedures . . . 262
Example: copybook for ODBC data definitions 265
ODBC names truncated or abbreviated for
COBOL . . . . . . . . . . . . . . 266
Compiling and linking programs that make ODBC
calls . . . . . . . . . . . . . . . . 267
Understanding ODBC error messages . . . . . 267
Errors from an ODBC driver . . . . . . . 267
Errors from the data source. . . . . . . . 267
Errors from the driver manager . . . . . . 268
Part 4. Developing object-oriented
programs . . . . . . . . . . . . 269
Chapter 18. Writing object-oriented
programs . . . . . . . . . . . . . 271
Example: mail-order catalog . . . . . . . . 271
Subclasses . . . . . . . . . . . . . 273
Defining a class . . . . . . . . . . . . 274
CLASS-ID paragraph for defining a class . . . 274
REPOSITORY paragraph for defining a class 275
WORKING-STORAGE SECTION for defining a
class . . . . . . . . . . . . . . . 275
Example: defining a class . . . . . . . . 276
Defining a class method . . . . . . . . . . 277
METHOD-ID paragraph for defining a class
method . . . . . . . . . . . . . . 277
Overriding a method . . . . . . . . . . 277
INPUT-OUTPUT SECTION for defining a
method . . . . . . . . . . . . . . 278
DATA DIVISION for defining a method . . . 278
PROCEDURE DIVISION for defining a method 279
Coding special methods . . . . . . . . . 279
Example: defining a method . . . . . . . 280
Defining a client program . . . . . . . . . 285
REPOSITORY paragraph for defining a client 285
WORKING-STORAGE SECTION for defining a
client . . . . . . . . . . . . . . . 285
Creating and freeing instances of classes . . . 286
Manipulating object references . . . . . . 286
Invoking methods . . . . . . . . . . . 287
Example: defining a client . . . . . . . . 288
Defining a subclass . . . . . . . . . . . 289
CLASS-ID paragraph for defining a subclass 290
REPOSITORY paragraph for defining a subclass 290
WORKING-STORAGE SECTION for defining a
subclass . . . . . . . . . . . . . . 290
Defining a subclass method . . . . . . . 291
Example: defining a subclass (with methods) 292
Defining a metaclass . . . . . . . . . . . 301
CLASS-ID paragraph for defining a metaclass 301
REPOSITORY paragraph for defining a
metaclass . . . . . . . . . . . . . . 302
WORKING-STORAGE SECTION for defining a
metaclass . . . . . . . . . . . . . . 302
Defining a metaclass method . . . . . . . 302
Changing the definition of a class or subclass 303
Changing a client program . . . . . . . . 303
vi Programming Guide
Example: defining a metaclass (with methods) 304
Chapter 19. System Object Model. . . 311
SOM Interface Repository . . . . . . . . . 311
Accessing the SOM Interface Repository . . . 311
Populating the SOM Interface Repository . . . 312
SOM environment variables . . . . . . . . 312
SOM services . . . . . . . . . . . . . 313
SOM methods and functions . . . . . . . 313
Class initialization . . . . . . . . . . . 314
Changing SOM class interfaces . . . . . . 315
Chapter 20. Using SOM IDL-based
class libraries . . . . . . . . . . . 317
SOM objects . . . . . . . . . . . . . . 317
SOM IDL. . . . . . . . . . . . . . . 318
Mapping IDL to COBOL . . . . . . . . . 319
Using IDL operations. . . . . . . . . . 319
Expressing IDL attributes . . . . . . . . 320
Common IDL types . . . . . . . . . . 321
Complex IDL types . . . . . . . . . . 324
Passing COBOL arguments and return values 327
Example: using a SOM IDL-based class library 332
Handling errors and exceptions . . . . . . . 334
Passing environment variables. . . . . . . 335
Checking the exception type field . . . . . 335
Handling exceptions . . . . . . . . . . 335
Example: checking SOM exceptions . . . . . 335
Creating and initializing object instances . . . . 337
Looking at the IDL file . . . . . . . . . . 338
Avoiding memory leaks . . . . . . . . . . 339
Example: COBOL variable-length string class 340
Source code for helper routines . . . . . . . 342
Chapter 21. Wrapping or converting
procedure-oriented programs . . . . 343
OO view of COBOL programs. . . . . . . . 343
Wrapping procedure-oriented programs . . . . 344
Coordinating procedural code with interface
actions . . . . . . . . . . . . . . 344
Integrating procedural code into OO systems 344
Changing