COBOL 400 User's Guide - c0918120
COBOL 400 User's Guide - c0918120
COBOL 400 User's Guide - c0918120
Before using this information and the product it supports, be sure to read the general information under Notices on page ix.
Contents
Notices . . . . . . . . . . . . . . . Programming Interface Information Trademarks and Service Marks .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ix ix x xi xi xiii 1 1 2 2 3 5 5 6 9 9 11 15 15 16 28 28 29 31 32 37 38 39 39 51 52 55 56 57 57 63 63 64 64 66 67 67 69
About This Manual . . . . . . . . . . . . . . Who Should Use This Manual . . . . . . . . Industry Standards Used in Compiler Design
Chapter 1. An Introduction to the COBOL/400 Programming Language Extensions to the ANSI Standard . . . . . . . . . . . . . . . . . . . . . . . . Features of the COBOL/400 Compiler . . . . . . . . . . . . . . . . . . . . . . Using COBOL/400 Syntax Notation . . . . . . . . . . . . . . . . . . . . . . . Reading the Syntax Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . Reading IBM Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CL Entry Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . An Overview of COBOL/400 Programming . . . . . . . . . . . . . . . . . . . Chapter 2. Entering Your Source Program on the AS/400 System Designing Your COBOL/400 Program . . . . . . . . . . . . . . . . . . . Entering Source Using SEU . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 3. Compiling a COBOL/400 Program . . . . . . . Using the Create COBOL Program (CRTCBLPGM) Command Using the CRTCBLPGM Prompt Displays . . . . . . . . . . Entering CRTCBLPGM from the Command Line . . . . . . Entering CRTCBLPGM from a CL Program . . . . . . . . . Syntax of the CRTCBLPGM Command . . . . . . . . . . . Compiling Your Source Program For the Previous Release . Using the PROCESS Statement to Specify Compiler Options Understanding Compiler Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying the Format of Your Listing Browsing Your Compiler Listing Using SEU . . . . . . . . . A Sample Program and Listing . . . . . . . . . . . . . . . . Chapter 4. Running Your COBOL Program Replying to Run-Time Inquiry Messages . . Chapter 5. Debugging Your Program . Avoiding Common Coding Errors . . . . . Using Breakpoints . . . . . . . . . . . . . . Example of a Program Using Breakpoints Changing Program Variables . . . . . . Considerations for Using Breakpoints . Using a Trace . . . . . . . . . . . . . . . . . Example of Using a Trace . . . . . . . . Considerations for Using a Trace . . . . Using a Debug Run-Time Switch . . . . . . Using a COBOL Formatted Dump . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iii
Standard Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . Error Handling Overview . . . . . . . . . . . . . . . . . . . . . . . Using Error-Handling Application Programming Interfaces (APIs) Internal and External File Status . . . . . . . . . . . . . . . . . . General Error Detection . . . . . . . . . . . . . . . . . . . . . . . How File Status is Set . . . . . . . . . . . . . . . . . . . . . . . . Message Monitor Generation . . . . . . . . . . . . . . . . . . . . Ending of a COBOL Program . . . . . . . . . . . . . . . . . . . . Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Standard and Nonstandard Error Handling Models . . . . . . . . Effects of *STDERR and *NOSTDERR on File Status . . . . . . Processing of I/O Verbs . . . . . . . . . . . . . . . . . . . . . . . . . Common Exceptions and Some of Their Causes . . . . . . . . . . Recovery After a Failure . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 7. File and Data Management . . . . . . . . . . . . Device Independence and Device Dependence . . . . . . . . Spooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Output Spool . . . . . . . . . . . . . . . . . . . . . . . . . . . Input Spool . . . . . . . . . . . . . . . . . . . . . . . . . . . . System Override Considerations . . . . . . . . . . . . . . . . . File and Record Locking by COBOL . . . . . . . . . . . . . . . Locking and Releasing Records . . . . . . . . . . . . . . . . Sharing an Open Data Path . . . . . . . . . . . . . . . . . . Commitment Control Considerations . . . . . . . . . . . . . . . Unblocking Input Records and Blocking Output Records . . . File Status and Feedback Areas . . . . . . . . . . . . . . . . . File Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program-Described Files Externally Described Files . . . . . . . . . . . . . . . . . . . . . Data Description Specifications (DDS) . . . . . . . . . . . . Format 2 COPY Statement (DD, DDR, DDS, or DDSR Option) Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Structures Generated . . . . . . . . . . . . . . . . . . . Key Generation Examples . . . . . . . . . . . . . . . . . . . Declaring Data Items Using CVTOPT Data Types . . . . . . . DBCS-Graphic Fields . . . . . . . . . . . . . . . . . . . . . . Variable-length DBCS-Graphic Fields . . . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cross-system Data Considerations . . . . . . . . . . . . . . . Chapter 8. Transaction Files . . . . . . . . . . . . . . . . . Program-Described Transaction Files . . . . . . . . . . . . . Externally Described Transaction Files . . . . . . . . . . . . The Format 2 COPY Statement . . . . . . . . . . . . . . . Data Description Specifications . . . . . . . . . . . . . . . Processing an Externally Described Transaction File . . Using Indicators with Transaction Files . . . . . . . . . . . . Indicators in a Separate Indicator Area . . . . . . . . . . . Indicators in the Record Area . . . . . . . . . . . . . . . . ASSIGN Clause and the Separate Indicator Area Attribute Data Description EntryBoolean Data . . . . . . . . . . . INDICATORS Phrase . . . . . . . . . . . . . . . . . . . . . Indicators in a Separate Indicator Area . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
69 69 70 70 72 72 73 74 75 76 79 80 81 82 89 89 91 91 92 92 93 93 94 94 102 103 104 104 105 106 112 115 115 121 130 133 134 134 137 139 139 139 139 140 142 142 143 143 143 144 145 145
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iv
Indicators in the Record Area . . . . . . . . . Indicators Example Programs . . . . . . . . . Subfiles . . . . . . . . . . . . . . . . . . . . . . . Use of Subfiles . . . . . . . . . . . . . . . . . Multiple Device Files and Single Device Files Environment Division . . . . . . . . . . . . . . . . File-Control Entry . . . . . . . . . . . . . . . . Data Division . . . . . . . . . . . . . . . . . . . . File Description Entry . . . . . . . . . . . . . . Boolean Data Items . . . . . . . . . . . . . . . Procedure Division . . . . . . . . . . . . . . . . . Procedure Division Concepts . . . . . . . . . ACCEPT Statement . . . . . . . . . . . . . . . ACQUIRE Statement . . . . . . . . . . . . . . CLOSE Statement . . . . . . . . . . . . . . . . DROP Statement . . . . . . . . . . . . . . . . OPEN Statement . . . . . . . . . . . . . . . . Common Processing Facilities . . . . . . . . . READ Statement . . . . . . . . . . . . . . . . REWRITE Statement . . . . . . . . . . . . . . WRITE Statement . . . . . . . . . . . . . . . . USE Statement . . . . . . . . . . . . . . . . . Examples of Work Station Programs . . . . . . Basic Inquiry Program . . . . . . . . . . . . . Order Inquiry Programs Using Subfiles . . . . A Payment Update Program . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
146 146 156 158 162 171 171 175 175 176 176 176 177 178 179 179 180 181 182 191 193 199 200 200 206 217 233 233 233 234 241 241 241 241 242 246 249 249 250 251 253 255 255 256 258 262 263 264 265 265 266
Chapter 9. Printer Files . . . . . . . . . . . . . . . . . . . . . SPECIAL-NAMES Paragraph and the ADVANCING Phrase LINAGE Clause . . . . . . . . . . . . . . . . . . . . . . . . . FORMATFILE Files . . . . . . . . . . . . . . . . . . . . . . . .
Chapter 10. DISK and DATABASE Files . . . . . . . . . . . . . . . . . . DATABASE versus DISK Files . . . . . . . . . . . . . . . . . . . . . . . Processing Methods for DISK and DATABASE Files . . . . . . . . . . . COBOL Indexed Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . Referring to a Partial Key . . . . . . . . . . . . . . . . . . . . . . . . . . Logical File Considerations . . . . . . . . . . . . . . . . . . . . . . . . . COBOL Relative Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . COBOL Sequential Files . . . . . . . . . . . . . . . . . . . . . . . . . . . COBOL File Organization and AS/400 File Access Path Considerations File Processing Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . Descending File Considerations . . . . . . . . . . . . . . . . . . . . . . . . Chapter 11. COBOL/400 Programming Considerations Issuing a CL Command from a COBOL Program . . . . . Using the CORRESPONDING Phrase . . . . . . . . . . . LIKE Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . Reference Modification . . . . . . . . . . . . . . . . . . . . Reference Modification with Variable-length Tables . . Reference Modification Using Data Names . . . . . . . Reference Modification with Subscripting . . . . . . . . De-editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . De-editing Examples . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
Handling Data Errors . . . . . . . . . . . . . . . . . . . . Performance Considerations . . . . . . . . . . . . . . . . . PICTURE Clauses for Numeric Items . . . . . . . . . . Eight-Byte Binary Items . . . . . . . . . . . . . . . . . . Segmentation . . . . . . . . . . . . . . . . . . . . . . . . Calling a COBOL Program from a Non-COBOL Program Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . *NORANGE Option . . . . . . . . . . . . . . . . . . . . . *DUPKEYCHK Option . . . . . . . . . . . . . . . . . . . Relative Files . . . . . . . . . . . . . . . . . . . . . . . . Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . Commitment Control . . . . . . . . . . . . . . . . . . . . Reading without Record Locks . . . . . . . . . . . . . . Initializing Variables . . . . . . . . . . . . . . . . . . . . . Blocking Records . . . . . . . . . . . . . . . . . . . . . . Program Loops . . . . . . . . . . . . . . . . . . . . . . . . . Tracing a Loop in a Program . . . . . . . . . . . . . . . Errors That Can Cause a Loop . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
267 268 268 268 268 268 269 269 270 270 270 270 270 270 270 271 271 271 273 273 273 274 279 279 279 281 281 282 282 283 284 285 286 286 287 287 287 289 291 302 305 305 306 306 309 309 309 310 310 310 312
Chapter 12. Communicating Between Programs . . . . . . Transferring Control to Another Program . . . . . . . . . . . . . Main Programs and Subprograms . . . . . . . . . . . . . . . Returning Control from a Called Program . . . . . . . . . . . . . Initialization of Storage . . . . . . . . . . . . . . . . . . . . . . . . Calling Another Program . . . . . . . . . . . . . . . . . . . . . . Passing Data Using BY REFERENCE or BY CONTENT . . In the Linkage Section . . . . . . . . . . . . . . . . . . . . . . Grouping Data to be Passed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Call by Identifier Using Pointers in a COBOL/400 Program . . . . . . . . . . . . . Defining Pointers and Pointer Alignment . . . . . . . . . . . . Pointers and the REDEFINES Clause . . . . . . . . . . . . . Reading and Writing Pointers . . . . . . . . . . . . . . . . . . . . Initializing Pointers Using the NULL Figurative Constant . . . . LENGTH OF Special Register . . . . . . . . . . . . . . . . . . . Setting the Address of Linkage Items . . . . . . . . . . . . . . . Using ADDRESS OF and the ADDRESS OF Special Register Using Pointers in a MOVE Statement . . . . . . . . . . . . . . . Using Pointers in a CALL Statement . . . . . . . . . . . . . . . . Using Pointers and APIs to Access User Spaces . . . . . . . . Processing a Chained List . . . . . . . . . . . . . . . . . . . . . Data Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Local Data Area . . . . . . . . . . . . . . . . . . . . . . . . . . Program Initialization Parameters (PIP) Data Area . . . . . . File Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . Appendix A. Segmentation Feature . . Segmentation Concepts . . . . . . . . . . . Program Segments . . . . . . . . . . . . Segmentation Logic . . . . . . . . . . . . Segmentation Control . . . . . . . . . . . COBOL Source Program Considerations SegmentationSpecial Considerations .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
vi
Appendix B. Debugging Features . COBOL Source Language Debugging Compile-Time Switch . . . . . . . . Run-Time Switch . . . . . . . . . . USE FOR DEBUGGING Declarative DEBUG-ITEM Special Register . . Debugging Lines . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
313 313 313 314 316 319 321 323 323 323 325 327 327 327 329 329 330 331 333 335 335
Appendix C. Level of Language Support . . . . . . ANSI X3.23-1985 COBOL Standard . . . . . . . . . COBOL/400 Level of Language Support . . . . . . . SAA Common Programming Interface (CPI) Support
Appendix D. COBOL/400 Messages, the FIPS Flagger, and SAA Flagging COBOL/400 Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interactive Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compilation Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Responding to Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . COBOL Message Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . The Federal Information Processing Standard (FIPS) Flagger . . . . . . . . . SAA Flagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Appendix E. Differences Between ANSI 74 COBOL and ANSI 85 COBOL Migrating ANSI 74 COBOL Programs to ANSI 85 COBOL . . . . . . . . . . . Appendix F. Supporting International Languages with Double-Byte Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using DBCS Characters in Literals . . . . . . . . . . . . . . . . . . . . Identification Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . Environment Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Procedure Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SORT/MERGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compiler-Directing Statements Communications between Programs . . . . . . . . . . . . . . . . . . . FIPS Flagger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . COBOL Program Listings . . . . . . . . . . . . . . . . . . . . . . . . . Appendix G. AS/400 File Processing Examples Sequential File Creation . . . . . . . . . . . . . Sequential File Updating and Extension . . . . Indexed File Creation . . . . . . . . . . . . . . . Indexed File Updating . . . . . . . . . . . . . . Relative File Creation . . . . . . . . . . . . . . . Relative File Updating . . . . . . . . . . . . . . Relative File Retrieval . . . . . . . . . . . . . . Sorting and Merging Files . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
337 337 340 340 341 343 348 348 349 349 349 351 351 353 356 357 361 363 365 368 371 383 385
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Glossary of Abbreviations
Contents
vii
Index
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
389
viii
Notices
References in this publication to IBM products, programs, or services do not imply that IBM intends to make these available in all countries in which IBM operates. Any reference to an IBM licensed program in this publication is not intended to state or imply that only IBMs licensed program may be used. Any functionally equivalent product, program or service that does not infringe any of IBMs intellectual property rights may be used instead of the IBM product, program, or service. Evaluation and verification of operation in conjunction with other products, except those expressly designated by IBM, is the users responsibility. IBM may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. You can send license inquiries, in writing, to the IBM Director of Licensing, IBM Corporation, 208 Harbor Drive, Stamford, Connecticut, USA 06904-2501 Important changes or additions to the text are indicated by a vertical line (|) to the left of the change or addition. This publication contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental.
| |
| | |
ix
For information about your display station, refer to: New Users Guide, SC41-8211.
xi
How to operate your display station when it is linked to the IBM AS/400 system and running AS/400 software. This means knowing how to use the OS/400 operating system and its Control Language (CL) to do such things as: Sign on and sign off the display station Interact with displays Use Help Enter CL commands Use Application Development Tools Respond to messages Perform file management.
The Programming: Control Language Programmers Guide, SC41-8077 which contains the basic concepts of OS/400 CL functions. To find out more about the operating system and its control language, refer to these IBM publications: Programming: Control Language Reference, SC41-0030 (a three-volume manual). Programming: Work Management Guide, SC41-8078 Advanced Backup and Recovery Guide, SC41-8079 The Data Management Guide, SC41-9658 which provides information on using data management support to allow an application to work with files. The manual includes information on: Fundamental structure and concepts of data management support on the system Data management support for display stations, printers, tapes, and diskettes, as well as spooling support Overrides and file redirection (temporarily making changes to files when an application is run) Copying files by using system commands to copy data from one place to another Tailoring a system using double-byte data. How to use the following Application Development Tools: The Screen Design Aid (SDA) is used to design and code displays. Information about this product is contained in Application Development Tools: Screen Design Aid Users Guide and Reference, SC09-1340. The Source Entry Utility (SEU) is a full-display editor you can use to enter and update your source members. Information about this product is contained in Application Development Tools: Source Entry Utility Users Guide and Reference, SC09-1338. The Structured Query Language (SQL) allows you to insert SQL statements into COBOL/400 programs. Information about this product is contained in Systems Application Architecture* Structured Query Language/400 Reference, SC41-9608 and in Systems Application Architecture* Structured Query Language/400 Programmers Guide, SC41-9609 The Customer Information Control System/400 (CICS/400*) licensed program allows you to enter transactions at remote work stations, and process them concurrently with user-written application programs. The licensed program
xii
includes functions for building, using, and maintaining databases, and for communicating with CICS on other operating systems. | | Information about using this product for application programming is contained in the CICS/400 Application Programming Guide. SC33-0822.
xiii
xiv
You must write the required clauses and the optional clauses, (when used), in the order shown in the diagram unless the associated rules explicitly state otherwise.
Note: Statements within a diagram of an entire paragraph do not start with and end with unless their beginning or ending coincides with that of the paragraph. Required items appear on the horizontal line (the main path). Optional items appear below the main path:
STATEMENTrequired item optional item
When you can choose from two or more items, they appear vertically, in a stack. If you must choose one of the items, one item of the stack appears on the main path. If choosing an item is optional, the entire stack appears below the main path:
STATEMENTrequired choice1 required choice2 optional choice1 optional choice2
An arrow returning to the left above an item indicates that this item can be repeated:
STATEMENTrepeatable item
A repeat arrow above a stack of required or optional choices indicates that you can make more than one choice from the stacked items, or repeat a single choice:
STATEMENTchoice3 choice1 choice4 choice2
1 2 3
The STATEMENT keyword must be specified and coded as shown. This operand is required. Either identifier-1 or literal-1 must be coded. The operand item-1 is optional. It can be coded or not, as required by the application. If coded, it can be repeated, with each entry separated by one or more blanks. Entry selections allowed for this operand are described at the bottom of the diagram. The operand identifier-4 is optional. If specified it may be repeated with one or more blanks separating each entry. Each entry may be assigned the keyword ROUNDED. In cases where multiple lines must be continued past the right margin, line order from top to bottom is preserved. The ON keyword is optional to the keyword SIZE ERROR, which is optional itself. If SIZE ERROR is coded, then the operand imperative-statement is required. The END-STATEMENT keyword can be coded to end the statement. It is not a required delimiter.
5 6
IBM Extension COBOL/400 language extensions to ANSI X3.23-1985 COBOL that are part of the text description are enclosed in IBM Extension bars, like this paragraph. End of IBM Extension COBOL clauses and statements illustrated within syntax diagrams that are syntax checked, but are treated as documentation by the COBOL/400 compiler, are enclosed by asterisks, as follows:
CL Entry Codes
The box that appears in the lower right corner of each CL syntax diagram contains the entry codes that specify the environment in which the command can be entered. The codes indicate whether or not the command can be: Used in a batch or interactive job (outside a compiled program; Job:B or I) Used in a batch or interactive compiled program (Pgm:B or I) Used in a batch or interactive REXX procedure (REXX:B or I) Used as a parameter for the CALL CL command, or passed as a character string to the system program QCMDEXC (Exec).
IDENTIFICATION DIVISION. 1 PROGRAM-ID. program-name. AUTHOR. comment-entry. INSTALLATION. comment-entry. DATE-WRITTEN. comment-entry. DATE-COMPILED. comment-entry. SECURITY. The SECURITY paragraph can be used to contain the program prologue. The prologue is a description of the program, and it may be as detailed or brief as the guidelines of an installation recommend. Lowercase letters are recommended for comments; however, because some printers can print only capital letters, the comments may be printed in capitals. The underscores highlight the comments. ENVIRONMENT DIVISION. 2 CONFIGURATION SECTION. 3 SOURCE-COMPUTER. IBM-AS4 . OBJECT-COMPUTER. IBM-AS4 . SPECIAL-NAMES. REQUESTOR IS CONSOLE. INPUT-OUTPUT SECTION. 4 FILE-CONTROL. SELECT file-name ASSIGN TO DISK-file-name ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS data-name. DATA DIVISION. 5 FILE SECTION. FD file-name BLOCK CONTAINS 2 RECORDS RECORD CONTAINS 8 CHARACTERS LABEL RECORDS ARE STANDARD DATA RECORD IS record-name 1 record-name PIC X(132). WORKING-STORAGE SECTION. 77 data-name PIC XX. LINKAGE SECTION. PROCEDURE DIVISION. 6 DECLARATIVES END DECLARATIVES. main-processing SECTION. mainline-paragraph. COBOL statements. STOP RUN.
The Identification Division 1 is the only division that must be included; all other divisions are optional. The Environment Division 2 is made up of two sections: the Configuration Section 3 , which describes the overall specifications of the source and object computers, and the Input-Output Section 4 , which defines each file, and specifies information needed for transmission of data between an external medium and the COBOL program. The Data Division 5 describes the files to be used in the program and the records contained within the files. It also describes any internal working-storage data items that are needed. The Procedure Division 6 consists of optional declaratives, and procedures that contain sections and/or paragraphs, sentences, and statements.
10
For a complete description of how to enter a source program using SEU, refer to the SEU Users Guide and Reference.
11
If there is an error in a unit of syntax-checking, the entire unit is presented in reverse image. The message at the bottom of the display refers to the first error in the unit. Syntax checking occurs line by line as you enter the source code. Error messages are generated by lines consisting of incomplete statements. These disappear when the statements are completed, as in the example: ADD A TO BCD. An error message is generated after the first line is entered and disappears after the second line is entered, when the statement is completed. A COBOL sentence can span a maximum of 496 lines. Also, if a source line is entered or changed, up to 496 lines of source code can be syntax checked as one unit. The following regulations apply to syntax checking for COBOL source functions: Source code on a line with an asterisk (*) or a slash (/) in column 7 is not syntax checked. An asterisk indicates a comment line; a slash indicates a comment line and page eject. No compiler options are honored during syntax checking. For example, the syntax checker accepts both quotation marks or apostrophes as nonnumeric delimiters provided they are not mixed within one unit of syntax checking. The syntax checker does not check if the delimiter is the one that will be specified in the CRTCBLPGM command for compiling COBOL source statements, or in the PROCESS statement. The first sentence following any of the paragraph headers listed below must begin on the same line as the paragraph header. PROGRAM-ID. AUTHOR. INSTALLATION. DATE-WRITTEN. DATE-COMPILED. SECURITY. SOURCE-COMPUTER. OBJECT-COMPUTER. SPECIAL-NAMES. Character replacement specified by the CURRENCY and DECIMAL-POINT clauses of the SPECIAL-NAMES paragraph is not honored during interactive syntax checking. When using the REPLACING Identifier-1 BY Identifier-2 clause of the COPY statement and when either identifier includes reference modification, SEU checks for matching parentheses only. for more information on reference modification, see Chapter 11, COBOL/400 Programming Considerations.
12
If the member type for the source program is SQLCBL or CICSSQLCBL, when the COBOL syntax checker encounters an SQL statement, the statement is passed to the SQL syntax checker. If an error is detected, a message is returned. If an SQL statement is encountered, and if the member type is not SQLCBL or CICSSQLCBL, a COBOL message is returned indicating that a COBOL statement is in error. If there are errors in the embedded SQL statement as well as errors in the preceding COBOL statements, the SQL error message will only be displayed after the preceding COBOL errors are corrected. For more information about SQL statements, refer to the SQL/400* Reference.
If the member type for the source program is CICSCBL or CICSSQLCBL, when the COBOL syntax checker encounters a CICS statement, the COBOL syntax checker checks for only basic syntax errors. If a CICS statement is encountered, and if the member type is not CICSCBL or CICSSQLCBL, a COBOL message is returned indicating that a COBOL statement is in error. For more information about CICS/400 statements, refer to the CICS/400 Application Programming Guide.
13
14
During compilation, the compiler checks the syntax of the COBOL source program line by line, and also checks the relationships between the lines.
Programming Note: The number of entries in the Object Definition Table (ODT) and the amount of storage required by a COBOL program varies with the number and kinds of COBOL statements used in the program. A combination of these factors can cause the AS/400 internal size limits for the program to be exceeded. If this occurs, try using the *NOUNREF option of the GENOPT parameter. If the problem persists, the program must be rewritten.
When the *NOUNREF option is specified, only names that are referenced or are needed for data structuring are defined. This option is useful when the program contains many unreferenced identifiers.
15
If you do not specify CBL as the source member type, the compiler issues a warning. If the Format 2 COPY statement is used in the program to access externally described files, the operating system provides information about the externally described files to the compiled program. If the COBOL compiler stops, the message LBL9001 Compile failed. Program not created. is issued. You can use a control language program that can monitor for this exception by using the control language Monitor Message (MONMSG) command.
16
Create COBOL Program (CRTCBLPGM) Type choices, press Enter. Program . . . . . . . . . Library . . . . . . . . Source file . . . . . . . Library . . . . . . . . Source member . . . . . . Generation severity level Text 'description' . . . . . . . . . . . . . . . . . . . . . . . . . PGMID CURLIB QLBLSRC LIBL PGM 29 SRCMBRTXT Name, Name, Name Name, Name, -29 PGMID CURLIB LIBL, PGM CURLIB
Additional Parameters Source listing options . . . . . + for more values Generation options . . . . . . . + for more values F3=Exit F4=Prompt F24=More keys F5=Refresh F12=Cancel SOURCE, NOLIST, NOSOURCE, LIST, SRC...
NOXREF...
Create COBOL Program (CRTCBLPGM) Type choices, press Enter. Conversion options . . . . . . . Message Limit: Number of messages . . . . . . Message limit severity . . . . Print file . . . . . . . . . . . Library . . . . . . . . . . . FIPS flagging . . . . . . . . . + for more values SAA flagging . . . . . . . . . . Extended display options . . . . + for more values Flagging severity . . . . . . . Replace program . . . . . . . . Target release . . . . . . . . . User profile . . . . . . . . . . F3=Exit F4=Prompt F24=More keys F5=Refresh NOMAX 29 QSYSPRT LIBL NOFLAG NOVARCHAR, VARCHAR...
1-9999, NOMAX -29 Name Name, LIBL, CURLIB NOFLAG, DFRWRT, FLAG NODFRWRT...
-99 NO, YES CURRENT, PRV, V2R1M ... USER, OWNER More... F13=How to use this display
Create COBOL Program (CRTCBLPGM) Type choices, press Enter. Authority . . . . . . . . . . . Compiler debugging dump: Intermediate text dump . . . . . LIBCRTAUT 1 65535 Name, LIBCRTAUT, ALL...
F5=Refresh
F12=Cancel
17
library-name Enter the name of the library to contain the created program object.
SRCFILE Parameter: Specifies the name of the source file that contains the COBOL source to be compiled. The possible values are: QLBLSRC Specifies that the source file, QLBLSRC, contains the COBOL source to be compiled.
18
source-file-member-name Enter the name of the member that contains the COBOL source.
GENLVL Parameter: Specifies the severity level that determines if a program object is created. The severity level corresponds to the severity level of the messages produced during compilation of the program. If the severity level of error messages is greater than the value you specify, a program object is not created. For example, if you specify 19 for this parameter, a program object is not created if the severity level of any of the messages is 20 or greater. The possible values are: 29 If errors occur with a severity level greater than 29, no program object is created.
*NOSOURCE or *NOSRC The compiler does not produce the source part of the listing. If you do not require a source listing, you should use this option because compilation may take less time.
*NOXREF The compiler does not produce a crossreference listing for the source program. *XREF The compiler produces a cross-reference listing for the source program.
*GEN The compiler creates a program object after the program is compiled. *NOGEN The compiler does not create a program object after the source program is compiled. You might specify this option if you want only error listings at this time.
severity-level Specify a one or two-digit number, 0 through 29. If errors occur with a severity level greater than this level, no program object is created.
TEXT Parameter: Allows you to enter text that briefly describes the program and its function. *SRCMBRTXT Use the same text for the program object as that which describes the database file member containing the COBOL source. If the source comes from a device or in-line file, specifying *SRCMBRTXT has the same effect as specifying *BLANK. *BLANK No text is specified.
*NOSEQUENCE The reference numbers are not checked for sequence errors. *SEQUENCE The reference numbers are checked for sequence errors. Sequence errors do not occur if the *LINENUMBER option is specified.
text-description Enter the text that briefly describes the program and its function. The text can be a maximum of 50 characters in length and must be enclosed in apostrophes. The apostrophes are not part of the 50-character string.
OPTION Parameter: Specifies the options to use when the COBOL source is compiled. The possible values are: *SOURCE or *SRC The compiler produces a source listing, consisting of the COBOL source input and all compilation-time error messages.
*NOVBSUM Verb usage counts are not printed. *VBSUM Verb usage counts are printed.
*NONUMBER The source-file sequence numbers are used for reference numbers. *NUMBER The user-supplied sequence numbers (columns 1 through 6) are used for reference numbers.
19
*LINENUMBER The sequence numbers created by the compiler are used for reference numbers. This option combines program source code and source code introduced by COPY statements into one consecutively numbered sequence. Use this option if you specify FIPS (Federal Information Processing Standards) flagging or SAA* flagging.
*NOSECLVL Second level message text is not listed for this compilation. *SECLVL Second level message text is listed for this compilation, along with the first-level error text. Note: The first-level error text is printed each time the error occurs.
*NOMAP The compiler does not list the Data Division map. *MAP The compiler lists the Data Division map.
*PRTCORR The compiler inserts comment lines in the compiler listing indicating which elementary items were included as a result of the use of the CORRESPONDING phrase. *NOPRTCORR The compiler does not insert comment lines in the compiler listing when the CORRESPONDING phrase is used.
*NOOPTIONS Options in effect are not listed for this compilation. *OPTIONS Options in effect are listed for this compilation.
*QUOTE Specifies that the delimiter quotation mark (") is used for nonnumeric literals and Boolean literals. This also specifies that the value of the figurative constant QUOTE has the EBCDIC value of a quotation mark. Note: Boolean data is a category of data items that are limited to a value of 1 or 0. A Boolean literal is a literal composed of a Boolean character enclosed in quotation marks and preceded by a B; for example: B"1". *APOST Specifies that the delimiter apostrophe (') is used for nonnumeric literals and Boolean literals. This also specifies that the value of the figurative constant QUOTE has the EBCDIC value of an apostrophe.
*NOSRCDBG This option determines the kind of information you see on your programmable work station when using the CoOperative Development Environment/400 to compile your COBOL programs. See the note on page 21 for further information. The compiler does not produce sourcelevel debugging information. If *NOLSTDBG is also in effect, the compiler does not produce source-level error information either. *SRCDBG This option determines the kind of information you see on your programmable work station when using the CoOperative Development Environment/400 product to compile your COBOL programs. See the note on page 21 for further information. The compiler produces source-level error information and source-level debugging information. You cannot specify *SRCDBG and *LSTDBG together. Specify one or the other.
20
*NOLSTDBG This option determines the kind of information you see on your programmable work station when using the CoOperative Development Environment/400 product to compile your COBOL programs. See the note on page 21 for further information. The compiler does not produce a listing view, source-level error information, or listing-level debugging information. *LSTDBG This option determines the kind of information you see on your programmable work station when using the CoOperative Development Environment/400 product to compile your COBOL programs. See the note on page 21 for further information. The compiler produces a listing view, and listing-level debugging information. If *NOSRCDBG is also in effect, the compiler does not produce source-level error information either. You cannot specify *SRCDBG and *LSTDBG together. Specify one or the other. | | | | | | | | | | | | | | | | Note: You can only use the *NOSRCDBG, *SRCDBG, *NOLSTDBG and *LSTDBG options if you are using the AD/Cycle CoOperative Development Environment/400 product to compile your program. If you specify one or more of these options but do not have the CODE/400 product installed, the COBOL/400 compiler will not continue processing and an error message is issued. For more information on these options, see the CODE Debug Tool User's Guide and Reference, SC09-1622.
GENOPT Parameter: Specifies the options to use when the program object is created. The listings could be required if a problem occurs in COBOL. The possible values are: *NOLIST No IRP (intermediate representation of program), associated hexadecimal code, or error messages are listed. *LIST The IRP, its associated hexadecimal code, and any error messages are listed.
*NOXREF Does not produce a cross-reference listing of the objects defined in the IRP. *XREF Produces a cross-reference listing of all objects defined in the IRP.
*NOPATCH Does not reserve space in the compiled program for a program patch area. *PATCH Reserves space in the compiled program for a program patch area. The program patch area can be used for debugging purposes.
*NODUMP Does not list the program template. *DUMP Lists the program template.
*NOATR Does not list the attributes for the IRP source. *ATR Lists the attributes for the IRP source.
*PRINT The compiler produces a spool listing. *NOPRINT The compiler does not produce a spool listing.
*RANGE At runtime, the system verifies that subscripts are within the correct ranges, but does not verify index ranges. It also
21
checks for reference modification and compiler-generated substring operations. *NORANGE Does not verify ranges at run-time. Note: The *RANGE option generates code for checking subscript ranges. For example, it ensures that you are not attempting to access the 21st element of a 20-element array. The *NORANGE option does not generate code to check subscript ranges. These options do not eliminate the zero subscript checking performed by the operating system. If zero subscripts occur, the operating system will not permit their use and issues message MCH0603.
*DDSFILLER When no matching fields are found by a COPY DDS statement, a single character FILLER field description, "07 FILLER PIC X", is always created.
*NOSYNC The SYNCHRONIZED clause is syntax checked. *SYNC The SYNCHRONIZED clause causes the alignment of an elementary item on a natural boundary in storage.
*NOCRTF Files that are unavailable at the time of an OPEN operation are not created dynamically. *CRTF Files that are unavailable at the time of an OPEN operation are created dynamically. When created, the file will inherit authority from the job profile. (See the discussion of the OPEN statement in the COBOL/400 Reference manual for the conditions under which dynamic file creation can occur.) Note: The maximum record length for a file that will be created dynamically is 32 766.
*UNREF Includes unreferenced data items in the compiled program. *NOUNREF Does not include unreferenced data items in the compiled program. This reduces the number of ODT (object definition table) entries used, allowing a larger program to be compiled. The unreferenced data items still appear in the crossreference listings produced by specifying OPTION (*XREF).
| |
*NODUPKEYCHK Does not check for duplicate keys for INDEXED files. *DUPKEYCHK Checks for duplicate keys for INDEXED files. (See the discussion of the READ statement in the COBOL/400 Reference manual for the conditions under which the existence of records with duplicate keys will be signalled to a program. Warning: Specifying this option can result in a loss in compiler performance.
*NOOPTIMIZE The compiler performs only standard optimizations for the program. *OPTIMIZE The compiler attempts to create a program that operates more efficiently and uses less storage. However, specifying *OPTIMIZE can substantially increase the time required to compile a program.
| | | | |
*NODDSFILLER If no matching fields are found by a COPY DDS statement, no field descriptions are generated.
*STDERR Standard error handling is used. See Chapter 6, COBOL/400 Exception and
22
Error Handling on page 69 for more information. *NOSTDERR The error handling method of Version 1, Releases 1 and 2, is used.
The BLOCK CONTAINS clause controls the number of records to be blocked. When no BLOCK CONTAINS clause is specified, the compiler allows blocking only of SEQUENTIAL access files with no START statement. The operating system determines the number of records to be blocked.
*NOEXTACCDSP The compiler does not allow extended ACCEPT or DISPLAY statements. *EXTACCDSP The compiler allows extended ACCEPT and DISPLAY statements. Refer to Appendix E of the COBOL/400 Reference for changes to the reserved word list that occur when you use this option.
*STDINZ The compiler initializes user data items to system defaults, provided that the items are not subject to a VALUE clause. *NOSTDINZ For those user items with no VALUE clause, the compiler does not initialize data items to system defaults.
*NOINZDLT Relative files with sequential access are not initialized with deleted records during the CLOSE operation if the files have been opened for OUTPUT. That is, the record boundary is determined by the number of records written. Subsequent OPEN operations allow access only up to the record boundary. *INZDLT Relative files with sequential access are initialized with deleted records during the CLOSE operation if the files were opened for OUTPUT. Active records in the files are not affected. That is, the record boundary is defined as the file size for subsequent I/O operations.
*FS21DUPKY The compiler reports a file status of 21 when processing an indexed file with duplicate keys in random or dynamic access mode, if the value of the key is changed between the mandatory READ statement and a following REWRITE or DELETE statement. *NOFS21DUPKY The compiler does not report a file status of 21 when processing an indexed file with duplicate keys in random or dynamic access mode. A REWRITE statement can change the key of a record. CVTOPT Parameter: Specifies how the compiler handles SAA date, time, and timestamp data types, DBCS-graphic data types, and variable-length character fields passed from externallydescribed files to your program through COPY DDS. The possible values are: *NOVARCHAR Variable-length fields are ignored, and are declared as FILLER fields. *VARCHAR Variable-length fields are declared as fixed-length group items, and are accessible to the program. For more information on variable-length fields, refer to
*NOBLK The compiler allows blocking only of SEQUENTIAL access files with no START statement. If a BLOCK CONTAINS clause is specified, the BLOCK CONTAINS clause is ignored, except for tape files. *BLK When used with BLOCK CONTAINS, the compiler allows blocking from DYNAMIC access files and SEQUENTIAL access files with a START statement. Blocking is not allowed for RELATIVE files opened for output operations.
23
*NOMAX Compilation continues until normal completion regardless of the number of errors encountered.
*NODATETIME Date, time, and timestamp data types are ignored, and are declared as FILLER fields. *DATETIME Date, time, and timestamp data types are declared as fixed-length character fields, and are accessible to the program.
1-9999 Compilation stops if the number of errors of the specified severity level or higher exceeds the number you specify. If no messages equal or exceed the maximum severity level, compilation continues regardless of the number of errors encountered. message-severity The possible values for the maximum error severity level are:
29 Compilation stops if the number of errors with severity level 29 or higher exceeds the maximum number of error messages specified.
*NOGRAPHIC DBCS-graphic data types are ignored, and are declared as FILLER fields. *GRAPHIC Fixed-length DBCS-graphic data types are declared as fixed-length alphanumeric fields, and are accessible to the program. When the *VARCHAR option is also in use, variable-length DBCS-graphic data types are declared as fixed-length group items, and are accessible to the program. For more information on DBCS-graphic data types, refer to DBCS-Graphic Fields on page 133. MSGLMT Parameter: Controls compilation by indicating the maximum number of error messages of a given error severity level that can occur before compilation stops. For example, you can stop compilation if more than three errors with a severity level of 20 or higher occur. In this example, you would specify 3 for the maximum number of error messages, and 20 for the maximum error severity level. If three errors of severity level 20 or higher occur, compilation continues, but when a fourth is encountered, compilation stops. If no messages equal or exceed the maximum severity level, compilation continues regardless of the number of errors encountered.
maximum-severity-level Specify a one or two-digit number, 0 through 29. Compilation stops if the number of errors with the specified severity level or higher exceeds the maximum number of error messages you specify.
PRTFILE Parameter: Specifies the name of the file to which the compiler listing is directed and the library where the file is located. The file should have a minimum record length of 132. If a file with a record length less than 132 is specified, information is lost. The possible values are: QSYSPRT If you do not specify a file name, the compiler listing is directed to QSYSPRT, an IBM-supplied file.
file-name Enter the name of the file to which the compiler listing is directed.
The possible library values are: *LIBL If a library-name is not specified, the system searches the library list, *LIBL, to find the library where the file is located.
message-limit The possible values for the maximum number of error messages are:
24
*CURLIB The current library is used. If you have not assigned a library as the current library, QGPL is used.
*NOOBSOLETE Obsolete language elements are not flagged. *OBSOLETE Obsolete language elements are flagged. SAAFLAG Parameter: Specifies if you want flagging of COBOL/400* functions that are not supported by SAA COBOL. (Select the *LINENUMBER option to ensure that the reference numbers used in the SAA COBOL messages are unique.) The possible values are: *NOFLAG SAA COBOL flagging is not performed. *FLAG SAA COBOL flagging is performed. EXTDSPOPT Parameter: Specifies the options to use for extended ACCEPT and extended DISPLAY statements for work station I/O. The possible values are: *DFRWRT Extended DISPLAY statements are held in a buffer until an extended ACCEPT statement is encountered, or until the buffer is filled. If an extended ACCEPT statement is not encountered before the buffer is filled, the contents of the buffer are written to the display. When an extended ACCEPT statement is encountered, the current contents of the buffer are written to the display. *NODFRWRT Each extended DISPLAY statement is performed as it is encountered.
library-name Enter the name of the library where the file is located.
FLAGSTD Parameter: Specifies the options for FIPS flagging. (Select the *LINENUMBER option to ensure that the reference numbers used in the FIPS messages are unique.) The possible values are: *NOFIPS The source program is not FIPS flagged. *MINIMUM FIPS flag for minimum subset and higher. *INTERMEDIATE FIPS flag for intermediate subset and higher. *HIGH FIPS flag for high subset.
*NOSEG The optional module SEGMENTATION is not FIPS flagged. *SEG1 FIPS flag for optional module SEGMENTATION level 1 and higher. *SEG2 FIPS flag for optional module SEGMENTATION level 2.
*NODEB The optional module DEBUG is not FIPS flagged. *DEB1 FIPS flag for optional module DEBUG level 1 and higher. *DEB2 FIPS flag for optional module DEBUG level 2. | | |
*UNDSPCHR Displayable and undisplayable characters are handled by extended ACCEPT and extended DISPLAY statements. *NOUNDSPCHR Use this option when the data to be displayed contains extended DBCS characters. Only displayable characters are handled by extended ACCEPT and extended DISPLAY statements.
25
Although you must use this option for display stations attached to remote 3174 and 3274 controllers, you can also use it for local work stations. If you do use this option, your data must contain displayable characters. If the data contains values less than hexadecimal 20, the results are not predictable, ranging from unexpected display formats to severe errors.
ification level. For example, V2R2M0 is version 2, release 2, modification level 0. Note: To use the object on the target system, you must save the object to the target release level specified on the create command and then restore it on the target system. The possible values are: *CURRENT The object is to be used on the release of the operating system currently running on your system. You can also use the object on a system with any subsequent release of the operating system installed. *PRV The object is to be used on the previous release with modification level 0 of the operating system. You can also use the object on a system with any subsequent release of the operating system installed.
*ACCUPDALL All types of data are predisplayed in the extended ACCEPT statements regardless of the existence of the UPDATE phrase. *ACCUPDNE Only numeric edited data are predisplayed in the extended ACCEPT statements that do not contain the UPDATE phrase. FLAG Parameter: Specifies the minimum severity level of messages to be printed. The possible values are: 0 All messages are printed.
severity-level Enter a one or two-digit number that specifies the minimum severity level of messages to be printed. Messages that have severity levels of the specified value or higher are listed.
REPLACE Parameter: Specifies if a new program object is created when a program object of the same name in the same library already exists. The possible values are: *YES A new program object is created and any existing program object of the same name in the specified library is moved to library QRPLOBJ. *NO A new program object is not created if a program object of the same name already exists in the specified library. TGTRLS Parameter: Specifies the release of the operating system on which you intend to use the object being created. You can specify an exact release level in the format VxRxMx, where Vx is the version, Rx is the release, and Mx is the mod-
release-level Specify the release in the format VxRxMx. The object can be used on a system with the specified release or with any subsequent release of the operating system installed.
Valid values depend on the current version, release, and modification level, and they change with each new release. USRPRF Parameter: Specifies the user profile that will run the compiled COBOL program. The profile of the program owner or the program user is used to run the program and control which objects can be used by the program (including the authority the program has for each object). This parameter is not updated if the program already exists. To change the value of USRPRF, delete the program and recompile using the correct value. The possible values are: *USER The user profile of the program user is to be used when the program is run. *OWNER The user profiles of both the programs owner and user are to be used when the program is run. The collective sets of
26
object authority in both user profiles are to be used to find and access objects during the running of the program. Any objects that are created during the program are owned by the programs user. Note: Specify the USRPRF parameter to reflect the security requirements of your installation. The security facilities available on the AS/400 system are described in detail in the Security Reference. AUT Parameter: Specifies the authority given to users who do not have specific authority to the program object, who are not on the authorization list, or whose group has no specific authority to the program object. You can alter the authority for all users, or for specific users after the program object is created by using the GRTOBJAUT (Grant Object Authority) or RVKOBJAUT (Revoke Object Authority) commands. The possible values are: *LIBCRTAUT The public authority for the object is taken from the CRTAUT keyword of the target library (the library that is to contain the created program object). This value is determined when the program object is created. If the CRTAUT value for the library changes after the program object is created, the new value does NOT affect any existing objects. *ALL Provides authority for all operations on the program object except those limited to the owner or controlled by authorization list management authority. The user can control the program object's existence, specify security for it, change it, and perform basic functions on it, but cannot transfer its ownership. *CHANGE Provides all data authority and the authority for performing all operations on
the program object except those limited to the owner or controlled by object authority and object management authority. The user can change the object and perform basic functions on it, such as running and debugging the program object. *USE Provides object operational authority and read authority; authority for basic operations on the program object such as running the program. The user is prevented from changing the object. *EXCLUDE The user cannot access the program object.
authorization-list-name Enter the name of an authorization list of users and authorities to which the program is added. The program object is secured by this authorization list, and the public authority for the program object is set to *AUTL. The authorization list must exist on the system when the CRTCBLPGM command is issued. Use the Create Authorization List (CRTAUTL) command to create your own authorization list.
Note: Specify the AUT parameter to reflect the security requirements of your installation. The security facilities available on the AS/400 system are described in detail in Security Reference. DUMP Parameter: An IBM COBOL/400 debugging aid for IBM service personnel. ITDUMP (n) Parameter: An IBM debugging aid provided for IBM service personnel. This parameter makes the compiler dump the internal text at certain times during the compilation of the source program.
27
Example 1
CRTCBLPGM SRCFILE(QGPL/QLBLSRC) SRCMBR(SAMPLE) SAAFLAG( FLAG)
Example 2
CRTCBLPGM PGM(TEST) SRCFILE(SOURCE1) CVTOPT( GRAPHIC) In the preceding example, the compiler looks for the file SOURCE1 in the library list, and looks for the member called TEST within that file. (The value for the SRCMBR parameter defaulted to *PGM, specifying to look for a member with the same name as the program to be created.) The compiler creates a COBOL/400 program called TEST from the source program found in the member TEST in the file SOURCE1. Specifying *GRAPHIC for the CVTOPT parameter indicates that if the DDS contains DBCS-graphic data types, you want the COBOL program to be able to reference them as alphanumeric fields.
28
29
TGTRLS( CURRENT USRPRF( USER) PRV OWNER release-level AUT( LIBCRTAUT) ALL CHANGE USE EXCLUDE authorization-list-name TEXT( SRCMBRTXT) BLANK 'description-text' DUMP(starting-statementending-statement) ITDUMP(dump-option) Job: B,I Pgm: B,I REXX: B,I Exec OPTION Details: SRC NOXREF GEN NOSEQUENCE NOVBSUM SOURCE XREF NOGEN SEQUENCE VBSUM NOSRC NOSOURCE
NONUMBER NOMAP NOOPTIONS QUOTE NOSECLVL NUMBER MAP OPTIONS APOST SECLVL LINENUMBER PRTCORR NOSRCDBG NOLSTDBG PRINT NOPRTCORR SRCDBG LSTDBG NOPRINT GENOPT Details: NOLIST NOXREF NOPATCH NODUMP NOATR LIST XREF PATCH DUMP ATR
30
release-level allows you to specify the release level on which you intend to use the object program. The values you can enter for this parameter depend on the current version, release, and modification level, and they change with each new release.
For more information about the TGTRLS parameter, see page 26. You should be aware of the following limitations: Support to compile for use with the previous release is only available when you use the TGTRLS parameter of the CRTCBLPGM command. You must specify *PRV or the release level when you compile the program; you must then save the program, using the Save Object (SAVOBJ) or the Save Library (SAVLIB) CL command, in order to successfully restore it to the previous release of the operating system. You cannot use the TGTRLS parameter for COBOL programs created in the System/38 environment. You can restore an object program to the previous release or to a subsequent release. You cannot restore an object program on a system that is more than one release lower. That is, only one release of downward compatibility is provided. You cannot use functions that are new to the current release of the operating system in a program that you compile for use at the previous release level. Programs may be retranslated when they are restored to the previous release; therefore, you cannot delete observability if the programs are to be retranslated. No product library should be in the system portion of your library list.
31
The following rules apply: The statement must be placed before the first source statement in the COBOL program immediately preceding the IDENTIFICATION DIVISION header. The statement begins with the word PROCESS. Options can appear on more than one line; however, only the first line can contain the word PROCESS. The word PROCESS and all options must appear within positions 8 through 72. Position 7 must be left blank. The remaining positions can be used as in COBOL source statements: positions 1 through 6 for sequence numbers, positions 73 through 80 for identification purposes. The options must be separated by blanks and/or commas. Options can appear in any order. If conflicting options are specified, for example, LIST and NOLIST, the last option encountered takes precedence. If the option keyword is correct and the suboption is in error, the default suboption is assumed. Not every CRTCBLPGM parameter has a corresponding option in the PROCESS statement. Refer to the following tables which indicate the allowable PROCESS statement options and the equivalent CRTCBLPGM command parameters and options. Defaults are underlined. Descriptions of the PROCESS statement options correspond to the parameter and option descriptions that start on page 18.
PROCESS Statement Option CRTCBLPGM GENLVL Parameter Option GENLVL(nn) nn
32
GEN NOGEN NOMAP MAP NONUMBER NUMBER LINENUMBER NOSECLVL SECLVL NOOPTIONS OPTIONS QUOTE APOST NOSEQUENCE SEQUENCE SOURCE (or SRC) NOSOURCE (or NOSRC) NOVBSUM VBSUM NOXREF XREF PRTCORR NOPRTCORR
*GEN *NOGEN *NOMAP *MAP *NONUMBER *NUMBER *LINENUMBER *NOSECLVL *SECLVL *NOOPTIONS *OPTIONS *QUOTE *APOST *NOSEQUENCE *SEQUENCE *SOURCE (or *SRC) *NOSOURCE (or *NOSRC) *NOVBSUM *VBSUM *NOXREF *XREF *PRTCORR *NOPRTCORR
33
NOINZDLT INZDLT NOLIST LIST STDERR NOSTDERR NODDSFILLER DDSFILLER NOSYNC SYNC NOCRTF CRTF NODUPKEYCHK DUPKEYCHK NOEXTACCDSP EXTACCDSP NOBLK BLK STDINZ NOSTDINZ FS21DUPKEY NOFS21DUPKEY RANGE NORANGE UNREF NOUNREF
*NOINZDLT *INZDLT *NOLIST *LIST *STDERR *NOSTDERR *NODDSFILLER *DDSFILLER *NOSYNC *SYNC *NOCRTF *CRTF *NODUPKEYCHK *DUPKEYCHK *NOEXTACCDSP *EXTACCDSP *NOBLK *BLK *STDINZ *NOSTDINZ *FS21DUPKY *NOFS21DUPKY *RANGE *NORANGE *UNREF *NOUNREF
34
NOFIPS MINIMUM INTERMEDIATE HIGH NOSEG SEG1 SEG2 NODEB DEB1 DEB2 NOOBSOLETE OBSOLETE
*NOFIPS *MINIMUM *INTERMEDIATE *HIGH *NOSEG *SEG1 *SEG2 *NODEB *DEB1 *DEB2 *NOOBSOLETE *OBSOLETE
PROCESS Statement Options EXTDSPOPT(a b c) DFRWRT NODFRWRT UNDSPCHR NOUNDSPCHR ACCUPDALL ACCUPDNE
CRTCBLPGM EXTDSPOPT Parameter Options *DFRWRT *NODFRWRT *UNDSPCHR *NOUNDSPCHR *ACCUPDALL *ACCUPDNE
NOSAAFLAG SAAFLAG
*NOFLAG *FLAG
FLAG(nn)
nn
35
The GRAPHIC option of the PROCESS statement is available for processing DBCS characters in DBCS literals. See Appendix F, Supporting International Languages with Double-Byte Character Sets on page 337 for information about DBCS support. The EXTDSPOPT option on the PROCESS statement should be coded with the associated options in brackets similar to FLAG(nn) syntax. You can specify more than one option within the brackets for the EXTDSPOPT option. For example, to specify DFRWRT and UNDSPCHR, type EXTDSPOPT(DFRWRT UNDSPCHR) It is also valid to specify EXTDSPOPT or EXTDSPOPT( ). When EXTDSPOPT alone is specified in the PROCESS statement, then all the default values for the additional options are in effect. If you specify EXTDSPOPT( ), it has no effect on your program. If conflicting options are specified, the last option specified overrides the others.
36
The following example shows the use of the COPY statement within the PROCESS statement. The COPY statement must be followed by a period. Notice also that, in this example, NOMAP overrides the corresponding option in the library member: 1 2 4 1 PROCESS XREF COPY DEFLTS. MAP, SOURCE, LIST NOMAP, FLAG(2 ) IDENTIFICATION DIVISION. MYPROG MYPROG DEFLTS MYPROG MYPROG
37
Time-Separation Characters
The TIMSEP parameter of job-related commands (such as CHGJOB) now specifies the time-separation character used in the time stamps that appear on compiler listings. In the absence of a TIMSEP value, the system value QTIMSEP is used by default.
38
Columns . . . : 1 71 Edit XMPLIB/QLBLSRC SEU==> XMPLE FMT CB ......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 14. DATA DIVISION. 15. FILE SECTION. 16. FD FILE1 17. RECORD CONTAINS 56 CHARACTERS 18. LABEL RECORDS ARE OMITTED 19. DATA RECORD IS REB-1. 2 . 1 REC-1 PIC X(56). _______________________________________________________________________________ Columns . . . : 1 71 Browse Spool file . . : XMPLE SEU==> .5 STMT .51 19 MSGID: LBL1327 SEVERITY: 3 SEQNBR: 19 .52 Message . . . . : 'REB-1' not defined in the program. Clause .53 ignored. .54 E N D O F M E S S A G E S .55 Message Summary .56 Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) F6=Move split line F21=System command Syntax error found. F19=Left F2 =Right F24=More keys
While browsing the compiler listing, you can scan for errors and correct those source statements that have errors. To scan for errors, type F ERR on the SEU command line. For complete information on browsing through a compiler listing, see the SEU Users Guide and Reference.
Command Summary
This summary, which is produced as a result of compilation, lists all options specified in the CRTCBLPGM command. Refer to Using the Create COBOL Program (CRTCBLPGM) Command on page 15 for more information about user-defined options.
39
5763CB1 V3R M5 1 Program . . . . . . . . . Library . . . . . . . . Source file . . . . . . . Library . . . . . . . . Source member . . . . . . Generation severity level Text 'description' . . . . Source listing options . . Generation options . . . . Conversion options . . . . Message limit: Number of messages . . . Message limit severity . Print file . . . . . . . . Library . . . . . . . . FIPS flagging . . . . . . SAA flagging . . . . . . . Extended display options . Flagging severity . . . . Replace program . . . . . Target release . . . . . . User profile . . . . . . . Authority . . . . . . . . Compiler . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
IBM SAA COBOL/4 . : SAMPLE . : TESTER . : QLBLSRC . : TESTER . : SAMPLE . : 29 . : BLANK . : NONE . : NONE . : NONE . . . . . . . . . . . . . : : : : : : : : : : : : : NOMAX 29 QSYSPRT LIBL NOFIPS NOFLAG
TESTER/SAMPLE
AS4
SYS
Page
NOSEG
NODEB
NOOBSOLETE
40
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/SAMPLE AS4 SYS 3/27/94 11: 1:51 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 1 PROCESS OPTIONS, SAAFLAG, SOURCE, MAP, XREF, 3/27/94 2 2 FLAG( ), MINIMUM, VBSUM. COBOL Compiler Options in Effect OPTIONS SOURCE XREF MAP VBSUM NONUMBER NOSEQUENCE GEN GENLVL(29) FLAG( ) MINIMUM NOSEG NODEB NOOBSOLETE SAAFLAG QUOTE NOSECLVL NOSRCDBG NOLSTDBG PRINT PRTCORR COBOL Generation Options in Effect NOLIST UNREF RANGE NOATR NOXREF NODUMP NOPATCH NOOPTIMIZE NODDSFILLER NOSYNC NOCRTF NODUPKEYCHK STDERR NOEXTACCDSP NOINZDLT NOFS9MTO M NOBLK STDINZ FS21DUPKY COBOL Conversion Options in Effect NOVARCHAR NODATETIME NOGRAPHIC
Page
Source Listing
Figure 8 illustrates a source listing. The statements in the source program are listed exactly as submitted. The source is not listed if the NOSOURCE option is specified. After the page in which the PROGRAM-ID paragraph is listed, all compiler output pages have the program-id name listed in the heading before the system name.
41
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/SAMPLE AS4 SYS 3/27/94 11: 1:51 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE A B C D E 3 3 IDENTIFICATION DIVISION. 4 4 PROGRAM-ID. SAMPLE. 5 5 AUTHOR. PROGRAMMER NAME. 6 6 INSTALLATION. COBOL DEVELOPMENT CENTRE. 7 7 DATE-WRITTEN. 11/27/87. 8 8 DATE-COMPILED. 3/27/94 11: 1:51 . 9 9 ENVIRONMENT DIVISION. 1 1 CONFIGURATION SECTION. 11 11 SOURCE-COMPUTER. IBM-AS4 . 3/27/94 12 12 OBJECT-COMPUTER. IBM-AS4 . 3/27/94 13 13 INPUT-OUTPUT SECTION. 14 14 FILE-CONTROL. 15 15 SELECT FILE-1 ASSIGN TO DISK-SAMPLE. 16 16 DATA DIVISION. 17 17 FILE SECTION. 18 18 FD FILE-1 19 19 LABEL RECORDS ARE STANDARD 2 2 RECORD CONTAINS 2 CHARACTERS 21 21 DATA RECORD IS RECORD-1. 22 22 1 RECORD-1. 23 23 2 FIELD-A PIC X(2 ). 24 24 WORKING-STORAGE SECTION. 25 25 1 FILLER. 26 26 5 KOUNT PIC S9(2) COMP-3. 27 27 5 LETTERS PIC X(26) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ". 28 28 5 ALPHA REDEFINES LETTERS 29 29 PIC X(1) OCCURS 26 TIMES. 3 3 5 NUMBR PIC S9(2) COMP-3. 31 31 5 DEPENDENTS PIC X(26) VALUE " 1234 1234 1234 1234 1234 ". 32 32 5 DEPEND REDEFINES DEPENDENTS 33 33 PIC X(1) OCCURS 26 TIMES. 34 34 COPY WRKRCD. 35 + 1 1 WORK-RECORD. WRKRCD 36 + 2 5 NAME-FIELD PIC X(1). WRKRCD 37 + 3 5 FILLER PIC X(1) VALUE SPACE. WRKRCD 38 + 4 5 RECORD-NO PIC S9(3). WRKRCD 39 + 5 5 FILLER PIC X(1) VALUE SPACE. WRKRCD 4 + 6 5 LOCATION PIC A(3) VALUE "NYC". WRKRCD 41 + 7 5 FILLER PIC X(1) VALUE SPACE. WRKRCD 42 + 8 5 NO-OF-DEPENDENTS WRKRCD 43 + 9 PIC X(2). WRKRCD 44 + 1 5 FILLER PIC X(7) VALUE SPACES. WRKRCD 45 35 77 WORKPTR USAGE POINTER. 36 37 THE FOLLOWING PARAGRAPH OPENS THE OUTPUT FILE TO 38 BE CREATED AND INITIALIZES COUNTERS 39 46 4 PROCEDURE DIVISION. 41 STEP-1. 47 42 OPEN OUTPUT FILE-1. 48 43 MOVE ZERO TO KOUNT, NUMBR. 44 45 THE FOLLOWING 3 PARAGRAPHS CREATE INTERNALLY THE 46 RECORDS TO BE CONTAINED IN THE FILE, WRITES THEM 47 ON THE DISK, AND DISPLAYS THEM 48 49 STEP-2. 49 5 ADD 1 TO KOUNT, NUMBR. 5 51 MOVE ALPHA (KOUNT) TO NAME-FIELD. 51 52 MOVE DEPEND (KOUNT) TO NO-OF-DEPENDENTS. 52 53 MOVE NUMBR TO RECORD-NO. 54 STEP-3. 53 55 DISPLAY WORK-RECORD. 54 56 WRITE RECORD-1 FROM WORK-RECORD. 57 STEP-4.
Page
42
55
56 57
58 59 6 61 62 63 64
58 59 6 61 62 63 64 65 66 67 68 69 7 71 72 73 74 75 76 77 78 79
PERFORM STEP-2 THRU STEP-3 UNTIL KOUNT IS EQUAL TO 26. THE FOLLOWING PARAGRAPH CLOSES FILE OPENED FOR OUTPUT AND RE-OPENS IT FOR INPUT STEP-5. CLOSE FILE-1. OPEN INPUT FILE-1. THE FOLLOWING PARAGRAPHS READS BACK THE FILE AND SINGLES OUT EMPLOYEES WITH NO DEPENDENTS STEP-6. READ FILE-1 RECORD INTO WORK-RECORD AT END GO TO STEP-8. STEP-7. IF NO-OF-DEPENDENTS IS EQUAL TO " " MOVE "Z" TO NO-OF-DEPENDENTS. GO TO STEP-6. STEP-8. CLOSE FILE-1. STOP RUN. E N D O F S O U R C E
Compiler-generated statement number: The numbers appear to the left of the source program listing. These numbers are referenced in all compiler output listings except for FIPS messages listings. A statement number can span several lines, and a line can contain more than one statement. Reference number: The numbers appear to the left of the source statements. The numbers that appear in this field and the column heading (shown as SEQNBR in this listing) are determined by an option specified in the CRTCBLPGM command or in the PROCESS statement, as shown in the following table:
Option NONUMBER NUMBER LINENUMBER Heading SEQNBR NUMBER LINNBR Origin Source-file sequence numbers Standard COBOL sequence numbers Compiler-generated sequence numbers
Sequence error indicator column: An S in this column indicates that the line is out of sequence. Sequence checking is performed on the reference number field only if the SEQUENCE option is specified. Copyname: The copyname, as specified in the COBOL COPY statement, is listed here for all records included in the source program by that COPY statement. If the DDS-ALL-FORMATS phrase is used, the name <--ALL-FMTS appears under COPYNAME. Change/date field: The date the line was last modified is listed here.
43
5763CB1 V3R M5 VERB ADD CLOSE DISPLAY GO IF MOVE OPEN PERFORM READ STOP WRITE
AS/4 COUNT 1 2 1 2 1 5 2 1 1 1 1
TESTER/SAMPLE
AS4
SYS
Page
E N D
O F
V E R B
U S A G E
B Y
C O U N T
22 1 RECORD-1 FS 23 2 FIELD-A FS 25 1 FILLER WS 26 2 KOUNT WS 27 2 LETTERS WS 28 2 ALPHA WS 3 2 NUMBR WS 31 2 DEPENDENTS WS 32 2 DEPEND WS 35 1 WORK-RECORD WS 36 2 NAME-FIELD WS 37 2 FILLER WS 38 2 RECORD-NO WS 39 2 FILLER WS 4 2 LOCATION WS 41 2 FILLER WS 42 2 NO-OF-DEPENDENTS WS 44 2 FILLER WS 45 77 WORKPTR WS FILE SECTION uses 2 bytes of storage WORKING-STORAGE SECTION uses 75 bytes of storage E N D O F D A T A
2 2 28 3 3
1 2 5 6 9 1 12
2 2 56 2 26 1 2 26 1 19 1 1 3 1 3 1 2 7 16
.D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D
633C 63AE 642 649 6512 65B 6632 66B4 6754 67D6 684C 68C 693C 69C2 7A98 7B2 7B9C 7C16 7C92
6512, DIMENSION(26)
66B4, DIMENSION(26)
D I V I S I O N
M A P
Statement number: The compiler-generated statement number where the data item was defined is listed for each data item in the Data Division map. Level of data item: The level number of the data item, as specified in the source program, is listed here. Index-names are identified by an IX in the level-number and a blank type field. Source name: The data name, as specified in the source program, is listed here.
44
Section: The section where the item was defined is shown here through the use of the following codes:
FS WS LS SM SR File Section Working-Storage Section Linkage Section Sort/Merge Section Special Register.
J K L
Displacement: The offset, in bytes, of the item from the level-01 group item is given here. Length: The decimal length of the item is listed here. Type: The data class type for the item is shown here through the use of the following codes:
GROUP A AN ANE INDEX BOOLN ZONED PACKED BINARY NE POINTR Group Item Alphabetic Alphanumeric Alphanumeric edited Index data item (USAGE INDEX) Boolean Zoned decimal (external decimal) Packed decimal (internal decimal) (USAGE COMP, COMP-3 or PACKED-DECIMAL) Binary (USAGE COMP-4 or BINARY) Numeric edited Pointer data item (USAGE POINTER)
Internal name: The compiler-generated internal names are listed here and are assigned as follows:
File names The internal name uses the form .Fnn, where .F indicates a file name, and nn is a unique two-digit number. Data names The internal name uses the form .Dxxxxxx, where .D indicates a data name or index name, and xxxxxx is a unique six-digit hex value. These names appear in the IRP listing if generated. N
45
For data items, the attributes indicate if the following information was specified for the item: REDEFINES VALUE JUSTIFIED SYNCHRONIZED BLANK WHEN ZERO SIGN IS LEADING SIGN IS LEADING SEPARATE SIGN IS SEPARATE INDICATORS. For table items, the dimensions for the item are listed here in the form DIMENSION (nn). For each dimension, a maximum OCCURS value is given. When a dimension is a variable, it is listed as such, giving the lowest and highest OCCURS values.
FIPS Messages
The FIPS messages, Figure 11, are listed when the FLAGSTD parameter is specified. See page 25 for more information about specifying the option for FIPS flagging. Only messages for the requested FIPS subset, optional modules and/or obsolete elements are listed. Note: The sequence number and column number are given for each time the message is issued.
5763CB1 V3R FIPS-ID O LBL82 LBL82 1 M5 1 AS/4 COBOL FIPS Messages DESCRIPTION AND SEQUENCE NUMBERS FLAGGED P TESTER/SAMPLE AS4 SYS 3/27/94 11: 1:51 Page 8
Following nonconforming standard items valid only at FIPS intermediate level or higher. COPY statement. 34 8 LBL83 Following nonconforming standard items valid only at FIPS high level. Q LBL83 3 DATE-COMPILED paragraph. 8 1 LBL85 Following nonconforming nonstandard items are IBM-defined or are IBM extensions. Q LBL85 4 Assignment-name in ASSIGN clause. 15 36 LBL8518 USAGE IS COMPUTATIONAL-3. 26 36 3 36 LBL852 USAGE IS POINTER. 35 26 LBL8561 COPY statement with default library assumed. 34 19 7 FIPS violations flagged. R E N D O F C O B O L F I P S M E S S A G E S
FIPS-ID: This field lists the FIPS message number. Description and reference numbers flagged: This field lists a description of the condition flagged, followed by a list of the reference numbers from the source program where this condition is found.
46
The type of reference numbers used, and their names in the heading (shown as SEQUENCE NUMBERS in this listing) are determined by an option specified in the CRTCBLPGM command or in the PROCESS statement, as shown in the following table:
Option NONUMBER NUMBER LINENUMBER Heading DESCRIPTION AND SEQUENCE NUMBERS FLAGGED DESCRIPTION AND USER-SUPPLIED NUMBERS FLAGGED DESCRIPTION AND LINE NUMBERS FLAGGED
Q R
Items grouped by level: These headings subdivide the FIPS messages by level and category. FIPS violations flagged: The total number of FIPS violations flagged is included at the end of the FIPS listing.
SAA Messages
Figure 12 shows the SAA messages that are listed when you specify the SAA flagging option. See the SAAFLAG parameter on page 25 or Using the PROCESS Statement to Specify Compiler Options on page 32 for more information about specifying this option.
5763CB1 V3R M5 1 SAA COBOL Messages TESTER/SAMPLE MSGID DESCRIPTION, SEQUENCE NUMBERS and COLUMN NUMBERS FLAGGED LBL88 LBL88 1 AS4 SYS 3/27/94 11: 1:51 Page 9
The following items have been flagged as non-portable across other SAA COBOL systems. Options APOST,NUMBER,SEQUENCE,GRAPHIC,NOCRTF,NODUPKEYCHK,NOSYNC and EXTACCDSP are not SAA COBOL. 1 8 LBL88 9 PROCESS statement. 1 8 LBL8843 USAGE IS POINTER. 35 26 3 SAA COBOL Messages were flagged. E N D O F S A A C O B O L M E S S A G E S
For more information about SAA flagging, see SAA Flagging on page 333.
Cross-Reference Listing
Figure 13 shows the cross-reference listing, which is produced when the XREF option is specified. It provides a list of all data references and procedure-name references, by statement number, within the source program.
47
5763CB1 V3R M5 1 AS/4 NAMES ( = Procedure-name) S ALPHA DEPEND DEPENDENTS DUMMY-SECTION FIELD-A FILE-1 KOUNT LETTERS LOCATION NAME-FIELD NO-OF-DEPENDENTS NUMBR RECORD-NO RECORD-1 STEP-1 STEP-2 STEP-3 STEP-4 STEP-5 STEP-6 STEP-7 STEP-8 WORK-RECORD WORKPTR
AS4
SYS
Page
Names field: The data name or procedure name referenced is listed here. All procedure names are flagged with an * before the name. The names are listed alphabetically. Defined field: The statement number where the name was defined within the source program is listed here. References field: All statement numbers are listed in the same sequence as the name is referenced in the source program. An * following a statement number indicates that the item was modified in that statement.
T U
Messages
Figure 14 shows the messages that are generated during program compilation.
5763CB1 V3R M5 1 AS/4 COBOL Messages TESTER/SAMPLE AS4 STMT X V 18 MSGID: LBL 65 SEVERITY: SEQNBR: 18 W Message . . . . : Blocking/Deblocking for file 'FILE-1' will be performed by compiler-generated code. Y E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) Z 1 1 Source records read . . . . . . . . : 79 Copy records read . . . . . . . . . : 1 Copy members processed . . . . . . : 1 Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program SAMPLE created in library TESTER. E N D O F C O M P I L A T I O N SYS 3/27/94 11: 1:51 Page 11
48
Statement number: This field lists the compiler-generated statement number associated with the statement in the source program for which the message was issued.1 Reference number: The reference number is issued here.1 The numbers that appear in this field and the column heading (shown here as SEQNBR) are determined by an option specified in the CRTCBLPGM command or in the PROCESS statement, as shown in the following table:
Option NONUMBER NUMBER LINENUMBER Heading SEQNBR NUMBER LINNBR Origin Source-file sequence numbers User-supplied sequence numbers Compiler-generated sequence numbers
When a message is issued for a record from a copy file, the number is preceded by a +. X
MSGID and Severity Level: These fields contain the message number and its associated severity level. Severity levels are defined as follows:
1 2 3 4 5 Informational Warning Error Severe Error Unrecoverable (usually a user error) Unrecoverable (usually a compiler error)
Y Z
Message: The message identifies the condition and indicates the action taken by the compiler. Message statistics: This field lists the total number of messages and the number of messages by severity level.
The totals listed are the number of messages generated for each severity by the compiler and are not always the number listed. For example, if FLAG(10) is specified, no messages of severity less than 10 are listed. The counts, however, do indicate the number that would have been printed if they had not been suppressed.
The statement number and the reference number do not appear on certain messages that reference missing items. For example, if the PROGRAM-ID paragraph is missing, message LBL0031 appears on the listing with no statement or reference number listed. Chapter 3. Compiling a Program
49
50
PAYROLL DEPARTMENT MENU 1. 2. 3. 4. Inquire into employee master Change employee master Add new employee Return
Option:____
The menu shown in this figure is normally displayed by a CL program in which each option calls a separate COBOL program. You can also create a command yourself to run a COBOL program by using a command definition. A command definition is an object that contains the definition of a command (including the command name, parameter descriptions, and validity-checking information), and identifies the program that performs the function requested by the command. The system-recognized identifier for the object is *CMD. For example, you can create a command, PAY, that calls a program, PAYROLL. PAYROLL is the name of a COBOL program that is called and run. You can enter the command interactively, or in a batch job. See the CL Programmers Guide for further information about using the command definition. When a COBOL program ends normally, the system returns control to the caller. The caller could be a work station user, a CL program (such as the menu-handling program), or another COBOL program.
Copyright IBM Corp. 1994
51
If a COBOL program ends abnormally during run time, the escape message LBE9001 Error message-id caused program to end. is issued. A CL program can monitor for this exception by using the Monitor Message (MONMSG) command. See the CL Reference for more information about control language commands. If a program ends for any reason other than by the use of the STOP statement or by falling through to the end of the program, the return code is set to 2. See the RTVJOBA and DSPJOB commands in the CL Programmers Guide for more information about return codes. When you are running a batch job that uses the ACCEPT statement, the input data is taken from the job stream. This data must be placed immediately following the CL CALL for the COBOL program. It is your responsibility to request (through multiple ACCEPT statements) the same amount of data as is available. See the ACCEPT Statement section of the COBOL/400 Reference for more information. Note: If more data is requested than is available, the CL command following the data is treated as input data. If more data is available than is requested, each extra line of data is treated as a CL command. In each instance, undesirable results can occur.
52
Create Job Description (CRTJOBD) Submit Job (SBMJOB). You can select one of four reply modes by specifying one of the following values for the INQMSGRPY parameter: SAME RQD DFT SYSRPYL No change is made in the way that replies are sent to inquiry messages All inquiry messages require a reply by the receiver of the inquiry messages A default reply is issued The system reply list is checked for a matching reply list entry. If a match occurs, the reply value in that entry is used. If no entry exists for that inquiry message, a reply is required.
You can use the Add Reply List Entry (ADDRPYLE) command to add entries to the system reply list, or the Work with Reply List Entry (WRKRPYLE) command to change or remove entries in the system reply list. See the CL Reference for details of the ADDRPYLE and WRKRPYLE commands. You can also reply to runtime inquiry messages with a user-defined error-handler. For more information about error-handling APIs, refer to the System Programmers Interface Reference.
53
54
The OS/400 functions let you test programs while protecting your production files, and let you observe and debug operations as a program runs. No special source code is required for using the OS/400 functions. The COBOL functions can be used independently of the OS/400 functions or in combination with them to: Debug a program Produce a formatted dump of the contents of fields, data structures, arrays, and tables. Source code is required for using COBOL debugging features and formatted dump capability. A formatted dump can also be obtained by a users response to a runtime message. OPEN-FEEDBACK and I-O-FEEDBACK contents can provide additional debugging information. The method for obtaining this information is described later in this chapter in File Status and Feedback Areas on page 103. While testing your programs, ensure that your library list is changed to direct the programs to a test library containing test data so that any existing real data is not affected. To prevent database files in production libraries from being modified unintentionally, you can specify UPDPROD(*NO) on the Start Debug (STRDBG) command or by using the Change Debug (CHGDBG) command. See the CL Reference for more information. Note: Refer to the CL Programmers Guide for the CL commands required for testing and debugging programs. No special statements for testing are contained in the program being tested. The program can be run normally without modification. All testing functions are specified in the job that contains the program, not in the actual program. Testing functions apply only to the job in which they are specified. A program can be used concurrently in two jobs: one job that is in a test environment and another that is in a normal processing environment. Testing functions allow you to observe the operations being performed while the program is running. These functions include using breakpoints and traces. (See Using Breakpoints on page 57 and Using a Trace on page 64 for more information.)
55
56
Using Breakpoints
A breakpoint is a statement number or a label in your program that stops program processing, and gives control to the display station user or to a specified program. If you use a statement number, it can be a statement number that appears on the compiler listing of the COBOL source program. If you use a label as a breakpoint, the label can be: Associated with a function performed by your COBOL program. For example, .OPEN indicates the open file function. An internal COBOL compiler generated label. For example, .L 1
indicates the first internally generated label. Note: To determine the internally generated labels for your program, use the GENOPT parameter on the CRTCBLPGM command to get an IRP listing of the program. When a breakpoint statement is about to be run for an interactive job, the system displays the breakpoint at which the program has stopped and, if requested, the values of program variables. After you get this information (in a display), you can go to a Command Entry display and then enter OS/400 commands to request other functions (such as displaying or changing a variable, adding a breakpoint, or adding a trace). See the CL Programmers Guide for more information on breakpoint concepts. For a batch job, a breakpoint program can be called when a breakpoint is reached. The breakpoint information is passed to the breakpoint program.
57
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/TESTPRT AS4 SYS 3/3 /94 17: 5:37 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. TESTPRT. 3 3 AUTHOR. PROGRAMMER NAME. 4 4 INSTALLATION. COBOL DEVELOPMENT CENTRE. 3/3 /94 5 5 DATE-WRITTEN. 11/27/87. 6 6 DATE-COMPILED. 3/3 /94 17: 5:37 . 7 7 ENVIRONMENT DIVISION. 8 8 CONFIGURATION SECTION. 9 9 SOURCE-COMPUTER. IBM-AS4 . 3/3 /94 1 1 OBJECT-COMPUTER. IBM-AS4 . 3/3 /94 11 11 INPUT-OUTPUT SECTION. 12 12 FILE-CONTROL. 13 13 SELECT FILE-1 ASSIGN TO DISK-SAMPLE. 14 14 DATA DIVISION. 15 15 FILE SECTION. 16 16 FD FILE-1 17 17 LABEL RECORDS ARE STANDARD 18 18 RECORD CONTAINS 2 CHARACTERS 19 19 DATA RECORD IS RECORD-1. 2 2 1 RECORD-1. 21 21 2 FIELD-A PIC X(2 ). 22 22 WORKING-STORAGE SECTION. 23 23 1 FILLER. 24 24 5 KOUNT PIC S9(2) COMP-3. 25 25 5 LETTERS PIC X(26) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ". 26 26 5 ALPHA REDEFINES LETTERS 27 27 PIC X(1) OCCURS 26 TIMES. 28 28 5 NUMBR PIC S9(2) COMP-3. 29 29 5 DEPENDENTS PIC X(26) VALUE " 1234 1234 1234 1234 1234 ". 3 3 5 DEPEND REDEFINES DEPENDENTS 31 31 PIC X(1) OCCURS 26 TIMES. 32 32 1 WORK-RECORD. 33 33 5 NAME-FIELD PIC X(1). 34 34 5 FILLER PIC X(1) VALUE SPACE. 35 35 5 RECORD-NO PIC S9(3). 36 36 5 FILLER PIC X(1) VALUE SPACE. 37 37 5 LOCATION PIC A(3) VALUE "NYC". 38 38 5 FILLER PIC X(1) VALUE SPACE. 39 39 5 NO-OF-DEPENDENTS 4 4 PIC X(2). 41 41 5 FILLER PIC X(7) VALUE SPACES. 42 43 THE FOLLOWING PARAGRAPH OPENS THE OUTPUT FILE TO 44 BE CREATED AND INITIALIZES COUNTERS 45 42 46 PROCEDURE DIVISION. 47 STEP-1. 43 48 OPEN OUTPUT FILE-1. 1 44 49 MOVE ZERO TO KOUNT, NUMBR. 5 51 THE FOLLOWING 3 PARAGRAPHS CREATE INTERNALLY THE 52 RECORDS TO BE CONTAINED IN THE FILE, WRITES THEM 53 ON THE DISK, AND DISPLAYS THEM 54 55 STEP-2. 45 56 ADD 1 TO KOUNT, NUMBR. 46 57 MOVE ALPHA (KOUNT) TO NAME-FIELD. 47 58 MOVE DEPEND (KOUNT) TO NO-OF-DEPENDENTS. 48 59 MOVE NUMBR TO RECORD-NO. 6 STEP-3. 49 61 DISPLAY WORK-RECORD. 5 62 WRITE RECORD-1 FROM WORK-RECORD. 63 STEP-4. 51 64 PERFORM STEP-2 THRU STEP-3 UNTIL KOUNT IS EQUAL TO 26. 65 66 THE FOLLOWING PARAGRAPH CLOSES FILE OPENED FOR 67 OUTPUT AND RE-OPENS IT FOR INPUT 68 69 STEP-5. 52 7 CLOSE FILE-1. 2 53 71 OPEN INPUT FILE-1. 72 73 THE FOLLOWING PARAGRAPHS READS BACK THE FILE AND 74 SINGLES OUT EMPLOYEES WITH NO DEPENDENTS 75
Page
58
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/TESTPRT AS4 SYS 3/3 /94 17: 5:37 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 76 STEP-6. 54 77 READ FILE-1 RECORD INTO WORK-RECORD 55 78 AT END GO TO STEP-8. 79 STEP-7. 56 8 IF NO-OF-DEPENDENTS IS EQUAL TO " " 57 81 MOVE "Z" TO NO-OF-DEPENDENTS. 58 82 GO TO STEP-6. 83 STEP-8. 59 84 CLOSE FILE-1. 6 85 STOP RUN. E N D O F S O U R C E
Page
The first breakpoint shows you where you are in the program. The following information is displayed when the break occurs:
59
Display Breakpoint Statement/Instruction Program . . . . . . . Recursion level . . . Start position . . . Format. . . . . . . . Length. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . : : : : : : 52 / 56 TESTPRT 1 1 CHAR DCL 5 KOUNT PACKED 2
To specify a variable for the PGMVAR parameter, begin every name you enter with an alphanumeric character (A through Z, $, #, or @). It can be followed by the characters (A through Z, 0 though 9, $, #, @, or _ ). The following example shows how to display a COBOL variable, RECORD-NO, in the program example. Because the hyphen is treated by the OS/400 operating system as a special character, RECORD-NO must be enclosed in quotation marks.
STRDBG ADDBKP TESTPRT STMT(58) PGMVAR('RECORD-NO')
To display the value of a table element, enter the appropriate occurrence numbers (subscripts) with the variable name. Up to seven dimensions of subscripting are allowed, and the subscripts must be separated by commas. Do not use an index-name or index data-item as a subscript. When an index is entered as a subscript, the operating system uses the internal value of the index as the subscript, and undesirable results can occur. The following example shows how to specify the COBOL variable TABLE1 with three dimensions. PGMVAR('TABLE1(SUB1, SUB2, SUB3)') One or more blanks are allowed after each comma separating subscripts, but the total length of the variable plus subscripts, parentheses, commas, and blanks specified with the PGMVAR keyword cannot exceed 132 characters. For more information on how to code variables in CL commands, see the CL Reference.
60
Variable names can be qualified in the PGMVAR parameter. For example: PGMVAR('NAME-FIELD OF WORK-RECORD') Another technique can be used to display variables that are not elements of a multi-dimensional table. For example, to display the field NAME-FIELD, you can use the COBOL Data Division map to find its COBOL internal name (I-NAME). Next, use the IRP cross-reference listing to find the Object Definition Table (ODT) number for the internal-name. (See Using the PROCESS Statement to Specify Compiler Options on page 32 for information on how to obtain these listings.) Figure 19 shows the Data Division map, and Figure 20 on page 62 shows the cross-reference listing for the program example, TESTPRT.
5763CB1 V3R M5 1 STMT LVL SOURCE NAME 16 FD FILE-1 AS/4 COBOL Data Division Map TESTER/TESTPRT SECTION DISP LENGTH TYPE I-NAME FS .F 1 AS4 SYS 3/3 /94 17: 5:37 Page ATTRIBUTES DEVICE DISK, ORGANIZATION SEQUENTIAL, ACCESS SEQUENTIAL, RECORD CONTAINS 2 CHARACTERS, LABEL RECORDS STANDARD 4
2 1 RECORD-1 FS 21 2 FIELD-A FS 23 1 FILLER WS 24 2 KOUNT WS 25 2 LETTERS WS 26 2 ALPHA WS 28 2 NUMBR WS 29 2 DEPENDENTS WS 3 2 DEPEND WS 32 1 WORK-RECORD WS 33 2 NAME-FIELD WS 34 2 FILLER WS 35 2 RECORD-NO WS 36 2 FILLER WS 37 2 LOCATION WS 38 2 FILLER WS 39 2 NO-OF-DEPENDENTS WS 41 2 FILLER WS FILE SECTION uses 2 bytes of storage WORKING-STORAGE SECTION uses 75 bytes of storage E N D O F D A T A
2 2 28 3 3
1 2 5 6 9 1 12
2 2 56 2 26 1 2 26 1 19 1 1 3 1 3 1 2 7
.D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D .D
633C 63AE 642 649 6512 65B 6632 66B4 6754 67D6 684C 68C 693C 69C2 6A98 6B2 6B9C 6C16
6512, DIMENSION(26)
66B4, DIMENSION(26)
D I V I S I O N
M A P
61
5763SS1 V3R M5 92 925 IBM COBOL/4 5763CB1 V3R M5 IRP LISTING FOR TESTPRT 3/3 /94 17: 5:37 Page 43 ODT ODT Name SEQ Cross Reference ( Indicates Where Defined) 184 .DMPFBH1 514 185 .DMPFBH2 515 14F .DMPFBIB 452 148 .DMPFBLN 445 15B .DMPFBLO 471 186 .DMPFBLP 512 516 182 .DMPFBLS 512 14C .DMPFBL1 449 1 65 1 66 14D .DMPFBL2 45 16 .DMPFBMF 476 14E .DMPFBMN 451 995 1 98 1 99 1118 1119 18 .DMPFBND 5 9 15 .DMPFBOB 453 15A .DMPFBOF 47 152 .DMPFBOL 458 15F .DMPFBPO 475 161 .DMPFBQN 477 155 .DMPFBRC 461 153 .DMPFBRW 459 158 .DMPFBSC 468 149 .DMPFBSF 446 14A .DMPFBSL 447 14B .DMPFBSN 448 146 .DMPFBTY 443 1 97 1117 159 .DMPFBUF 469 183 .DMPFBVL 513 18B .DMPIOFB 522 1A .DMPIOFS 545 546 547 1A6 .DMPKYLN 551 165 .DMPNDEV 481 1 87 1145 144 .DMPOFBS 441 442 443 444 445 446 447 448 449 45 451 452 453 454 458 459 46 461 462 467 468 469 47 471 472 473 474 475 476 477 478 479 48 481 482 5 8 5 9 51 1AA .DMPRCD 555 1AC .DMPRCDN 557 1AE .DMPRDUP 559 1A1 .DMPRFMT 546 1A7 .DMPRRN 552 1A5 .DMPSRC 55 22 .D 6A98 685 221 .D 6B2 686 222 .D 6B9C 687 767 914 916 223 .D 6C16 688 211 .D 63AE 67 21 .D 633C 669 789 9 4 212 .D 642 671 672 673 676 677 213 .D 649 672 753 757 761 765 815 216 .D 65B 675 763 214 .D 6512 673 674 218 .D 66B4 677 678 217 .D 6632 676 754 758 769 21B .D 67D6 68 681 682 683 684 685 686 687 688 778 789 9 4 21A .D 6754 679 767 21D .D 68C 682 21C .D 684C 681 763 1 21F .D 69C2 684 21E .D 693C 683 769
Now you can use ODT number 021C (for NAME-FIELD), with the following commands, to add a breakpoint to the program example at statement 52.
STRDBG ADDBKP TESTPRT STMT(52) PGMVAR('/ 21C')
62
Display Breakpoint Statement/Instruction Program . . . . . . . Recursion level . . . Start position. . . . Format. . . . . . . . Length. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . : : : : : : 52 / 56 TESTPRT 1 1 CHAR DCL
63
See the CL Programmers Guide for descriptions of these commands and for more details about breakpoints.
Using a Trace
A trace is a record of some or all of the statements run in a program. If requested, a trace also records the values of specific variables used in the program statements. Program Statement 1 ...... 2 ...... 3 ...... 4 ...... 5 ...... 6 ...... 7 ...... 8 ...... . . . Trace Processing Order Variables 1 ....... 6 ....... 7 ....... 8 ....... 6 ....... 7 ....... 2 ....... 6 ....... 7 ....... . .
A trace differs from a breakpoint because the number of statements involved in the trace affects where the trace will end. The system records all the traced statements that were processed. You can request a display of the traced information, which shows the sequence in which the statements were processed and, if requested, the values of the variables used in the statements. You specify which statements the system will trace. You can also specify that variables be displayed only when their value has changed since the last trace statement was run. You can specify a trace of one statement in a program, a group of statements in a program, or all the statements in an entire program.
64
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 42 43 THE FOLLOWING PARAGRAPH OPENS THE OUTPUT FILE TO 44 BE CREATED AND INITIALIZES COUNTERS 45 42 46 PROCEDURE DIVISION. 47 STEP-1. 43 48 OPEN OUTPUT FILE-1. 44 49 MOVE ZERO TO KOUNT, NUMBR. 5 51 THE FOLLOWING 3 PARAGRAPHS CREATE INTERNALLY THE 52 RECORDS TO BE CONTAINED IN THE FILE, WRITE THEM 53 ON THE DISK, AND DISPLAY THEM 54 55 STEP-2. 45 56 ADD 1 TO KOUNT, NUMBR. 46 57 MOVE ALPHA (KOUNT) TO NAME-FIELD. 47 58 MOVE DEPEND (KOUNT) TO NO-OF-DEPENDENTS. 48 59 MOVE NUMBR TO RECORD-NO. 6 STEP-3. 49 61 DISPLAY WORK-RECORD. 5 62 WRITE RECORD-1 FROM WORK-RECORD. 63 STEP-4. 51 64 PERFORM STEP-2 THRU STEP-3 UNTIL KOUNT IS EQUAL TO 26. 65 66 THE FOLLOWING PARAGRAPH CLOSES FILE OPENED FOR 67 OUTPUT AND RE-OPENS IT FOR INPUT 68 69 STEP-5. 52 7 CLOSE FILE-1. 53 71 OPEN INPUT FILE-1. 72 73 THE FOLLOWING PARAGRAPHS READ BACK THE FILE AND 74 SINGLE OUT EMPLOYEES WITH NO DEPENDENTS 75 76 STEP-6. 54 77 READ FILE-1 RECORD INTO WORK-RECORD 55 78 AT END GO TO STEP-8. 79 STEP-7. 56 8 IF NO-OF-DEPENDENTS IS EQUAL TO " " 57 81 MOVE "Z" TO NO-OF-DEPENDENTS. 58 82 GO TO STEP-6. 83 STEP-8. 59 84 CLOSE FILE-1. 6 85 STOP RUN. E N D O F S O U R C E
COPYNAME
CHG DATE 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94
Figure 23 on page 66 is an example of a listing of the traced information. This information is produced by the Display Trace Data (DSPTRCDTA) command: DSPTRCDTA OUTPUT( PRINT) CLEAR( YES) This command is explained in the CL Reference.
65
5763SS1 V3R M5 Display Trace Data Job . . . : DSP 2 User . . . : PGMRS Number . . . . : 4122 Statement/ Program Instruction Recursion Level Sequence Number TESTPRT 54 1 1 Start position . . . . . . . . . . . . : 1 Length . . . . . . . . . . . . . . . . : DCL Format . . . . . . . . . . . . . . . . : CHAR Variable . . . . . . . . . . . . . . . : 5 NO-OF-DEPENDENTS Type . . . . . . . . . . . . . . . . : CHARACTER Length . . . . . . . . . . . . . . . : 2 ...+....1....+....2....+....3....+....4....+....5 ' ' Statement/ Program Instruction Recursion Level Sequence Number TESTPRT 56 1 2 TESTPRT 57 1 3 TESTPRT 58 1 4 Start position . . . . . . . . . . . . : 1 Length . . . . . . . . . . . . . . . . : DCL Format . . . . . . . . . . . . . . . . : CHAR Variable . . . . . . . . . . . . . . . : 5 NO-OF-DEPENDENTS Type . . . . . . . . . . . . . . . . : CHARACTER Length . . . . . . . . . . . . . . . : 2 ...+....1....+....2....+....3....+....4....+....5 'Z ' Statement/ Program Instruction Recursion Level Sequence Number TESTPRT 54 1 5 TESTPRT 56 1 6 Start position . . . . . . . . . . . . : 1 Length . . . . . . . . . . . . . . . . : DCL Format . . . . . . . . . . . . . . . . : CHAR Variable . . . . . . . . . . . . . . . : 5 NO-OF-DEPENDENTS Type . . . . . . . . . . . . . . . . : CHARACTER Length . . . . . . . . . . . . . . . : 2 ...+....1....+....2....+....3....+....4....+....5 '1 ' Statement/ Program Instruction Recursion Level Sequence Number TESTPRT 58 1 7 TESTPRT 54 1 8 TESTPRT 56 1 9 Start position . . . . . . . . . . . . : 1 Length . . . . . . . . . . . . . . . . : DCL Format . . . . . . . . . . . . . . . . : CHAR Variable . . . . . . . . . . . . . . . : 5 NO-OF-DEPENDENTS Type . . . . . . . . . . . . . . . . : CHARACTER Length . . . . . . . . . . . . . . . : 2 ...+....1....+....2....+....3....+....4....+....5 '2 ' Statement/ Program Instruction Recursion Level Sequence Number TESTPRT 58 1 1 TESTPRT 54 1 11 TESTPRT 56 1 12
66
program, removing trace requests from a program, removing data collected from previous traces, displaying trace information, and displaying the traces that have been specified for a program. In addition to statement numbers, names of COBOL-generated routines can appear on the trace output STMT field. See the CL Programmers Guide for more information on traces.
67
68
69
LBE7200 is a run-time message that is usually issued when an unmonitored severe error occurs in your COBOL program. Under *NOSTDERR, it can also be issued when an error occurs in the absence of an appropriate error handler. System message MCH1202 is a typical example of an unmonitored severe error. This kind of error results in the COBOL run-time message LBE7200 (or LBE7204 if the error occurs in a program called by a COBOL program). System messages MCH3601 and MCH0601 are other examples of unmonitored severe errors. For I/O operations, there are several important error handling phrases and clauses. These are the AT END/INVALID KEY and NO DATA phrases (coded at the COBOL statement level), the USE procedure, and the FILE STATUS clause (coded at the file level). During arithmetic and I/O operations, errors are detected by the system, which sends messages; the messages are then monitored by COBOL. Similar to the case of an error that results from division by zero, COBOL does detect some errors during an I/O operation. Regardless of how an error is detected during an I/O operation, the result will always be an internal file status in which the first character is not zero, run-time message, or both. General-Use Programming Interface
| |
70
COBOL keeps its own copies of these two data items, both of which are stored in the COBOL File Information Block (FIB). In this chapter, file status and (major/minor) return code refer to COBOLs copies unless otherwise specified. During the processing of an I/O statement, the file status can be updated in one of three ways, as described below. The contents of the file status determine which error handling procedures to run. Error handling procedures take control after an unsuccessful input or output operation, which is denoted by any file status in which the first character is not zero. Before any of these procedures run, the file status is copied into the external file status. The file status is set in one of three ways: Method A (all files): COBOL checks the contents of variables in file control blocks. If the contents are not what is expected, a file status of other than zero is set. Most file statuses set in this way result from checking the COBOL File Information Block (FIB) and the system User File Control Block (UFCB). Method B (transaction files): COBOL checks the major and minor return codes from the system. If the major return code is not zero, the return code (consisting of major and minor return codes) is translated into a file status. If the major return code is zero, the file status may have been set by Method A or C. Note that for subfile READ, WRITE, and REWRITE operations, only Methods A and C apply. For a list of return codes and their corresponding file statuses, see File Structure Support Summary and Status Key Values in the COBOL/400 Reference. Method C (all files): A message is sent by the system when COBOL calls on data management to perform an I/O operation. COBOL then monitors for these messages and sets a file status accordingly. COBOL specifically monitors for a message by generating message monitors in the program object produced at compilation time. Message monitor generation is based on the types of files (organization type and access type are examples) that you specify in a program. Thus, a message that is specifically monitored for in one program may fall under the generic I/O handler in another. More information about message monitor generation will follow in this chapter. COBOL monitors for most messages sent by the system in response to an I/O operation. Typical I/O exceptions result in CPF messages that begin with CPF4 or CPF5, and COBOL does specific monitoring for these. For a list of messages for which COBOL does specific monitoring, see File Structure Support Summary and Status Key Values in the COBOL/400 Reference.
71
72
73
| |
74
A STOP RUN statement is implied when a main COBOL program has no next executable statement (implicit EXIT PROGRAM for a COBOL subprogram), that is, when processing falls through the last statement of a program. Inquiry messages can be issued in response to a COBOL statement (namely a STOP literal), but they are usually issued when a severe error occurs in a program, or when a COBOL operation does not complete successfully. (Examples are LBE7205, LBE7207, and LBE7208.) There are four common replies to a COBOL inquiry message: C, D, F, and G (cancel, cancel and dump, cancel and full dump, continue). The first three cause (as their final steps) an implicit STOP RUN followed by escape message LBE9001. LBE9001 indicates that the program is ending because of a message. An implicit or explicit STOP RUN statement, or a GOBACK statement that appears in a main program, ends the entire COBOL run unit. If an escape message (LBE9001) is issued as the final step of a run unit, the caller of the first COBOL program can monitor for it. (This is because the first COBOL program to be called becomes the main program.) If a COBOL run unit consists of several COBOL and non-COBOL programs, it is the main COBOL program that can issue the escape message. Thus, any non-COBOL program that is called after the main program cannot monitor for the escape message.
Return Codes
When you specify a TRANSACTION file in your program, the FILE STATUS clause of your SELECT statement can contain two data names: the external file status, and the (major and minor) return code. As described under Internal and External File Status on page 70, a file status can be set in one of three ways; however, return codes are set by the system after any transaction I/O that calls data management. Consequently, most error conditions that result in a system message also have an associated return code. Return codes are similar to file status values. That is, CPF messages sent by the system are grouped together under message monitors, and each message monitor sets one or more file statuses. Similarly, CPF messages are grouped together, and each group of messages generates the same major return code. (The minor return code is not necessarily the same.) The main difference between file statuses and return codes is that the grouping of CPF messages is different. Although COBOL only sets return codes for TRANSACTION files, other types of files (such as printer files) also set return codes. You can access the return codes for these files through an ACCEPT from I-O-FEEDBACK operation.
75
Yes
C,D,F
Set i nt er nal f i l e s t at us
End of f i l e
Al l ot her s
Yes
I nval i d key
No
No
No
No
Yes
Note:
= Go to
on next page
76
E E E
D, F
Does an er r or handl er ex i s t ?
Cal l er r or handler
Yes
No
77
*1
severe er r or ?
No
Yes
C,D,F
*2
Moni tored severe er r or ?
No Yes
*3
Is f i l e s t at us equal to 9 0 or 9 P ?
No
Yes
Yes
Run Er r or Declarative
No
End of f i l e
Al l ot her s
No
No
No
Yes
78
Other I/O exceptions may occur that COBOL does not expect. These also result in CPF4xxx and CPF5xxx messages, but there is not specific monitoring for them. Instead, they are caught by a generic I/O error handler. This error handler monitors for certain ranges of CPF4xxx and CPF5xxx messages; it sets the file status to 90 and follows the Yes branch from position *3 in Figure 25 on page 78. An I/O exception may occur that is being specifically monitored for and which, according to the nonstandard error handling model, is severe enough to stop the program. In this situation no file status is set. These I/O exceptions result in specific COBOL escape messages followed by an ending of the program; they follow the Yes branch from position *2 in Figure 25. Example: CPF4238 - INDARA mismatch between program and file There is specific monitoring for this message, and the result is error message LBE7021 followed by an ending of the program. Other COBOL messages that fall into this category are LBE7020 and LBE7022. During an I/O operation, a problem may occur that is not expected by the system. These problems generally result in messages (such as those starting with MCH) that fall outside the CPF4xxx and CPF5xxx range. Such errors, known as unmonitored severe errors, follow the Yes branch from position *1 in Figure 25. These errors are handled by an all-purpose message monitor and result in an ending of the COBOL program. No file status is set.
79
2 or higher
No
Yes
No
Yes
Yes
Yes
Note:
= Go to
on next page
80
Yes
Yes
Yes
Yes
No
Yes
Yes
Note: Follow the parts of the diagram that apply to your statements.
81
For more information on using pointers, refer to Using Pointers in a COBOL/400 Program on page 282. MCH0602 Pointer alignment: The pointer alignment in the Working-Storage Section of the calling program does not match the alignment in the Linkage Section of the called program. Alignment must be on a 16-byte boundary. For more information on using pointers, refer to Using Pointers in a COBOL/400 Program on page 282. MCH3601 Pointer error: A reference is made to a record or a field within a record and the associated file has been closed or has never been opened. For example, the OPEN for the file was unsuccessful and the processing of any other I/O statement for that file is attempted. The file status should be checked before any other I/O is attempted. CPF2415 End of requests: An attempt has been made to accept input from the job input stream while the system is running in batch mode and no input is available.
82
83
For a description of major and minor return codes that may help in diagnosing I/O errors on the TRANSACTION file, see the ICF Programmers Guide or the Data Management Guide. Figure 27 gives an example of an error recovery procedure.
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A A A* A A A A A A A A A A A A A A A
D I S P L AY
F I LE
F OR
E R R OR
R E COV E R Y
E X AMP L E I ND A R A CF 0 1 ( 0 1
F OR MA T 1 12 12 28
' E ND O F
P R OGR AM ' )
I NP U T F L D
84
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. RECOVERY. 3 3 ENVIRONMENT DIVISION. 4 4 CONFIGURATION SECTION. 5 5 SOURCE-COMPUTER. IBM-AS4 . 6 6 OBJECT-COMPUTER. IBM-AS4 . 7 7 INPUT-OUTPUT SECTION. 8 8 FILE-CONTROL. 9 9 SELECT RECOVFILE 1 1 ASSIGN TO WORKSTATION-RECVFILE-SI 11 11 ORGANIZATION IS TRANSACTION 12 12 ACCESS MODE IS SEQUENTIAL 13 13 FILE STATUS IS STATUS-FLD, STATUS-FLD-2 14 14 CONTROL-AREA IS CONTROL-FLD. 15 15 SELECT PRINTER-FILE 16 16 ASSIGN TO PRINTER-QPRINT. 17 17 18 DATA DIVISION. 18 19 FILE SECTION. 19 2 FD RECOVFILE 2 21 LABEL RECORDS ARE OMITTED 21 22 DATA RECORD IS RECOV-REC. 22 23 1 RECOV-REC. 23 24 COPY DDS-ALL-FORMATS OF RECVFILE. 24 + 1 5 RECVFILE-RECORD PIC X(5). + 2 INPUT FORMAT:FORMAT1 FROM FILE RECVFILE OF LIBRARY COBNATEX + 3 25 + 4 5 FORMAT1-I REDEFINES RECVFILE-RECORD. 26 + 5 6 INPUTFLD PIC X(5). + 6 OUTPUT FORMAT:FORMAT1 FROM FILE RECVFILE OF LIBRARY COBNATEX + 7 + 8 5 FORMAT1-O REDEFINES RECVFILE-RECORD. 25 27 26 FD PRINTER-FILE. 28 27 1 PRINTER-REC. 29 28 5 PRINTER-RECORD PIC X(132). 29 3 3 WORKING-STORAGE SECTION. 31 31 32 1 I-O-VERB PIC X(1 ). 32 33 1 STATUS-FLD PIC X(2). 33 34 88 NO-ERROR VALUE " ". 34 35 88 ACQUIRE-FAILED VALUE "9H". 35 36 88 TEMPORARY-ERROR VALUE "9N". 36 37 1 STATUS-FLD-2 PIC X(4). 37 38 1 CONTROL-FLD. 38 39 5 FUNCTION-KEY PIC X(2). 39 4 5 PGM-DEVICE-NAME PIC X(1 ). 4 41 5 RECORD-FORMAT PIC X(1 ). 41 42 1 END-INDICATOR PIC 1 INDICATOR 1 42 43 VALUE B" ". 43 44 88 END-NOT-REQUESTED VALUE B" ". 44 45 88 END-REQUESTED VALUE B"1". 45 46 1 USE-PROC-FLAG PIC 1 46 47 VALUE B" ". 47 48 88 USE-PROC-NOT-EXECUTED VALUE B" ". 48 49 88 USE-PROC-EXECUTED VALUE B"1". 49 5 1 RECOVERY-FLAG PIC 1 5 51 VALUE B" ". 51 52 88 NO-RECOVERY-DONE VALUE B" ". 52 53 88 RECOVERY-DONE VALUE B"1". 53 54 1 HEADER-LINE. 54 55 5 FILLER PIC X(6 ) 55 56 VALUE SPACES. 56 57 5 FILLER PIC X(72) 57 58 VALUE "ERROR REPORT". 58 59 1 DETAIL-LINE. 59 6 5 FILLER PIC X(15) 6 61 VALUE SPACES. 61 62 5 DESCRIPTION PIC X(25) 62 63 VALUE SPACES. 63 64 5 DETAIL-VALUE PIC X(92) 64 65 VALUE SPACES.
COPYNAME
CHG DATE 2/ 1/94 2/ 5/94 2/ 1/94 2/ 1/94 2/ 2/94 2/ 2/94 2/ 1/94 2/ 1/94 2/ 5/94 3/22/94 2/ 5/94 2/ 1/94 2/ 5/94 2/ 5/94 2/ 5/94 2/ 5/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 5/94 2/ 5/94 2/ 5/94 2/ 5/94 3/22/94
85
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 65 66 1 MESSAGE-LINE. 66 67 5 FILLER PIC X(15) 67 68 VALUE SPACES. 68 69 5 DESCRIPTION PIC X(117) 69 7 VALUE SPACES. 7 71 PROCEDURE DIVISION. 72 DECLARATIVES. 73 HANDLE-ERRORS SECTION. 74 USE AFTER STANDARD ERROR PROCEDURE ON RECOVFILE. 1 75 DISPLAY-ERROR. 71 76 SET USE-PROC-EXECUTED TO TRUE. 72 77 WRITE PRINTER-REC FROM HEADER-LINE AFTER ADVANCING PAGE. 73 78 MOVE "ERROR OCCURRED IN" TO DESCRIPTION OF DETAIL-LINE. 74 79 MOVE I-O-VERB TO DETAIL-VALUE OF DETAIL-LINE. 75 8 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 5 LINES. 76 81 MOVE "FILE STATUS =" TO DESCRIPTION OF DETAIL-LINE. 77 82 MOVE STATUS-FLD TO DETAIL-VALUE OF DETAIL-LINE. 2 78 83 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 79 84 MOVE "EXTENDED FILE STATUS =" TO DESCRIPTION OF DETAIL-LINE. 8 85 MOVE STATUS-FLD-2 TO DETAIL-VALUE OF DETAIL-LINE. 81 86 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 82 87 MOVE "CONTROL-AREA =" TO DESCRIPTION OF DETAIL-LINE. 83 88 MOVE CONTROL-FLD TO DETAIL-VALUE OF DETAIL-LINE. 84 89 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 9 CHECK-ERROR. 85 91 IF TEMPORARY-ERROR AND NO-RECOVERY-DONE THEN 86 92 MOVE " ERROR RECOVERY BEING ATTEMPTED " 3 93 TO DESCRIPTION OF MESSAGE-LINE 87 94 WRITE PRINTER-REC FROM MESSAGE-LINE 95 AFTER ADVANCING 3 LINES 88 96 PERFORM ERROR-RECOVERY 97 ELSE 89 98 IF RECOVERY-DONE THEN 4 9 99 MOVE " ERROR AROSE FROM RETRY AFTER RECOVERY " 1 TO DESCRIPTION OF MESSAGE-LINE 91 1 1 WRITE PRINTER-REC FROM MESSAGE-LINE 1 2 AFTER ADVANCING 3 LINES 92 1 3 MOVE " PROGRAM TERMINATED " 1 4 TO DESCRIPTION OF MESSAGE-LINE 93 1 5 WRITE PRINTER-REC FROM MESSAGE-LINE 1 6 AFTER ADVANCING 2 LINES 94 1 7 GO TO ERROR-EXIT 1 8 ELSE 95 1 9 SET NO-RECOVERY-DONE TO TRUE. 96 11 MOVE " EXECUTION CONTINUES " 111 TO DESCRIPTION OF MESSAGE-LINE. 97 112 WRITE PRINTER-REC FROM MESSAGE-LINE 113 AFTER ADVANCING 2 LINES. 98 114 GO TO END-OF-DECLARATIVES. 115 ERROR-RECOVERY. 99 116 SET RECOVERY-DONE TO TRUE. 1 117 DROP PGM-DEVICE-NAME FROM RECOVFILE. 1 1 118 ACQUIRE PGM-DEVICE-NAME FOR RECOVFILE. 5 119 ERROR-EXIT. 1 2 12 CLOSE RECOVFILE 121 PRINTER-FILE. 122 END-OF-DECLARATIVES. 123 END DECLARATIVES. 124 125 MAIN-PROGRAM SECTION. 126 MAINLINE. 1 3 127 MOVE "OPEN" TO I-O-VERB. 1 4 128 OPEN I-O RECOVFILE 129 OUTPUT PRINTER-FILE. 1 5 13 PERFORM I-O-PARAGRAPH UNTIL END-REQUESTED. 6 1 6 131 CLOSE RECOVFILE 132 PRINTER-FILE. 1 7 133 STOP RUN. 134 I-O-PARAGRAPH. 1 8 135 MOVE "WRITE" TO I-O-VERB. 1 9 136 SET USE-PROC-NOT-EXECUTED TO TRUE. 11 137 WRITE RECOV-REC FORMAT IS "FORMAT1" 138 INDICATOR IS END-INDICATOR. 111 139 IF USE-PROC-EXECUTED AND RECOVERY-DONE THEN 7 112 14 GO TO I-O-PARAGRAPH.
COPYNAME
CHG DATE
86
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 113 141 MOVE "READ" TO I-O-VERB. 114 142 SET USE-PROC-NOT-EXECUTED TO TRUE. 115 143 SET NO-RECOVERY-DONE TO TRUE. 116 144 READ RECOVFILE FORMAT IS "FORMAT1" 145 INDICATOR IS END-INDICATOR. 8 117 146 IF NO-ERROR THEN 118 147 PERFORM SOME-PROCESSING. 148 SOME-PROCESSING. 119 149 (INSERT SOME DATABASE PROCESSING, FOR EXAMPLE). E N D O F S O U R C E
COPYNAME
CHG DATE
1 2 3 4 5 6 7 8
This defines processing that takes place when an I/O error occurs on RECOVFILE. This prints out information to help in diagnosing the problem. If the file-status equals 9N (temporary error), and no previous error recovery has been attempted for this I/O operation, error recovery is now attempted. To avoid program looping, recovery is not attempted now if it was attempted previously. Recovery consists of dropping, then reacquiring, the program device on which the I/O error occurred. The mainline of the program consists of writing to and reading from a device until the user signals an end to the program by pressing F1. If the WRITE operation failed but recovery was done, the WRITE is attempted again. If the READ operation failed, processing will continue by writing to the device again, and then attempting the READ again.
87
88
DEV(QPRINT) Printer
The COBOL device name in the ASSIGN clause defines the COBOL functions that can be processed on the selected file. At compilation time, certain COBOL func Copyright IBM Corp. 1994
89
tions are valid only for a specific COBOL device name; in this respect, COBOL is device dependent. The following are examples of device dependency: SUBFILE operations are valid only for a WORKSTATION device. Indicators are valid only for WORKSTATION or FORMATFILE devices. LINAGE is valid only for the PRINTER device. OPEN INPUT WITH NO REWIND is valid only for a TAPEFILE device. For example, assume that the file name FILEY is associated in the COBOL program with the FORMATFILE device. The device FORMATFILE is an independent device type. Therefore, no line or page control specifications are valid in the COBOL program in the WRITE ADVANCING statement. When the program is run, the actual I/O device is specified in the description of FILEY. For example, the device might be a printer; only the default line and page control or those defined in the DDS would be used:
COBOL program SELECT file-name ASSIGN TO FORMATFILE-FILEY
FILEY
DEV(QPRINT) Printer
CL commands can be used to override a parameter in the specified file description or to redirect a file at compilation time or run time. File redirection allows the user to specify one file at compilation time and another file at run time:
FILEX Compile Time COBOL Program SELECT file-name ASSIGN TO FORMATFILE-FILEX Override Command: OVRDKTF FILE(FILEX) TOFILE (FILEA) FILEA Diskette Run Time
DEV(QPRINT)
DEV(QDKT)
In the preceding example, the Override to Diskette File command (OVRDKTF) allows the program to run with an entirely different device file than was specified at compilation time. Not all file redirections or overrides are valid. At run time, checking occurs to ensure that the specifications within the COBOL program are valid for the file being processed. The OS/400 operating system allows some file redirections even if device specifics are contained in the program. For example, if the COBOL device name is PRINTER and the actual file the program uses is not a printer, the operating system ignores the COBOL print spacing and skipping specifications.
90
There are other file redirections that the operating system does not allow and that cause program termination. For example, if the COBOL device name is DATABASE or DISK and a keyed READ operation is specified in the program, the program is terminated if the actual file the program uses is not a disk or database file. See System Override Considerations on page 92 for more detailed information on valid file redirections and file overrides.
Spooling
The AS/400 system provides for the use of input and output spooling functions. Each AS/400 file description contains a spool attribute that determines whether spooling is used for the file at run time. The COBOL program is not aware that spooling is being used. The actual physical device from which a file is read or to which a file is written is determined by the spool reader or the spool writer. See the Data Management Guide for more detailed information on spooling.
Output Spool
Output spooling is valid for batch and interactive jobs. The description of the file that is specified in COBOL by the system-name contains the specification for spooling as shown in the following example:
COBOL program QPRINT File SPOOL(*YES) OUTQ(QPRINT) Output Queue QPRINT
Run Time
Print Writer
Printer Device
File override commands can be used at run time to override the spooling options that are specified in the file description, such as the number of copies to be printed. In addition, AS/400 spooling support allows you to redirect a file after the program has run. For example, you can direct the printer output to a different device, such as a diskette.
91
Input Spool
Input spooling is valid only for inline data files in batch jobs. If the input data read by COBOL comes from a spooled file, COBOL is not aware of which device the data was spooled in from. The data is read from a spooled inline file:
Diskette
Spooled File
See the Data Management Guide for more information on inline data files.
Another form of file overriding is to redirect the COBOL program to access a different file. When the override redirects the program to a file of the same type (such as a printer file to another printer file), the file is processed in the same manner as the original file. When the override redirects the program to a file of a different type, the overriding file is processed in the same manner as the original file would have been processed. Device-dependent specifications in the COBOL program are ignored, and the defaults are taken by the system.
Not all file redirections are valid. For example, an indexed file for a COBOL program can only be overridden to another indexed file with a keyed access path.
Multiple member processing can be accomplished for a database file by overriding a database file to process all members. Note the following exceptions: A database source file used for a COBOL program cannot be overridden to process all members. Specifying OVRDBF MBR(*ALL) will result in the termination of the compilation.
92
A database file used for a COPY statement cannot be overridden to process all members. Specifying OVRDBF MBR(*ALL) will cause the COPY statement to be ignored. The COBOL programmer must ensure that file overrides are applied properly. For more information on valid file redirections, the device dependent characteristics ignored, and the defaults assumed, see the Data Management Guide.
EXTEND mode is a method of adding records to the end of a sequential file when the file is opened. The shared-for-read lock state allows another user to open the file with a lock state of shared-for-read, shared-for-update, shared-no-update, or exclusive-allow-read, but the user cannot specify the exclusive use of the file. The shared-for-update lock state allows another user to open the file with a shared-for-read or shared-forupdate lock state. The operating system places the shared-for-read lock on the device file and an exclusive-allow-read lock state on the device. Another user can open the file but cannot use the same device. Note: When a COBOL program opens a physical file for OUTPUT, that file will be subject to an exclusive lock for the period of time necessary to clear the member. For more information on allocating resources and the lock states, see the Data Management Guide.
93
To prevent the READ statement from locking records on files opened in I/O (update) mode, you can use the NO LOCK phrase. The READ WITH NO LOCK statement unlocks records locked by a previous READ statement. For more information about this phrase, refer to the section on the READ statement in the COBOL/400 Reference. For a logical file based on one physical file, the lock is placed on the record in the physical file. If a logical file is based on more than one physical file, a lock is placed on one record in each physical file. This lock applies not only to other programs, but also to the original program if it attempts to update the same underlying physical record through a second file. Note: When a file with indexed or relative organization is opened for I/O, using random or dynamic access, a failed I/O operation on any of the I/O verbs except WRITE also unlocks the record. A WRITE operation is not considered an update operation; therefore, the record lock is not released. For more information about releasing database records read for update, see the Data Management Guide.
94
made to the database (a COMMIT statement is processed). If the changes are not valid, or if a problem occurs during processing, the changes can be canceled (a ROLLBACK statement is processed). (When a file is cleared after being opened for OUTPUT, processing of a ROLLBACK does not restore cleared records to the file.) Changes made to records in a file that is not under commitment control are always permanent. Such changes are never affected by subsequent COMMIT or ROLLBACK statements. Each point where a COMMIT or ROLLBACK is successfully processed is a commitment boundary. (If no COMMIT or ROLLBACK has yet been issued in a program, a commitment boundary is created by the first open of any file under commitment control.) The committing or rolling back of changes only affects changes made since the previous commitment boundary. The synchronizing of changes at commitment boundaries makes restart or recovery procedures after a failure easier. For more information, see Recovery After a Failure on page 82. When commitment control is used for database files, records in those files are subject to either a high lock level LCKLVL (*ALL) or a low lock level LCKLVL(*CHG). With a low lock level (*CHG), all records that are changed (rewritten, deleted, or added) in files under commitment control are locked until a COMMIT or ROLLBACK statement is successfully processed. With a high lock level (*ALL), all records accessed, whether for input or output, are locked until a COMMIT or ROLLBACK is successfully processed. For both record locking levels, no other job can modify data in locked records until the COMMIT or ROLLBACK has been successfully completed. (A locked record can only be modified within the same job and through the same physical or logical file.) The lock level also governs whether locked records can be read. With a high lock level (*ALL), you cannot read locked records in a database file. With a low lock level (*CHG), you can read locked records in a database file, provided the file is opened as INPUT in your job, or opened as I/O and READ WITH NO LOCK is used. | | | | | A third lock level can be obtained by specifying LCKLVL(*CS), in which every record accessed from files under commitment control is locked. Records that are not updated or deleted are locked only until a different record is accessed. Records that are updated, added, or deleted are locked until the transaction is committed or rolled back. Other jobs, where files are not under commitment control, can always read locked records, regardless of the lock level used, provided the files are opened as INPUT. Because it is possible in some cases for other jobs to read locked records, data can be accessed before it is permanently committed to a database. If a ROLLBACK statement is processed after another job has read locked records, the data accessed will not reflect the contents of the database. Table 2 shows record locking considerations for files with and without commitment control.
95
DELETE
READ
READ . .
I-O Without Commitment Control With Commitment Control *CHG *ALL I-O Without Commitment Control With Commitment Control *CHG *ALL
READ . .
READ
REWRITE
REWRITE .
START
START . .
START
START
WRITE
WRITE .
WRITE
WRITE .
A file under commitment control can be closed or opened without affecting the status of changes made since the last commitment boundary. A COMMIT must still be issued to make the changes permanent, or a ROLLBACK issued to cancel the changes. A COMMIT statement, when processed, leaves files in the same open or closed state as before processing. All files under commitment control within the same job must be journaled to the same journal. For more information about journal management and its related functions, and for more information about commitment control, refer to the Advanced Backup and Recovery Guide. Commitment control must also be specified outside the COBOL language through the OS/400 control language (CL). The Start Commitment Control (STRCMTCTL) command establishes the capability for commitment control and sets the level of record locking at the high level (*ALL), or the low level (*CHG). The STRCMTCTL command does not automatically initiate commitment control for a file. That file must also be specified in the COMMITMENT CONTROL clause of the I-O-CONTROL paragraph within the COBOL program. The commitment control environment is normally ended by using the End Commitment Control
96
(ENDCMTCTL) command. This causes any uncommitted changes for database files under commitment control to be canceled. (An implicit ROLLBACK is processed.) Refer to the CL Reference for more information on the STRCMTCTL and ENDCMTCTL commands. For more information about commitment control, see the Advanced Backup and Recovery Guide. Note: The ability to prevent reading of uncommitted data that has been changed is a function of commitment control and is only available if you are running under commitment control. Normal (noncommitted) database support is not changed by the commitment control extension, and allows reading of locked records when a file that is opened only for input is read. Try to use files consistently. Typically, files should always be run under commitment control or never be run under commitment control. Figure 29 on page 98 illustrates a possible usage of commitment control in a banking environment. The program processes transactions for transferring funds from one account to another. If no problems occur during the transaction, the changes are committed to the database file. If the transfer cannot take place because of improper account number or insufficient funds, a ROLLBACK is issued to cancel the changes.
97
Conditioning
Condition Name
Length
Functions
Sequence Number
Indicator
Indicator
Indicator
Not (N)
Not (N)
Line
Pos
9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 19 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 7 0 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 8 0
A* A* A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
P R OMP T
S CR E E N F I L E
NAME
ACC T F R OM 99 98
5Y
0I
1 3 3
ACC T T O 97
5Y
0I
4 4
R 96 96
T R AN S AM T E R R F MT
10Y02 I
5 5 6 7
CA 0 1 ( 1 5 ' E ND O F P R OGR AM ' ) P U T R E T A I N OV E R L A Y 3 ' ACCOU N T MA S T E R U P D A T E ' 3 ' F R OM ACCOU N T N UMB E R ' 2 3 C H E CK ( ME ) E R R MS G ( ' I N V A L I D F R OM ACCOU N T + N UMB E R ' 9 9 ) E R R MS G ( ' I N S U F F I C I E N T F U ND S I N F R OM + ACCOU N T ' 9 8 ) 3 ' T O ACCOU N T N UMB E R ' 2 3 C H E CK ( ME ) E R R MS G ( ' I N V A L I D T O ACCOU N T + N UMB E R ' 9 7 ) 3 ' AMOU N T T R AN S F E R R E D ' 23 5 ' I NVA L I D F I L E S T A T U S ' 5 ' I N V A L I D K E Y I N R E WR I T E '
98
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. ACCOUNT. 3 3 AUTHOR. PROGRAMMER NAME. 4 4 INSTALLATION. COBOL DEVELOPMENT CENTRE. 5 5 DATE-WRITTEN. 2/ 2/88. 8 8 DATE-COMPILED. 5/24/92 14: 2:39 . 7 7 ENVIRONMENT DIVISION. 8 8 CONFIGURATION SECTION. 9 9 SOURCE-COMPUTER. IBM-AS4 . 1 1 OBJECT-COMPUTER. IBM-AS4 . 11 11 INPUT-OUTPUT SECTION. 12 12 FILE-CONTROL. 13 13 SELECT ACCOUNT-FILE ASSIGN TO DATABASE-ACCTMST 14 14 ORGANIZATION IS INDEXED 15 15 ACCESS IS DYNAMIC 16 16 RECORD IS EXTERNALLY-DESCRIBED-KEY 17 17 FILE STATUS IS ACCOUNT-FILE-STATUS. 18 18 SELECT DISPLAY-FILE ASSIGN TO WORKSTATION-ACCTFMTS-SI 1 19 19 ORGANIZATION IS TRANSACTION. 2 2 21 I-O-CONTROL. 21 22 COMMITMENT CONTROL FOR ACCOUNT-FILE. 2 23 22 24 DATA DIVISION. 23 25 FILE SECTION. 24 26 FD ACCOUNT-FILE 25 27 LABEL RECORDS ARE STANDARD. 26 28 1 ACCOUNT-RECORD. 27 29 COPY DDS-ALL-FORMATS OF ACCTMST. 28 + 1 5 ACCTMST-RECORD PIC X(82). + 2 I-O FORMAT:ACCNTREC FROM FILE ACCTMST OF LIBRARY XMPLIB + 3 + 4 THE KEY DEFINITIONS FOR RECORD FORMAT ACCNTREC + 5 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 6 1 ACCNTKEY ASCENDING SIGNED NO 29 + 7 5 ACCNTREC REDEFINES ACCTMST-RECORD. 3 + 8 6 ACCNTKEY PIC S9(5). 31 + 9 6 NAME PIC X(2 ). 32 + 1 6 ADDR PIC X(2 ). 33 + 11 6 CITY PIC X(2 ). 34 + 12 6 STATE PIC X(2). 35 + 13 6 ZIP PIC S9(5). 36 + 14 6 BALANCE PIC S9(8)V9(2). 3 37 31 FD DISPLAY-FILE 38 32 LABEL RECORDS ARE STANDARD. 39 33 1 DISPLAY-REC. 4 34 COPY DDS-ALL-FORMATS OF ACCTFMTS. 41 + 1 5 ACCTFMTS-RECORD PIC X(2 ). + 2 INPUT FORMAT:ACCTPMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 3 CUSTOMER ACCOUNT PROMPT 42 + 4 5 ACCTPMT-I REDEFINES ACCTFMTS-RECORD. 43 + 5 6 ACCTFROM PIC S9(5). 44 + 6 6 ACCTTO PIC S9(5). 45 + 7 6 TRANSAMT PIC S9(8)V9(2). + 8 OUTPUT FORMAT:ACCTPMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 9 CUSTOMER ACCOUNT PROMPT + 1 5 ACCTPMT-O REDEFINES ACCTFMTS-RECORD. + 11 INPUT FORMAT:ERRFMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 12 + 13 5 ERRFMT-I REDEFINES ACCTFMTS-RECORD. + 14 OUTPUT FORMAT:ERRFMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 15 + 16 5 ERRFMT-O REDEFINES ACCTFMTS-RECORD. 46 35 WORKING-STORAGE SECTION. 47 36 77 ACCOUNT-FILE-STATUS PIC X(2).
COPYNAME
CHG DATE 2/ 1/94 2/ 4/94 1/27/94 1/27/94 2/ 4/94 3/ 1/94 1/27/94 1/27/94 1/27/94 1/27/94 1/27/94 1/27/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
99
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 48 37 77 IND-ON PIC 1 VALUE B"1". 49 38 77 IND-OFF PIC 1 VALUE B" ". 5 39 1 DISPFILE-INDICS. 51 4 COPY DDS-ALL-FORMATS-INDIC OF ACCTFMTS. 3 52 + 1 5 ACCTFMTS-RECORD. + 2 INPUT FORMAT:ACCTPMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 3 CUSTOMER ACCOUNT PROMPT 53 + 4 6 ACCTPMT-I-INDIC. 54 + 5 7 IN15 PIC 1 INDIC 15. + 6 END OF PROGRAM 55 + 7 7 IN97 PIC 1 INDIC 97. + 8 INVALID TO ACCOUNT NUMBER 56 + 9 7 IN98 PIC 1 INDIC 98. + 1 INSUFFICIENT FUNDS IN FROM ACCOUNT 57 + 11 7 IN99 PIC 1 INDIC 99. + 12 INVALID FROM ACCOUNT NUMBER + 13 OUTPUT FORMAT:ACCTPMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 14 CUSTOMER ACCOUNT PROMPT 58 + 15 6 ACCTPMT-O-INDIC. 59 + 16 7 IN97 PIC 1 INDIC 97. + 17 INVALID TO ACCOUNT NUMBER 6 + 18 7 IN98 PIC 1 INDIC 98. + 19 INSUFFICIENT FUNDS IN FROM ACCOUNT 61 + 2 7 IN99 PIC 1 INDIC 99. + 21 INVALID FROM ACCOUNT NUMBER + 22 INPUT FORMAT:ERRFMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 23 + 24 6 ERRFMT-I-INDIC. + 25 OUTPUT FORMAT:ERRFMT FROM FILE ACCTFMTS OF LIBRARY XMPLIB + 26 62 + 27 6 ERRFMT-O-INDIC. 63 + 28 7 IN95 PIC 1 INDIC 95. 64 + 29 7 IN96 PIC 1 INDIC 96. 41 65 42 PROCEDURE DIVISION. 43 DECLARATIVES. 44 ERROR-SECTION SECTION. 45 USE AFTER STANDARD EXCEPTION PROCEDURE ON ACCOUNT-FILE. 46 ERROR-PARAGRAPH. 66 47 IF ACCOUNT-FILE-STATUS IS NOT EQUAL "23" THEN 67 48 MOVE IND-ON TO IN96 OF ERRFMT-O-INDIC 4 49 ELSE 68 5 MOVE IND-ON TO IN95 OF ERRFMT-O-INDIC. 5 69 51 WRITE DISPLAY-REC FORMAT IS "ERRFMT" 52 INDICATORS ARE ERRFMT-O-INDIC. 7 53 READ DISPLAY-FILE. 71 54 CLOSE DISPLAY-FILE 55 ACCOUNT-FILE. 72 56 STOP RUN. 57 END DECLARATIVES. 58 MAIN-PROGRAM SECTION. 59 MAINLINE. 73 6 OPEN I-O DISPLAY-FILE 61 I-O ACCOUNT-FILE. 74 62 MOVE ZEROS TO ACCTPMT-I-INDIC 63 ACCTPMT-O-INDIC. 75 64 PERFORM WRITE-READ-DISPLAY. 76 65 PERFORM VERIFY-ACCOUNT-NO UNTIL IN15 EQUAL IND-ON. 77 66 CLOSE DISPLAY-FILE 67 ACCOUNT-FILE. 78 68 STOP RUN. 69 VERIFY-ACCOUNT-NO. 79 7 PERFORM VERIFY-TO-ACCOUNT. 8 71 IF IN97 OF ACCTPMT-O-INDIC EQUAL IND-OFF THEN 81 72 PERFORM VERIFY-FROM-ACCOUNT. 82 73 PERFORM WRITE-READ-DISPLAY. 74 VERIFY-FROM-ACCOUNT. 83 75 MOVE ACCTFROM TO ACCNTKEY. 84 76 READ ACCOUNT-FILE 85 77 INVALID KEY MOVE IND-ON TO IN99 OF ACCTPMT-O-INDIC. 86 78 IF IN99 OF ACCTPMT-O-INDIC EQUAL IND-ON THEN 6 79 8 ROLLBACK 81 87 82 ELSE 88 83 PERFORM UPDATE-FROM-ACCOUNT.
COPYNAME
CHG DATE
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
100
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 84 VERIFY-TO-ACCOUNT. 89 85 MOVE ACCTTO TO ACCNTKEY. 9 86 READ ACCOUNT-FILE 91 87 INVALID KEY MOVE IND-ON TO IN97 OF ACCTPMT-O-INDIC. 7 92 88 IF IN97 OF ACCTPMT-O-INDIC EQUAL IND-ON THEN 89 9 ROLLBACK 8 91 93 92 ELSE 94 93 PERFORM UPDATE-TO-ACCOUNT. 94 UPDATE-TO-ACCOUNT. 95 95 ADD TRANSAMT TO BALANCE. 96 96 REWRITE ACCOUNT-RECORD. 97 UPDATE-FROM-ACCOUNT. 97 98 SUBTRACT TRANSAMT FROM BALANCE. 98 99 REWRITE ACCOUNT-RECORD. 99 1 IF BALANCE IS LESS THAN THEN 1 1 1 MOVE IND-ON TO IN98 OF ACCTPMT-O-INDIC 1 2 1 3 ROLLBACK 9 1 4 1 1 1 5 ELSE 1 6 1 7 COMMIT. 1 1 8 1 2 1 9 WRITE-READ-DISPLAY. 1 3 11 WRITE DISPLAY-REC FORMAT IS "ACCTPMT" 111 INDICATORS ARE ACCTPMT-O-INDIC. 11 1 4 112 MOVE ZEROS TO ACCTPMT-I-INDIC 113 ACCTPMT-O-INDIC. 1 5 114 READ DISPLAY-FILE RECORD 115 INDICATORS ARE ACCTPMT-I-INDIC. 116 E N D O F S O U R C E
COPYNAME
CHG DATE
1 2
A separate indicator area is provided for the program. The COMMITMENT CONTROL clause specifies files to be placed under commitment control. Any files named in this clause are affected by the COMMIT and ROLLBACK verbs. The Format 2 COPY statement with the indicator attribute INDIC, defines data description entries in WORKING-STORAGE for the indicators to be used in the program. IN96 is set if there is an invalid file status. IN95 is set if there is an INVALID KEY condition on the REWRITE operation. IN99 is set if the entered account number is invalid for the account to which money is being transferred. IN97 is set if the entered account number is invalid for the account to which money is being transferred. If an INVALID KEY condition occurs on the READ, a ROLLBACK is used and the record lock placed on the record after the first READ is released. If the transfer of funds is not allowed (an indicator has been set), the ROLLBACK statement is processed. All changes made to database files under commitment control are canceled. If the transfer of funds was valid (no indicators have been set), the COMMIT statement is processed, and all changes made to database files under commitment control become permanent.
4 5 6 7 8 9
101
11
The INDICATORS phrase is required for options on the work station display that are controlled by indicators.
102
For disk and database files, when you use BLOCK CONTAINS, and if the blocking factor of zero is specified or calculated, the system determines the blocking factor. There are certain instances in which the blocking factor you specify may be changed. See the Database Guide for more information about these situations. Where a block of records is written or read, the I/O feedback area contains the number of records in that block. The I/O-FEEDBACK area is not updated after each read or write for files where multiple records are blocked and unblocked by COBOL. It is updated when the next block is read or written. See I/O FEEDBACK in the COBOL/400 Reference for more information. For database files, you may not see all changes as they occur, if the changes are made in different programs. For a description of the effect of blocking on changes to database files, see the discussion on sequential-only processing in the Database Guide.
See the ACCEPT Statement section of the COBOL/400 Reference for more information on specifying this statement. See the Attribute Data Formats section of the COBOL/400 Reference for information on the OPEN-FEEDBACK and the I-O-FEEDBACK areas. Refer to the Data Management Guide for information on OPEN-FEEDBACK and I-O-FEEDBACK and the layout and description of the data areas contained in the feedback areas. When the FILE STATUS clause is specified, the system moves a value into the status key data item after each input/output request that explicitly or implicitly refers to this file. This 2-character value indicates the run status of the statement. When the compiler generates code to block output records or unblock input records, file status values that are caused by OS/400 exceptions are set only when a block is processed. For more information about blocking records, refer to Unblocking Input Records and Blocking Output Records on page 102. The I-O-FEEDBACK area is not updated after each read or write for files in which multiple records are blocked and unblocked by COBOL.
103
For database files, you may not see all changes as they occur, if the changes are made in different programs. For a description of the effect of blocking on changes to database files, see the discussion on Sequential-Only Processing in the Database Guide.
File Descriptions
All files on the AS/400 system are defined to the OS/400 operating system. The extent to which files can be defined differs: A program-described file is described at the field level within the COBOL program in the Data Division. The description of the file to the operating system includes information about the type of file and the length of the records in the file. An externally described file is described at the field level to the operating system through IDDU, SQL/400* commands, or DDS. If you create a file (for instance, by using the CRTPF command) without specifying DDS for it, the file still has a field description. The single field has the same name as the file, and has the record length you specified in the create command. The description includes information about the type of file, such as database or a device, and a description of each field and its attributes. The file must be created before you compile the program. Both externally described files and program-described files must be defined in the COBOL program within the INPUT-OUTPUT SECTION and the FILE SECTION. Record descriptions in the FILE SECTION for externally described files can be defined with the Format 2 COPY statement. Device-dependent functions such as forms control are not extracted by the Format 2 COPY operation. Only field-level descriptions are extracted. When EXTERNALLY-DESCRIBED-KEY is specified as RECORD KEY, the fields that make up RECORD KEY are also extracted from DDS. For more information on the Format 2 COPY statement, see Figure 37 on page 112 and the accompanying text. Note: Actual file processing within the Procedure Division is the same, if the file is externally described or program-described.
Program-Described Files
Records and fields for a program-described file are described by coding record descriptions in the File Section of the COBOL program instead of using the Format 2 COPY statement. The file must exist on the system before the program can run, except when you use dynamic file creation, by specifying GENOPT(*CRTF) on the CRTCBLPGM command. For more information, refer to the description of the GENOPT parameter on page 22, or the OPEN statement in the COBOL/400 Reference. To create a file, use one of the Create File commands, which can be found in the CL Reference.
104
DDS can be used with the Create File commands. For a COBOL indexed file, a keyed access path must be created. Specify a key in DDS when the file is created. The record key in COBOL must match the key defined when the file was created.
105
OS/4 System Field-Level Description of a File COBOL 1 File is Externally Described through DDS.
OS/4 System OS/4 System Record-Level Field-Level Description of Description of a File a File COBOL 3 Program Described File. COBOL 4 File is Externally Described through DDS.
COBOL 2 Program Described File. The compiler does not copy a field-level description.
Figure 31. Example showing how COBOL can relate to AS/400 files
The COBOL program uses the field level description of a file that is defined to the operating system. The COBOL user coded a Format 2 COPY statement for the record description. At compilation time, the compiler copies in the external field-level description and translates it into a syntactically correct COBOL record description. The file must exist at compilation time. An externally described file is used as a program-described file in the COBOL program. The entire record description for the file is coded in the COBOL program. This file does not have to exist at compilation time. A file is described to the operating system as far as the record level only. The entire record description must be coded in the COBOL program. This file does not have to exist at compilation time. A file name can be specified for compilation time, and a different file name can be specified for run time. A COBOL Format 2 COPY statement generates the record description for the file at compilation time. At run time, a different library list or a file override command can be used so that a different file is accessed by the program. The file description copied in at compilation time is used to describe the input records used at run time.
Note: For externally described files, the two file formats must be the same. Otherwise, a level check error will occur.
106
In addition, DDS keywords can be used to: Specify Specify Specify Specify edit codes for a field (EDTCDE) edit words for a field (EDTWRD) that duplicate key values are not allowed for the file (UNIQUE) a text description for a record format or a field (TEXT).
See the DDS Reference for a complete list of the DDS keywords that are valid for a database file.
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A * * F L DR E F DS TRE F D I S T R I B U T I ON A P P L I C A T I ON F I E L D R E F E R E NC E A R DS TRE F T E X T ( ' D I S T R I B U T I ON F I E L D R E F ' ) A * COMMON F I E L D S U S E D A S R E F E R E NC E A B A S DA T 6 0 E D T CD E ( Y ) A T E X T ( ' B A S E DA T A F I E L D ' ) A * F I E L D S U S E D B Y C U S T OME R MA S T E R F I L E A CU S T 5 CH E CK ( MF ) A CO L H DG ( ' C U S T OME R ' ' N UMB E R ' ) A N AME 20 CO L H DG ( ' C U S T OME R N AME ' ) A AD D R R R E F F L D ( N AME ) A CO L H DG ( ' C U S T OME R AD D R E S S ' ) A CI TY R R E F F L D ( N AME ) A CO L H DG ( ' C U S T OME R C I T Y ' ) A S TAT E 2 CH E CK ( MF ) A CO L H DG ( ' S T A T E ' ) A S R H COD 6 CH E CK ( MF ) A CO L H DG ( ' S E A R C H ' ' COD E ' ) A T E X T ( ' C U S T OME R N UMB E R S E A R C H COD E ' ) A Z I P 5 0 CH E CK ( MF ) A CO L H DG ( ' Z I P ' ' COD E ' ) A CU S T Y P 1 0 R A NG E ( 1 5 ) A CO L H DG ( ' C U S T ' ' T Y P E ' ) A T E X T ( ' C U S T OME R T Y P E 1 = GOV 2 = S C H 3 = B + A U S 4 = P T 5 =O T H ' ) A AR B A L 8 2 CO L H DG ( ' ACC T S R E C ' ' B A L A NC E ' ) A E D T CD E ( J ) A OR D B A L R R E F F L D ( AR B A L ) A CO L H DG ( ' A / R AM T I N ' ' OR D E R F I L E ' ) A L S T AM T R R E F F L D ( AR B A L ) A CO L H DG ( ' L A S T ' ' AMOU N T ' ' P A I D ' ) A T E X T ( ' L A S T AMOU N T P A I D I N A / R ' ) A A A A
This example of a field reference file shows the definitions of the fields that are used by the CUSMSTL (customer master logical) file, which is shown in Figure 33 on page 109. The field reference file normally contains the definitions of fields that
107
are used by other files. The following text describes some of the entries for this field reference file. 1 The BASDAT field is edited by the Y edit code, as indicated by the keyword EDTCDE (Y). If this field is used in an externally described output file for a COBOL program, the COBOL-generated field is compatible with the data type specified in the DDS. The field is edited when the record is written. When the field is used in a program-described output file, compatibility with the DDS fields in the file is the users responsibility. When DDS is not used to create the file, appropriate editing of the field in the COBOL program is also the users responsibility. The CHECK(MF) entry specifies that the field is a mandatory fill field when it is entered from a display work station. Mandatory fill means that all characters for the field must be entered from the display work station. The ADDR and CITY fields share the same attributes that are specified for the NAME field, as indicated by the REFFLD keyword. The RANGE keyword, which is specified for the CUSTYP field, ensures that the only valid numbers that can be entered into this field from a display work station are 1 through 5. The COLHDG keyword provides a column head for the field if it is used by the Application Development Tools (Appl Dev Tools). The ARBAL field is edited by the J edit code, as indicated by the keyword EDTCDE(J). A text description (TEXT keyword) is provided for some fields. The TEXT keyword is used for documentation purposes and appears in various listings.
3 4
5 6 7
108
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* * A A* A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
L OG I CA L
C U S T OME R MA S T E R
F I LE U N I QU E P F I L E ( CU S MS T P ) T E X T ( ' C U S T OME R MA S T E R
R E COR D ' )
1 2 3 4 5
A logical file for processing the customer master physical file (CUSMSTP) is defined and named CUSMSTL. The UNIQUE keyword indicates that duplicate key values for this file are not allowed. One record format (CUSREC) is defined for the CUSMSTL file, which is to be based upon the physical file CUSMSTP. The CUST field is identified as the key field for this file. If field attributes (such as length, data type, and decimal positions) are not specified in the DDS for a logical file, the attributes are obtained from the corresponding field in the physical file. Any field attributes specified in the DDS for the logical file override the attributes for the corresponding field in
Chapter 7. File and Data Management
109
the physical file. The definition of the fields in the physical file could refer to a field reference file. A field reference file is a data description file consisting of field names and their definitions, such as size and type. When a field reference file is used, the same fields that are used in multiple record formats have to be defined only once in the field reference file. For more information on a field reference file, see the Database Guide. Figure 32 on page 107 shows an example of a field reference file that defines the attributes of the fields used in the database file. See the Database Guide for more information regarding field reference files.
CUS-MASTER. COPY DDS-CUSREC OF CUSLIB-CUSTMAST. I-O FORMAT: CUSREC FROM FILE CUSTMAST OF LIBRARY CUSLIB CUSTOMER MASTER RECORD THE KEY DEFINITIONS FOR THE RECORD FORMAT CUSREC NUMBER NAME RETRIEVAL TYPE ALTSEQ 1 CUST ASCENDING AN NO 5 CUSREC. 6 CUST PIC X(5). CUSTOMER NUMBER 6 NAME PIC X(2 ). CUSTOMER NAME 6 ADDR PIC X(2 ). CUSTOMER ADDRESS 6 CITY PIC X(2 ). CUSTOMER CITY 6 STATE PIC X(2). STATE ABBREVIATION 6 ZIP PIC S9(5) COMP-3. ZIP CODE 6 SHRCOD PIC X(6). CUSTOMER NAME SEARCH CODE 6 CUSTYP PIC 9(1). CUSTOMER TYPE 6 ARBAL PIC S9(6)V9(2) COMP-3. ACCT/REC BALANCE 1
CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC
Figure 34. Example of the Results of the Format 2 COPY Statement (DDS)
110
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* * A A* A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
L OG I CA L
C U S T OME R MA S T E R
This is the name associated with the ALIAS keyword, which will be included in the program. Available through the DDS ALIAS option, an alias is an alternative name that allows a data name of up to 30 characters to be included in a COBOL/400 program.
111
CUS-MASTER. COPY DD-CUSREC OF CUSLIB-CUSTMAST. I-O FORMAT: CUSREC FROM FILE CUSTMAST OF LIBRARY CUSLIB CUSTOMER MASTER RECORD THE KEY DEFINITIONS FOR THE RECORD FORMAT CUSREC NUMBER NAME RETRIEVAL TYPE ALTSEQ 1 CUSTOMER-NUMBER ASCENDING AN NO 5 CUSREC. 6 CUSTOMER-NUMBER PIC X(5). CUSTOMER NUMBER 6 CUSTOMER-NAME PIC X(2 ). CUSTOMER NAME 6 ADDRESS PIC X(2 ). CUSTOMER ADDRESS 6 CITY PIC X(2 ). CUSTOMER CITY 6 STATE PIC X(2). STATE ABBREVIATION 6 ZIP PIC S9(5) COMP-3. ZIP CODE 6 SEARCH-CODE PIC X(6). CUSTOMER NAME SEARCH CODE 6 CUSTOMER-TYPE PIC 9(1) CUSTOMER TYPE 6 ACCT-REC-BALANCE PIC S9(6)V9(2) COMP-3. ACCT/REC BALANCE
CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC
Figure 36. Example of the Results of the Format 2 COPY Statement (DD) with the ALIAS Keyword
IBM Extension
COPYDD-format-name DD-ALL-FORMATS -I -INDICATOR DDR-format-name -O -INDICATORS DDR-ALL-FORMATS -I-O -INDIC DDS-format-name DDS-ALL-FORMATS DDSR-format-name DDSR-ALL-FORMATS OFfile-name IN library-name- SUPPRESS REPLACING ==pseudo-text-1== BY ==pseudo-text-2== identifier-1 identifier-2 literal-1 literal-2 word-1 word-2
112
You can use the Format 2 COPY statement (DD, DDR, DDS, or DDSR option) to create COBOL Data Division statements to describe a file that exists on the system. These descriptions are based on the version of the file in existence at compilation time. They do not make use of any DDS source statements for the file. Refer to the COPY Statement section of the COBOL/400 Reference for more information about the COPY statement. Note: The Format 2 COPY statement (DD, DDR, DDS, or DDSR option) will be denoted by the term Format 2 COPY statement throughout this manual. The Format 2 COPY statement can be used only in the Data Division. You should ensure that a group level item that has a level-number less than 05 precedes the statement. The DD option is used to reference ALIAS (alternative) names. The specification of an ALIAS name in DDS allows a data name of up to 30 characters to be included in the COBOL program. When the DD option is used, any ALIAS names present replace the corresponding DDS field names. All underscores in the ALIAS names are translated into hyphens before any replacing occurs. The DDR option does everything that the DD option does. It also copies the internal DDS format field names, replacing the invalid COBOL characters @, #, $, and _ with the valid COBOL characters A, N, D, and - accordingly. This option also removes any underscores from the ends of the field names. The DDS option copies in the internal DDS format field names. For examples of keys and key names that can be generated when you use the DDS option of the Format 2 COPY statement, see pages 121 through 127. The DDSR option does everything that the DDS option does. It also copies the internal DDS format field names, replacing the invalid COBOL characters @, #, $, and _ with the valid COBOL characters A, N, D, and - accordingly. This option also removes any underscores from the ends of the field names. The following shows the effect of the DDR or DDSR option on invalid COBOL field names:
Original Field Name FLD_A NUMBER#1 POINT@7 BALANCE$ Modified Field Name FLD-A NUMBERN1 POINTA7 BALANCED
When the RECORD KEY clause specifies EXTERNALLY-DESCRIBED-KEY, a format can be copied only once under an FD. For example, if all of the formats of a file are copied under an FD, no other Format 2 COPY statement can be specified for the same file under that FD. The format-name is the name of the DDS record format definition that is to be translated into COBOL data description entries. The format-name must follow the rules for formation of any COBOL/400 name.
113
If neither -I nor -O is specified, -I-O is assumed. If format-name is specified without the Indicator attribute, and both -I and -O formats are to be generated, each record format is generated as a redefinition of an 05 elementary item defined as: The size of the largest record format that will be generated. If ALL-FORMATS is specified (without the Indicator attribute) each record format is generated as a redefinition of an 05 elementary item defined as either: The size of the largest record format in the file, if the COPY statement appears in the File Section The size of the largest record format that will be generated, if the COPY statement appears outside of the File Section. When the Indicator attribute is specified, no redefinition takes place. Instead, each of the formats generates a separate data structure. More information can be found about the Indicator attribute in the section, Indicator Attribute of the Format 2 COPY Statement on page 118. Library-name is optional. If it is not specified, the current job library list is used as the default value. File-name is the name of an AS/400 system file. The generated DDS entries represent the record format defined in the file. The file must be created before the program is compiled. If the file is a database file, a single I/O format is generated. For all other file types, the description generated varies as follows: If -I is specified, the generated data description entries contain either: The input and input/output fields for a nonsubfile format The input, output, and input/output fields for a subfile format. If -O is specified, the generated data description entries contain either: The output and input/output fields for a nonsubfile format The input, output, and input/output fields for a subfile format. Note: Subfile records with only output or input/output fields, and no field indicators specified, generate I/O formats. If a separate storage area is needed in WORKING-STORAGE for each format, an individual COPY statement must be specified for each format.
114
For example, if you assume that the file CUSTMASTER contains two formats CUSADR and CUSTDETL, the following COPY statements could be specified:
. . . FD
FILE-X LABEL RECORDS ARE STANDARD. 01 FILE-X-RECS. COPY DDS-ALL-FORMATS OF CUSTMASTER-QGPL. (See Note 1.) . . . WORKING-STORAGE SECTION. 01 ADR-REC. COPY DDS-CUSTADR OF CUSTMASTER. (See Note 2.) 01 DETAIL-REC. COPY DDS-CUSTDETL OF CUSTMASTER. (See Note 2.) Notes: 1. This COPY statement generates only one storage area for all formats. 2. These COPY statements generate separate storage areas.
Indicators
Indicators are Boolean data items that can have the values B"0" or B"1". When you define a record format for a file using DDS, you can condition the options using indicators; indicators can also be used to reflect particular responses. These indicators are known as OPTION and RESPONSE, respectively. Option indicators provide options such as spacing, underlining, and allowing or requesting data transfer from a program to a printer or display device. Response indicators provide response information to a program from a device, such as function keys pressed by a work station user, and whether data has been entered. Indicators can be used with TRANSACTION files and FORMATFILE files, but never with database files.
115
Possible Entry key field number key field name ASCENDING, DESCENDING ZONE, DIGIT, SIGNED, ABSVAL, AN (alphanumeric), N (numeric) J (DBCS item), DDS - L (date), DDS - T (time), DDS - Z (timestamp), DDS - G (fixed-length graphic), VARLEN (variable-length character or bracketed DBCS item), G VARLEN (variable-length DBCS-graphic) NO, YES
ALTSEQ
If redefinition is required to allow for the generation of multiple formats, a group level name is generated as follows: 05 file-name-RECORD PIC X(size of largest record). For each format, a group level name is assigned as follows: INPUT 05 format-name-I OUTPUT 05 format-name-O I/O Format 05 format-name
116
PHYSICAL, LOGICAL, PRINTER, AND COMMUNICATIONS FILES (Blank) P S B F Default Packed decimal Zoned decimal/signed numeric Binary Floating point single precision double precision Character Hexadecimal data Date Time Timestamp DBCS-Only data DBCS-Either data DBCS-Open data DBCS-Graphic data PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC X(n) S9(n) COMP-3 S9(n) S9(n) COMP-4 9(5) COMP-4 9(10) COMP-4 X(n) X(n) X(n) X(n) X(n) X(n) X(n) X(n) X(2n) PIC PIC PIC PIC S9(n-m)V9(m) S9(n-m)V9(m) COMP-3 S9(n-m)V9(m) S9(n-m)V9(m) COMP-4
A H L T Z J E O G
DISPLAY FILES (Blank) X N Y I W A D F Default Alphabetic Only Numeric Shift Numeric Only Inhibit Keyboard entry Katakana Alphanumeric Shift Digits only Floating point single precision double precision Numeric-only character Signed-numeric shift DBCS-either DBCS-only DBCS-open DBCS-graphic PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC X(n) X(n) X(n) X(n) X(n) X(n) X(n) 9(5) COMP-4 9(10) COMP-4 X(n) X(n) X(n) X(n) X(2n) PIC PIC PIC PIC PIC S9(n-m)V9(m) S9(n-m)V9(m) S9(n-m)V9(m) S9(n-m)V9(m)
S9(n)
M S E J O G
COBOL treats floating point fields as FILLER. See 'Floating Point Fields'. In DDS, if the field has an attribute of VARLEN, the result is two additional bytes at the beginning of the field. FILLER items by default. See 'Date, Time, and Timestamp Fields'.
Indicator Structures
If indicators are requested, and exist in the format, an additional group name (06 level) is generated at the beginning of the structure, followed by entries (07 level) for the relevant individual indicators. 06 format-name(-I or -O)-INDIC. 07 INxx PIC 1 INDIC xx.
117
For example: 06 SAMPLE1-I-INDIC. 07 IN01 PIC 1 INDIC 07 IN04 PIC 1 INDIC 07 IN05 PIC 1 INDIC 07 IN07 PIC 1 INDIC 06 FLD1 PIC ... . 06 FLD2 PIC ... .
118
For example:
1 RCUSREC. COPY DDS-CUSREC-I OF CUSFILE. I-O FORMAT: CUSREC FROM FILE CUSFILE OF LIBRARY CUSLIB THE KEY DEFINITIONS FOR RECORD FORMAT CUSREC NUMBER NAME RETRIEVAL TYPE ALTSEQ 1 ARBAL ASCENDING SIGNED NO 2 AREACD DESCENDING ABSVAL NO 5 CUSREC. 6 ARBAL PIC S9(7)V9(2) COMP-3 6 AREACD PIC S9(3) COMP-3. 6 BOSTAZ PIC X(1). 6 CNTCT PIC X(15). 6 CRCHKZ PIC S9(2). 6 CSTAT PIC X(1). 6 CUSTNZ PIC S9(6). 6 DLORD PIC S9(6). 6 DSCPCZ PIC S9(2)V9(3) COMP-3. 6 INDUS PIC S9(2). 6 NAME1 PIC X(25). 6 NAME2 PIC X(25). 6 NAME3 PIC X(25). 6 NAME4 PIC X(25). 6 PHONE PIC S9(7) COMP-3. 6 PRICIZ PIC S9(2). 6 SHPINZ PIC X(25). 6 SLSMAZ PIC X(3). 6 TAXCDZ PIC S9(2). 6 TERMSZ PIC S9(2).
CUSREC
CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC CUSREC
Redefinition of Formats
Pay particular attention to the REDEFINES clause that may be generated for the ALL-FORMATS or -I-O phrases. Because all formats are redefined on the same area (generally a buffer area), several field names can describe the same area of storage, and unpredictable results can occur if the entire format area is not reinitialized prior to each output operation. Data items that are subordinate to the data item specified in a MOVE CORRESPONDING statement do not correspond and are not moved when they contain a REDEFINES clause or are subordinate to a redefining item. To avoid reinitialization, multiple Format 2 COPY statements using -I and -O suffixes can be used to create separate areas of storage in the Working-Storage section for each format or format type (input or output). READ INTO and WRITE FROM statements can be used with these record formats.
119
For example:
. . .
FD ORDER-ENTRY-SCREEN ... 1 ORDER-ENTRY-RECORD ... WORKING-STORAGE SECTION. 1 ORDSFL-I-FORMAT. COPY DDS-ORDSFL-I OF DOESCR. 1 ORDSFL-O-FORMAT. COPY DDS-ORDSFL-O OF DOESCR. PROCEDURE DIVISION. READ SUBFILE ORDER-ENTRY-SCREEN NEXT MODIFIED RECORD INTO ORDSFL-I-FORMAT FORMAT IS "ORDSFL" AT END SET NO-MODIFIED-SUBFILE-RCD TO TRUE. MOVE CORR ORDSFL-I TO ORDSFL-O. REWRITE SUBFILE ORDER-ENTRY-RECORD FROM ORDSFL-O-FORMAT FORMAT IS "ORDSFL" ...
. . . . . .
. . .
. . .
120
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A A* A A A A A A* A A A A A A A A A A A A A A A A A A A A A A A A A
P H Y S I CA L R P F R E CO R D MT H DAY Y E AR I T EM
F I L E
PF1
F OR
KEY
G E N E R A T I ON
E X AMP L E S
2 2 4 8
K K
MT H DAY
The physical file described by Figure 40 forms a basis for the examples that follow. Each example refers to a logical file (derived from the physical file) that specifies EXTERNALLY-DESCRIBED-KEY in its SELECT clause.
121
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A A* A A* A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
L OG I C A L R R E CO R D 1 DA T E K K MT H DAY
F I L E
L F1
F OR
CON C A T
K E Y WO R D
E X AMP L E S
PF I L E (PF 1) CON C A T ( M T H D A Y Y E AR )
For the logical file described by Figure 41, COPY DDS generates keys and key names derived from the physical file:
122
FD 1
LF1 LABEL RECORDS ARE STANDARD. LOG-RECORD. COPY DDS-ALL-FORMATS OF LF1. 5 LF1-RECORD PIC X(8). I-O FORMAT:RECORD1 FROM FILE LF1
OF LIBRARY COPYDDS
THE KEY DEFINITIONS FOR RECORD FORMAT RECORD1 NUMBER NAME RETRIEVAL 1 MTH-DDS ASCENDING KEY NAME ORIGINATES FROM PHYSICAL FILE 2 DAY-DDS-DDS ASCENDING KEY NAME ORIGINATES FROM PHYSICAL FILE 5 RECORD1 REDEFINES LF1-RECORD. 6 DATE-DDS PIC X(8). 6 FILLER REDEFINES DATE-DDS. 7 MTH-DDS PIC X(2). 7 DAY-DDS-DDS PIC X(2). 7 FILLER PIC X(4).
TYPE AN AN
ALTSEQ NO NO
The COPY statement adds the suffix -DDS to the field names MTH and DATE because MTH is a key that originates from the physical file, and DATE is a COBOL reserved word. The COPY statement adds the suffix -DDS twice to the field name DAY because DAY is both a key that originates from the physical file and a COBOL reserved word. Note that if you move your COPY statement from the File Section to the WorkingStorage Section or to the Linkage Section, the fields subordinate to DATE-DDS are no longer available:
WORKING-STORAGE SECTION. 1 WRK-RECORD. COPY DDS-ALL-FORMATS OF LF1. 5 LF1-RECORD PIC X(8). I-O FORMAT:RECORD1 FROM FILE LF1 5 RECORD1 6 DATE-DDS REDEFINES LF1-RECORD. PIC X(8).
OF LIBRARY COPYDDS
123
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A A* A A* A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
L OG I C A L R R E CO R D 2 MON T H K MT H
F I L E
L F2
F OR
R E N AM E
K E Y WO R D
E X AMP L E S
PF I L E (PF 1) R E N AM E ( M T H )
For the logical file described by Figure 44, COPY DDS generates a key and key name derived from the physical file:
124
FD 1
LF2 LABEL RECORDS ARE STANDARD. LOG-RECORD. COPY DDS-ALL-FORMATS OF LF2. 5 LF2-RECORD PIC X(2). I-O FORMAT:RECORD2 FROM FILE LF2
OF LIBRARY COPYDDS
THE KEY DEFINITIONS FOR RECORD FORMAT RECORD2 NUMBER NAME RETRIEVAL 1 MTH-DDS ASCENDING KEY NAME ORIGINATES FROM PHYSICAL FILE 5 RECORD2 REDEFINES LF2-RECORD. 6 MONTH PIC X(2). 6 MTH-DDS REDEFINES MONTH PIC X(2).
TYPE AN
ALTSEQ NO
The COPY statement adds the suffix -DDS to the field name MTH because MTH is a key that originates from the physical file.
125
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A A* A A* A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
L OG I C A L R R E CO R D 3 YY K YY
F I L E
L F3
F OR
SS T
K E Y WO R D
E X AMP L E S
PF I L E (PF 1) I S S T ( Y E AR 2 2 )
126
For the logical file described by Figure 46 on page 126, COPY DDS generates the following specifications:
FD 1 LF3 LABEL RECORDS ARE STANDARD. LOG-RECORD. COPY DDS-ALL-FORMATS OF LF3. 5 LF3-RECORD PIC X(2). I-O FORMAT:RECORD3 FROM FILE LF3
OF LIBRARY COPYDDS
THE KEY DEFINITIONS FOR RECORD FORMAT RECORD3 NUMBER NAME RETRIEVAL 1 YY ASCENDING 5 RECORD3 REDEFINES LF3-RECORD. 6 YY PIC X(2).
TYPE AN
ALTSEQ NO
The COPY statement does not add a suffix to the field name YY because YY is neither a key that originates from the physical file nor a COBOL reserved word.
Floating-Point Fields
COBOL treats floating-point fields as FILLER. The fields can contain floating-point values set outside of COBOL. A COMP-4 definition is generated to maintain proper alignment in the record, but the data is not in binary format. No attempt must be made to use floating-point data for processing in the COBOL program. Floating-point key fields are not allowed. In cases where some formats exist with a floating-point key field and other formats do not, use one or more Format 2 COPY statements with specific format names, rather than the ALL-FORMATS option. Note: If you have not specified your own program collating sequence, you can create a record containing floating-point fields in your COBOL program by moving LOW-VALUES to the entire record before moving in the values of the non-floating-point fields. This will give the floating-point fields in the record a value of zero. Note that the above method is only recommended if valid floating-point fields with a value of zero are desirable for your particular application.
127
For example:
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 15 16 COPY DDS W I T H O U T REPLACING OPTION 17 14 18 COPY DDS-CUSMST OF CUSMSTP. + 1 I-O FORMAT:CUSMST FROM FILE CUSMSTP OF LIBRARY COBNATEX + 2 CUSTOMER MASTER RECORD 15 + 3 5 CUSMST. 16 + 4 6 CUST PIC X(5). + 5 CUSTOMER NUMBER 17 + 6 6 NAME PIC X(25). + 7 CUSTOMER NAME 18 + 8 6 ADDR PIC X(2 ). + 9 CUSTOMER ADDRESS 19 + 1 6 CITY PIC X(2 ). + 11 CUSTOMER CITY 2 + 12 6 STATE PIC X(2). + 13 STATE 21 + 14 6 ZIP PIC S9(5) COMP-3. + 15 ZIP CODE
COPYNAME
CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 19 2 COPY DDS W I T H REPLACING OPTION 21 31 22 COPY DDS-CUSMST OF CUSMSTP 32 23 REPLACING NAME BY ADDR-LINE-1 33 24 ADDR BY ADDR-LINE-2 34 25 CITY BY ADDR-LINE-3. + 1 I-O FORMAT:CUSMST FROM FILE CUSMSTP OF LIBRARY COBNATEX + 2 CUSTOMER MASTER RECORD 35 + 3 5 CUSMST. 36 + 4 6 CUST PIC X(5). + 5 CUSTOMER NUMBER 37 + 6 6 ADDR-LINE-1 PIC X(25). + 7 CUSTOMER NAME 38 + 8 6 ADDR-LINE-2 PIC X(2 ). + 9 CUSTOMER ADDRESS 39 + 1 6 ADDR-LINE-3 PIC X(2 ). + 11 CUSTOMER CITY 4 + 12 6 STATE PIC X(2). + 13 STATE 41 + 14 6 ZIP PIC S9(5) COMP-3. + 15 ZIP CODE
COPYNAME
CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST
Access Path
The description of an externally described file contains the access path that describes how records are to be retrieved from the file. Records can be retrieved based on an arrival sequence (nonkeyed) access path or on a keyed sequence access path.
128
The arrival sequence access path is based on the order in which the records are stored in the file. Records are added only to the end of the file. For the keyed sequence access path, the sequence in which records are retrieved from the file is based on the contents of the key fields defined in the DDS for the file. For example, in the DDS shown in Figure 33 on page 109, CUST is defined as the key field. The keyed sequence access path is updated whenever records are added, deleted, or when the contents of a key field change. See the Database Guide for a complete description of the access paths for an externally described database file.
129
Level Checking
When a COBOL/400 program uses an externally described file, the operating system provides a level check function (LVLCHK). This function ensures that the format has not changed since compilation time. The compiler always provides the information required by level checking when an externally described file is used (that is, when a record description was defined for the file by using the Format 2 COPY statement). Only those formats that were copied by the Format 2 COPY statement under the FD for a file are level checked. The level check function will be initiated at run time based on the selection made on the create, change, or override file commands. The default on the create file command is to request level checking. If level checking was requested, level checking occurs on a record format basis when the file is opened. If a level check error occurs, COBOL sets a file status of 39 at OPEN time. When no level checking was requested, and the file is re-created using an existing format, existing COBOL programs that use that format may not work without recompilation, depending on the changes to the format. For instance, A change of keys will certainly cause a failure of the program on any I/O statement A change in the record length will cause any REWRITE to fail A change in the record layout can cause various errors in the processing of such a record. You should use extreme caution when using COBOL programs without level checking or recompiling the programs. Note: The compiler does not provide level checking for program-described files. For more information on level checking, see the Data Management Guide.
130
Variable-length Fields
You can bring a variable-length field into your program if you specify *VARCHAR on the CVTOPT parameter of the CRTCBLPGM command, or the VARCHAR option of the PROCESS statement. When *VARCHAR is specified, your COBOL/400 program will convert a variable-length field from an externally described file into a COBOL/400 group item. An example of such a group item is: 6 ITEM1. 49 ITEM1-LENGTH 49 ITEM1-DATA PIC S9(4) COMP-4. PIC X(n).
where n represents the maximum length of the variable-length field. Within the program, the PIC S9(4) COMP-4 is treated like any other declaration of this type, and the PIC X(n) is treated as standard alphanumeric. Since the maximum value that ITEM1-LENGTH can hold is 9 999, this is the length of the longest variable-length field you can write from a COBOL program. When *VARCHAR is not specified, variable-length fields are ignored and declared as FILLER fields in COBOL/400 programs. If *NOVARCHAR is specified, the item is declared as follows: 6 FILLER PIC x(n+2).
For syntax information, see the CVTOPT parameter on page 23. Your program can perform any valid character operations on the generated data portion; however, because of the structure of the field, the length portion must be valid binary data. This data is not valid if it is negative, or greater than the maximum field length. If the first two bytes of the field do not contain a valid binary number, an error will occur if you try to WRITE or REWRITE a record containing the field (or UPDATE or PUT the field in a database), and file status 90 is returned. The following conditions apply when you specify variable-length fields: If a variable-length field is encountered when a field is extracted for an externally described file or an externally described data structure, it is declared in a COBOL/400 program as a fixed-length character field. For single-byte character fields, the length of the declared COBOL/400 field is the length of the DDS field plus 2 bytes. For DBCS-graphic data fields, the length of the declared COBOL/400 field is two times the length of the DDS field plus 2 bytes. For more information on graphic data types, see DBCS-Graphic Fields on page 133. The two extra bytes in the COBOL/400 field contain a binary number that represents the current length of the variable-length field. Figure 50 on page 132 shows the COBOL/400 field length of variable-length fields.
131
length character-data BIN(2) CHAR(N) declared length in DDS For single-byte character fields: For DBCS-graphic data type fields: 2 2 + N = COBOL/4 = COBOL/4 field length field length
+ 2(N)
Your COBOL/400 program can perform any valid character calculation operations on the declared fixed-length field. However, because of the structure of the field, the first two bytes of the field must contain valid binary data (invalid current field-length data is non-numeric, less than 0, or greater than the DDS field length.) An error occurs for an input or output operation if the first two bytes of the field contain invalid field-length data; file status 90 is returned. If you do not specify *VARCHAR, you can encounter problems performing WRITE operations on variable-length fields, because you cannot assign a value to FILLER. The two-byte field may have a value (for example X'4 4 ') which gives a length beyond the range allowed for the field. This causes an I/O error. To see an example of a program using variable-length fields, refer to Examples on page 134.
132
If you declare date, time or timestamp items in your program as FILLER, do not attempt to WRITE records containing these fields, since you will not be able to set them to values that will be accepted by the system.
Null-capable Fields
Although your program can process null-capable fields, null values are not supported. READ, SORT, and MERGE operations can be performed on null-capable fields, but if the fields actually contain null values, errors occur.
DBCS-Graphic Fields
The DBCS-graphic data type is a character string in which each character is represented by 2 bytes. The DBCS-graphic data type does not contain shift-out (SO) or shift-in (SI) characters. The difference between single-byte and DBCS-graphic data is shown in the following figure: 1 byte 1 byte 1 byte 1 byte 1 char 1 char 1 char 1 char 1 byte 1 byte 1 byte 1 byte 1 character 1 character
Figure 51. Comparing Single-byte and Graphic Data
Single-byte data
DBCS-graphic data
DBCS-graphic data is brought into your COBOL/400 program only if you specify the *GRAPHIC value on the CVTOPT parameter of the CRTCBLPGM command, or the CVTGRAPHIC option of the PROCESS statement. If you do not specify DBCS-graphic data, graphic data is ignored and declared as FILLER fields in your COBOL/400 program. For a description and the syntax of the CVTOPT parameter, see page 23. The following conditions apply when DBCS-graphic data is specified: DBCS-graphic data is copied into a COBOL/400 program as a fixed-length alphanumeric field. Every DBCS-graphic data character has a length of 2 bytes. Every fixed-length DBCS-graphic data field has a length of 2 bytes times the number of characters in the field. For a description of the field length of variable-length graphic data fields, see Variable-length Fields on page 131. Your COBOL/400 program can perform any valid character operations on the fixed-length fields.
133
where n is the number of characters in the DDS field. If you specify CVTOPT( VARCHAR NOGRAPHIC), and the compiler encounters a variable-length DBCS-graphic data item, the resulting program contains the following: 6 NAME (Variable-length field) 49 NAME-LENGTH PIC S9(4) COMP-4. (Number of 2-byte characters) 49 FILLER PIC X(2n). (Graphic field) where n is the number of characters in the DDS field. If you specify CVTOPT( VARCHAR GRAPHIC), and the compiler encounters a variablelength DBCS-graphic data item, the resulting program contains the following: 6 NAME (Variable-length field) 49 NAME-LENGTH PIC S9(4) COMP-4. (Number of 2-byte characters) 49 NAME-DATA PIC X(2n). (Graphic field) where n is the number of characters in the DDS field.
Examples
Figure 52 on page 135 shows an example of a DDS file that defines a variablelength DBCS-graphic data item. Figure 53 on page 136 shows the COBOL/400 program using a COPY DDS statement, and the resulting listing when the program is compiled.
134
A A A A A A A A A A
R SAMPLEFILE VARITEM TIMEITEM DATEITEM TIMESTAMP GRAPHITEM VGRAPHITEM 1 1 1 T L Z G G VARLEN TIMFMT( HMS) DATFMT( YMD)
VARLEN
135
5763CB1 V3R M5 1 IBM SAA COBOL/4 TESTER/PGM1 AS4 SYS 4/24/94 8:55:54 Program . . . . . . . . . . . . . . : PGM1 Library . . . . . . . . . . . . . : TESTER Source file . . . . . . . . . . . . : QLBLSRC Library . . . . . . . . . . . . . : TESTER Source member . . . . . . . . . . . : PGM1 4/24/94 8:23: 6 Generation severity level . . . . . : 29 Text 'description' . . . . . . . . . : Data types example Source listing options . . . . . . . : NONE Generation options . . . . . . . . . : NONE Conversion options . . . . . . . . . : VARCHAR DATETIME GRAPHIC Message limit: Number of messages . . . . . . . . : NOMAX Message limit severity . . . . . . : 29 Print file . . . . . . . . . . . . . : QSYSPRT Library . . . . . . . . . . . . . : LIBL FIPS flagging . . . . . . . . . . . : NOFIPS NOSEG NODEB NOOBSOLETE SAA flagging . . . . . . . . . . . . : NOFLAG Extended display options . . . . . . : Flagging severity . . . . . . . . . : Replace program . . . . . . . . . . : YES Target release . . . . . . . . . . . : CURRENT User profile . . . . . . . . . . . . : USER Authority . . . . . . . . . . . . . : LIBCRTAUT Compiler . . . . . . . . . . . . . . : IBM SAA COBOL/4 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/PGM1 AS4 SYS 4/24/94 8:55:54 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 1 Identification division. 1/ 2/94 2 2 Program-id. pgm1. 2/13/94 3 3 Environment division. 1/ 2/94 4 4 Configuration section. 1/ 2/94 5 5 Source-computer. ibm-as4 . 1/ 2/94 6 6 Object-computer. ibm-as4 . 1/ 2/94 7 7 Input-output section. 1/ 2/94 8 8 File-control. 1/ 2/94 9 9 Select file1 4/23/94 1 1 assign to database-samplefile 2/13/94 11 11 organization is sequential 4/23/94 12 12 access is sequential 4/23/94 13 13 file status is fs1. 4/23/94 14 14 Data division. 1/ 2/94 15 15 File section. 1/ 2/94 16 16 fd file1. 1/ 2/94 17 17 1 record1. 1/ 2/94 18 18 copy dds-all-formats of samplefile. 2/13/94 19 + 1 5 SAMPLEFILE-RECORD PIC X(546). <-ALL-FMTS + 2 I-O FORMAT:SAMPLEFILE FROM FILE SAMPLEFILE OF LIBRARY TESTER <-ALL-FMTS + 3 <-ALL-FMTS 2 + 4 5 SAMPLEFILE REDEFINES SAMPLEFILE-RECORD. <-ALL-FMTS 21 + 5 6 VARITEM. <-ALL-FMTS + 6 (Variable length field) <-ALL-FMTS 22 + 7 49 VARITEM-LENGTH PIC S9(4) COMP-4. <-ALL-FMTS 23 + 8 49 VARITEM-DATA PIC X(1 ). <-ALL-FMTS 24 + 9 6 TIMEITEM PIC X(8). <-ALL-FMTS + 1 (Time field) <-ALL-FMTS 25 + 11 6 DATEITEM PIC X(8). <-ALL-FMTS + 12 (Date field) <-ALL-FMTS 26 + 13 6 TIMESTAMP PIC X(26). <-ALL-FMTS + 14 (Timestamp field) <-ALL-FMTS 27 + 15 6 GRAPHITEM PIC X(2 ). <-ALL-FMTS + 16 (Graphic field) <-ALL-FMTS 28 + 17 6 VGRAPHITEM. <-ALL-FMTS + 18 (Variable length field) <-ALL-FMTS 29 + 19 49 VGRAPHITEM-LENGTH PIC S9(4) COMP-4. <-ALL-FMTS + 2 (Number of 2-byte characters) <-ALL-FMTS 3 + 21 49 VGRAPHITEM-DATA PIC X(2 ). <-ALL-FMTS + 22 (Graphic field) <-ALL-FMTS 31 19 working-storage section. 4/22/94 32 2 77 fs1 pic x(2). 4/23/94 33 21 Procedure division. 1/ 9/94 22 Mainline. 1/ 2/94 34 23 stop run. 1/ 2/94 E N D O F S O U R C E 5738CB1 V2R2M 1 AS/4 COBOL Messages TESTER/PGM1 AS4 SYS 4/24/94 8:55:54 STMT 16 MSGID: LBL 65 SEVERITY: SEQNBR: 16 Message . . . . : Blocking/Deblocking for file 'FILE1' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 23 Copy records read . . . . . . . . . : 22 Copy members processed . . . . . . : 1 Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program PGM1 created in library TESTER. E N D O F C O M P I L A T I O N
Page
Page
Page
136
137
138
139
Control display management functions such as when fields are to be erased, overlaid, or retained when new data is displayed. Associate indicators 01 through 99 with function keys designated as type CA or CF. If a function key is designated as CF, both the modified data record and the response indicator are returned to the program. If a function key is designated as CA, the response indicator is returned to the program, but the data record usually contains default values for input-only fields and values written to the format for hidden output/input fields. For more information about type CF and CA function keys, see the DDS Reference. Assign an edit code (EDTCDE keyword) or edit word (EDTWRD keyword) to a field to specify how the fields values are to be displayed. Specify subfiles. Display format data defines or describes a display. A display device record format contains three types of fields:
Input Fields: Input fields pass from the device to the program when the program reads a record. Input fields can be initialized with a default value; if the default value is not changed, the default value passes to the program. Uninitialized input fields are displayed as blanks where the work station user can enter data. Output Fields: Output fields pass from the program to the device when the program writes a record to a display. The program or the record format in the device file can provide output fields. Output/Input (both) Fields: An output/input field is an output field that can be changed to become an input field. Output/input fields pass from the program when the program writes a record to a display and pass to the program when the program reads a record from the display. Output/input fields are used when the user is to change or update the data that is written to the display from the program.
140
For a detailed description of a data communications file, see the ICF Programmers Guide. For more information on externally defined display files, see the Data Management Guide. For a list of the valid data description specifications (DDS) keywords, see the DDS Reference. Figure 54 shows an example of the DDS for a display device file:
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 2 2 23 2 4 25 2 6 27 28 29 30 3 1 3 2 33 3 4 35 3 6 37 38 39 40 4 1 4 2 43 4 4 45 4 6 47 48 49 50 5 1 5 2 5 3 5 4 55 5 6 57 5 8 5 9 60 6 1 6 2 6 3 6 4 65 6 6 67 6 8 6 9 70 7 1 7 2 7 3 7 4 75 7 6 77 7 8 7 9 80
F I LE
- -
C U S M I NQ R E F ( CU SMS T P ) T E X T ( ' C U S T OME R P R OMP T ' ) C A 0 3 ( 1 5 ' E ND O F P R OGR AM ) 3 ' C U S T OME R MA S T E R I NQU I R Y ' 3 ' C U S T OME R N UMB E R ' 2/ 0 E R R M S G ( ' C U S T OME R N UMB E R NO T F OU ND + P R E S S R E S E T , T H E N E N T E R V A L I D N UMB E + R ' 99 ) 3 ' U S E F 3 T O E ND P R OG R AM , U S E E N T E R + T O R E T U R N T O P R OMP T S C R E E N ' T E X T ( ' C U S T OME R D I S P L A Y ' ) C A 0 3 ( 1 5 ' E ND O F P R OGR AM ' ) OV E R L A Y 3 ' N AME ' 11 3 ' AD D R E S S ' 11 3 'CI TY ' 11 3 ' S TAT E ' 11 2 1 ' Z I P COD E ' 31 3 ' A / R B A L A NC E ' 17
1 3 3
8 8 9 9 1/ 0 1/ 0 11 11 11 11 12 12
Figure 54. Example of the Data Description Specifications for a Display Device File
This display device file contains two record formats: CUSPMT and CUSFLDS. 1 The attributes for the fields in this file are defined in the CUSMSTP field reference file. For example, EDTCDE(J) is defined in CUSMSTP for the field ARBAL. The F3 key is associated with indicator 15, with which the user ends the program. The ERRMSG keyword identifies the error message that is displayed if indicator 99 is set on in the program that uses this record format.
2 3
141
The OVERLAY keyword is used for the record format CUSFLDS so that the CUSPMT record on the display will not be erased when the CUSFLDS record is written to the display. The constants such as Name, Address, and City describe the fields that are written out by the program. The line and position entries identify where the fields or constants are written on the display.
5 6
142
The rules for the ASSIGN clause are as follows: Device must be WORKSTATION If -SI is coded, file-name must refer to a file that has the file level keyword INDARA specified in its DDS. For more information about the ASSIGN clause, see ASSIGN Clause on page 172.
143
Special Considerations
The special considerations for the clauses used with the Boolean data follow. All other rules for clauses are the same as those for other data as described in the COBOL Program Structure section of the COBOL/400 Reference.
PICTURE Clause: An elementary Boolean data name is defined by a PICTURE containing a single 1. USAGE Clause: USAGE must be defined implicitly or explicitly as DISPLAY.
144
OCCURS Clause: When the OCCURS clause and the INDICATOR clause are both specified at an elementary level, a table of Boolean data items is defined with each element in the table corresponding to an external indicator. The first element in the table corresponds to the indicator number specified in the INDICATOR clause; the second element corresponds to the indicator that sequentially follows the indicator specified by the INDICATOR clause.
For example, if the following is coded, SWITCHES (1) corresponds to indicator 16, SWITCHES (2) corresponds to indicator 17,..., and SWITCHES (10) corresponds to indicator 25:
7 SWITCHES PIC 1 OCCURS 1 TIMES INDICATOR 16.
INDICATOR Clause: If indicator fields are in a separate indicator area, the INDICATOR clause associates an indicator defined in DDS with a Boolean data item. If indicator fields are in the record area, the INDICATOR clause is syntaxchecked, but is treated as a comment.
Integer-3 must have a value of 1 through 99. The INDICATOR clause must be specified at an elementary level only.
VALUE Clause: The VALUE clause specifies the initial content of a Boolean data item. The allowable values for Boolean literals are B"0", B"1", and ZERO. LIKE Clause: You cannot use this clause to change the length of the data item.
INDICATORS Phrase
When the INDICATORS phrase is used in READ, REWRITE, and WRITE statements (see Figure 57 on page 150), it specifies which indicators are to be read, rewritten, and written. The identifier specified in the INDICATORS phrase can be either of the following: An elementary Boolean data item A group item with elementary Boolean data items subordinate to it. (The Boolean data items can be anywhere in the group, but they are the only items you can read, write, or rewrite.) The identifier cannot be subordinate to an item that is subject to an OCCURS clause.
145
format but not referenced by the INDICATORS phrase are assumed to be OFF. Indicators referenced by the INDICATORS phrase but not used in the DDS for the format are ignored. If the INDICATORS phrase is not specified, the following occurs: In the READ statement, indicators are not updated. In a WRITE or REWRITE statement, indicators are treated as though they are set to OFF.
146
Figure 60 on page 155 shows a program that uses indicators in a separate indicator area, defined in a table in WORKING-STORAGE. The associated DDS for the file is the same as Figure 58 on page 152.
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P )
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 2 2 23 2 4 25 2 6 27 28 29 30 3 1 3 2 33 3 4 35 3 6 37 38 39 40 4 1 4 2 43 4 4 45 4 6 47 48 49 50 5 1 5 2 5 3 5 4 55 5 6 57 5 8 5 9 60 6 1 6 2 6 3 6 4 65 6 6 67 6 8 6 9 70 7 1 7 2 7 3 7 4 75 7 6 77 7 8 7 9 80
A* A* A A A A* A A A A A* A A A A A A A A A A A A A A A A A A A
D I S P L AY R
F I LE
DD S
F OR
I ND I CA T OR
E X AMP L E S CF CF CF
F OR MA T 1
/ 3( 99 0 0 /5(51 0 / 9( 52
D E P T NO 01
10 10 20
1 0 ' D E P A R T ME N T N UMB E R : ' 32 2 6 ' P R OD U C E MON T H L Y R E P OR T S ' DSPAT R ( B L ) 01 ' F5 26 ' F9 53 ' F3 = D A I L Y R E P OR T ' = MON T H L Y R E P OR T ' = T E RM I NA T E '
24 24 24
Figure 55. Example of a Program Using Indicators in the Record Area without Using the INDICATORS Phrase in the I/O StatementData Description Specifications
1 2 3 4 5 6
The INDARA keyword is not used; indicators are stored in the record area with the data fields. One record format, FORMAT1, is specified. Three indicators are associated with three function keys. Indicator 99 will be set on when you press F3, and so on. One field is defined for input. Indicator 01 is defined to cause the associated constant field to blink if the indicator is on. The function (F) key definitions are documented on the work station display.
147
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLE71. 3 PROGRAM EXAMPLE WITH INDICATORS IN RECORD AREA. 3 4 AUTHOR. PROGRAMMER NAME. 4 5 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 6 DATE-WRITTEN. 12/ 8/88. 6 7 DATE-COMPILED. 5/24/94 11: 2:36 . 7 8 ENVIRONMENT DIVISION. 8 9 CONFIGURATION SECTION. 9 1 SOURCE-COMPUTER. IBM-AS4 . 1 11 OBJECT-COMPUTER. IBM-AS4 . 11 12 INPUT-OUTPUT SECTION. 12 13 FILE-CONTROL. 13 14 SELECT DISPFILE 14 15 ASSIGN TO WORKSTATION-DSPFILEX 1 15 16 ORGANIZATION IS TRANSACTION 16 17 ACCESS IS SEQUENTIAL. 17 18 DATA DIVISION. 18 19 FILE SECTION. 19 2 FD DISPFILE 2 21 LABEL RECORDS ARE OMITTED 21 22 DATA RECORD IS DISP-REC. 22 23 1 DISP-REC. 23 24 COPY DDS-ALL-FORMATS OF DSPFILEX. 2 24 + 1 5 DSPFILEX-RECORD PIC X(8). + 2 INPUT FORMAT:FORMAT1 FROM FILE DSPFILEX OF LIBRARY XMPLIB + 3 25 + 4 5 FORMAT1-I REDEFINES DSPFILEX-RECORD. 26 + 5 6 FORMAT1-I-INDIC. 27 + 6 7 IN99 PIC 1 INDIC 99. 3 + 7 END OF PROGRAM 28 + 8 7 IN51 PIC 1 INDIC 51. + 9 DAILY REPORT 29 + 1 7 IN52 PIC 1 INDIC 52. + 11 MONTHLY REPORT 3 + 12 6 DEPTNO PIC X(5). + 13 OUTPUT FORMAT:FORMAT1 FROM FILE DSPFILEX OF LIBRARY XMPLIB + 14 31 + 15 5 FORMAT1-O REDEFINES DSPFILEX-RECORD. 32 + 16 6 FORMAT1-O-INDIC. 33 + 17 7 IN 1 PIC 1 INDIC 1. 25 34 26 WORKING-STORAGE SECTION. 35 27 1 CURRENT-DATE. 36 28 5 CURR-YEAR PIC 9(2). 37 29 5 CURR-MONTH PIC 9(2). 38 3 5 CURR-DAY PIC 9(2). 39 31 1 INDIC-AREA. 4 4 32 5 IN 1 PIC 1. 41 33 88 NEW-MONTH 5 VALUE B"1". 42 34 5 IN51 PIC 1. 43 35 88 WANT-DAILY VALUE B"1". 44 36 5 IN52 PIC 1. 45 37 88 WANT-MONTHLY VALUE B"1". 46 38 5 IN99 PIC 1. 47 39 88 NOT-END-OF-JOB VALUE B" ". 48 4 88 END-OF-JOB VALUE B"1". 49 41 PROCEDURE DIVISION. 42 XAMPLE3-MAIN. 5 43 OPEN I-O DISPFILE. 51 44 ACCEPT CURRENT-DATE FROM DATE. 52 45 SET NOT-END-OF-JOB TO TRUE. 53 46 PERFORM DISPLAY-SCREEN THRU READ-AND-PROCESS-SCREEN 47 UNTIL END-OF-JOB. 54 48 CLOSE DISPFILE. 55 49 STOP RUN. 5 DISPLAY-SCREEN. 56 51 MOVE ZEROS TO INDIC-AREA. 6 57 52 IF CURR-DAY = 1 THEN 58 53 SET NEW-MONTH TO TRUE. 7 59 54 MOVE CORR INDIC-AREA TO FORMAT1-O-INDIC. 8 6 55 WRITE DISP-REC FORMAT IS "FORMAT1". 9 56 READ-AND-PROCESS-SCREEN. 61 57 MOVE ZEROS TO INDIC-AREA. 62 58 READ DISPFILE FORMAT IS "FORMAT1". 1
COPYNAME
CHG DATE 3/ 9/94 3/22/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/25/94 3/25/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
Figure 56 (Part 1 of 2). Example of a Program Using Indicators in the Record Area without Using the INDICATORS Phrase in the I/O StatementCOBOL Source Program
148
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 63 59 MOVE CORR FORMAT1-I-INDIC TO INDIC-AREA. 11 64 6 IF WANT-DAILY THEN 65 61 CALL "DAILY" USING DEPTNO 12 62 ELSE 66 63 IF WANT-MONTHLY THEN 67 64 CALL "MONTHLY" USING DEPTNO. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) Source records read . . . . . . . . : Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program XMPLE71 created in E N D 64 17 1
COPYNAME
CHG DATE
library XMPLIB. O F C O M P I L A T I O N
Figure 56 (Part 2 of 2). Example of a Program Using Indicators in the Record Area without Using the INDICATORS Phrase in the I/O StatementCOBOL Source Program
1 2 3
The separate indicator area attribute, SI, is not coded in the ASSIGN clause. The Format 2 COPY statement defines data fields and indicators in the record area. Because the file does not have a separate indicator area, response and option indicators are defined in the order in which they are used in the DDS, and the indicator numbers are treated as documentation. All indicators used by the program are defined with meaningful names in data description entries in WORKING-STORAGE. Indicator numbers are omitted here because they have no effect. For each indicator, a meaningful level-88 condition-name is associated with a value for that indicator. Initialize group level to zeros. IN01 in WORKING-STORAGE is set on if it is the first day of the month. Indicators appropriate to the output of FORMAT1 are copied to the record area. FORMAT1 is written to the work station display with both data and indicator values in the record area. The INDICATORS phrase is not necessary because there is no separate indicator area and indicator values have been set in the record area through the previous MOVE CORRESPONDING statement.
5 6 7 8 9
1 11 12
FORMAT1, including both data and indicators, is read from the display. The response indicators for FORMAT1 are copied from the record area to the data description entries in WORKING-STORAGE. If F5 has been pressed, a program call is processed.
149
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLE713. 3 SAMPLE PROGRAM - FILE WITH INDICATORS IN RECORD AREA 3 4 AUTHOR. PROGRAMMER NAME. 4 5 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 6 DATE-WRITTEN. 12/1 /88. 6 7 DATE-COMPILED. 5/24/94 11: 4:34 . 7 8 ENVIRONMENT DIVISION. 8 9 CONFIGURATION SECTION. 9 1 SOURCE-COMPUTER. IBM-AS4 . 1 11 OBJECT-COMPUTER. IBM-AS4 . 11 12 INPUT-OUTPUT SECTION. 12 13 FILE-CONTROL. 13 14 SELECT DISPFILE 14 15 ASSIGN TO WORKSTATION-DSPFILEX 1 15 16 ORGANIZATION IS TRANSACTION 16 17 ACCESS IS SEQUENTIAL. 17 18 DATA DIVISION. 18 19 FILE SECTION. 19 2 FD DISPFILE 2 21 LABEL RECORDS ARE OMITTED 21 22 DATA RECORD IS DISP-REC. 22 23 1 DISP-REC. 23 24 COPY DDS-ALL-FORMATS OF DSPFILEX. 2 24 + 1 5 DSPFILEX-RECORD PIC X(8). + 2 INPUT FORMAT:FORMAT1 FROM FILE DSPFILEX OF LIBRARY XMPLIB + 3 25 + 4 5 FORMAT1-I REDEFINES DSPFILEX-RECORD. 26 + 5 6 FORMAT1-I-INDIC. 27 + 6 7 IN99 PIC 1 INDIC 99. 3 + 7 END OF PROGRAM 28 + 8 7 IN51 PIC 1 INDIC 51. + 9 DAILY REPORT 29 + 1 7 IN52 PIC 1 INDIC 52. + 11 MONTHLY REPORT 3 + 12 6 DEPTNO PIC X(5). + 13 OUTPUT FORMAT:FORMAT1 FROM FILE DSPFILEX OF LIBRARY XMPLIB + 14 31 + 15 5 FORMAT1-O REDEFINES DSPFILEX-RECORD. 32 + 16 6 FORMAT1-O-INDIC. 33 + 17 7 IN 1 PIC 1 INDIC 1. 25 34 26 WORKING-STORAGE SECTION. 35 27 1 CURRENT-DATE. 36 28 5 CURR-YEAR PIC 9(2). 37 29 5 CURR-MONTH PIC 9(2). 38 3 5 CURR-DAY PIC 9(2). 31 39 32 77 IND-OFF PIC 1 VALUE B" ". 4 33 77 IND-ON PIC 1 VALUE B"1". 34 41 35 1 RESPONSE-INDICS. 42 36 5 END-OF-PROGRAM PIC 1. 4 43 37 5 DAILY-REPORT PIC 1. 44 38 5 MONTHLY-REPORT PIC 1. 45 39 1 OPTION-INDICS. 46 4 5 NEW-MONTH PIC 1. 41 47 42 PROCEDURE DIVISION. 43 XMPLE3-MAIN. 48 44 OPEN I-O DISPFILE. 49 45 ACCEPT CURRENT-DATE FROM DATE. 5 46 MOVE IND-OFF TO END-OF-PROGRAM. 51 47 PERFORM DISPLAY-SCREEN THRU READ-AND-PROCESS-SCREEN 48 UNTIL END-OF-PROGRAM = IND-ON. 52 49 CLOSE DISPFILE. 53 5 STOP RUN. 51 52 DISPLAY-SCREEN. 54 53 MOVE ZEROS TO OPTION-INDICS. 55 54 IF CURR-DAY = 1 THEN 5 56 55 MOVE IND-ON TO NEW-MONTH. 57 56 WRITE DISP-REC FORMAT IS "FORMAT1" 6 57 INDICATORS ARE OPTION-INDICS. 58
COPYNAME
CHG DATE 3/ 7/94 3/22/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/22/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/22/94
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
Figure 57 (Part 1 of 2). Example of a Program Using Indicators in the Record Area and the INDICATORS phrase in the I/O StatementsCOBOL Source Program
150
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 59 READ-AND-PROCESS-SCREEN. 58 6 MOVE ZEROS TO RESPONSE-INDICS. 59 61 READ DISPFILE FORMAT IS "FORMAT1" 7 62 INDICATORS ARE RESPONSE-INDICS. 8 6 63 IF DAILY-REPORT = IND-ON THEN 61 64 CALL "DAILY" USING DEPTNO 9 65 ELSE 62 66 IF MONTHLY-REPORT = IND-ON THEN 63 67 CALL "MONTHLY" USING DEPTNO. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) Source records read . . . . . . . . : 67 Copy records read . . . . . . . . . : 17 Copy members processed . . . . . . : 1 Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program XMPLE713 created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
Figure 57 (Part 2 of 2). Example of a Program Using Indicators in the Record Area and the INDICATORS phrase in the I/O StatementsCOBOL Source Program
1 2 3
The separate indicator area attribute, SI, is not coded in the ASSIGN clause. The Format 2 COPY statement defines data fields and indicators in the record area. Because the file does not have a separate indicator area, response and option indicators are defined in the order in which they are used in the DDS, and the indicator numbers are treated as documentation. All indicators used by the program are defined with meaningful names in data description entries in WORKING-STORAGE. Indicator numbers are omitted here because they have no effect. Indicators should be defined in the order needed by the display file. IN01 in WORKING-STORAGE is set on if it is the first day of the month. FORMAT1 is written to the work station display: The INDICATORS phrase causes the contents of the variable OPTION-INDICS to be copied to the beginning of the record area. Data and indicator values are written to the work station display.
5 6
7 8 9
FORMAT1, including both data and indicators, is read from the work station display. The INDICATORS phrase causes bytes to be copied from the beginning of the record area to RESPONSE-INDICS. If F5 has been pressed, a program call is processed.
151
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1 52 53 54 55 56 57 58 59 60 6 1 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
A* A* A A A A A* A A A A A* A A A A A A A A A A A A A A A A A A
D I S P L AY
F I LE
DD S
F OR
I ND I CA T OR
E X AMP L E S I ND A R A CF 0 3 ( 9 9 CF 0 5 ( 5 1 CF 0 9 ( 5 2
F OR MA T 1
D E P T NO 01
10 10 20
1 0 ' D E P A R T ME N T N UMB E R : ' 32 2 6 ' P R OD U C E MON T H L Y R E P OR T S ' DSPAT R ( B L ) 01 ' F5 26 ' F9 53 ' F3 = D A I L Y R E P OR T ' = MON T H L Y R E P OR T ' = T E RM I NA T E '
24 24 24
Figure 58. Example of a Program Using Indicators in a Separate Indicator Area, Defined in WORKING-STORAGE by Using the COPY Statement, DDS Format
The INDARA keyword is specified; indicators are stored in a separate indicator area, not in the record area. Except for this specification, the DDS for this file is the same as that shown in Figure 55 on page 147.
152
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLE717. 3 SAMPLE PROGRAM - FILE WITH SEPARATE INDICATORS AREA 3 4 AUTHOR. PROGRAMMER NAME. 4 5 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 6 DATE-WRITTEN. 12/ 8/88. 6 7 DATE-COMPILED. 5/24/94 12:53:17 . 7 8 ENVIRONMENT DIVISION. 8 9 CONFIGURATION SECTION. 9 1 SOURCE-COMPUTER. IBM-AS4 . 1 11 OBJECT-COMPUTER. IBM-AS4 . 11 12 INPUT-OUTPUT SECTION. 12 13 FILE-CONTROL. 13 14 SELECT DISPFILE 14 15 ASSIGN TO WORKSTATION-DSPFILE-SI 1 15 16 ORGANIZATION IS TRANSACTION 16 17 ACCESS IS SEQUENTIAL. 18 17 19 DATA DIVISION. 18 2 FILE SECTION. 19 21 FD DISPFILE 2 22 LABEL RECORDS ARE OMITTED 21 23 DATA RECORD IS DISP-REC. 22 24 1 DISP-REC. 23 25 COPY DDS-ALL-FORMATS OF DSPFILE. 2 24 + 1 5 DSPFILE-RECORD PIC X(5). + 2 INPUT FORMAT:FORMAT1 FROM FILE DSPFILE OF LIBRARY XMPLIB + 3 25 + 4 5 FORMAT1-I REDEFINES DSPFILE-RECORD. 26 + 5 6 DEPTNO PIC X(5). + 6 OUTPUT FORMAT:FORMAT1 FROM FILE DSPFILE OF LIBRARY XMPLIB + 7 + 8 5 FORMAT1-O REDEFINES DSPFILE-RECORD. 26 27 27 WORKING-STORAGE SECTION. 28 28 1 CURRENT-DATE. 29 29 5 CURR-YEAR PIC 9(2). 3 3 5 CURR-MONTH PIC 9(2). 31 31 5 CURR-DAY PIC 9(2). 32 32 33 77 IND-OFF PIC 1 VALUE B" ". 33 34 77 IND-ON PIC 1 VALUE B"1". 34 35 1 DISPFILE-INDICS. 35 36 COPY DDS-ALL-FORMATS-INDIC OF DSPFILE. 3 36 + 1 5 DSPFILE-RECORD. + 2 INPUT FORMAT:FORMAT1 FROM FILE DSPFILE OF LIBRARY XMPLIB + 3 37 + 4 6 FORMAT1-I-INDIC. 38 + 5 7 IN51 PIC 1 INDIC 51. 4 + 6 DAILY REPORT 39 + 7 7 IN52 PIC 1 INDIC 52. + 8 MONTHLY REPORT 4 + 9 7 IN99 PIC 1 INDIC 99. + 1 END OF PROGRAM + 11 OUTPUT FORMAT:FORMAT1 FROM FILE DSPFILE OF LIBRARY XMPLIB + 12 41 + 13 6 FORMAT1-O-INDIC. 42 + 14 7 IN 1 PIC 1 INDIC 1. 37 43 38 PROCEDURE DIVISION. 39 4 MAIN-PROCESS. 41 44 42 OPEN I-O DISPFILE. 45 43 ACCEPT CURRENT-DATE FROM DATE. 46 44 MOVE IND-OFF TO IN99 IN FORMAT1-I-INDIC. 47 45 PERFORM DISPLAY-SCREEN THRU READ-AND-PROCESS-SCREEN 46 UNTIL IN99 IN FORMAT1-I-INDIC = IND-ON. 48 47 CLOSE DISPFILE. 49 48 STOP RUN. 49 5 DISPLAY-SCREEN. 51 5 52 MOVE ZEROS TO FORMAT1-O-INDIC. 51 53 IF CURR-DAY = 1 THEN 52 54 MOVE IND-ON TO IN 1 IN FORMAT1-O-INDIC. 5
COPYNAME
CHG DATE 3/ 9/94 3/22/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/22/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/ 9/94 3/22/94
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
Figure 59 (Part 1 of 2). COBOL Listing Using Indicators in a Separate Indicator Area
153
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 53 55 WRITE DISP-REC FORMAT IS "FORMAT1" 56 INDICATORS ARE FORMAT1-O-INDIC. 6 57 58 READ-AND-PROCESS-SCREEN. 59 54 6 MOVE ZEROS TO FORMAT1-I-INDIC. 55 61 READ DISPFILE FORMAT IS "FORMAT1" 62 INDICATORS ARE FORMAT1-I-INDIC. 7 56 63 IF IN51 IN FORMAT1-I-INDIC = IND-ON THEN 57 64 CALL "DAILY" USING DEPTNO 8 65 ELSE 58 66 IF IN52 IN FORMAT1-I-INDIC = IND-ON THEN 59 67 CALL "MONTHLY" USING DEPTNO. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 23 MSGID: LBL 6 SEVERITY: 1 SEQNBR: 25 Message . . . . : No OUTPUT fields found for format FORMAT1. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 67 Copy records read . . . . . . . . . : 22 Copy members processed . . . . . . : 2 Sequence errors . . . . . . . . . . : Highest severity message issued . . : 1 LBL 9 1 Program XMPLE717 created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
Figure 59 (Part 2 of 2). COBOL Listing Using Indicators in a Separate Indicator Area
1 2
The separate indicator area attribute, SI, is specified in the ASSIGN clause. The Format 2 COPY statement generates data descriptions in the record area for data fields only. The data description entries for the indicators are not generated because a separate indicator area has been specified for the file. The Format 2 COPY statement, with the INDICATOR attribute, INDIC, defines data description entries in WORKING-STORAGE for all indicators used in the DDS for the record format for the file. Because the file has a separate indicator area, the indicator numbers used in the data description entries are not treated as documentation. IN01 in the separate indicator area for FORMAT1 is set on if it is the first day of the month. The INDICATORS phrase is required to send indicator values to the work station display. The INDICATORS phrase is required to receive indicator values from the work station display. If you have pressed F5, IN51 is set on. If IN51 has been set on, a program call is processed.
4 5 6 7 8
154
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLE72 . 3 PROGRAM EXAMPLE 4 FILE WITH SEPARATE INDICATORS AREA IN WORKING STORAGE 3 5 AUTHOR. PROGRAMMER NAME. 4 6 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 7 DATE-WRITTEN. 12/ 8/88. 6 8 DATE-COMPILED. 5/24/94 12:46: . 7 9 ENVIRONMENT DIVISION. 8 1 CONFIGURATION SECTION. 9 11 SOURCE-COMPUTER. IBM-AS4 . 1 12 OBJECT-COMPUTER. IBM-AS4 . 11 13 INPUT-OUTPUT SECTION. 12 14 FILE-CONTROL. 13 15 SELECT DISPFILE 14 16 ASSIGN TO WORKSTATION-DSPFILE-SI 1 15 17 ORGANIZATION IS TRANSACTION 16 18 ACCESS IS SEQUENTIAL. 19 17 2 DATA DIVISION. 18 21 FILE SECTION. 19 22 FD DISPFILE 2 23 LABEL RECORDS ARE OMITTED 21 24 DATA RECORD IS DISP-REC. 22 25 1 DISP-REC. 23 26 COPY DDS-ALL-FORMATS OF DSPFILE. 2 24 + 1 5 DSPFILE-RECORD PIC X(5). + 2 INPUT FORMAT:FORMAT1 FROM FILE DSPFILE OF LIBRARY XMPLIB + 3 25 + 4 5 FORMAT1-I REDEFINES DSPFILE-RECORD. 26 + 5 6 DEPTNO PIC X(5). + 6 OUTPUT FORMAT:FORMAT1 FROM FILE DSPFILE OF LIBRARY XMPLIB + 7 + 8 5 FORMAT1-O REDEFINES DSPFILE-RECORD. 27 27 28 WORKING-STORAGE SECTION. 28 29 1 CURRENT-DATE. 29 3 5 CURR-YEAR PIC 9(2). 3 31 5 CURR-MONTH PIC 9(2). 31 32 5 CURR-DAY PIC 9(2). 33 32 34 1 INDIC-AREA. 33 35 5 INDIC-TABLE OCCURS 99 PIC 1 INDICATOR 1. 3 34 36 88 IND-OFF VALUE B" ". 35 37 88 IND-ON VALUE B"1". 38 36 39 1 DISPFILE-INDIC-USAGE. 37 4 5 IND-NEW-MONTH PIC 9(2) VALUE 1. 38 41 5 IND-DAILY PIC 9(2) VALUE 51. 4 39 42 5 IND-MONTHLY PIC 9(2) VALUE 52. 4 43 5 IND-EOJ PIC 9(2) VALUE 99. 44 41 45 PROCEDURE DIVISION. 46 47 XMPLE-MAIN. 42 48 OPEN I-O DISPFILE. 43 49 ACCEPT CURRENT-DATE FROM DATE. 44 5 SET IND-OFF (IND-EOJ) TO TRUE. 45 51 PERFORM DISPLAY-SCREEN THRU READ-AND-PROCESS-SCREEN 52 UNTIL IND-ON (IND-EOJ). 46 53 CLOSE DISPFILE. 47 54 STOP RUN. 55 56 DISPLAY-SCREEN. 57 48 58 MOVE ZEROS TO INDIC-AREA. 49 59 IF CURR-DAY = 1 THEN 5 6 SET IND-ON (IND-NEW-MONTH) TO TRUE. 5 51 61 WRITE DISP-REC FORMAT IS "FORMAT1" 62 INDICATORS ARE INDIC-TABLE. 6 63 64 READ-AND-PROCESS-SCREEN. 65 52 66 READ DISPFILE FORMAT IS "FORMAT1" 67 INDICATORS ARE INDIC-TABLE. 7
COPYNAME
CHG DATE 1/22/94 3/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 3/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 3/22/94
Figure 60 (Part 1 of 2). Example of a Program Using Indicators in a Separate Indicator Area, Defined in a Table in WORKING-STORAGE
Chapter 8. Transaction Files
155
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 53 68 IF IND-ON (IND-DAILY) THEN 8 54 69 CALL "DAILY" USING DEPTNO 7 ELSE 55 71 IF IND-ON (IND-MONTHLY) THEN 56 72 CALL "MONTHLY" USING DEPTNO. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 23 MSGID: LBL 6 SEVERITY: 1 SEQNBR: 26 Message . . . . : No OUTPUT fields found for format FORMAT1. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 72 Copy records read . . . . . . . . . : 8 Copy members processed . . . . . . : 1 Sequence errors . . . . . . . . . . : Highest severity message issued . . : 1 LBL 9 1 Program XMPLE72 created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
Figure 60 (Part 2 of 2). Example of a Program Using Indicators in a Separate Indicator Area, Defined in a Table in WORKING-STORAGE
1 2 3
The separate indicator area attribute, SI, is specified in the ASSIGN clause. The Format 2 COPY statement generates fields in the record area for data fields only. A table of 99 Boolean data items is defined in WORKING-STORAGE. The INDICATOR clause for this data description entry causes these data items to be associated with indicators 1 through 99 respectively. The use of such a table may result in improved performance as compared to the use of a group item with multiple subordinate entries for individual indicators. A series of data items is defined in WORKING-STORAGE to provide meaningful subscript names with which to refer to the table of indicators. The use of such data items is not required. INDIC-TABLE (01) in the separate indicator area for FORMAT1 is set on if it is the first day of the month. The INDICATOR phrase is required to send indicator values to the work station display. The INDICATOR phrase is required to receive indicator values from the work station display. If F5 has been pressed, INDIC-TABLE (51) will be set on. If INDIC-TABLE (51) has been set on, program DAILY is called.
5 6 7 8
Subfiles
Subfiles can be specified in the DDS for a display file to allow you to handle multiple records of the same type on a display. See Figure 61 on page 157 for an example of a subfile display. A subfile is a group of records that are read from or written to a display device. The program processes one record at a time, but the operating system and the work station send and receive blocks of records. If more records are transmitted than can be shown on the display at one time, the work station operator can page through the block of records without returning control to the program.
156
Records to be included in a subfile are specified in the DDS for the file. The number of records that can be contained in a subfile must also be specified in the DDS. One file can contain more than one subfile; however, only twelve subfiles can be active concurrently for a device. Twelve subfiles can be displayed on a device at the same time. The DDS for a subfile consists of two record formats: a subfile record format and a subfile control record format. The subfile record format contains the field descriptions for the records in the subfile. Specifications of the subfile record format on a READ, WRITE, or REWRITE causes the specified subfile record to be processed, but does not directly affect the displayed data. Specification of the subfile control record format on the READ or WRITE statement causes the physical read, write, or setup operations of a subfile to take place. Figure 62 on page 159 shows an example of the DDS for a subfile record format, and Figure 63 on page 161 shows an example of the DDS for a subfile control record format. For a description of how the records in a subfile can be displayed and for a description of the keywords that can be specified for a subfile, see the Data Management Guide and also the DDS Reference.
Customer Name Search Search Code Number Name XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX _____ Address XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX City XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX State XX XX XX XX XX XX XX XX XX XX XX XX XX XX
To use a subfile for a display file in a COBOL program, you must specify the SUBFILE phrase with the input/output operation. Valid subfile operations are: READ SUBFILE file-name RECORD WRITE SUBFILE record-name REWRITE SUBFILE record-name.
157
Subfiles can be processed sequentially with the READ SUBFILE NEXT MODIFIED statement, or processed randomly by specifying a relative key value. A relative key is an unsigned number that can be used directly by the system to locate a record in a file. The TRANSACTION file must be an externally defined file. In COBOL, all access to the subfile is done with a relative record number. If the SUBFILE phrases are used with a TRANSACTION file, the SELECT statement in the Environment Division must state that ACCESS MODE IS DYNAMIC and must specify the RELATIVE KEY to be used. If more than one display device is acquired by a display file, there is a separate subfile for each individual display device. If a subfile has been created for a particular display device acquired by a TRANSACTION file, all input operations that refer to a record format for the subfile are performed against the subfile belonging to that device. See the discussion on the TERMINAL phrase on page 182 of this chapter for information about how to determine which device is used. Any operations that reference a record format name that is not designated as a subfile are processed as an input/output operation directly to the display device.
Use of Subfiles
Some typical uses of subfiles include:
Use Display Only Display With Selection Modification Input Only (with no validity checking) Input Only (with validity checking) Combination of Tasks Meaning The work station user reviews the display. The user requests more information about one of the items on display. The user modifies one or more of the records. A subfile is used for a data-entry function. A subfile is used for a data-entry function, and the records are checked as well. A subfile can be used as a display with modification.
158
GX2 1- 98 91- 0 UM/05 0* Pr i nt ed i n U. S . A. * Number of sheet s per pad may var y sl i ghtl y. Page of
Conditioning
Location Us ag e ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 23 2 4 25 2 6 27 2 8 29 30 3 1 32 33 3 4 35 3 6 37 38 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A* A A A* A A A 51 A N5 1 A* A A 52 A 53 A 54 A* A A A A A 52 A 53 A 54 A* A A 52 A 53 A 54 A* A A A 55 A N5 6 A* A
DD S
UP DA T E
F OR C U S T OME R
P A Y ME N T ' )
AC P P M T
4 T E X T ( ' ACC E P T P A Y ME N T ' ) V A L U E S ( ' * Y E S ' ' * NO ' ) D S P A T R ( R I MD T ) D S P A T R ( ND P R ) 15TEXT ( DSPAT DSPAT DSPAT ' C U S T OME R R(R I ) R ( ND ) R ( PR ) N UMB E R ' )
CU S T
AMP A I D
02B
PA I D ' )
E CP MS G
3 1A
OV R P M T
8Y
2O
S T S CD E
1A
The data description specifications (DDS) for a subfile record format describe the records in the subfile: 1 2 3 4 5 The SFL keyword identifies the record format as a subfile. The line and position entries define the location of the fields on the display. The VALUES keyword specifies that the user can only specify *YES or *NO as values for the ACPPMT field. The usage entries define whether the named field is to be an output (O), input (I), output/input (B), or hidden (H) field. The entry CHECK(FE) specifies that the user cannot skip to the next input field without pressing one of the field exit keys.
159
The entry AUTO(RAB) specifies that data entered into the field AMPAID is to be automatically right-justified, and the leading characters are to be filled with blanks. The entry CMP(GT 0) specifies that the data entered for the field AMPAID is to be compared to zero to ensure that the value is greater than zero. The EDTCDE keyword specifies the desired editing for output field OVRPMT. EDTCDE(1) indicates that the field OVRPMT is to be printed with commas, decimal point, and no sign. Also, a zero balance will be printed, and leading zeros will be suppressed. The DSPATR keyword is used to specify the display attributes for the named field when the corresponding indicator status is true. The attributes specified are: BL (blink) RI (reverse image) PR (protect) MDT (set modified data tag) ND (nondisplay).
7 8
160
GX2 1- 98 91- 0 UM/05 0* Pr i nt ed i n U. S . A. * Number of sheet s per pad may var y sl i ghtl y. Page of
Conditioning
Location Us ag e ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 23 2 4 25 2 6 27 2 8 29 30 3 1 32 33 3 4 35 3 6 37 38 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A A A A A A A A A A* A A A A* A A A A* A A A A A A A A A A A A A A A A A
R CON T R O L 1
61 62 62
T E X T ( ' S U B F I L E CON T R O L ' ) S F L CT L ( S UB F I L E 1 ) SFL S I Z ( 17 ) S F L P AG ( 1 7 ) S F L CL R S F LDSP S F L DS PCT L OV E R L A Y L OC K HE L P ( 9 9 CA 1 2 ( 9 8 CA 1 1 ( 9 7 ' HE L P K E Y ' ) ' E ND P A Y ME N T U P D A T E ' ) ' I GNOR E I N P U T ' ) I GNOR E I N V A L I D I N P U T + F 1 2 - E ND P A Y ME N T +
99
S F L MS G ( ' F 1 1 U P DA T E ' ) 1 1 1 3 4 3 3 3
63 63
64
2 ' C U S T OME R P A Y ME N T U P D A T E 6 5 ' DA T E ' 7 8 D A T E E D T CD E ( Y ) 2 ' ACC E P T ' 2 ' P A Y ME N T ' 1 4 ' C U S T OME R ' 2 6 ' P A Y ME N T ' 3 7 ' E X C E P T I ON ME S S AG E '
P R OMP T '
Figure 63. Data Description Specifications for a Subfile Control Record Format
The subfile control record format defines the attributes of the subfile, the search input field, constants, and command keys. The keywords used indicate the following: 1 2 3 4 5 6 SFLCTL identifies this record as a subfile control record and names the associated subfile record (SUBFILE1). SFLSIZ indicates the total number of records to be included in the subfile (17). SFLPAG indicates the total number of records in a page (17). SFLCLR indicates when the subfile should be cleared (when indicator 61 is on). SFLDSP indicates when to display the subfile (when indicator 62 is on). SFLDSPCTL indicates when to display the subfile control record (when indicator 62 is on).
161
7 8 9
The LOCK keyword prevents the work station user from using the keyboard when the CONTROL1 record format is initially displayed. HELP allows the user to press the Help key and sets indicator 99 on. SFLMSG identifies the constant as a message that is displayed if indicator 99 is on.
In addition to the control information, the subfile control record format defines the constants to be used as column headings for the subfile record format. Refer to Figure 63 on page 161 for an example of the subfile control record format.
162
I n t e r n a t i o n a l B u s i n e s s Ma c h i n es
File Progr ammer Date
Conditioning
Location Us ag e ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
For m Type
Sequence Number
Indi cator
Indi cator
Not (N)
Decimal Po s i t i o n s
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 1 4 15 16 17 18 19 2 0 2 1 22 2 3 24 2 5 26 27 2 8 29 3 0 3 1 32 3 3 34 3 5 36 37 38 39 4 0 4 1 4 2 4 3 44 4 5 46 4 7 48 49 50 5 1 5 2 53 5 4 55 5 6 5 7 58 5 9 60 6 1 6 2 63 6 4 65 6 6 67 6 8 6 9 70 7 1 7 2 7 3 7 4 75 7 6 77 7 8 7 9 80
A* A * DD S F OR T H E MU L T I P L E D E V I C E D I S P L A Y F I L E A* A R S I GNON I NV I T E ///////// / / / / bbbbbb A O 5 2 0 ' b b b / / / / / / /b/b/b b b b b b b b b ' A DSPAT R ( R I ) / // A O 6 2 0 ' bb ' A DSPAT R ( R I ) // A O 6 3 8 ' bb ' A DSPAT R ( R I ) The f or mat SI GNON has / // A O 7 2 0 ' bb ' the keyword INVI TE A DSPAT R ( R I ) as s oc i a t e d wi t h i t . T h i s A O 7 27 'M D F ' A DSPAT R ( H I B L ) means that, i f f ormat SI GNON // A O 7 3 8 ' bb ' i s usA i n a WRI T E s t at ement , ed DSPAT R ( R I ) / // the A devi ce to whi ch i t i s O 8 2 0 ' bb ' DSPAT R ( R I ) wr i t iA wi l l be i nvi t ed. ng A O 8 3 8 ' bb ' // A DSPAT R ( R I ) / bbbbb //////////// A O 9 2 0 ' / / / / / /b/b/b/b b b b b b b b b b b b ' A DSPAT R ( R I ) / / A O 2 0 2 0 ' P L E A S E L OGON ' A DSPAT R ( H I ) A P A S SWOR D 1/ A 0 I 2 0 4 3 D S P A T R ( P C ND ) / A WR ONG 2/ A 0 O 21 43 A R U P DA T E A O 3 5 ' U P DA T E OF P E R S ONN E L F I L E ' A DSPAT R ( B L ) A O 7 5 ' T Y P E I N E MP L OY E E NUMB E R + A T O B E U P DA T E D ' A NUM 7A I 7 4 4D S P A T R ( R I PC ) A R E MP L OY E E A O 3 5 ' E MP L OY E E NUMB E R ' A NUM 7A B 3 2 5D S P A T R ( PC ) A O 5 5 ' E MP L OY E E NAME ' A NAME 3/ A 0 B 5 2 5D S P A T R ( PC ) A O 7 5 ' E MP L OY E E ADD R E S S ' A O 9 5 ' S TREE T ' A S TREE T 3/ A 0 B 9 2 5D S P A T R ( PC ) A O 11 5 ' AP AR T ME N T NUMB E R ' A AP T NO 5A B 1 1 2 5 ' D S P A T R ( PC ) A O 13 5 'CI TY ' A CI TY 2/ A 0 B 1 3 2 5D S P A T R ( PC ) A O 15 5 ' P R OV I NC E ' A P R OV 2/ A 0 B 1 5 2 5D S P A T R ( PC ) A R R E COV E R Y A O 3 5 ' T H E E MP L OY E E NUMB E R YOU + A HAV E G I V E N I S I NVA L I D ' A O 6 5 ' T YP E Y TO R E T R Y ' A O 8 5 ' T YP E N TO E X I T ' / A AN SWE R 1X I 10 5D S P A T R ( R I PC ) A VA L U E S ( ' Y ' ' N ' ) A A A A A A
163
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may vary sl i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P )
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 6 1 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80
164
A* A* A* A A A A A A A A A A A A A A A A A
DD S
F OR
T HE
P H Y S I CA L
F I LE
P A S S WOR D U N I QU E
/ 10 10
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may vary sl i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P )
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 1 4 15 16 17 18 19 20 2 1 22 2 3 24 2 5 26 27 2 8 29 3 0 3 1 32 3 3 34 3 5 36 37 38 39 4 0 4 1 4 2 4 3 44 4 5 46 4 7 48 49 50 5 1 5 2 5 3 5 4 55 5 6 5 7 58 5 9 60 6 1 6 2 63 6 4 65 6 6 6 7 68 6 9 70 7 1 7 2 7 3 7 4 75 7 6 77 7 8 7 9 80
A* A * D D S F OR T H E P H Y S I CA L F I L E T E R M A * WH I C H CON T A I N S T H E L I S T O F T E R M I N A L S A* A R T E RM / A T E RM 10 A A A A A A A A A A A A A A
165
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/SAMPMDF AS4 SYS 3/31/94 13:58: 5 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. SAMPMDF. 3 3 AUTHOR. PROGRAMMER NAME. 4 5 6 THE FOLLOWING PROGRAM DEMONSTRATES SOME OF THE FUNCTIONS 7 AVAILABLE WITH MULTIPLE DEVICE FILE SUPPORT. 8 9 4 1 INSTALLATION. COBOL DEVELOPMENT CENTRE. 5 11 DATE-WRITTEN. 2/ 2/87. 6 12 DATE-COMPILED. 3/31/94 13:58: 5 . 7 13 ENVIRONMENT DIVISION. 8 14 CONFIGURATION SECTION. 9 15 SOURCE-COMPUTER. IBM-AS4 . 1 16 OBJECT-COMPUTER. IBM-AS4 . 11 17 SPECIAL-NAMES. ATTRIBUTE-DATA IS ATTR. 1 12 18 INPUT-OUTPUT SECTION. 13 19 FILE-CONTROL. 14 2 SELECT MULTIPLE-FILE 15 21 ASSIGN TO WORKSTATION-MULT 16 22 ORGANIZATION IS TRANSACTION 2 17 23 ACCESS MODE IS SEQUENTIAL 18 24 FILE STATUS IS MULTIPLE-FS1, MULTIPLE-FS2 3 19 25 CONTROL-AREA IS MULTIPLE-CONTROL-AREA. 26 4 2 27 SELECT TERMINAL-FILE 21 28 ASSIGN TO DATABASE-TERM 22 29 ORGANIZATION IS SEQUENTIAL 23 3 ACCESS IS SEQUENTIAL 24 31 FILE STATUS IS TERMINAL-FS1. 32 25 33 SELECT PASSWORD-FILE 26 34 ASSIGN TO DATABASE-PASSWORD 27 35 ORGANIZATION IS INDEXED 28 36 RECORD KEY IS EXTERNALLY-DESCRIBED-KEY 29 37 ACCESS MODE IS RANDOM 3 38 FILE STATUS IS PASSWORD-FS1. 39 31 4 SELECT PRINTER-FILE 32 41 ASSIGN TO PRINTER-QPRINT. 33 42 DATA DIVISION. 34 43 FILE SECTION. 35 44 FD MULTIPLE-FILE. 36 45 1 MULTIPLE-REC. COPY DDS-SIGNON OF MULT. 5 37 + 1 5 MULT-RECORD PIC X(2 ). SIGNON + 2 INPUT FORMAT:SIGNON FROM FILE MULT OF LIBRARY TESTER SIGNON + 3 SIGNON 38 + 4 5 SIGNON-I REDEFINES MULT-RECORD. SIGNON 39 + 5 6 PASSWORD PIC X(1 ). 6 SIGNON + 6 OUTPUT FORMAT:SIGNON FROM FILE MULT OF LIBRARY TESTER SIGNON + 7 SIGNON 4 + 8 5 SIGNON-O REDEFINES MULT-RECORD. SIGNON 41 + 9 6 WRONG PIC X(2 ). SIGNON 46 42 47 FD TERMINAL-FILE. 43 48 1 TERMINAL-REC. COPY DDS-ALL-FORMATS OF TERM. 44 + 1 5 TERM-RECORD PIC X(1 ). <-ALL-FMTS + 2 I-O FORMAT:TERM FROM FILE TERM OF LIBRARY TESTER <-ALL-FMTS + 3 <-ALL-FMTS 45 + 4 5 TERM REDEFINES TERM-RECORD. <-ALL-FMTS 46 + 5 6 TERM PIC X(1 ). <-ALL-FMTS 49 47 5 FD PASSWORD-FILE. 48 51 1 PASSWORD-REC. COPY DDS-ALL-FORMATS OF PASSWORD. 49 + 1 5 PASSWORD-RECORD PIC X(2 ). <-ALL-FMTS + 2 I-O FORMAT:PASSWORDS FROM FILE PASSWORD OF LIBRARY TESTER <-ALL-FMTS + 3 <-ALL-FMTS + 4 THE KEY DEFINITIONS FOR RECORD FORMAT PASSWORDS <-ALL-FMTS + 5 NUMBER NAME RETRIEVAL TYPE ALTSEQ <-ALL-FMTS + 6 1 PASSKEY ASCENDING AN NO <-ALL-FMTS 5 + 7 5 PASSWORDS REDEFINES PASSWORD-RECORD. <-ALL-FMTS 51 + 8 6 PASSKEY PIC X(1 ). <-ALL-FMTS 52 + 9 6 PASSWORD PIC X(1 ). <-ALL-FMTS 52
Page
Figure 65 (Part 1 of 4). COBOL Source Listing for Multiple Device File Support
166
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/SAMPMDF AS4 SYS 3/31/94 13:58: 5 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 53 53 FD PRINTER-FILE. 54 54 1 PRINTER-REC. 55 55 5 PRINTER-RECORD PIC X(132). 56 56 57 WORKING-STORAGE SECTION. 58 59 6 DECLARE THE FILE STATUS FOR EACH FILE 61 62 57 63 1 MULTIPLE-FS1 PIC X(2) VALUE SPACES. 58 64 1 MULTIPLE-FS2. 7 59 65 5 MULTIPLE-MAJOR PIC X(2) VALUE SPACES. 6 66 5 MULTIPLE-MINOR PIC X(2) VALUE SPACES. 61 67 1 TERMINAL-FS1 PIC X(2) VALUE SPACES. 62 68 1 PASSWORD-FS1 PIC X(2) VALUE SPACES. 69 7 71 DECLARE STRUCTURE FOR HOLDING FILE ATTRIBUTES 72 73 63 74 1 STATION-ATTR. 64 75 5 STATION-TYPE PIC X(1). 8 65 76 5 STATION-SIZE PIC X(1). 66 77 5 STATION-LOC PIC X(1). 67 78 5 FILLER PIC X(1). 68 79 5 STATION-ACQUIRE PIC X(1). 69 8 5 STATION-INVITE PIC X(1). 7 81 5 STATION-DATA PIC X(1). 71 82 5 STATION-STATUS PIC X(1). 72 83 5 STATION-DISPLAY PIC X(1). 73 84 5 STATION-KEYBOARD PIC X(1). 74 85 5 STATION-SIGNON PIC X(1). 75 86 5 FILLER PIC X(5). 87 88 89 DECLARE THE CONTROL AREA FOR MULTIPLE-FILE 9 91 76 92 1 MULTIPLE-CONTROL-AREA. 77 93 5 MULTIPLE-KEY-FEEDBACK PIC X(2) VALUE SPACES. 78 94 5 MULTIPLE-DEVICE-NAME PIC X(1 ) VALUE SPACES. 79 95 5 MULTIPLE-FORMAT-NAME PIC X(1 ) VALUE SPACES. 96 97 98 DECLARE ERROR REPORT VARIABLES 99 1 8 1 1 1 HEADER-LINE. 81 1 2 5 FILLER PIC X(6 ) VALUE SPACES. 82 1 3 5 FILLER PIC X(72) 83 1 4 VALUE "MDF ERROR REPORT". 84 1 5 1 DETAIL-LINE. 85 1 6 5 FILLER PIC X(15) VALUE SPACES. 86 1 7 5 DESCRIPTION PIC X(25) VALUE SPACES. 87 1 8 5 DETAIL-VALUE PIC X(92) VALUE SPACES. 1 9 11 111 DECLARE COUNTERS, FLAGS AND STORAGE VARIABLES 112 113 88 114 1 CURRENT-TERMINAL PIC X(1 ) VALUE SPACES. 89 115 1 TERMINAL-ARRAY. 9 116 5 LIST-OF-TERMINALS OCCURS 25 TIMES. 91 117 7 DEVICE-NAME PIC X(1 ). 92 118 1 COUNTER PIC 9(3) VALUE IS 1. 93 119 1 NO-OF-TERMINALS PIC 9(3) VALUE IS 1. 94 12 1 TERMINAL-LIST-FLAG PIC 1. 95 121 88 END-OF-TERMINAL-LIST VALUE IS B"1". 96 122 88 NOT-END-OF-TERMINAL-LIST VALUE IS B" ". 97 123 1 NO-DATA-FLAG PIC 1. 98 124 88 NO-DATA-AVAILABLE VALUE IS B"1". 99 125 88 DATA-AVAILABLE VALUE IS B" ". 126
Page
Figure 65 (Part 2 of 4). COBOL Source Listing for Multiple Device File Support
167
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/SAMPMDF AS4 SYS 3/31/94 13:58: 5 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 127 PROCEDURE DIVISION. 128 129 DECLARATIVES. 13 131 MULTIPLE-SECTION SECTION. 132 USE AFTER STANDARD EXCEPTION PROCEDURE ON MULTIPLE-FILE. 133 134 MULTIPLE-PARAGRAPH. 1 1 135 WRITE PRINTER-REC FROM HEADER-LINE AFTER ADVANCING PAGE. 1 2 136 MOVE "FILE NAME IS:" TO DESCRIPTION OF DETAIL-LINE. 1 3 137 MOVE "MULTIPLE FILE" TO DETAIL-VALUE OF DETAIL-LINE. 1 4 138 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 5 LINES. 1 5 139 MOVE "FILE STATUS IS:" TO DESCRIPTION OF DETAIL-LINE. 1 6 14 MOVE MULTIPLE-FS1 TO DETAIL-VALUE OF DETAIL-LINE. 1 7 141 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 1 8 142 MOVE "EXTENDED STATUS IS:" TO DESCRIPTION OF DETAIL-LINE. 9 1 9 143 MOVE MULTIPLE-FS2 TO DETAIL-VALUE OF DETAIL-LINE. 11 144 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 111 145 ACCEPT STATION-ATTR FROM ATTR. 9A 112 146 MOVE "FILE ATTRIBUTES ARE:" TO DESCRIPTION OF DETAIL-LINE. 113 147 MOVE STATION-ATTR TO DETAIL-VALUE OF DETAIL-LINE. 114 148 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 115 149 STOP RUN. 15 151 TERMINAL-SECTION SECTION. 152 USE AFTER STANDARD EXCEPTION PROCEDURE ON TERMINAL-FILE. 153 TERMINAL-PARAGRAPH. 116 154 WRITE PRINTER-REC FROM HEADER-LINE AFTER ADVANCING PAGE. 117 155 MOVE "FILE NAME IS:" TO DESCRIPTION OF DETAIL-LINE. 118 156 MOVE "TERMINAL FILE" TO DETAIL-VALUE OF DETAIL-LINE. 119 157 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 5 LINES. 12 158 MOVE "FILE STATUS IS:" TO DESCRIPTION OF DETAIL-LINE. 121 159 MOVE TERMINAL-FS1 TO DETAIL-VALUE OF DETAIL-LINE. 122 16 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 123 161 STOP RUN. 162 163 PASSWORD-SECTION SECTION. 164 USE AFTER STANDARD EXCEPTION PROCEDURE ON PASSWORD-FILE. 165 PASSWORD-PARAGRAPH. 124 166 WRITE PRINTER-REC FROM HEADER-LINE AFTER ADVANCING PAGE. 125 167 MOVE "FILE NAME IS:" TO DESCRIPTION OF DETAIL-LINE. 126 168 MOVE "PASSWORD FILE" TO DETAIL-VALUE OF DETAIL-LINE. 127 169 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 5 LINES. 128 17 MOVE "FILE STATUS IS:" TO DESCRIPTION OF DETAIL-LINE. 129 171 MOVE PASSWORD-FS1 TO DETAIL-VALUE OF DETAIL-LINE. 13 172 WRITE PRINTER-REC FROM DETAIL-LINE AFTER ADVANCING 2 LINES. 131 173 STOP RUN. 174 175 END DECLARATIVES. 176 177 178 MAIN PROGRAM LOGIC BEGINS HERE 179 18 181 MAIN-LINE SECTION. 182 MAIN-LINE-PARAGRAPH. 132 183 OPEN I-O MULTIPLE-FILE 1 184 INPUT TERMINAL-FILE 185 I-O PASSWORD-FILE 186 OUTPUT PRINTER-FILE. 187 133 188 MOVE 1 TO COUNTER. 134 189 SET NOT-END-OF-TERMINAL-LIST TO TRUE. 19 PERFORM 135 191 FILL-TERMINAL-LIST UNTIL END-OF-TERMINAL-LIST. 192 PERFORM 136 193 ACQUIRE-AND-INVITE-TERMINALS 194 VARYING COUNTER FROM 1 BY 1 195 UNTIL COUNTER GREATER THAN NO-OF-TERMINALS. 137 196 MOVE 1 TO COUNTER. 138 197 SET DATA-AVAILABLE TO TRUE. 198 PERFORM 139 199 POLL-TERMINALS UNTIL NO-DATA-AVAILABLE. 2 PERFORM 14 2 1 DROP-TERMINALS 2 2 VARYING COUNTER FROM 1 BY 1 2 3 UNTIL COUNTER GREATER THAN NO-OF-TERMINALS.
Page
Figure 65 (Part 3 of 4). COBOL Source Listing for Multiple Device File Support
168
5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/SAMPMDF AS4 SYS 3/31/94 13:58: 5 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 141 2 4 CLOSE MULTIPLE-FILE 2 5 TERMINAL-FILE 2 6 PASSWORD-FILE 2 7 PRINTER-FILE. 142 2 8 STOP RUN. 2 9 21 211 PROCEDURES 212 213 214 PROCEDURE-SECTION SECTION. 215 FILL-TERMINAL-LIST. 143 216 READ TERMINAL-FILE RECORD INTO LIST-OF-TERMINALS(COUNTER) 217 AT END 144 218 SET END-OF-TERMINAL-LIST TO TRUE 145 219 SUBTRACT 1 FROM COUNTER 146 22 MOVE COUNTER TO NO-OF-TERMINALS. 147 221 ADD 1 TO COUNTER. 222 223 ACQUIRE-AND-INVITE-TERMINALS. 148 224 ACQUIRE LIST-OF-TERMINALS(COUNTER) FOR MULTIPLE-FILE. 11 149 225 WRITE MULTIPLE-REC 12 226 FORMAT IS "SIGNON" 227 TERMINAL IS LIST-OF-TERMINALS(COUNTER). 228 229 POLL-TERMINALS. 15 23 READ MULTIPLE-FILE RECORD. 13 151 231 IF MULTIPLE-FS2 EQUAL "31 " THEN 152 232 SET NO-DATA-AVAILABLE TO TRUE. 14 153 233 IF DATA-AVAILABLE THEN 154 234 MOVE MULTIPLE-DEVICE-NAME TO CURRENT-TERMINAL 155 235 PERFORM PASSWORD-VALIDATION. 15 236 237 PASSWORD-VALIDATION. 156 238 MOVE CURRENT-TERMINAL TO PASSKEY OF PASSWORD-REC. 157 239 READ PASSWORD-FILE RECORD. 158 24 IF PASSWORD OF SIGNON-I EQUAL PASSWORD OF PASSWORD-REC THEN 159 241 CALL "UPDT" USING CURRENT-TERMINAL 16 242 MOVE SPACES TO WRONG OF SIGNON-O 243 ELSE 161 244 MOVE "INVALID PASSWORD" TO WRONG OF SIGNON-O. 162 245 WRITE MULTIPLE-REC 246 FORMAT IS "SIGNON" 247 TERMINAL IS CURRENT-TERMINAL. 248 249 DROP-TERMINALS. 163 25 DROP LIST-OF-TERMINALS(COUNTER) FROM MULTIPLE-FILE. 16 E N D O F S O U R C E
Page
Figure 65 (Part 4 of 4). COBOL Source Listing for Multiple Device File Support
169
6 7
Format SIGNON is the format with the INVITE keyword. This is the format that will be used to invite devices via the WRITE statement. This is the declaration for the extended file-status MULTIPLE-FS2. It is a 4-byte field that is subdivided into a major return code (first 2 bytes) and a minor return code (last 2 bytes). STATION-ATTR is where the ACCEPT statement contains the attribute data for the TRANSACTION file MULTIPLE-FILE. See item 9A . In this statement, the extended file status MULTIPLE-FS2 is being written. This is an example of accepting attribute-data for the TRANSACTION file MULTIPLE-FILE. Because there is no interest in a specific program device, but rather the last program device used, the FOR phrases are not used with the ACCEPT. This statement opens the TRANSACTION file MULTIPLE-FILE. Because the ACQPGMDEV parameter of the CRTDSPF command has the value *NONE, no program devices are implicitly acquired when this file is opened. This statement acquires the program device contained in the variable LIST-OF-TERMINALS (COUNTER), for the TRANSACTION file MULTIPLE-FILE. This WRITE statement is inviting the program device specified in the TERMINAL phrase. The format SIGNON has the DDS keyword INVITE associated with it. Refer to item 13 . This READ statement will read from any invited program device. See item 12 . If the wait time expires before anyone inputs to the invited devices, the extended file status will be set to 0310 and processing will continue. See item 14 . In this statement, the extended file status for MULTIPLE-FILE is being checked to see if the wait time expired. The program device name stored in the control area is used to determine which program device was used to sign on. See item 4 . This DROP statement detaches the program device contained in the variable LIST-OF-TERMINALS from the TRANSACTION file MULTIPLE-FILE.
8 9 9A
11
12
13
14 15 16
170
171
ASSIGN Clause
The ASSIGN clause associates the TRANSACTION file with a display file or ICF file through the use of assignment-name-1. Assignment-name-1 has the following structure: Format ASSIGNWORKSTATION -file-name TO SI
Device specifies the type of device associated with the file. The value must be WORKSTATION. The AS/400 file name is a one-to-ten character external name of the display file or ICF file specified on the create device file commands, CRTDSPF or CRTICFF. The attribute -SI is used to specify the file level option for a separate indicator area. See Using Indicators with Transaction Files on page 142 for further details. The second and subsequent assignment-names are syntax-checked, but are treated as documentation.
ORGANIZATION Clause
The ORGANIZATION clause specifies the logical structure of a file. TRANSACTION organization signifies interaction between the program and either a work station user or another system.
TRANSACTION Organization: TRANSACTION processing is defined as the random arrival of a record from one of multiple possible sources followed by appropriate processing, and finally, by the output of results or feedback information of some type to the source of the record.
In some cases, all records are homogeneous; that is, a logical transaction is completed with one exchange of records. In other situations, a series of records is passed back and forth in a logical progression with various record types either being selected by the initiator or as part of the processing based on input data values. Each transaction can be processed by a different program, or multiple transactions can be processed by the same program, depending on the system environment. The initiation of a transaction can cause a program to be scheduled to process the transaction. A transaction can consist of a series of alternating requests and responses (a dialogue). Each request and response can consist of multiple logical records.
172
173
CONTROL-AREA Clause
The CONTROL-AREA clause specifies device-dependent and system-dependent information that is used to control input/output operations for TRANSACTION files. Data-name-6 is a CONTROL-AREA data item that must be defined in the LINKAGE SECTION or WORKING-STORAGE SECTION. Data-name-6 is assumed to have the following format: 01 data-name-6. 02 function-key PIC X(2). (Function key feedback field) 02 device-name PIC X(10). (Program device name) 02 record-format PIC X(10). (Record format)
Data-name-6 must be 2, 12, or 22 characters long. Based upon the length of data-name-6, the compiler assumes the availability of key feedback bytes, the program device name, and record format. Programming Note: For an ICF file, the actual name of a device may be different from the program device name (data-name-11). Information is moved into data-name-6 for each READ operation from a file that has been assigned to a WORKSTATION device type. The information is valid only if the READ operation is successfully completed (provided the wait time has not expired). The information is in the fixed format as shown in the following example: FILE-CONTROL. SELECT SCREEN-FILE ASSIGN TO WORKSTATION-MYFMTS ORGANIZATION IS TRANSACTION CONTROL-AREA IS TRANSACTION-CONTROL-AREA. WORKING-STORAGE SECTION. 1 TRANSACTION-CONTROL-AREA. FEEDBACK ITEM 2 FUNCTION-KEY PIC XX. 2 TERMINAL-ID PIC X(1 ). 2 FORMAT-NAME PIC X(1 ).
. . .
174
Each field in the TRANSACTION-CONTROL-AREA data item in the example is described as follows: FUNCTION-KEY: A two-digit number inserted in the field by the work station interface that identifies the function key the operator pressed to initiate the transaction. The codes are as follows:
00 01-24 90 91 92 93 94 95 99 Enter key Function keys 1 through 24 Roll Up/Page Down key Roll Down/Page Up key Print key Help key Clear key Home key Undefined
Any function keys for which feedback information is desired must be defined for the display file using DDS. TERMINAL-ID: The program device name. FORMAT-NAME: The DDS record format name that was referenced by the last I/O statement run.
175
Format FDfile-name RECORDinteger-4 CONTAINS integer-3 TO CHARACTERS LABELRECORDSTANDARD IS OMITTED RECORDS ARE . DATARECORDdata-name-2 IS RECORDS ARE
The LABEL RECORDS clause specifies whether or not labels are present. This clause is required in every file description entry. This clause is syntax-checked, but is treated as documentation.
176
ACCEPT Statement
The ACCEPT statement retrieves information (attribute data) about a particular program device associated with a TRANSACTION file. ACCEPT Statement Format 6 Attribute Data ACCEPTidentifier-1FROMmnemonic-name FORidentifier-2 literal-1 FORfile-name-1
This format of the ACCEPT statement can only be used for files with an organization of TRANSACTION. Mnemonic-name must be associated with the functionname ATTRIBUTE-DATA in the SPECIAL-NAMES paragraph. If file-name is not specified, the default file for the ACCEPT statement is the first TRANSACTION file specified in a SELECT clause of the FILE-CONTROL paragraph. Literal-1 or the contents of identifier-2, if specified, indicates the program device name for which attribute data is made available. This device must be defined by a CRTDSPF, ADDICFDEVE, or OVRICFDEVE CL command. The device does not actually have to be acquired. Literal-1, if specified, must be nonnumeric and 10 characters or fewer in length. The contents of identifier-2, if specified, must be an alphanumeric data item 10 characters or fewer in length. If an incorrect program device name is specified, or if the file is not open at the time the ACCEPT statement is processed, message LBE7205 ACCEPT ATTRIBUTE-DATA statement has failed (C D F). is issued and processing terminates. If both FOR phrases are omitted (indicating the default TRANSACTION file is being used), the ACCEPT statement uses the program device from which a READ, WRITE, REWRITE, or ACCEPT (Attribute Data) operation on the default file was most recently performed. If the only prior operation on the file was an OPEN, the ACCEPT statement uses the program device implicitly acquired by the file when the file was opened. When both FOR phrases are omitted, a program device must have been acquired to use this particular format of the ACCEPT statement. Program device attributes are moved into identifier-1 from the appropriate attribute data format, according to the rules for a group MOVE without the CORRESPONDING phrase.
177
You can make use of multiple display files along with ordinary files in a program that includes an Extended ACCEPT or Extended DISPLAY statement. (See the COBOL/400 Reference for more information.)
ACQUIRE Statement
The ACQUIRE statement acquires a program device for a TRANSACTION file. ACQUIRE Statement TRANSACTION File ACQUIREidentifierFORfile-name literal
Literal or the contents of identifier indicates the program device name to be acquired by the specified file. Literal, if specified, must be nonnumeric and 10 characters or fewer in length. Identifier, if specified, must refer to an alphanumeric data item 10 characters or fewer in length. File-name must be the name of a file with an organization of TRANSACTION, and the file must be open when the ACQUIRE statement is run. A compilation error message is issued if the organization is not TRANSACTION. For a description of conditions that must be met before a communications device can be acquired, see the ICF Programmers Guide. For more information about the requirements for displays, see the Data Management Guide. Successful completion of the ACQUIRE operation makes the program device available for input and output operations. If the ACQUIRE operation is unsuccessful, the file status value is set to 9H and the USE AFTER EXCEPTION/ERROR procedure is called (if specified). For more information, refer to Chapter 6, COBOL/400 Exception and Error Handling. Only one program device can be implicitly acquired when a file is opened. If a file is an ICF file, the single implicitly acquired program device is determined by the ACQPGMDEV parameter of the CRTICFF command. If the file is a display file, the
178
single implicitly acquired program device is determined by the first entry in the DEV parameter of the CRTDSPF command. Additional program devices must be explicitly acquired. A program device is explicitly acquired by using the ACQUIRE statement. For an ICF file, that device must have been defined to the file with the ADDICFDEVE or OVRICFDEVE CL command before the file was opened. For display files there is no such requirement. That is, the device named in the ACQUIRE statement does not have to be specified in the DEV parameter of the CRTDSPF command, the CHGDSPF command, or the OVRDSPF command. For a display file, the program device name must match the display device. The ACQUIRE statement can also be used as an aid in recovering from I/O errors. For more information, see the ACQUIRE Statement section of the COBOL/400 Reference. For more information about these commands, see the CL Reference.
CLOSE Statement
The CLOSE statement terminates the processing of volumes and files, with optional lock where applicable. CLOSE Statement Format 3 TRANSACTION File CLOSEfile-name-1 LOCK WITH
For a detailed discussion of the CLOSE statement, see the CLOSE Statement section of the COBOL/400 Reference.
DROP Statement
The DROP statement releases a program device that has been acquired by a TRANSACTION file. DROP Statement DROPidentifierFROMfile-name literal
179
Literal or the contents of identifier indicates the program device name of the device to be dropped. Literal, if specified, must be nonnumeric and 10 characters or fewer in length. Identifier, if specified, must refer to an alphanumeric data item, 10 characters or fewer in length. File-name must refer to a file with an organization of TRANSACTION, and the file must be open to be used in the DROP statement. If no DROP statement is issued, program devices attached to a TRANSACTION file are implicitly released when that file is finally closed. Program devices specified in a DROP statement must have been acquired by the TRANSACTION file, either through an explicit ACQUIRE or through an implicit ACQUIRE at OPEN time. After successful running of the DROP statement, the program device is no longer available for input or output operations through the TRANSACTION file. The device can be reacquired if necessary. The contents of the record area associated with a released program device are no longer available, even if the device is reacquired. If the DROP operation is unsuccessful, the USE AFTER EXCEPTION/ERROR procedure is processed (if specified). For more information, refer to Chapter 6, COBOL/400 Exception and Error Handling. The DROP statement can also be used as an aid in recovering from I/O errors. For more information, see the DROP Statement section of the COBOL/400 Reference.
OPEN Statement
The OPEN statement initiates the processing of files. OPEN Statement Format 3 TRANSACTION Files OPEN I-Ofile-name
A TRANSACTION file must be opened in the I/O mode. For a further discussion of the OPEN statement, see the COBOL/400 Reference. The OPEN statement can cause a program device to be implicitly acquired for a TRANSACTION file. For a further discussion about the acquiring of program devices, see the ACQUIRE Statement on page 178.
180
FORMAT Phrase
The literal or identifier specified must be a character string of 10 characters or fewer in length. Multiple data records, each with a different format, can be concurrently active for a TRANSACTION file. If the FORMAT phrase is specified, it must specify a valid format name that is defined to the system, and the I/O operation must be performed on a data record of the same format. If the format is an invalid name or if it does not exist, the FILE STATUS data item, if specified, is set to a value of 9K and the contents of the record area are undefined.
DB-FORMAT-NAME Special Register: After the running of an input/output statement for a TRANSACTION file, the DB-FORMAT-NAME special register is modified according to the following rules:
If the input/output operation is successful, the record format name is implicitly moved to the special register after completion of the input/output operation. If the input/output operation is unsuccessful, DB-FORMAT-NAME contains the record format name used in the last successful input/output operation. When the FORMAT phrase is not specified, DB-FORMAT-NAME can be used if the file contains a default record format name. The default value is always moved to the DB-FORMAT-NAME special register. DB-FORMAT-NAME is implicitly defined as PICTURE X(10).
INDICATORS Phrase
The identifier specified in the INDICATORS phrase must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. When a data record is written or rewritten, indicators can be written or rewritten with it. The indicators can control how the record is displayed and the various data management functions. When a data record is read, indicators can be read with it. The indicators can be used to pass information about the data record and how it was entered into your program. By defining a format using DDS, you determine what functions are to be controlled by indicators, and which indicators control a particular function. For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files on page 142.
181
SUBFILE Phrase
When the SUBFILE phrase is specified, it indicates that all formats referenced by the statement are subfiles. When SUBFILE is not specified in a TRANSACTION I/O statement, it indicates that none of the formats referenced by the statement are subfiles. This information is not verified at compilation time. If it is specified incorrectly, the subfile is processed as a series of input/output operations directly to the display device. When the specified format name exists as a display file format, the READ/WRITE operations complete successfully. When SUBFILE is not specified, the RELATIVE KEY data item associated with the file, if specified, is not referenced or changed by the I/O operation. When SUBFILE is specified, a RELATIVE KEY data item must be defined for the file. Its value is referenced, and sometimes changed, by the I/O operation. See each of the statements associated with SUBFILE operations for a detailed description of when and how the RELATIVE KEY data item is changed. The SUBFILE phrase can be specified only for display files.
TERMINAL Phrase
When the TERMINAL phrase is specified, it indicates a specific program device is to be used for a READ, WRITE, or REWRITE operation on a TRANSACTION file. The TERMINAL phrase can be omitted for I/O operations on single device files, because that device is always used. If the TERMINAL phrase is omitted for an I/O operation on a TRANSACTION file that has acquired multiple program devices, the program device that last attempted a READ, WRITE, REWRITE, ACQUIRE, DROP, or ACCEPT (Attribute Data) operation on the file is used. If the only prior operation on the file was an OPEN, the default program device used is the program device implicitly acquired by the TRANSACTION file when the file was opened. A run-time error message occurs if no program device has been acquired when the file is opened. For a READ statement with both the TERMINAL phrase and the NO DATA phrase specified, the imperative-statement in the NO DATA phrase is run only if data is not immediately available from the program device specified by the TERMINAL phrase. If the TERMINAL phrase is specified and the data-item or literal has a value of blanks, the phrase is treated at run time as if it were not specified.
READ Statement
The READ statement makes available a record from a device, using a named format. If the format is a subfile, the READ statement makes available a specified record from that subfile.
182
READ Statement Format 4 TRANSACTION File (Nonsubfile) READfile-name RECORD INTOidentifier-1 FORMATidentifier-2 IS literal-1 TERMINALidentifier-3 IS literal-2 INDICATORidentifier-4 INDICATORS IS INDIC ARE NO DATAimperative-statement-1 ENDimperative-statement-2 AT NOTENDimperative-statement-3 END-READ AT
Format 4 is used only to read a format that is not a subfile. The RELATIVE KEY data item, if specified in the FILE-CONTROL entry, is not used. The Format 4 READ statement is not valid for a subfile record. However, a Format 4 READ statement for the subfile control record format must be used to place those subfile records that were updated on a display into the subfile. If the requested data is available, it is returned in the record area. The names of the record format and the program device are returned in the I-O-FEEDBACK area in the CONTROL-AREA. The READ statement is valid only when there are acquired devices for the file. If a READ is processed and there are no acquired devices, the file status is set to 92 (logic error).
183
The manner in which the Format 4 READ statement functions depends on: If the READ is for a single device file or a multiple device file If a specific program device has been requested through the TERMINAL phrase If a specific record format has been requested through the FORMAT phrase If the NO DATA phrase has been specified. In the following sections, references to data available or returned include the situation where only the response indicators are set. This also applies even when a separate indicator area is used and the indicators are not returned in the record area for the file. The following chart shows the possible combinations of phrases and the function performed for a single device file or a multiple device file. For example, if TERMINAL is N, FORMAT is N, and NO DATA is N, the single device is D and multiple device is A.
Function Checked at Compilation Determined at Run Time Phrase TERMINAL2 FORMAT2 NO DATA Single Device Multiple Device Y=Yes N=No
Code ARead From Invited Program Device (Multiple Device Files only)
This type of READ receives data from the first invited program device that has data available. Invited program devices are work stations or other communication devices that are invited to send input. The inviting is done by writing to the program device with a format specifying the DDS keyword INVITE. Once an invited program device is actually read from, it is no longer invited. That program device will not be used for input by another READ statement unless reinvited, or unless a READ is directed to it specifying the TERMINAL phrase or FORMAT phrase. The record format returned from the program device is determined by the system. See the chapter on display device support in the Data Management Guide for information on how record format is determined for work stations. See the ICF Programmers Guide for information on the FMTSLT parameter on the ADDICFDEVE and OVRICFDEVE commands. This READ can be completed without returning any data in the following cases: If there are no invited devices. If a controlled cancelation of the job occurs. This results in a file status value of 9A and a major/minor return code value of 0309.
If the phrase is specified and the data item or literal is blank, the phrase is treated at run time as if it were not specified. COBOL/400 Users Guide
184
If the NO DATA phrase is omitted, and the specified wait time expires. This results in a file status value of 00 and a major/minor return code value of 0310. If the specified wait time is the value entered on the WAITRCD parameter for the file. If the NO DATA phrase is specified, and no data is immediately available when the READ is processed. If data is available, it is returned in the record area. The record format is returned in the I-O-FEEDBACK area and in the CONTROL-AREA. For more information about Reading from Invited Program Devices, see the ICF Programmers Guide.
185
1. The program device is determined as follows: a. If the TERMINAL phrase is omitted or contains a blank value, the default program device is used. The default program device is the program device used by the last attempted READ, WRITE, REWRITE, ACQUIRE, DROP or ACCEPT (Attribute Data) statement. If none of these operations has been done, the program device implicitly acquired when the file was opened is used. If there are no acquired devices, the AT END condition exists. b. If the TERMINAL phrase is specified, the indicated program device is used. 2. The record format is determined as follows: a. If the FORMAT phrase is omitted or contains blanks, the record format returned is determined by the system. For information on how the record format is calculated for work station devices, refer to the Data Management Guide. For information about how the record format is determined for communications, see the section on the FMTSLT parameter on the ADDICFDEVE and OVRICFDEVE commands in the ICF Programmers Guide. b. If the FORMAT phrase is specified, the indicated record format is returned. If the data available does not match the requested record format, a file status of 9G is set. 3. Program processing stops until data becomes available. The data is returned in the record area after the READ statement is run. If the program device was previously invited, it will no longer be invited after this READ statement.
INTO Phrase
The INTO phrase can be specified if: Only one record description is subordinate to the file description entry, OR All record names associated with file-name and the data item referenced by identifier-1 describe a group item or an elementary alphanumeric item.
FORMAT Phrase
Literal-1 or identifier-2 specifies the name of the record format to be read. Literal-1, if specified, must be nonnumeric and 10 characters or fewer in length. Identifier-2, if specified, must refer to an alphanumeric data item, 10 characters or fewer in length. If identifier-2 contains blanks, the READ statement is run as if the FORMAT phrase were omitted.
NO DATA Phrase
When the NO DATA phrase is specified, the READ statement determines if data is immediately available. If data is available, the data is returned in the record area. If no data is immediately available, imperative-statement-1 is processed. The NO DATA phrase prevents the READ statement from waiting for data to become available.
186
TERMINAL Phrase
Literal-2 or identifier-3 specifies the program device name. Literal-2, if specified, must be nonnumeric and 10 characters or fewer in length. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or fewer in length. The program device must have been acquired before the READ statement is processed. If identifier-3 contains blanks, the READ statement is processed as if the TERMINAL phrase were omitted. For a single device file, the TERMINAL phrase can be omitted. The program device is assumed to be that single device. If the TERMINAL phrase is omitted for a READ of a TRANSACTION file that has acquired multiple program devices, the default program device is used. See the discussion of the TERMINAL phrase on page 182, to see how the default program device is determined.
AT END Phrase
Imperative-statement-2 is performed when the AT END condition is detected. Note: An AT END condition occurs at the following times: During a READ statement for a sequentially accessed file when no next logical record exists in the file, or when the number of significant digits in the relative record number is larger than the size of the relative key data item, or when an optional input file is not present. During a RETURN statement when no logical record exists for the associated sort or merge file. During a SEARCH statement when the search operation ends without satisfying the condition specified in any of the associated WHEN phrases.
END-READ Phrase
The END-READ phrase serves to explicitly delimit the scope of the statement.
187
READ Statement Format 5 TRANSACTION File (Subfile) READ SUBFILEfile-name MODIFIED RECORD NEXT INTOidentifier-1 FORMATidentifier-2 IS literal-1 TERMINALidentifier-3 IS literal-2 INDICATORidentifier-4 INDICATORS IS INDIC ARE INVALIDimperative-statement-1 KEY NOT INVALIDimperative-statement-2 KEY ENDimperative-statement-3 AT NOTENDimperative-statement-4 END-READ AT
Format 5 is used only to read a format that is a subfile record. The AT END phrase can only be used when the NEXT MODIFIED phrase is specified. The INVALID KEY phrase must not be used when the NEXT MODIFIED phrase is specified.
188
Format 5 cannot be used for communications devices. If the subfile format of the READ statement is used for a communications device, the READ fails and a file status of 90 is set.
Random Access of Subfile Records: The NEXT MODIFIED phrase must not be used to randomly access records in a subfile. The INVALID KEY phrase can only be used for random access of subfile records. Sequential Access of Subfile Records: The NEXT MODIFIED phrase must be specified to access subfile records sequentially. The AT END phrase can only be specified with the NEXT MODIFIED phrase.
FORMAT Phrase
When a format-name is not specified, the format used is the last record format written to the display device that contains input fields, input/output fields, or hidden fields. If no such format exists for the display file, the format used is the record format of the last WRITE operation to the display device. Note: An input field is a field specified in a display file or database file that is reserved for information supplied by a user. If the FORMAT phrase is specified, literal-1 or the contents of identifier-2 must specify a format, which is active for the appropriate program device. The READ statement reads a data record of the specified format.
189
To ensure correct results, always specify the FORMAT phrase for multiple format files. For more information on the FORMAT phrase, see the Procedure Division, Common Processing Facilities on page 181.
TERMINAL Phrase
See Format 4 of the READ Statement for general considerations concerning the TERMINAL phrase. For a Format 5 READ, if the TERMINAL phrase is omitted for a file that has multiple devices acquired for it, a record is read from the subfile associated with the default program device. See the discussion of the TERMINAL phrase on page 182, to see how the default program device is determined.
AT END Phrase
If the NEXT MODIFIED phrase is specified and there is no user-modified record in the subfile, the AT END condition exists, and the READ operation is unsuccessful. Specify the AT END phrase when the NEXT MODIFIED phrase is used, and no applicable USE procedure is specified for the file name. If the AT END phrase and a USE procedure are both specified for a file, and the AT END condition arises, control transfers to the AT END imperative statement and the USE procedure is not run.
END-READ Phrase
The END-READ phrase serves to explicitly delimit the scope of the statement.
190
REWRITE Statement
The REWRITE statement is used to replace a subfile record that already exists in the subfile. REWRITE Statement Format 2 TRANSACTION File (Subfile) REWRITE SUBFILErecord-name-1 FROMidentifier-1 FORMATidentifier-2 IS literal-1 TERMINALidentifier-3 IS literal-2 INDICATORidentifier-4 INDICATORS IS INDIC ARE INVALIDimperative-statement-1 KEY NOT INVALIDimperative-statement-2 END-REWRITE KEY
The number of character positions in the record referenced by record-name must be equal to the number of character positions in the record being replaced. A successful READ operation on the record must be done prior to the REWRITE operation. The record replaced in the subfile is the record in the subfile accessed by the previous READ operation.
FORMAT Phrase
The record format specified in the FORMAT phrase must be the record format accessed on the previous READ operation. Literal-1 or the contents of identifier-2 must be the name of the subfile format accessed on the previous READ. For more information on the FORMAT phrase, see Common Processing Facilities on page 181.
191
TERMINAL Phrase
The TERMINAL phrase indicates which program devices subfile is to have a record rewritten. If the TERMINAL phrase is specified, literal-2 or identifier-3 must refer to a work station that has been acquired by the TRANSACTION file. If literal-2 or identifier-3 contains blanks, the TERMINAL phrase has no effect. The program device specified by the TERMINAL phrase must have been acquired, either explicitly or implicitly, and must have a subfile associated with the device. Literal-2 or identifier-3 must be a valid program device name. Literal-2, if specified, must be nonnumeric and 10 characters or fewer. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or fewer. If the TERMINAL phrase is omitted from a TRANSACTION file that has acquired multiple program devices, the subfile used is the subfile associated with the last program device from which a READ of the TRANSACTION file was attempted. The REWRITE statement cannot be used for communications devices. If the REWRITE statement is used for a communications device, the operation fails and a file status of 90 is set.
END-REWRITE Phrase
The END-REWRITE phrase serves to explicitly delimit the scope of the statement.
192
WRITE Statement
The WRITE statement releases a logical record to the file. WRITE Statement Format 4 TRANSACTION File (Nonsubfile) WRITErecord-name-1 FROMidentifier-1 FORMATidentifier-2 IS literal-1 TERMINALidentifier-3 IS literal-2 STARTINGidentifier-4 AT LINE literal-3 BEFOREROLLINGidentifier-5 AFTER LINES literal-4 LINE identifier-6UPidentifier-7 THROUGH literal-5 DOWN literal-6 LINES THRU LINE INDICATORidentifier-8 END-WRITE INDICATORS IS INDIC ARE
TERMINAL Phrase
The TERMINAL phrase specifies the program devices to which the output record is to be sent. The contents of literal-2 or identifier-3 must be the name of a program device previously acquired, either implicitly or explicitly, by the file. Literal-2, if specified, must be nonnumeric and 10 characters or fewer in length. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or fewer in length. A value of blanks is treated as if the TERMINAL phrase were omitted. If only a single program device was acquired by the TRANSACTION file, the
Chapter 8. Transaction Files
193
TERMINAL phrase can be omitted. That program device is always used for the WRITE. If the TERMINAL phrase is omitted for a WRITE operation to a TRANSACTION file that has acquired multiple program devices, the default program device is used. See the discussion of the TERMINAL phrase on page 182 to see how the default program device is determined.
STARTING Phrase
The STARTING phrase specifies the starting line number for the record formats that use the variable start line keyword. This phrase is only valid for display devices. The actual line number on which a field begins can be determined from the following equation:
Where: Actual-line is the actual line number Start-line is the starting line number specified in the program DDS Start-line is the line number specified in positions 39 through 41 of the Data Description Specifications form. The WRITE operation is successful if: The result of the above equation is positive and less than or equal to the number of lines on the display. The value specified for the STARTING phrase is 0. In this case, a value of 1 is assumed. The WRITE operation is unsuccessful, and the program ends, if: The result of the above equation is greater than the number of lines on the display. The value specified for the STARTING phrase is negative. If the value specified for the STARTING phrase is within the screen area, any fields outside of the screen area are ignored. Literal-3 of the STARTING phrase must be a numeric literal. Identifier-4 must be an elementary numeric item. To use the STARTING phrase, the DDS record level keyword SLNO(*VAR) must be specified for the format being written. If the record format does not specify this keyword, the STARTING phrase is ignored at run time. The DDS keyword CLRL also affects the STARTING phrase. CLRL controls how much of the display is cleared when the WRITE statement is processed.
194
See the DDS Reference for further information on SLNO(*VAR) and CLRL keywords.
ROLLING Phrase
The ROLLING phrase allows you to move lines displayed on the work station screen. All or some of the lines on the screen can be rolled up or down. The lines vacated by the rolled lines are cleared, and can have another screen format written into them. This phrase is only valid for display devices. ROLLING is specified in the WRITE statement that is writing a new format to the display You must specify whether the write is before or after the roll, the range of lines you want to roll, how many lines you want to roll these lines, and whether the roll operation is up or down. After lines are rolled, the fields on these lines retain their DDS display attributes, for example, underlining, but lose their DDS usage attributes, for example, inputcapability. Fields on lines that are written and then rolled (BEFORE ROLLING phrase) also lose their usage attributes. If any part of a format is rolled, the entire format loses its usage attributes. If more than one format exists, only the rolled formats lose their usage attributes. When you specify the ROLLING phrase, the following general rules apply. The DDS record level keyword ALWROL must be specified for every record format written in a WRITE statement containing the ROLLING phrase. Other DDS keywords mutually exclusive with the ALWROL keyword must not be used. Either of the DDS keywords, CLRL or OVERLAY, must be specified for a record format that is to be written and rolled to prevent the display from being cleared when that record format is written. See the DDS Reference manual for more information on DDS keywords. All the identifiers and literals must represent positive integer values. The roll starting line number (identifier-5 or literal-4) must not exceed the ending line number (identifier-6 or literal-5). The contents of lines that are rolled outside of the window specified by the starting and ending line numbers disappear. Figure 67 on page 197 shows an example of a rolling operation. An initial screen format, FMT1, is written on the display. The program processes this screen format and is now ready to write the next screen format, FMT2, to the work station screen. Part of FMT1 is rolled down two lines before FMT2 is written to the display. Processing of the following WRITE statement causes part of FMT1 to be rolled down two lines, and FMT2 to be written to the display: WRITE SCREENREC FORMAT "FMT2" AFTER ROLLING LINES 14 THROUGH 2 DOWN 2 LINES When this WRITE statement is run, the following steps occur: 1. The contents of lines 14 through 20 are rolled down two lines.
195
a. The contents of lines 14 through 18 now appear on lines 16 through 20. b. The contents of lines 14 and 15 are vacated and cleared. c. The contents of lines 19 and 20 are rolled outside the window and disappear. 2. After the rolling operation takes place, FMT2 is written to the display. a. Part of FMT2 is written to the area vacated by the roll operation. b. Part of FMT2 is written over the data left from FMT1. 3. When the contents of the display are returned to the program by a READ statement, only the input capable fields of FMT2 are returned.
196
DISPLAY BEFORE PROCESSING THE WRITE STATEMENT UPDATE CUSTOMER ORDER RECORD Line 3 TO END THIS JOB, PRESS F7 Line 8 ENTER YOUR OPERATOR NUMBER: ___ Line 13 Line 14 ENTER CUSTOMER NUMBER: _____ Line 15 PRESS F3 TO DISPLAY OPTION MENU Line 17 Line 2 These seven lines DISPLAY AFTER PROCESSING THE WRITE STATEMENT of FMT1 will be rolled down 2 lines. UPDATE CUSTOMER ORDER RECORD Line 3 TO END THIS JOB, PRESS F7 Line 8 ITEM NUMBER ORDERED: _____ Line 12 QUANTITY ORDERED: ______ Line 14 ENTER CUSTOMER NUMBER: XXXXX Line 17 PRESS F3 TO DISPLAY OPTION MENU Line 19 These three lines of FMT2 have been written over the previous lines.
Figure 67. Example of ROLLING Operation
197
WRITE Statement Format 5 TRANSACTION File (Subfile) WRITE SUBFILErecord-name-1 FROMidentifier-1 FORMATidentifier-2 IS literal-1 TERMINALidentifier-3 IS literal-2 INDICATORidentifier-4 INDICATORS IS INDIC ARE INVALIDimperative-statement-1 KEY NOT INVALIDimperative-statement-2 END-WRITE KEY
Format 5 can only be used for display devices. If the subfile form of the WRITE statement is used for any other type of device, the WRITE operation fails and a file status of 90 is set. If the format is a subfile record, and SUBFILE is specified, the RELATIVE KEY clause must have been specified on the SELECT clause for the file being written. The record written to the subfile is the record in the subfile identified by the format name that has a relative record number equal to the value of the RELATIVE KEY data item. See the Data Management Guide for more information on subfiles.
TERMINAL Phrase
See the explanation following Format 4 for general considerations concerning the TERMINAL phrase. The TERMINAL phrase specifies which program devices subfile is to have a record written to it. If the TERMINAL phrase is specified, literal-2 or identifier-3 must refer to a work station associated with the TRANSACTION file. If literal-2 or identifier-3 contains a value of blanks, the TERMINAL phrase is treated as if it were not specified. The work station specified by the TERMINAL phrase must have been acquired, either explicitly or implicitly.
198
If the TERMINAL phrase is omitted, the subfile used is the subfile associated with the default program device. See the discussion of the TERMINAL phrase on page 182 to see how the default program device is determined.
END-WRITE Phrase
The END-WRITE phrase serves to explicitly delimit the scope of the statement. For a further discussion of the WRITE statement, the FROM phrase, and the INVALID KEY phrase, see the COBOL/400 Reference. For information on the FORMAT phrase, see the Procedure Division, Common Processing Facilities on page 181.
USE Statement
The USE statement specifies procedures for input/output error handling that are in addition to the standard procedures provided by the input/output control system. Format USE AFTEREXCEPTION STANDARD ERROR PROCEDUREfile-name-1 ON I-O
See the USE Statement section of the COBOL/400 Reference for a further discussion of the USE statement.
199
Conditioning
Condition Name
Length
Functions
Sequence Number
Indicator
Indicator
Indicator
Not (N)
Not (N)
Line
Pos
9 1 0 1 1 1 2 1 3 1 4 1 5 16 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 7 0 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 8 0
CU SMI NQ R E F ( CU SMS T P ) T E X T ( ' CU S T OME R P ROMP T ' ) CA0 3 ( 1 5 ' E ND OF P ROGRAM ' ) 3 ' CU S T OME R MAS T E R I NQU I R Y ' 3 ' CU S T OME R NUMB E R ' 2/ 0 E R RMSG( ' CU S T OME R NUMB E R NOT F OUND + P R E S S R E S E T , T HE N E N T E R VAL I D NUMB E + R ' 99 ) 3 ' U S E F 3 T O E ND P ROGR AM, U S E E N T E R + T O R E T UR N T O P ROMP T SCR E E N ' T E X T ( ' CU S T OME R D I S P L AY ' ) CA0 3 ( 1 5 ' E ND OF P ROGRAM ' ) OVE R L AY 3 ' NAME ' 11 3 ' ADDR E S S ' 11 3 ' CI T Y ' 11 3 ' S T AT E ' 11 2 1 ' Z I P CODE ' 31 3 ' A / R B AL ANCE ' 17
1 3 3
8 8 9 9 1/ 0 1/ 0 11 11 11 11 12 12
Figure 68. Example of a TRANSACTION Inquiry Program Using a Single Display Device
The data description specifications (DDS) for the display device file (CUSMINQ) to be used by this program describe two record formats: CUSPMT and CUSFLDS. The CUSPMT record format contains the constant Customer Master Inquiry, which identifies the display. It also contains the prompt Customer Number and the input
200
field (CUST) where you enter the customer number. Five underscores appear under the input field CUST on the display where you are to enter the customer number. The error message: Customer number not found is also included in this record format. This message is displayed if indicator 99 is set to ON by the program. In addition, this record format defines a function key that you can press to end the program. When you press function key F3, indicator 15 is set to ON in the COBOL program. This indicator is then used to end the program. The CUSFLDS record format contains the following constants: Name Address City State Zip Code A/R Balance. These constants identify the fields to be written out from the program. This record format also describes the fields that correspond to these constants. All of these fields are described as output fields (blank in position 38) because they are filled in by the program; you do not enter any data into these fields. To enter another customer number, press Enter in response to this record. Notice that the CUSFLDS record overlays the CUSPMT record. Therefore, when the CUSFLDS record is written to the display, the CUSPMT record remains on the display. In addition to describing the constants, fields, and attributes for the display, the record formats also define the line numbers and horizontal positions where the constants and fields are to be displayed. Note: The field attributes are defined in a physical file (CUSMSTP) used for field reference purposes, instead of in the DDS for the display file. For example, EDTCDE(J) is defined in CUSMSTP for the field ARBAL.
201
Conditioning
Condition Name
Length
Functions
Form Type
Indicator
Indicator
Sequence Number
Indicator
Not (N)
Not (N)
Line
Pos
9 10 11 12 13 1 4 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 34 35 36 37 3 8 39 4 0 4 1 42 4 3 44 4 5 46 47 4 8 49 5 0 5 1 5 2 5 3 54 5 5 56 5 7 58 59 6 0 6 1 6 2 6 3 6 4 6 5 66 6 7 68 6 9 7 0 7 1 7 2 7 3 7 4 7 5 76 7 7 78 7 9 8 0
A * * P HY S I CAL A R A A A A A A A A A A A A A A A A A K A
CU S T OME R MAS T E R F I L E TEXT ( 5 TEXT ( 25 TEXT ( 2/ 0 TEXT ( / 20 TEXT ( 2 TEXT ( 5 // 00 TEXT ( 6 TEXT ( 1 // 00 TEXT ( 3=B U S 8 /2 0 TEXT ( 8 /2 0 TEXT ( 8 /2 0 TEXT ( 6 // 00 TEXT ( 8 /2 0 TEXT ( 1/ / 2 0 0 TEXT ( 1/ / 2 0 0 TEXT (
' ORDE R HE ADE R R ECORD ' ) ' CU S T OME R NUMB E R ' ) ' CU S T OME R NAME ' ) ' CU S T OME R ADDR E S S ' ) ' CU S T OME R C I T Y ' ) ' S T AT E ' ) ' Z I P CODE ' ) ' CU S T OME R NUMB E R S E ARCH CODE ' ) ' CU S T OME R T YP E 1 =GOV 2 = SCH + 4 =P V T 5 =OT ' ) ' ACCOUN T S R EC . B AL ANCE ' ) ' A / R AMT I N ORDE R F I L E ' ) ' L AS T AMOUN T P A I D I N A / R ' ) ' L AS T DA T E P A I D I N A / R ' ) ' CU S T OME R CR E D I T L I MI T ' ) ' CU S T OME R S AL E S T H I S Y E AR ' ) ' CU S T OME R S AL E S L AS T Y E AR ' )
Figure 69. Data Description Specification for the Record Format CUSMST.
The data description specifications (DDS) for the database file that is used by this program describe one record format: CUSMST. Each field in the record format is described, and the CUST field is identified as the key field for the record format.
202
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLE766. 3 SAMPLE TRANSACTION INQUIRY PROGRAM USING 1 DISPLAY DEVICE 3 4 AUTHOR. PROGRAMMER NAME. 4 5 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 6 DATE-WRITTEN. 12/21/88. 6 7 DATE-COMPILED. 5/24/94 13:42:5 . 7 8 ENVIRONMENT DIVISION. 8 9 CONFIGURATION SECTION. 9 1 SOURCE-COMPUTER. IBM-AS4 . 1 11 OBJECT-COMPUTER. IBM-AS4 . 11 12 INPUT-OUTPUT SECTION. 12 13 FILE-CONTROL. 13 14 SELECT CUST-DISPLAY 14 15 ASSIGN TO WORKSTATION-CUSMINQ 15 16 ORGANIZATION IS TRANSACTION 16 17 CONTROL-AREA IS WS-CONTROL. 17 18 SELECT CUST-MASTER 18 19 ASSIGN TO DATABASE-CUSMSTP 19 2 ORGANIZATION IS INDEXED 2 21 ACCESS IS RANDOM 21 22 RECORD KEY IS CUST OF CUSMST 22 23 FILE STATUS IS CM-STATUS. 23 24 DATA DIVISION. 24 25 FILE SECTION. 25 26 FD CUST-DISPLAY 26 27 LABEL RECORDS ARE OMITTED. 27 28 1 DISP-REC. 28 29 COPY DDS-ALL-FORMATS OF CUSMINQ. 29 + 1 5 CUSMINQ-RECORD PIC X(8 ). + 2 INPUT FORMAT:CUSPMT FROM FILE CUSMINQ OF LIBRARY XMPLIB + 3 CUSTOMER PROMPT 3 + 4 5 CUSPMT-I REDEFINES CUSMINQ-RECORD. 31 + 5 6 CUSPMT-I-INDIC. 32 + 6 7 IN15 PIC 1 INDIC 15. + 7 END OF PROGRAM 33 + 8 7 IN99 PIC 1 INDIC 99. + 9 CUSTOMER NUMBER NOT FOUND PRESS RESET, THE 34 + 1 6 CUST PIC X(5). + 11 CUSTOMER NUMBER + 12 OUTPUT FORMAT:CUSPMT FROM FILE CUSMINQ OF LIBRARY XMPLIB + 13 CUSTOMER PROMPT 35 + 14 5 CUSPMT-O REDEFINES CUSMINQ-RECORD. 36 + 15 6 CUSPMT-O-INDIC. 37 + 16 7 IN99 PIC 1 INDIC 99. + 17 CUSTOMER NUMBER NOT FOUND PRESS RESET, THE + 18 INPUT FORMAT:CUSFLDS FROM FILE CUSMINQ OF LIBRARY XMPLIB + 19 CUSTOMER DISPLAY 38 + 2 5 CUSFLDS-I REDEFINES CUSMINQ-RECORD. 39 + 21 6 CUSFLDS-I-INDIC. 4 + 22 7 IN15 PIC 1 INDIC 15. + 23 END OF PROGRAM + 24 OUTPUT FORMAT:CUSFLDS FROM FILE CUSMINQ OF LIBRARY XMPLIB + 25 CUSTOMER DISPLAY 41 + 26 5 CUSFLDS-O REDEFINES CUSMINQ-RECORD. 42 + 27 6 NAME PIC X(25). + 28 CUSTOMER NAME 43 + 29 6 ADDR PIC X(2 ). + 3 CUSTOMER ADDRESS 44 + 31 6 CITY PIC X(2 ). + 32 CUSTOMER CITY 45 + 33 6 STATE PIC X(2). + 34 STATE 46 + 35 6 ZIP PIC S9(5). + 36 ZIP CODE 47 + 37 6 ARBAL PIC S9(6)V9(2). + 38 ACCOUNTS REC. BALANCE 3 48 31 FD CUST-MASTER 49 32 LABEL RECORDS ARE STANDARD. 5 33 1 CUST-REC. 51 34 COPY DDS-CUSMST OF CUSMSTP. + 1 I-O FORMAT:CUSMST FROM FILE CUSMSTP OF LIBRARY XMPLIB
COPYNAME
CHG DATE 1/22/94 3/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94 1/22/94
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
CUSMST
Figure 70 (Part 1 of 2). Source Listing of a TRANSACTION Inquiry Program Using a Single Display Device.
203
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN + 2 CUSTOMER MASTER RECORD + 3 THE KEY DEFINITIONS FOR RECORD FORMAT CUSMST + 4 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 5 1 CUST ASCENDING AN NO 52 + 6 5 CUSMST. 53 + 7 6 CUST PIC X(5). + 8 CUSTOMER NUMBER 54 + 9 6 NAME PIC X(25). + 1 CUSTOMER NAME 55 + 11 6 ADDR PIC X(2 ). + 12 CUSTOMER ADDRESS 56 + 13 6 CITY PIC X(2 ). + 14 CUSTOMER CITY 57 + 15 6 STATE PIC X(2). + 16 STATE 58 + 17 6 ZIP PIC S9(5) COMP-3. + 18 ZIP CODE 59 + 19 6 SRHCOD PIC X(6). + 2 CUSTOMER NUMBER SEARCH CODE 6 + 21 6 CUSTYP PIC S9(1) COMP-3. + 22 CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5=OT 61 + 23 6 ARBAL PIC S9(6)V9(2) COMP-3. + 24 ACCOUNTS REC. BALANCE 62 + 25 6 ORDBAL PIC S9(6)V9(2) COMP-3. + 26 A/R AMT. IN ORDER FILE 63 + 27 6 LSTAMT PIC S9(6)V9(2) COMP-3. + 28 LAST AMT. PAID IN A/R 64 + 29 6 LSTDAT PIC S9(6) COMP-3. + 3 LAST DATE PAID IN A/R 65 + 31 6 CRDLMT PIC S9(6)V9(2) COMP-3. + 32 CUSTOMER CREDIT LIMIT 66 + 33 6 SLSYR PIC S9(8)V9(2) COMP-3. + 34 CUSTOMER SALES THIS YEAR 67 + 35 6 SLSLYR PIC S9(8)V9(2) COMP-3. + 36 CUSTOMER SALES LAST YEAR 35 68 36 WORKING-STORAGE SECTION. 69 37 1 ONE PIC 1 VALUE B"1". 7 38 1 CM-STATUS PIC X(2). 71 39 1 WS-CONTROL. 72 4 2 WS-IND PIC X(2). 73 41 2 WS-FORMAT PIC X(1 ). 74 42 PROCEDURE DIVISION. 43 BEGIN. 75 44 OPEN I-O CUST-DISPLAY, INPUT CUST-MASTER. 76 45 MOVE ZERO TO IN99 OF CUSPMT-O. 46 LOOP. 77 47 WRITE DISP-REC FORMAT IS "CUSPMT". 78 48 READ CUST-DISPLAY RECORD. 79 49 IF IN15 OF CUSPMT-I 5 IS EQUAL TO ONE 8 51 THEN GO TO FINIS. 81 52 MOVE CUST OF CUSPMT-I TO CUST OF CUSMST. 82 53 READ CUST-MASTER RECORD. 83 54 IF CM-STATUS IS NOT EQUAL " " THEN 84 55 MOVE ONE TO IN99 OF CUSPMT-O, GO TO LOOP. 86 56 MOVE CORRESPONDING CUSMST TO CUSFLDS-O. 87 57 WRITE DISP-REC FORMAT IS "CUSFLDS". 88 58 READ CUST-DISPLAY RECORD. 89 59 IF IN15 OF CUSFLDS-I 6 IS EQUAL TO ONE 9 61 THEN GO TO FINIS. 91 62 MOVE ZERO TO IN99 OF CUSPMT-O. 92 63 GO TO LOOP. 64 FINIS. 93 65 CLOSE CUST-DISPLAY, CUST-MASTER. 66 RETURN-TO-CALLER. 94 67 EXIT PROGRAM. E N D O F S O U R C E
COPYNAME CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST
CHG DATE
Figure 70 (Part 2 of 2). Source Listing of a TRANSACTION Inquiry Program Using a Single Display Device.
The complete source listing for this program example is shown here. In particular, note the FILE-CONTROL and FD entries and the data structures generated by the Format 2 COPY statements.
204
The WRITE operation in statement 77 writes the CUSPMT format to the display. This record prompts you to enter a customer number. If you enter a customer number and press Enter, the next READ operation then reads the record back into the program. The READ operation in statement 82 uses the customer number (CUST) field to retrieve the corresponding CUSMST record from the CUSMSTP file. If no record is found in the CUSMSTP file, indicator 99 is set on. The GO TO operation in statement 84, which is run when indicator 99 is set on, causes the program to branch back to the beginning. The message: Customer number not found is displayed when the format is written, because it is conditioned by indicator 99 in the DDS for the file. When you receive this message, the keyboard locks. You must press the Reset key in response to this message to unlock the keyboard. You can then enter another customer number. If the READ operation retrieves a record from the CUSMSTP file, the WRITE operation writes the CUSFLDS record to the display work station. This record contains the customers name, address, and accounts receivable balance. You then press Enter, and the program branches back to the beginning. You can enter another customer number or end the program. To end the program, press F3, which sets on indicator 15 in the program. When indicator 15 is on, the program closes all files and processes the EXIT PROGRAM statement. The program then returns control to the individual who called the COBOL program. This is the initial display written by the WRITE operation in statement 77:
This display appears if a record is found in the CUSMSTP file for the customer number entered in response to the first display:
205
Use F3 to end program, use enter key to return to prompt screen Name EXAMPLE WHOLESALERS LTD. Address ANYWHERE STREET City ACITY State IL Zipcode 12345 A/R balance 137. 2
This display appears if the CUSMSTP file does not contain a record for the customer number entered in response to the first display:
Customer Master Inquiry Customer Number Use F3 to end program, use enter key to return to prompt screen
Customer number not found, press reset, then enter valid number
206
GX2 1- 98 91- 0 UM/05 0* P r i n t e d i n U . S . A. * Number of sheets per pad may var y sl i ghtl y. Page of
Conditioning
Location Us age ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80
A * * P H Y S I CAL A A* A R A* A A A* A A* A A A A A* A A A A A A* A A* A A A A A A A A* A A A* A A A A A A A* A A A* A* A A A* A A A K A K A
ORD E R D E T A I L
5 5 3
/ 0 / 0
I N OR D E R ' +
COL HDG ( ' QUAN T I T Y ' ' ORD E R E D ' ) T E X T ( ' QUAN T I T Y OR D E R E D ' ) D E S CR P P R I CE 3/ 0 6 2 COL HDG ( ' I T EM D E S CR I P T I ON ' ) CMP ( G T 0 ) / COL HDG ( ' P R I CE ' ) T E X T ( ' S E L L I NG P R I CE ' ) E D T CD E ( J ) COL HDG ( ' E X T E N S I ON ' ) T E X T ( ' E X T E N S I ON AMOUN T OF QT YOR D X + P R I CE ' ) CH E CK ( MF ) COL HDG ( ' B I N ' ' NO . ' )
E X T ENS
WH S L OC ORDDA T CU S T Y P
3 6 1
/ 0
0 /
T E X T ( ' DA T E OR D E R WA S + ENT E R ED ' ) R ANGE ( 1 5 ) COL HDG ( ' CU S T ' ' T Y P E ' ) T E X T ( ' CU S T OME R T Y P E 1 =GOV 2 = S CH + 3 = B U S 4 = P V T 5 =OT ' ) CH E CK ( MF ) COL HDG ( ' S T A T E ' )
S TAT E
AC T MT H AC T Y R ORD E R N L I NNUM
2 2
0 /
COL HDG ( ' ACC T ' ' MT H ' ) T E X T ( ' ACCOUN T I NG MON T H OF S AL E ' ) COL HDG ( ' ACC T ' ' Y E AR ' ) T E X T ( ' ACCOUN T I NG Y E AR OF S A L E ' )
/ 0
Figure 71 (Part 1 of 3). Data Description Specifications for an Order Inquiry Program
207
I n t er n at i on al Bu s i n e s s Mac h i ne s
Fi l e Programmer Date
Conditioning
Location
Condition Name
Length
U s age ( b / O/ I / B/ H/ M/ N/ P) /
And/Or/Comment (A/O/*)
Funct i ons
Form Type
Sequence Number
Decimal Pos i t i on s
Indicator
Indicator
Indicator
Not (N)
Not (N)
Not (N)
Line
Pos
9 1 0 1 1 1 2 1 3 14 1 5 16 1 7 18 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 7 0 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 8 0
/ A * * OR D I NQD E X I S T I NG OR D E R R E V I EW A R S UB 1 / A I T EM 5 0 1/ 0 / A Q T YOR D 3 0 1/ 0 A D E S CR P 3/ 0 1/ 0 A P R I CE 6 2 1/ 0 / A E X T ENS 8 2 10 A A A R S UBCT L 1 A 58 A 57 A N5 8 A A A 57 A A A N4 5 AON 4 7 A A A A A 1 A 3 A OR D E R N 5Y / B 0 3 A 61 A 47 A 62 A A 4 / A OR DDA T 6 0 4 A 5 A CU S T 5 5 A NAME 25 3 A ADDR 20 4 A CI TY 20 5 A S TAT E 2 6 / A ZIP 5 0 6 A 1 A OR DAMT 8 2 1 A A 2 A S T S OR D 12 2 A 3 A S T S OP N 12 3 A 4 A CU S OR D 15 4 A A 5 A S HP V I A 15 5 A 6 / A P R T DA T 6 0 6 A 7 / A I NVNUM 5 0 7 A 7 / A AC T MT H 2 0 7 A 7 / A AC T Y R 2 0 7 A 8 A 8 A 8 A 8 A 8
SFL 2 T E X T ( ' I T E M NUMB E R ' ) 9 T E X T ( ' QUAN T I T Y OR D E R E D ' ) 1 4 T E X T ( ' I T E M D E S CR I P T I ON ' ) 4 6 T E X T ( ' S E L L I NG P R I CE ' ) 5 6 E D T CD E ( J ) T E X T ( ' E X T E N S I ON AMOUN T OF + Q T YOR D X P R I CE ' ) S F L C T L ( S UB 1 ) S F L CL R S F LDSP S F L D S PC T L SFL S I Z ( 57 ) S F L P AG ( 1 4 ) S F L E ND OV E R L AY L OCK R OL L U P ( 9 7 ' CON T I NU E D I S P L AY ' ) CA 1 2 ( 9 8 ' E ND OF P ROGR AM ' ) S E T OF F ( 5 7 ' D I S P L A Y S U B F I L E ' ) S E T OF F ( 5 8 ' OF F =D I S P L AY S U B C T L 1 ON= + CL E AR S U B F I L E ' ) 2 ' E X I S T I NG OR D E R I NQU I R Y ' 2 ' OR D E R ' 8 T E X T ( ' OR D E R NUMB E R ' ) E R RMS G ( ' OR D E R NUMB E R NO T F OUND ' 6 1 ) E R RMS G ( ' NO L I NE S F OR T H I S OR D E R ' 4 7 ) E R RMS G ( ' NO CU S T OME R R E COR D F OUND F O+ R T H I S OR D E R ' 6 2 ) 2 ' DA T E ' 7 T E X T ( ' DA T E OR D E R WA S E N T E R E D ' ) 2 ' CU S T # ' 9 T E X T ( ' CU S T OME R NUMB E R ' ) 1 6 T E X T ( ' CU S T OME R NAME ' ) 1 6 T E X T ( ' CU S T OME R ADDR E S S ' ) 1 6 T E X T ( ' CU S T OME R C I T Y ' ) 1 6 T E X T ( ' CU S T OME R S T A T E ' ) 3 1 T E X T ( ' Z I P COD E ' ) 4 4 ' T OT AL ' 5 1 T E X T ( ' T O T A L DOL L AR AMOUN T OF T H E + OR D E R ' ) 44 ' S TAT US ' 51 4 4 ' OP E N ' 51 4 4 ' CU S T OME R OR D E R ' 5 9 T E X T ( ' CU S T OME R P U R CHA S E OR D E R + NUMB E R ' ) 44 ' SH I P V I A ' 5 9 T E X T ( ' S H I P P I NG I N S T R UC T I ON S ' ) 4 4 ' P R I N T E D DA T E ' 5 7 T E X T ( ' DA T E OR D E R WA S P R I N T E D ' ) 2 9 ' I NVO I CE ' 3 8 T E X T ( ' I NVO I CE NUMB E R ' ) 6 4 ' MT H ' 6 8 T E X T ( ' ACCOUN T I NG MON T H OF S A L E ' ) 7 2 ' Y E AR ' 7 7 T E X T ( ' ACCOUN T I NG Y E AR OF S A L E ' ) 2 ' I T EM ' 8 ' QT Y ' 1 4 ' I T E M D E S CR I P T I ON ' 4 6 ' P R I CE ' 5 5 ' E X T E N S I ON '
Figure 71 (Part 2 of 3). Data Description Specifications for an Order Inquiry Program
208
GX2 1- 98 91- 0 UM/05 0* P r i n t ed i n U . S . A. * Number of sheets per pad may var y sl i ghtl y. Page of
Conditioning
Location Us age ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 19 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 7 0 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 8 0
A * * P H Y S I CAL A R A A A A A A A A A A A A A A A A A A A A A A A A K A A A A A A A A A
ORDHDR P ORDHDR CU S T ORD E R N ORDDA T CU S OR D S HP V I A ORD S T S OP R NAM ORDAMT CU S T Y P I NVNUM P R T DA T OP N S T S T OT L I N AC T MT H AC T Y R S TAT E AMP A I D ORD E R N
ORD E R H E AD E R F I L E T E X T ( ' OR D E R H E AD E R R E COR D ' ) 5 T E X T ( ' CU S T OME R NUMB E R ' ) // 5 00 T E X T ( ' OR D E R NUMB E R ' ) 6 // 00 T E X T ( ' DA T E OR D E R E N T E R E D ' ) 15 T E X T ( ' CU S T OME R P URCHA S E ORD E R + NUMB E R ' ) 15 T E X T ( ' S H I P P I NG I N S T R UC T I ON S ' ) 1 // 00 T E X T ( ' OR D E R S T A T U S 1 PCS 2CN T 3CHK + 4 R D Y 5 P R T 6 PCK ' ) 1/ 0 T E X T ( ' OP E R A T OR WHO E N T E R E D + OR D ' ) 8 /2 0 T E X T ( ' DOL L AR AMOUN T OF + OR D E R ' ) 1 / / 00 T E X T ( ' CU S T OME R T Y P E 1 =GOV 2 = S CH + 3 = B U S 4 = P V T 5 =OT ' ) 5 // 00 T E X T ( ' I NVO I CE NUMB E R ' ) 6 // 00 T E X T ( ' DA T E OR D E R WA S P R I N T E D ' ) 1 / / 00 T E X T ( ' OR D E R OP E N S T A T U S 1 =OP E N + 2 =CL OS E 3 =CANCE L ' ) 3 // 00 T E X T ( ' T OT AL L I NE I T EMS I N ORD E R ' ) 2 // 00 T E X T ( ' ACCOUN T I NG MON T H OF S AL E ' ) 2 // 00 T E X T ( ' ACCOUN T I NG Y E AR OF S A L E ' ) 2 T E X T ( ' S T AT E ' ) 8 /2 0 T E X T ( ' T OT AL AMOUN T P A I D ' )
Figure 71 (Part 3 of 3). Data Description Specifications for an Order Inquiry Program
209
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLE773. 3 SAMPLE ORDER INQUIRY PROGRAM 3 4 AUTHOR. PROGRAMMER NAME. 4 5 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 6 DATE-WRITTEN. 12/22/88. 8 8 DATE-COMPILED. 5/24/94 13:29:54 . 7 8 ENVIRONMENT DIVISION. 8 9 CONFIGURATION SECTION. 9 1 SOURCE-COMPUTER. IBM-AS4 . 1 11 OBJECT-COMPUTER. IBM-AS4 . 11 12 INPUT-OUTPUT SECTION. 12 13 FILE-CONTROL. 13 14 SELECT ORDER-HEADER-FILE 14 15 ASSIGN TO DATABASE-ORDHDRP 15 16 ORGANIZATION IS INDEXED 16 17 ACCESS MODE IS RANDOM 17 18 RECORD KEY IS ORDERN OF ORDER-HEADER-RECORD. 18 19 SELECT ORDER-DETAIL-FILE 19 2 ASSIGN TO DATABASE-ORDDTLP 2 21 ORGANIZATION IS INDEXED 21 22 ACCESS IS DYNAMIC 22 23 RECORD KEY IS ORDER-DETAIL-RECORD-KEY. 23 24 SELECT CUSTOMER-MASTER-FILE 24 25 ASSIGN TO DATABASE-CUSMSTP 25 26 ORGANIZATION IS INDEXED 26 27 ACCESS IS RANDOM 27 28 RECORD KEY IS CUST OF CUSTOMER-MASTER-RECORD. 28 29 SELECT EXISTING-ORDER-DISPLAY-FILE 29 3 ASSIGN TO WORKSTATION-ORDINQD 3 31 ORGANIZATION IS TRANSACTION 31 32 ACCESS IS DYNAMIC 32 33 RELATIVE KEY IS SUBFILE-RECORD-NUMBER 33 34 FILE STATUS IS STATUS-CODE-ONE. 34 35 DATA DIVISION. 35 36 FILE SECTION. 36 37 FD ORDER-HEADER-FILE 37 38 LABEL RECORDS ARE STANDARD. 38 39 1 ORDER-HEADER-RECORD. 39 4 COPY DDS-ORDHDR OF ORDHDRP. + 1 I-O FORMAT:ORDHDR FROM FILE ORDHDRP OF LIBRARY XMPLIB + 2 ORDER HEADER RECORD + 3 THE KEY DEFINITIONS FOR RECORD FORMAT ORDHDR + 4 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 5 1 ORDERN ASCENDING SIGNED NO 4 + 6 5 ORDHDR. 41 + 7 6 CUST PIC X(5). + 8 CUSTOMER NUMBER 42 + 9 6 ORDERN PIC S9(5) COMP-3. + 1 ORDER NUMBER 43 + 11 6 ORDDAT PIC S9(6) COMP-3. + 12 DATE ORDER ENTERED 44 + 13 6 CUSORD PIC X(15). + 14 CUSTOMER PURCHASE ORDER NUMBER 45 + 15 6 SHPVIA PIC X(15). + 16 SHIPPING INSTRUCTIONS 46 + 17 6 ORDSTS PIC S9(1) COMP-3. + 18 ORDER STATUS 1PCS 2CNT 3CHK 4RDY 5PRT 6PC 47 + 19 6 OPRNAM PIC X(1 ). + 2 OPERATOR WHO ENTERED ORD 48 + 21 6 ORDAMT PIC S9(6)V9(2) COMP-3. + 22 DOLLAR AMOUNT OF ORDER 49 + 23 6 CUSTYP PIC S9(1) COMP-3. + 24 CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5=OT 5 + 25 6 INVNUM PIC S9(5) COMP-3. + 26 INVOICE NUMBER 51 + 27 6 PRTDAT PIC S9(6) COMP-3. + 28 DATE ORDER WAS PRINTED 52 + 29 6 OPNSTS PIC S9(1) COMP-3. + 3 ORDER OPEN STATUS 1=OPEN 2= CLOSE 3=CANCEL 53 + 31 6 TOTLIN PIC S9(3) COMP-3. + 32 TOTAL LINE ITEMS IN ORDER 54 + 33 6 ACTMTH PIC S9(2) COMP-3. + 34 ACCOUNTING MONTH OF SALE 55 + 35 6 ACTYR PIC S9(2) COMP-3. + 36 ACCOUNTING YEAR OF SALE
COPYNAME
CHG DATE 1/25/94 3/22/94 3/22/94 1/25/94 1/25/94 1/25/94 3/ 1/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 3/21/94 1/25/94 1/26/94 1/26/94 1/25/94 3/21/94 1/25/94 1/25/94 1/27/94 1/25/94 1/25/94 1/25/94 1/25/94 1/26/94 1/25/94 3/23/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 1/25/94 3/21/94
ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR
210
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 56 + 37 6 STATE PIC X(2). + 38 STATE 57 + 39 6 AMPAID PIC S9(6)V9(2) COMP-3. + 4 AMOUNT PAID 41 58 42 FD ORDER-DETAIL-FILE 59 43 LABEL RECORDS ARE STANDARD. 6 44 1 ORDER-DETAIL-RECORD. 61 45 COPY DDS-ORDDTL OF ORDDTLP. + 1 I-O FORMAT:ORDDTL FROM FILE ORDDTLP OF LIBRARY XMPLIB + 2 ORDER DETAIL RECORD + 3 THE KEY DEFINITIONS FOR RECORD FORMAT ORDDTL + 4 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 5 1 ORDERN ASCENDING SIGNED NO + 6 2 LINNUM ASCENDING SIGNED NO 62 + 7 5 ORDDTL. 63 + 8 6 CUST PIC X(5). + 9 CUSTOMER NUMBER 64 + 1 6 ORDERN PIC S9(5) COMP-3. + 11 ORDER NUMBER 65 + 12 6 LINNUM PIC S9(3) COMP-3. + 13 LINE NUMBER OF LINE IN ORDER 66 + 14 6 ITEM PIC S9(5) COMP-3. + 15 ITEM NUMBER 67 + 16 6 QTYORD PIC S9(3) COMP-3. + 17 QUANTITY ORDERED 68 + 18 6 DESCRP PIC X(3 ). + 19 ITEM DESCRIPTION 69 + 2 6 PRICE PIC S9(4)V9(2) COMP-3. + 21 SELLING PRICE 7 + 22 6 EXTENS PIC S9(6)V9(2) COMP-3. + 23 EXTENSION AMOUNT OF QTYORD X PRICE 71 + 24 6 WHSLOC PIC X(3). + 25 BIN NO. 72 + 26 6 ORDDAT PIC S9(6) COMP-3. + 27 DATE ORDER WAS ENTERED 73 + 28 6 CUSTYP PIC S9(1) COMP-3. + 29 CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5= 74 + 3 6 STATE PIC X(2). + 31 STATE 75 + 32 6 ACTMTH PIC S9(2) COMP-3. + 33 ACCOUNTING MONTH OF SALE 76 + 34 6 ACTYR PIC S9(2) COMP-3. + 35 ACCOUNTING YEAR OF SALE 77 46 66 ORDER-DETAIL-RECORD-KEY RENAMES ORDERN THRU LINNUM. 47 78 48 FD CUSTOMER-MASTER-FILE 79 49 LABEL RECORDS ARE STANDARD. 8 5 1 CUSTOMER-MASTER-RECORD. 81 51 COPY DDS-CUSMST OF CUSMSTP. + 1 I-O FORMAT:CUSMST FROM FILE CUSMSTP OF LIBRARY XMPLIB + 2 CUSTOMER MASTER RECORD + 3 THE KEY DEFINITIONS FOR RECORD FORMAT CUSMST + 4 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 5 1 CUST ASCENDING AN NO 82 + 6 5 CUSMST. 83 + 7 6 CUST PIC X(5). + 8 CUSTOMER NUMBER 84 + 9 6 NAME PIC X(25). + 1 CUSTOMER NAME 85 + 11 6 ADDR PIC X(2 ). + 12 CUSTOMER ADDRESS 86 + 13 6 CITY PIC X(2 ). + 14 CUSTOMER CITY 87 + 15 6 STATE PIC X(2). + 16 STATE 88 + 17 6 ZIP PIC S9(5) COMP-3. + 18 ZIP CODE 89 + 19 6 SRHCOD PIC X(6). + 2 CUSTOMER NUMBER SEARCH CODE 9 + 21 6 CUSTYP PIC S9(1) COMP-3. + 22 CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5=OT 91 + 23 6 ARBAL PIC S9(6)V9(2) COMP-3. + 24 ACCOUNTS REC. BALANCE 92 + 25 6 ORDBAL PIC S9(6)V9(2) COMP-3.
CHG DATE
ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL ORDDTL
CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST
211
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN + 26 A/R AMT. IN ORDER FILE 93 + 27 6 LSTAMT PIC S9(6)V9(2) COMP-3. + 28 LAST AMT. PAID IN A/R 94 + 29 6 LSTDAT PIC S9(6) COMP-3. + 3 LAST DATE PAID IN A/R 95 + 31 6 CRDLMT PIC S9(6)V9(2) COMP-3. + 32 CUSTOMER CREDIT LIMIT 96 + 33 6 SLSYR PIC S9(8)V9(2) COMP-3. + 34 CUSTOMER SALES THIS YEAR 97 + 35 6 SLSLYR PIC S9(8)V9(2) COMP-3. + 36 CUSTOMER SALES LAST YEAR 52 98 53 FD EXISTING-ORDER-DISPLAY-FILE 99 54 LABEL RECORDS ARE OMITTED. 1 55 1 EXISTING-ORDER-DISPLAY-RECORD. 1 1 56 COPY DDS-ALL-FORMATS OF ORDINQD. 1 2 + 1 5 ORDINQD-RECORD PIC X(171). + 2 I-O FORMAT:SUB1 FROM FILE ORDINQD OF LIBRARY XMPLIB + 3 1 3 + 4 5 SUB1 REDEFINES ORDINQD-RECORD. 1 4 + 5 6 ITEM PIC S9(5). + 6 ITEM NUMBER 1 5 + 7 6 QTYORD PIC S9(3). + 8 QUANTITY ORDERED 1 6 + 9 6 DESCRP PIC X(3 ). + 1 ITEM DESCRIPTION 1 7 + 11 6 PRICE PIC S9(4)V9(2). + 12 SELLING PRICE 1 8 + 13 6 EXTENS PIC S9(6)V9(2). + 14 EXTENSION AMOUNT OF QTYORD X PRICE + 15 INPUT FORMAT:SUBCTL1 FROM FILE ORDINQD OF LIBRARY XMPLIB + 16 1 9 + 17 5 SUBCTL1-I REDEFINES ORDINQD-RECORD. 11 + 18 6 SUBCTL1-I-INDIC. 111 + 19 7 IN97 PIC 1 INDIC 97. + 2 CONTINUE DISPLAY 112 + 21 7 IN98 PIC 1 INDIC 98. + 22 END OF PROGRAM 113 + 23 7 IN57 PIC 1 INDIC 57. + 24 DISPLAY SUBFILE 114 + 25 7 IN58 PIC 1 INDIC 58. + 26 OFF = DISPLAY SUBCTL1 ON = CLEAR SUBFILE 115 + 27 7 IN61 PIC 1 INDIC 61. + 28 ORDER NUMBER NOT FOUND 116 + 29 7 IN47 PIC 1 INDIC 47. + 3 NO LINE FOR THIS ORDER 117 + 31 7 IN62 PIC 1 INDIC 62. + 32 NO CUSTOMER RECORD 118 + 33 6 ORDERN PIC S9(5). + 34 ORDER NUMBER + 35 OUTPUT FORMAT:SUBCTL1 FROM FILE ORDINQD OF LIBRARY XMPLIB + 36 119 + 37 5 SUBCTL1-O REDEFINES ORDINQD-RECORD. 12 + 38 6 SUBCTL1-O-INDIC. 121 + 39 7 IN58 PIC 1 INDIC 58. + 4 OFF = DISPLAY SUBCTL1 ON = CLEAR SUBFILE 122 + 41 7 IN57 PIC 1 INDIC 57. + 42 DISPLAY SUBFILE 123 + 43 7 IN45 PIC 1 INDIC 45. 124 + 44 7 IN47 PIC 1 INDIC 47. + 45 NO LINE FOR THIS ORDER 125 + 46 7 IN61 PIC 1 INDIC 61. + 47 ORDER NUMBER NOT FOUND 126 + 48 7 IN62 PIC 1 INDIC 62. + 49 NO CUSTOMER RECORD 127 + 5 6 ORDERN PIC S9(5). + 51 ORDER NUMBER 128 + 52 6 ORDDAT PIC S9(6). + 53 DATE ORDER WAS ENTERED 129 + 54 6 CUST PIC X(5). + 55 CUSTOMER NUMBER 13 + 56 6 NAME PIC X(25). + 57 CUSTOMER NAME 131 + 58 6 ADDR PIC X(2 ). + 59 CUSTOMER ADDRESS 132 + 6 6 CITY PIC X(2 ).
COPYNAME CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST
CHG DATE
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
212
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN + 61 CUSTOMER CITY 133 + 62 6 STATE PIC X(2). + 63 CUSTOMER STATE 134 + 64 6 ZIP PIC S9(5). + 65 ZIP CODE 135 + 66 6 ORDAMT PIC S9(6)V9(2). + 67 TOTAL AMOUNT OF ORDER 136 + 68 6 STSORD PIC X(12). 137 + 69 6 STSOPN PIC X(12). 138 + 7 6 CUSORD PIC X(15). + 71 CUSTOMER PURCHASE ORDER NUMBER 139 + 72 6 SHPVIA PIC X(15). + 73 SHIPPING INSTRUCTIONS 14 + 74 6 PRTDAT PIC S9(6). + 75 DATE ORDER WAS PRINTED 141 + 76 6 INVNUM PIC S9(5). + 77 INVOICE NUMBER 142 + 78 6 ACTMTH PIC S9(2). + 79 ACCOUNTING MONTH OF SALE 143 + 8 6 ACTYR PIC S9(2). + 81 ACCOUNTING YEAR OF SALE 57 144 58 WORKING-STORAGE SECTION. 145 59 1 EXISTING-ORDER-DISPLAY-KEY. 146 6 5 SUBFILE-RECORD-NUMBER PIC 9(2) 147 61 VALUE ZERO. 62 148 63 1 ORDER-STATUS-COMMENT-VALUES. 149 64 5 FILLER PIC X(12) 15 65 VALUE "1-IN PROCESS". 151 66 5 FILLER PIC X(12) 152 67 VALUE "2-CONTINUED ". 153 68 5 FILLER PIC X(12) 154 69 VALUE "3-CREDIT CHK". 155 7 5 FILLER PIC X(12) 156 71 VALUE "4-READY PRT ". 157 72 5 FILLER PIC X(12) 158 73 VALUE "5-PRINTED ". 159 74 5 FILLER PIC X(12) 16 75 VALUE "6-PICKED ". 161 76 5 FILLER PIC X(12) 162 77 VALUE "7-INVOICED ". 163 78 5 FILLER PIC X(12) 164 79 VALUE "8-INVALID ". 165 8 5 FILLER PIC X(12) 166 81 VALUE "9-CANCELED ". 82 167 83 1 ORDER-STATUS-COMMENT-TABLE 168 84 REDEFINES ORDER-STATUS-COMMENT-VALUES. 169 85 5 ORDER-STATUS OCCURS 9 TIMES. 17 86 1 ORDER-STATUS-COMMENT PIC X(12). 87 171 88 1 OPEN-STATUS-COMMENT-VALUES. 172 89 5 FILLER PIC X(12) 173 9 VALUE "1-OPEN ". 174 91 5 FILLER PIC X(12) 175 92 VALUE "2-CLOSED ". 176 93 5 FILLER PIC X(12) 177 94 VALUE "3-CANCELED ". 95 178 96 1 OPEN-STATUS-COMMENT-TABLE 179 97 REDEFINES OPEN-STATUS-COMMENT-VALUES. 18 98 5 OPEN-STATUS OCCURS 3 TIMES. 181 99 1 OPEN-STATUS-COMMENT PIC X(12). 1 182 1 1 1 ERRHDL-PARAMETERS. 183 1 2 5 STATUS-CODE-ONE PIC X(2). 184 1 3 88 SUBFILE-IS-FULL VALUE "9M". 1 4 185 1 5 1 ERRPGM-PARAMETERS. 186 1 6 5 DISPLAY-PARAMETER PIC X(8) 187 1 7 VALUE "ORD22 D ". 188 1 8 5 DUMMY-ONE PIC X(6) 189 1 9 VALUE SPACES. 19 11 5 DUMMY-TWO PIC X(8) 191 111 VALUE SPACES.
COPYNAME <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
CHG DATE
213
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 192 112 5 STATUS-CODE-TWO. 193 113 1 PRIMARY PIC X(1). 194 114 1 SECONDARY PIC X(1). 195 115 1 FILLER PIC X(5) 196 116 VALUE SPACES. 117 197 118 1 SWITCH-AREA. 198 119 5 SW 1 PIC 1. 199 12 88 NO-MORE-DETAIL-LINE-ITEMS VALUE B"1". 2 121 88 MORE-DETAIL-LINE-ITEMS-EXIST VALUE B" ". 2 1 122 5 SW 2 PIC 1. 2 2 123 88 WRITE-DISPLAY VALUE B"1". 2 3 124 88 READ-DISPLAY VALUE B" ". 2 4 125 5 SW 3 PIC 1. 2 5 126 88 SUBCTL1-FORMAT VALUE B"1". 2 6 127 88 NOT-SUBCTL1-FORMAT VALUE B" ". 2 7 128 5 SW 4 PIC 1. 2 8 129 88 SUB1-FORMAT VALUE B"1". 2 9 13 88 NOT-SUB1-FORMAT VALUE B" ". 131 21 132 1 INDICATOR-AREA. 211 133 5 IN98 PIC 1 INDIC 98. 212 134 88 END-OF-EXISTING-ORDER-INQUIRY VALUE B"1". 213 135 5 IN97 PIC 1 INDIC 97. 214 136 88 CONTINUE-DETAIL-LINES-DISPLAY VALUE B"1". 215 137 5 IN62 PIC 1 INDIC 62. 216 138 88 CUSTOMER-NOT-FOUND VALUE B"1". 217 139 88 CUSTOMER-EXIST VALUE B" ". 218 14 5 IN61 PIC 1 INDIC 61. 219 141 88 ORDER-NOT-FOUND VALUE B"1". 22 142 88 ORDER-EXIST VALUE B" ". 221 143 5 IN58 PIC 1 INDIC 58. 222 144 88 CLEAR-SUBFILE VALUE B"1". 223 145 88 DISPLAY-SUBFILE-CONTROL VALUE B" ". 224 146 5 IN57 PIC 1 INDIC 57. 225 147 88 DISPLAY-SUBFILE VALUE B"1". 226 148 5 IN47 PIC 1 INDIC 47. 227 149 88 NO-DETAIL-LINES-FOR-ORDER VALUE B"1". 228 15 88 DETAIL-LINES-FOR-ORDER-EXIST VALUE B" ". 229 151 5 IN45 PIC 1 INDIC 45. 23 152 88 END-OF-ORDER VALUE B"1". 153 231 154 PROCEDURE DIVISION. 155 156 DECLARATIVES. 157 TRANSACTION-ERROR SECTION. 158 USE AFTER STANDARD ERROR PROCEDURE 159 EXISTING-ORDER-DISPLAY-FILE. 16 WORK-STATION-ERROR-HANDLER. 232 161 IF SUBFILE-IS-FULL THEN 162 NEXT SENTENCE 163 ELSE 233 164 DISPLAY "WORK-STATION ERROR" STATUS-CODE-ONE. 165 END DECLARATIVES. 166 167 INQUIRY-INTO-EXISTING-ORDER SECTION. 168 MAINLINE-ROUTINE. 234 169 PERFORM SET-UP-ROUTINE. 235 17 PERFORM EXISTING-ORDER-INQUIRY 171 UNTIL END-OF-EXISTING-ORDER-INQUIRY. 236 172 PERFORM CLEAN-UP-ROUTINE. 173 174 SET-UP-ROUTINE. 237 175 OPEN INPUT ORDER-HEADER-FILE 176 ORDER-DETAIL-FILE 177 CUSTOMER-MASTER-FILE 178 I-O EXISTING-ORDER-DISPLAY-FILE. 238 179 MOVE SPACES TO CUST OF SUBCTL1-O 18 NAME OF SUBCTL1-O 181 ADDR OF SUBCTL1-O 182 CITY OF SUBCTL1-O 183 STATE OF SUBCTL1-O 184 STSORD OF SUBCTL1-O 185 STSOPN OF SUBCTL1-O 186 CUSORD OF SUBCTL1-O.
COPYNAME
CHG DATE
214
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 239 187 MOVE ZEROS TO ORDERN OF SUBCTL1-O 188 ORDDAT OF SUBCTL1-O 189 ZIP OF SUBCTL1-O 19 ORDAMT OF SUBCTL1-O 191 PRTDAT OF SUBCTL1-O 192 INVNUM OF SUBCTL1-O 193 ACTMTH OF SUBCTL1-O 194 ACTYR OF SUBCTL1-O. 24 195 MOVE ALL B' ' TO INDICATOR-AREA. 241 196 SET READ-DISPLAY 197 NOT-SUBCTL1-FORMAT 198 NOT-SUB1-FORMAT TO TRUE. 242 199 MOVE CORR INDICATOR-AREA TO SUBCTL1-O-INDIC. 243 2 WRITE EXISTING-ORDER-DISPLAY-RECORD FORMAT IS "SUBCTL1". 244 2 1 READ EXISTING-ORDER-DISPLAY-FILE RECORD. 245 2 2 MOVE CORR SUBCTL1-I-INDIC TO INDICATOR-AREA. 2 3 2 4 EXISTING-ORDER-INQUIRY. 246 2 5 IF CONTINUE-DETAIL-LINES-DISPLAY THEN 247 2 6 PERFORM READ-NEXT-ORDER-DETAIL-RECORD 248 2 7 IF MORE-DETAIL-LINE-ITEMS-EXIST THEN 249 2 8 IF ORDERN OF ORDER-DETAIL-RECORD IS NOT EQUAL TO 2 9 ORDERN OF ORDER-HEADER-RECORD THEN 25 21 SET DISPLAY-SUBFILE TO TRUE 251 211 SET NO-DETAIL-LINES-FOR-ORDER TO TRUE 212 ELSE 252 213 PERFORM SUBFILE-SET-UP 214 ELSE 253 215 SET DISPLAY-SUBFILE TO TRUE 254 216 SET NO-DETAIL-LINES-FOR-ORDER TO TRUE 217 ELSE 255 218 PERFORM ORDER-NUMBER-VALIDATION. 256 219 MOVE CORR INDICATOR-AREA TO SUBCTL1-O-INDIC. 257 22 SET WRITE-DISPLAY TO TRUE. 258 221 SET SUBCTL1-FORMAT TO TRUE. 259 222 WRITE EXISTING-ORDER-DISPLAY-RECORD FORMAT IS "SUBCTL1". 26 223 READ EXISTING-ORDER-DISPLAY-FILE RECORD. 261 224 MOVE CORR SUBCTL1-I-INDIC TO INDICATOR-AREA. 225 ORDER-NUMBER-VALIDATION. 262 226 PERFORM READ-ORDER-HEADER-FILE. 263 227 IF ORDER-EXIST THEN 264 228 PERFORM READ-CUSTOMER-MASTER-FILE 265 229 IF CUSTOMER-EXIST THEN 266 23 PERFORM READ-FIRST-ORDER-DETAIL-RECORD 267 231 IF DETAIL-LINES-FOR-ORDER-EXIST THEN 268 232 PERFORM SUBFILE-SET-UP 233 ELSE 234 NEXT SENTENCE 235 ELSE 236 NEXT SENTENCE 237 ELSE 238 NEXT SENTENCE. 239 READ-ORDER-HEADER-FILE. 269 24 MOVE ORDERN OF SUBCTL1-I OF EXISTING-ORDER-DISPLAY-RECORD 241 TO ORDERN OF ORDER-HEADER-RECORD. 27 242 READ ORDER-HEADER-FILE 271 243 INVALID KEY SET ORDER-NOT-FOUND TO TRUE. 244 READ-CUSTOMER-MASTER-FILE. 272 245 MOVE CUST OF ORDER-HEADER-RECORD 246 TO CUST OF CUSTOMER-MASTER-RECORD. 273 247 READ CUSTOMER-MASTER-FILE 274 248 INVALID KEY SET CUSTOMER-NOT-FOUND TO TRUE. 249 READ-FIRST-ORDER-DETAIL-RECORD. 275 25 MOVE ORDERN OF ORDER-HEADER-RECORD 251 TO ORDERN OF ORDER-DETAIL-RECORD. 276 252 MOVE 1 TO LINNUM OF ORDER-DETAIL-RECORD. 277 253 READ ORDER-DETAIL-FILE 278 254 INVALID KEY SET NO-DETAIL-LINES-FOR-ORDER TO TRUE. 255 SUBFILE-SET-UP. 279 256 SET CLEAR-SUBFILE TO TRUE. 28 257 MOVE CORR INDICATOR-AREA TO SUBCTL1-O-INDIC. 281 258 SET WRITE-DISPLAY TO TRUE. 282 259 SET SUBCTL1-FORMAT TO TRUE. 283 26 WRITE EXISTING-ORDER-DISPLAY-RECORD FORMAT IS "SUBCTL1". 284 261 SET DISPLAY-SUBFILE-CONTROL TO TRUE.
COPYNAME
CHG DATE
215
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 285 262 PERFORM BUILD-DISPLAY-SUBFILE 263 UNTIL NO-MORE-DETAIL-LINE-ITEMS 264 OR SUBFILE-IS-FULL. 286 265 MOVE CORR ORDHDR OF ORDER-HEADER-RECORD 266 TO SUBCTL1-O OF EXISTING-ORDER-DISPLAY-RECORD. 287 267 MOVE CORR CUSMST OF CUSTOMER-MASTER-RECORD 268 TO SUBCTL1-O OF EXISTING-ORDER-DISPLAY-RECORD. 288 269 MOVE ORDER-STATUS(ORDSTS) TO STSORD. 289 27 MOVE OPEN-STATUS(OPNSTS) TO STSOPN. 29 271 SET MORE-DETAIL-LINE-ITEMS-EXIST TO TRUE. 291 272 MOVE ZEROS TO SUBFILE-RECORD-NUMBER. 273 BUILD-DISPLAY-SUBFILE. 292 274 MOVE CORR ORDDTL OF ORDER-DETAIL-RECORD 275 TO SUB1 OF EXISTING-ORDER-DISPLAY-RECORD. 293 276 SET WRITE-DISPLAY TO TRUE. 294 277 SET SUB1-FORMAT TO TRUE. 295 278 ADD 1 TO SUBFILE-RECORD-NUMBER. 296 279 WRITE SUBFILE EXISTING-ORDER-DISPLAY-RECORD FORMAT IS "SUB1". 297 28 IF SUBFILE-IS-FULL THEN 298 281 SET DISPLAY-SUBFILE TO TRUE 282 ELSE 299 283 PERFORM READ-NEXT-ORDER-DETAIL-RECORD 3 284 IF NO-MORE-DETAIL-LINE-ITEMS THEN 285 NEXT SENTENCE 286 ELSE 3 1 287 IF ORDERN OF ORDER-DETAIL-RECORD IS NOT EQUAL TO 288 ORDERN OF ORDER-HEADER-RECORD THEN 3 2 289 SET DISPLAY-SUBFILE TO TRUE 3 3 29 SET NO-MORE-DETAIL-LINE-ITEMS TO TRUE 291 ELSE 292 NEXT SENTENCE. 293 READ-NEXT-ORDER-DETAIL-RECORD. 3 4 294 READ ORDER-DETAIL-FILE NEXT RECORD 3 5 295 AT END SET DISPLAY-SUBFILE TO TRUE 3 6 296 SET NO-MORE-DETAIL-LINE-ITEMS TO TRUE. 297 CLEAN-UP-ROUTINE. 3 7 298 CLOSE ORDER-HEADER-FILE 299 ORDER-DETAIL-FILE 3 CUSTOMER-MASTER-FILE 3 1 EXISTING-ORDER-DISPLAY-FILE. 3 8 3 2 STOP RUN. E N D O F S O U R C E
COPYNAME
CHG DATE
This is the initial order-entry prompt display written to the work station:
Existing Order Entry Order 124 Date Cust # Item Qty Invoice Item Description
Total Status Open Customer order Ship via Printed date Mth Price Extension Year
This display appears if there are detail order records for the customer whose order number was entered in the first display:
216
Existing Order Entry Order 17924 Date 11 587 Cust # 112 Item Qty 33 1 3 331 1 44529 4 44958 2 461 2 1 462 1 1 479 2 2 ABC HARDWARE LTD. 123 ANYWHERE AVE. TORONTO ONT M4K A Invoice 17924 Item Description TORQUE WRENCH 75LB 14 INCH TORQUE WRENCH W/GAUGE 2 LB WOOD CHISEL - 3 1/4 POWER DRILL 1/2 REV WROUGHT IRON RAILING 4FTX6FT WROUGHT IRON HAND RAIL 6FT ESCUTCHEON BRASS 15X4 INCHES
Total 7426656 Status 7-INVOICED Open 2-CLOSED Customer order TESTCS17933 Ship via TRUCKCO Printed date 82788 Mth 12 Price Extension 9115 273.45 15777 65 .95 684 56.87 82 797.5 793 237.75 7178 77.35 44488 213.
1I Year 88
This display appears if the ORDHDRP file does not contain a record for the order number entered on the first display:
Existing Order Entry Order 124 Date Cust # Item Qty Invoice Item Description
Total Status Open Customer order Ship via Printed date Mth Price Extension Year
217
GX2 1- 98 91- 0 UM/05 0* P r i n t ed i n U . S . A. * Number of sheets per pad may var y sl i ghtl y. Page of
Conditioning
Location Us age ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1 52 53 54 55 56 57 58 59 60 6 1 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80
A * * L OG I CAL A R A* A A A A A A A A A A A A A A A A A A K A K A A A A A A A A A A A A A
ORDHDR L ORDHDR CU S T I NVNUM ORD E R N ORDDA T CU S OR D S HP V I A ORD S T S OP R NAM ORDAMT CU S T Y P P R T DA T OP N S T S T OT L I N AC T MT H AC T Y R S TAT E AMP A I D CU S T I NVNUM
Figure 73 (Part 1 of 3). Example of a Data Description Specification for a Payment Update Program
218
GX2 1- 98 91- 0 UM/05 0* P r i n t ed i n U . S . A. * Number of sheets per pad may var y sl i ghtl y. Page of
Conditioning
Location Us age ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1 52 53 54 55 56 57 58 59 60 6 1 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80
A* A* A* A A A* A A A 51 A N5 1 A* A A 52 A 53 A 54 A* A A A A A 52 A 53 A 54 A* A A 52 A 53 A 54 A* A A A 55 A N5 6 A* A
DD S F OR T H E D I S P L AY D E V I CE F I L E P AY / D T D UP / ACCOUN T S R E CE I VAB L E I N T E R AC T I V E P AYME N T UP DA T E R S UB F I L E 1 ACP PMT 4A I 5 SFL T E X T ( ' S U B F I L E F OR CU S T OME R P AYME N T ' ) 4 T E X T ( ' ACCE P T P AYME N T ' ) VAL U E S ( ' * Y E S ' ' * NO ' ) D S P A T R ( R I MD T ) D S P A T R ( ND P R )
CU S T
5 1 5 T E X T ( ' CU S T OME R NUMB E R ' ) DSPAT R ( R I ) D S P A T R ( ND ) DSPAT R ( PR ) 5 2 4 T E X T ( ' AMOUN T P A I D ' ) CH E CK ( F E ) AU T O( R AB ) CMP ( G T / ) 0 DSPAT R ( R I ) D S P A T R ( ND ) DSPAT R ( PR ) 5 3 7 T E X T ( ' E XCE P T I ON ME S S AGE ' ) DSPAT R ( R I ) D S P A T R ( ND ) DSPAT R ( PR ) 5 7 / T E X T ( ' OVE R P AYME N T ' ) 0 E D T CD E ( 1 ) DSPAT R ( B L ) D S P A T R ( ND ) T E X T ( ' S T A T U S COD E ' )
AMP A I D
8 / 2B 0
E CPMSG
3 1A
OVR PMT
8 Y 2O
S T S CD E
1A
Figure 73 (Part 2 of 3). Example of a Data Description Specification for a Payment Update Program
219
GX2 1- 98 91- 0 UM/05 0* P r i n t ed i n U . S . A. * Number of sheets per pad may var y sl i ghtl y. Page of
Conditioning
Location Us age ( b/ O/ I / B/ H/ M/ N/ P) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
P os
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1 52 53 54 55 56 57 58 59 60 6 1 62 63 64 65 66 67 68 69 70 7 1 72 73 74 75 76 77 78 79 80
A* A A A A A A A A A* A A A A* A A A A* A A A A A A A A A* A A A A* A A A A
R CON T ROL 1
61 62 62
T E X T ( ' S U B F I L E CON T ROL ' ) S F L CT L ( S UB F I L E 1 ) SFL S I Z ( 17 ) S F L P AG ( 1 7 ) S F L CL R S F LDSP S F L D S PC T L OV E R L AY L OCK HE L P ( 9 9 CA 1 2 ( 9 8 CA 1 1 ( 9 7 ' HE L P K E Y ' ) ' E ND P AYME N T UP DA T E ' ) ' I GNOR E I NP U T ' ) I GNOR E I NVAL I D I NP U T + F 1 2 - E ND P AYME N T +
99
63 63 64
2 ' CU S T OME R P AYME N T U P DA T E P ROMP T ' 6 5 ' DA T E ' 7 8DA T E E D T CD E ( Y ) 2 ' ACCE P T ' 2 ' P AYME N T ' 1 4 ' CU S T OME R ' 2 6 ' P AYME N T ' 3 7 ' E XCE P T I ON ME S S AGE ' T E X T ( ' ME S S AGE R E CORD ' ) OV E R L AY L OCK
71
24
( * NO * Y E S ) '
Figure 73 (Part 3 of 3). Example of a Data Description Specification for a Payment Update Program
220
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. PAYUPDT. 3 3 ENVIRONMENT DIVISION. 4 4 CONFIGURATION SECTION. 5 5 SOURCE-COMPUTER. IBM-AS4 . 6 6 OBJECT-COMPUTER. IBM-AS4 . 7 7 INPUT-OUTPUT SECTION. 8 8 FILE-CONTROL. 9 9 SELECT CUSTOMER-INVOICE-FILE 1 1 ASSIGN TO DATABASE-ORDHDRL 11 11 ORGANIZATION IS INDEXED 12 12 ACCESS MODE IS SEQUENTIAL 13 13 RECORD KEY IS COMP-KEY 14 14 FILE STATUS IS STATUS-CODE-ONE. 15 15 SELECT CUSTOMER-MASTER-FILE 16 16 ASSIGN TO DATABASE-CUSMSTP 17 17 ORGANIZATION IS INDEXED 18 18 ACCESS IS RANDOM 19 19 RECORD KEY IS CUST OF CUSTOMER-MASTER-RECORD. 2 2 SELECT PAYMENT-UPDATE-DISPLAY-FILE 21 21 ASSIGN TO WORKSTATION-PAYUPDTD 22 22 ORGANIZATION IS TRANSACTION 23 23 ACCESS IS DYNAMIC 24 24 RELATIVE KEY IS REL-NUMBER 25 25 FILE STATUS IS STATUS-CODE-ONE 26 26 CONTROL-AREA IS WS-CONTROL. 27 27 28 DATA DIVISION. 28 29 FILE SECTION. 29 3 FD CUSTOMER-INVOICE-FILE 3 31 LABEL RECORDS ARE STANDARD. 31 32 1 CUSTOMER-INVOICE-RECORD. 32 33 COPY DDS-ORDHDR OF ORDHDRL. + 1 I-O FORMAT:ORDHDR FROM FILE ORDHDRL OF LIBRARY XMPLIB + 2 + 3 THE KEY DEFINITIONS FOR RECORD FORMAT ORDHDR + 4 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 5 1 CUST ASCENDING AN NO + 6 2 INVNUM ASCENDING SIGNED NO 33 + 7 5 ORDHDR. 34 + 8 6 CUST PIC X(5). + 9 CUSTOMER NUMBER 35 + 1 6 INVNUM PIC S9(5) COMP-3. + 11 INVOICE NUMBER 36 + 12 6 ORDERN PIC S9(5) COMP-3. + 13 ORDER NUMBER 37 + 14 6 ORDDAT PIC S9(6) COMP-3. + 15 DATE ORDER ENTERED 38 + 16 6 CUSORD PIC X(15). + 17 CUSTOMER PURCHASE ORDER NUMBER 39 + 18 6 SHPVIA PIC X(15). + 19 SHIPPING INSTRUCTIONS 4 + 2 6 ORDSTS PIC S9(1) COMP-3. + 21 ORDER STATUS 1PCS 2CNT 3CHK 4RDY 5PRT 6PC 41 + 22 6 OPRNAM PIC X(1 ). + 23 OPERATOR WHO ENTERED ORD 42 + 24 6 ORDAMT PIC S9(6)V9(2) COMP-3. + 25 DOLLAR AMOUNT OF ORDER 43 + 26 6 CUSTYP PIC S9(1) COMP-3. + 27 CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5=OT 44 + 28 6 PRTDAT PIC S9(6) COMP-3. + 29 DATE ORDER WAS PRINTED 45 + 3 6 OPNSTS PIC S9(1) COMP-3. + 31 ORDER OPEN STATUS 1=OPEN 2= CLOSE 3=CANCEL 46 + 32 6 TOTLIN PIC S9(3) COMP-3. + 33 TOTAL LINE ITEMS IN ORDER 47 + 34 6 ACTMTH PIC S9(2) COMP-3. + 35 ACCOUNTING MONTH OF SALE 48 + 36 6 ACTYR PIC S9(2) COMP-3. + 37 ACCOUNTING YEAR OF SALE 49 + 38 6 STATE PIC X(2). + 39 STATE 5 + 4 6 AMPAID PIC S9(6)V9(2) COMP-3. + 41 AMOUNT PAID 51 34 66 COMP-KEY RENAMES CUST THRU INVNUM. 35
COPYNAME
CHG DATE 2/ 1/94 3/22/94 2/ 1/94 2/ 1/94 2/ 2/94 2/ 2/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 3/22/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 2/ 1/94 3/14/94
ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR ORDHDR
221
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 52 36 FD CUSTOMER-MASTER-FILE 53 37 LABEL RECORDS ARE STANDARD. 54 38 1 CUSTOMER-MASTER-RECORD. 55 39 COPY DDS-CUSMST OF CUSMSTP. + 1 I-O FORMAT:CUSMST FROM FILE CUSMSTP OF LIBRARY XMPLIB + 2 CUSTOMER MASTER RECORD + 3 THE KEY DEFINITIONS FOR RECORD FORMAT CUSMST + 4 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 5 1 CUST ASCENDING AN NO 56 + 6 5 CUSMST. 57 + 7 6 CUST PIC X(5). + 8 CUSTOMER NUMBER 58 + 9 6 NAME PIC X(25). + 1 CUSTOMER NAME 59 + 11 6 ADDR PIC X(2 ). + 12 CUSTOMER ADDRESS 6 + 13 6 CITY PIC X(2 ). + 14 CUSTOMER CITY 61 + 15 6 STATE PIC X(2). + 16 STATE 62 + 17 6 ZIP PIC S9(5) COMP-3. + 18 ZIP CODE 63 + 19 6 SRHCOD PIC X(6). + 2 CUSTOMER NUMBER SEARCH CODE 64 + 21 6 CUSTYP PIC S9(1) COMP-3. + 22 CUSTOMER TYPE 1=GOV 2=SCH 3=BUS 4=PVT 5=OT 65 + 23 6 ARBAL PIC S9(6)V9(2) COMP-3. + 24 ACCOUNTS REC. BALANCE 66 + 25 6 ORDBAL PIC S9(6)V9(2) COMP-3. + 26 A/R AMT. IN ORDER FILE 67 + 27 6 LSTAMT PIC S9(6)V9(2) COMP-3. + 28 LAST AMT. PAID IN A/R 68 + 29 6 LSTDAT PIC S9(6) COMP-3. + 3 LAST DATE PAID IN A/R 69 + 31 6 CRDLMT PIC S9(6)V9(2) COMP-3. + 32 CUSTOMER CREDIT LIMIT 7 + 33 6 SLSYR PIC S9(8)V9(2) COMP-3. + 34 CUSTOMER SALES THIS YEAR 71 + 35 6 SLSLYR PIC S9(8)V9(2) COMP-3. + 36 CUSTOMER SALES LAST YEAR 4 72 41 FD PAYMENT-UPDATE-DISPLAY-FILE 73 42 LABEL RECORDS ARE OMITTED. 74 43 1 PAYMENT-UPDATE-DISPLAY-RECORD. 75 44 COPY DDS-ALL-FORMATS OF PAYUPDTD. 76 + 1 5 PAYUPDTD-RECORD PIC X(59). + 2 INPUT FORMAT:SUBFILE1 FROM FILE PAYUPDTD OF LIBRARY XMPLIB + 3 SUBFILE FOR CUSTOMER PAYMENT 77 + 4 5 SUBFILE1-I REDEFINES PAYUPDTD-RECORD. 78 + 5 6 ACPPMT PIC X(4). + 6 ACCEPT PAYMENT 79 + 7 6 CUST PIC X(5). + 8 CUSTOMER NUMBER 8 + 9 6 AMPAID PIC S9(6)V9(2). + 1 AMOUNT PAID 81 + 11 6 ECPMSG PIC X(31). + 12 EXCEPTION MESSAGE 82 + 13 6 OVRPMT PIC S9(6)V9(2). + 14 OVERPAYMENT 83 + 15 6 STSCDE PIC X(1). + 16 STATUS CODE + 17 OUTPUT FORMAT:SUBFILE1 FROM FILE PAYUPDTD OF LIBRARY XMPLIB + 18 SUBFILE FOR CUSTOMER PAYMENT 84 + 19 5 SUBFILE1-O REDEFINES PAYUPDTD-RECORD. 85 + 2 6 SUBFILE1-O-INDIC. 86 + 21 7 IN51 PIC 1 INDIC 51. 87 + 22 7 IN52 PIC 1 INDIC 52. 88 + 23 7 IN53 PIC 1 INDIC 53. 89 + 24 7 IN54 PIC 1 INDIC 54. 9 + 25 7 IN55 PIC 1 INDIC 55. 91 + 26 7 IN56 PIC 1 INDIC 56. 92 + 27 6 CUST PIC X(5). + 28 CUSTOMER NUMBER 93 + 29 6 AMPAID PIC S9(6)V9(2). + 3 AMOUNT PAID 94 + 31 6 ECPMSG PIC X(31). + 32 EXCEPTION MESSAGE
COPYNAME
CHG DATE
CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST CUSMST
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
222
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 95 + 33 6 OVRPMT PIC S9(6)V9(2). + 34 OVERPAYMENT 96 + 35 6 STSCDE PIC X(1). + 36 STATUS CODE + 37 INPUT FORMAT:CONTROL1 FROM FILE PAYUPDTD OF LIBRARY XMPLIB + 38 SUBFILE CONTROL 97 + 39 5 CONTROL1-I REDEFINES PAYUPDTD-RECORD. 98 + 4 6 CONTROL1-I-INDIC. 99 + 41 7 IN99 PIC 1 INDIC 99. + 42 HELP KEY 1 + 43 7 IN98 PIC 1 INDIC 98. + 44 END PAYMENT UPDATE 1 1 + 45 7 IN97 PIC 1 INDIC 97. + 46 IGNORE INPUT + 47 OUTPUT FORMAT:CONTROL1 FROM FILE PAYUPDTD OF LIBRARY XMPLIB + 48 SUBFILE CONTROL 1 2 + 49 5 CONTROL1-O REDEFINES PAYUPDTD-RECORD. 1 3 + 5 6 CONTROL1-O-INDIC. 1 4 + 51 7 IN61 PIC 1 INDIC 61. 1 5 + 52 7 IN62 PIC 1 INDIC 62. 1 6 + 53 7 IN99 PIC 1 INDIC 99. + 54 HELP KEY 1 7 + 55 7 IN63 PIC 1 INDIC 63. 1 8 + 56 7 IN64 PIC 1 INDIC 64. + 57 INPUT FORMAT:MESSAGE1 FROM FILE PAYUPDTD OF LIBRARY XMPLIB + 58 MESSAGE RECORD + 59 5 MESSAGE1-I REDEFINES PAYUPDTD-RECORD. + 6 OUTPUT FORMAT:MESSAGE1 FROM FILE PAYUPDTD OF LIBRARY XMPLIB + 61 MESSAGE RECORD 1 9 + 62 5 MESSAGE1-O REDEFINES PAYUPDTD-RECORD. 11 + 63 6 MESSAGE1-O-INDIC. 111 + 64 7 IN71 PIC 1 INDIC 71. 45 112 46 WORKING-STORAGE SECTION. 47 113 48 1 REL-NUMBER PIC 9( 5) 114 49 VALUE ZEROS. 5 115 51 1 WS-CONTROL. 116 52 5 WS-IND PIC X( 2). 117 53 5 WS-FORMAT PIC X(1 ). 118 54 1 SYSTEM-DATE. 119 55 5 SYSTEM-YEAR PIC 99. 12 56 5 SYSTEM-MONTH PIC 99. 121 57 5 SYSTEM-DAY PIC 99. 122 58 1 PROGRAM-DATE. 123 59 5 PROGRAM-MONTH PIC 99. 124 6 5 PROGRAM-DAY PIC 99. 125 61 5 PROGRAM-YEAR PIC 99. 126 62 1 FILE-DATE REDEFINES PROGRAM-DATE 127 63 PIC S9(6). 128 64 1 EXCEPTION-STATUS. 129 65 5 STATUS-CODE-ONE PIC XX. 13 66 88 SUBFILE-IS-FULL VALUE '9M'. 131 67 1 EXCEPTION-MESSAGES. 132 68 5 MESSAGE-ONE PIC X(31) 133 69 VALUE 'CUSTOMER DOES NOT EXIST '. 134 7 5 MESSAGE-TWO PIC X(31) 135 71 VALUE 'NO INVOICES EXIST FOR CUSTOMER '. 136 72 5 MESSAGE-THREE PIC X(31) 137 73 VALUE 'CUSTOMER HAS AN OVER PAYMENT OF'. 138 74 1 PROGRAM-VARIABLES. 139 75 5 AMOUNT-OWED PIC S9(6)V99. 14 76 5 AMOUNT-PAID PIC S9(6)V99. 141 77 5 INVOICE-BALANCE PIC S9(6)V99. 142 78 1 ERRPGM-PARAMETERS. 143 79 5 DISPLAY-PARAMETER PIC X(8) 144 8 VALUE 'PAYUPDTD'. 145 81 5 DUMMY-ONE PIC X(6) 146 82 VALUE SPACES. 147 83 5 DUMMY-TWO PIC X(6) 148 84 VALUE SPACES. 149 85 5 STATUS-CODE-TWO. 15 86 1 PRIMARY PIC X(1). 151 87 1 SECONDARY PIC X(1).
COPYNAME <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
CHG DATE
223
5763CB1 V3R M5 STMT SEQNBR -A 1 152 88 153 89 154 9 155 91 92 156 93 1 157 94 158 95 159 96 16 97 161 98 162 99 163 1 164 1 1 165 1 2 166 1 3 167 1 4 168 1 5 169 1 6 17 1 7 171 1 8 172 1 9 173 11 174 111 175 112 176 113 177 114 178 115 179 116 18 117 181 118 182 119 183 12 121 184 122 1 185 123 186 124 187 125 188 126 189 127 19 128 191 129 192 13 193 131 194 132 195 133 196 134 197 135 198 136 199 137 2 138 2 1 139 2 2 14 2 3 141 2 4 142 2 5 143 2 6 144 2 7 145 2 8 146 2 9 147 21 148 211 149 212 15 213 151 214 152 215 153 216 154 217 155 218 156 219 157 22 158 221 159 222 16 223 161 224 162 163
AS/4 COBOL Source B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 FILLER PIC X(5) VALUE SPACES. 5 DUMMY-THREE PIC X(1 ) VALUE SPACES. SWITCH-AREA. 5 SW 1 PIC 88 WRITE-DISPLAY 88 READ-DISPLAY 5 SW 2 PIC 88 SUBFILE1-FORMAT 88 NOT-SUBFILE1-FORMAT 5 SW 3 PIC 88 CONTROL1-FORMAT 88 NOT-CONTROL1-FORMAT 5 SW 4 PIC 88 NO-MORE-TRANSACTIONS-EXIST 88 TRANSACTIONS-EXIST 5 SW 5 PIC 88 CUSTOMER-NOT-FOUND 88 CUSTOMER-EXIST 5 SW 6 PIC 88 NO-MORE-INVOICES-EXIST 88 CUSTOMER-INVOICE-EXIST 5 SW 7 PIC 88 NO-MORE-PAYMENT-EXIST 88 PAYMENT-EXIST 5 SW 8 PIC 88 INPUT-ERRORS-EXIST 88 NO-INPUT-ERRORS-EXIST 5 SW 9 PIC 88 OVER-PAYMENT-DISPLAYED-ONCE 88 OVER-PAYMENT-NOT-DISPLAYED
COPYNAME
CHG DATE
1. VALUE B'1'. VALUE B' '. 1. VALUE B'1'. VALUE B' '. 1. VALUE B'1'. VALUE B'1'. 1. VALUE B'1'. VALUE B' '. 1. VALUE B'1'. VALUE B' '. 1. VALUE B'1'. VALUE B' '. 1. VALUE B' '. VALUE B' '. 1. VALUE B'1'. VALUE B' '. 1. VALUE B'1'. VALUE B' '.
INDICATOR-AREA. 5 IN99 PIC 1 88 HELP-IS-NEEDED 88 HELP-IS-NOT-NEEDED 5 IN98 PIC 1 88 END-OF-PAYMENT-UPDATE 5 IN97 PIC 1 88 IGNORE-INPUT 5 IN51 PIC 1 88 DISPLAY-ACCEPT-PAYMENT 88 DO-NOT-DISPLAY-ACCEPT-PAYMENT 5 IN52 PIC 1 88 REVERSE-FIELD-IMAGE 88 DO-NOT-REVERSE-FIELD-IMAGE 5 IN53 PIC 1 88 DO-NOT-DISPLAY-FIELD 88 DISPLAY-FIELD 5 IN54 PIC 1 88 PROTECT-INPUT-FIELD 88 DO-NOT-PROTECT-INPUT-FIELD 5 IN55 PIC 1 88 MAKE-FIELD-BLINK 88 DO-NOT-MAKE-FIELD-BLINK 5 IN56 PIC 1 88 DISPLAY-OVER-PAYMENT 88 DO-NOT-DISPLAY-OVER-PAYMENT 5 IN61 PIC 1 88 CLEAR-SUBFILE 88 DO-NOT-CLEAR-SUBFILE 5 IN62 PIC 1 88 DISPLAY-SCREEN 88 DO-NOT-DISPLAY-SCREEN 5 IN63 PIC 1 88 DISPLAY-ACCEPT-HEADING 88 DO-NOT-DISPLAY-ACCEPT-HEADING 5 IN64 PIC 1 88 DISPLAY-EXCEPTION 88 DO-NOT-DISPLAY-EXCEPTION 5 IN71 PIC 1 88 DISPLAY-ACCEPT-MESSAGE 88 DO-NOT-DISPLAY-ACCEPT-MESSAGE
INDIC VALUE VALUE INDIC VALUE INDIC VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE INDIC VALUE VALUE
99. B'1'. B' '. 98. B'1'. 97. B'1'. 51. B'1'. B' '. 52. B'1'. B' '. 53. B'1'. B' '. 54. B'1'. B' '. 55. B'1'. B' '. 56. B'1'. B' '. 61. B'1'. B' '. 62. B'1'. B' '. 63. B'1'. B' '. 64. B'1'. B' '. 71. B'1'. B' '.
224
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 225 164 PROCEDURE DIVISION. 165 166 DECLARATIVES. 167 168 TRANSACTION-ERROR SECTION. 169 USE AFTER STANDARD ERROR PROCEDURE 17 PAYMENT-UPDATE-DISPLAY-FILE. 171 WORK-STATION-ERROR-HANDLER. 226 172 IF SUBFILE-IS-FULL THEN 173 NEXT SENTENCE 174 ELSE 227 175 DISPLAY 'ERROR IN PAYMENT-UPDATE' STATUS-CODE-ONE. 176 END DECLARATIVES. 177 178 CUSTOMER-PAYMENT-UPDATE SECTION. 179 MAINLINE-ROUTINE. 228 18 PERFORM SET-UP-ROUTINE. 229 181 PERFORM PROCESS-TRANSACTION-FILE 182 UNTIL END-OF-PAYMENT-UPDATE. 23 183 PERFORM CLEAN-UP-ROUTINE. 184 185 SET-UP-ROUTINE. 231 186 OPEN I-O CUSTOMER-INVOICE-FILE 187 CUSTOMER-MASTER-FILE 188 PAYMENT-UPDATE-DISPLAY-FILE. 232 189 MOVE ALL B' ' TO INDICATOR-AREA 19 SWITCH-AREA. 233 191 ACCEPT SYSTEM-DATE FROM DATE. 234 192 MOVE SYSTEM-YEAR TO PROGRAM-YEAR. 235 193 MOVE SYSTEM-MONTH TO PROGRAM-MONTH. 236 194 MOVE SYSTEM-DATE TO PROGRAM-DAY. 237 195 SET WRITE-DISPLAY 196 CONTROL1-FORMAT 197 DO-NOT-DISPLAY-OVER-PAYMENT 198 DO-NOT-PROTECT-INPUT-FIELD 199 DO-NOT-REVERSE-FIELD-IMAGE 2 DO-NOT-MAKE-FIELD-BLINK 2 1 CLEAR-SUBFILE TO TRUE. 238 2 2 MOVE CORR INDICATOR-AREA TO CONTROL1-O-INDIC. 239 2 3 WRITE PAYMENT-UPDATE-DISPLAY-RECORD 2 4 FORMAT IS 'CONTROL1'. 24 2 5 SET DO-NOT-CLEAR-SUBFILE TO TRUE. 241 2 6 PERFORM INITIALIZE-SUBFILE-RECORD 17 TIMES. 242 2 7 SET DISPLAY-SCREEN TO TRUE. 243 2 8 MOVE CORR INDICATOR-AREA TO CONTROL1-O-INDIC. 244 2 9 WRITE PAYMENT-UPDATE-DISPLAY-RECORD 21 FORMAT IS 'CONTROL1'. 245 211 READ PAYMENT-UPDATE-DISPLAY-FILE RECORD 212 FORMAT IS 'CONTROL1'. 246 213 MOVE CORR CONTROL1-I-INDIC TO INDICATOR-AREA. 214 PROCESS-TRANSACTION-FILE. 247 215 IF HELP-IS-NOT-NEEDED THEN 248 216 IF IGNORE-INPUT THEN 249 217 SET WRITE-DISPLAY 218 CONTROL1-FORMAT 219 CLEAR-SUBFILE 22 DISPLAY-FIELD 221 DO-NOT-DISPLAY-OVER-PAYMENT 222 DO-NOT-PROTECT-INPUT-FIELD 223 DO-NOT-REVERSE-FIELD-IMAGE 224 DO-NOT-DISPLAY-ACCEPT-PAYMENT 225 DO-NOT-DISPLAY-ACCEPT-HEADING 226 DO-NOT-DISPLAY-ACCEPT-MESSAGE 227 DO-NOT-MAKE-FIELD-BLINK TO TRUE 25 228 MOVE CORR INDICATOR-AREA TO CONTROL1-O-INDIC 251 229 WRITE PAYMENT-UPDATE-DISPLAY-RECORD 23 FORMAT IS 'CONTROL1' 252 231 SET DO-NOT-CLEAR-SUBFILE TO TRUE 253 232 MOVE TO REL-NUMBER 254 233 PERFORM INITIALIZE-SUBFILE-RECORD 17 TIMES 234 ELSE 255 235 SET TRANSACTIONS-EXIST 236 DO-NOT-DISPLAY-ACCEPT-HEADING 237 DO-NOT-DISPLAY-ACCEPT-MESSAGE 238 DO-NOT-DISPLAY-EXCEPTION TO TRUE 256 239 PERFORM READ-MODIFIED-SUBFILE-RECORD
COPYNAME
CHG DATE
225
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 257 24 PERFORM TRANSACTION-VALIDATION 241 UNTIL NO-MORE-TRANSACTIONS-EXIST 258 242 SET NO-INPUT-ERRORS-EXIST TO TRUE 259 243 PERFORM TEST-FOR-RECORD-INPUT-ERRORS 244 VARYING REL-NUMBER 245 FROM 1 246 BY 1 247 UNTIL REL-NUMBER IS GREATER THAN 17 248 OR INPUT-ERRORS-EXIST 26 249 IF NO-INPUT-ERRORS-EXIST THEN 261 25 IF OVER-PAYMENT-DISPLAYED-ONCE THEN 262 251 SET WRITE-DISPLAY 252 CONTROL1-FORMAT 253 DO-NOT-DISPLAY-OVER-PAYMENT 254 DO-NOT-PROTECT-INPUT-FIELD 255 DO-NOT-REVERSE-FIELD-IMAGE 256 DO-NOT-MAKE-FIELD-BLINK 257 DO-NOT-DISPLAY-ACCEPT-PAYMENT 258 DO-NOT-DISPLAY-ACCEPT-HEADING 259 DO-NOT-DISPLAY-ACCEPT-MESSAGE 26 DO-NOT-DISPLAY-EXCEPTION 261 CLEAR-SUBFILE 262 DISPLAY-FIELD 263 TO TRUE 263 264 MOVE CORR INDICATOR-AREA TO CONTROL1-O-INDIC 264 265 WRITE PAYMENT-UPDATE-DISPLAY-RECORD 266 FORMAT IS 'CONTROL1' 265 267 SET DO-NOT-CLEAR-SUBFILE TO TRUE 266 268 MOVE TO REL-NUMBER 267 269 PERFORM INITIALIZE-SUBFILE-RECORD 17 TIMES 27 ELSE 268 271 SET OVER-PAYMENT-DISPLAYED-ONCE TO TRUE 272 ELSE 273 NEXT SENTENCE 274 ELSE 275 NEXT SENTENCE. 269 276 SET WRITE-DISPLAY, DISPLAY-SCREEN TO TRUE. 27 277 MOVE CORR INDICATOR-AREA TO MESSAGE1-O-INDIC. 271 278 WRITE PAYMENT-UPDATE-DISPLAY-RECORD 279 FORMAT IS 'MESSAGE1'. 272 28 SET WRITE-DISPLAY, CONTROL1-FORMAT TO TRUE. 273 281 MOVE CORR INDICATOR-AREA TO CONTROL1-O-INDIC. 274 282 WRITE PAYMENT-UPDATE-DISPLAY-RECORD 283 FORMAT IS 'CONTROL1'. 275 284 READ PAYMENT-UPDATE-DISPLAY-FILE RECORD 285 FORMAT IS 'CONTROL1'. 276 286 MOVE CORR CONTROL1-I-INDIC TO INDICATOR-AREA. 287 READ-MODIFIED-SUBFILE-RECORD. 277 288 READ SUBFILE PAYMENT-UPDATE-DISPLAY-FILE 289 NEXT MODIFIED RECORD FORMAT IS 'SUBFILE1' 278 29 AT END SET NO-MORE-TRANSACTIONS-EXIST TO TRUE. 291 TEST-FOR-RECORD-INPUT-ERRORS. 279 292 READ SUBFILE PAYMENT-UPDATE-DISPLAY-FILE RECORD 293 FORMAT IS 'SUBFILE1'. 28 294 IF STSCDE OF SUBFILE1-I IS EQUAL TO '1' THEN 281 295 SET INPUT-ERRORS-EXIST TO TRUE 296 ELSE 297 NEXT SENTENCE. 298 TRANSACTION-VALIDATION. 282 299 MOVE CUST OF SUBFILE1-I OF PAYMENT-UPDATE-DISPLAY-RECORD 3 TO CUST OF CUSTOMER-MASTER-RECORD. 283 3 1 SET CUSTOMER-EXIST TO TRUE. 284 3 2 READ CUSTOMER-MASTER-FILE 285 3 3 INVALID KEY SET CUSTOMER-NOT-FOUND TO TRUE. 286 3 4 IF CUSTOMER-EXIST THEN 287 3 5 MOVE CUST OF CUSMST TO CUST OF ORDHDR 288 3 6 MOVE ZEROES TO INVNUM 289 3 7 SET CUSTOMER-INVOICE-EXIST TO TRUE 29 3 8 PERFORM START-ON-CUSTOMER-INVOICE-FILE 291 3 9 IF CUSTOMER-INVOICE-EXIST THEN 292 31 PERFORM READ-CUSTOMER-INVOICE-RECORD 293 311 IF CUSTOMER-INVOICE-EXIST THEN 294 312 PERFORM CUSTOMER-MASTER-FILE-UPDATE 295 313 MOVE AMPAID OF SUBFILE1-I TO AMOUNT-PAID 296 314 SET PAYMENT-EXIST TO TRUE
COPYNAME
CHG DATE
226
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 297 315 PERFORM PAYMENT-UPDATE 316 UNTIL NO-MORE-INVOICES-EXIST 317 OR NO-MORE-PAYMENT-EXIST 298 318 IF ARBAL OF CUSTOMER-MASTER-RECORD IS NEGATIVE 299 319 SET MAKE-FIELD-BLINK 32 DISPLAY-FIELD 321 DO-NOT-REVERSE-FIELD-IMAGE 322 OVER-PAYMENT-NOT-DISPLAYED 323 DISPLAY-OVER-PAYMENT 324 DISPLAY-EXCEPTION 325 DO-NOT-DISPLAY-ACCEPT-PAYMENT 326 PROTECT-INPUT-FIELD TO TRUE 3 327 MOVE ARBAL TO OVRPMT OF SUBFILE1-O 3 1 328 MOVE MESSAGE-THREE TO ECPMSG OF SUBFILE1-O 3 2 329 MOVE ' ' TO STSCDE OF SUBFILE1-O 3 3 33 PERFORM REWRITE-DISPLAY-SUBFILE-RECORD 331 ELSE 3 4 332 SET DO-NOT-DISPLAY-FIELD 333 DO-NOT-DISPLAY-OVER-PAYMENT 334 DO-NOT-REVERSE-FIELD-IMAGE 335 DO-NOT-MAKE-FIELD-BLINK 336 DO-NOT-DISPLAY-ACCEPT-PAYMENT 337 PROTECT-INPUT-FIELD TO TRUE 3 5 338 MOVE SPACES TO ECPMSG OF SUBFILE1-O 3 6 339 MOVE ZEROES TO OVRPMT OF SUBFILE1-O 3 7 34 MOVE ' ' TO STSCDE OF SUBFILE1-O 3 8 341 PERFORM REWRITE-DISPLAY-SUBFILE-RECORD 342 ELSE 3 9 343 PERFORM NO-CUSTOMER-INVOICE-ROUTINE 344 ELSE 31 345 PERFORM NO-CUSTOMER-INVOICE-ROUTINE 346 ELSE 311 347 SET REVERSE-FIELD-IMAGE 348 DO-NOT-PROTECT-INPUT-FIELD 349 DISPLAY-FIELD 35 DO-NOT-DISPLAY-OVER-PAYMENT 351 DO-NOT-MAKE-FIELD-BLINK 352 DISPLAY-EXCEPTION 353 DO-NOT-DISPLAY-ACCEPT-PAYMENT 354 DO-NOT-PROTECT-INPUT-FIELD TO TRUE 312 355 MOVE ZEROES TO OVRPMT OF SUBFILE1-O 313 356 MOVE MESSAGE-ONE TO ECPMSG OF SUBFILE1-O 314 357 MOVE '1' TO STSCDE OF SUBFILE1-O 315 358 PERFORM REWRITE-DISPLAY-SUBFILE-RECORD. 316 359 PERFORM READ-MODIFIED-SUBFILE-RECORD. 36 START-ON-CUSTOMER-INVOICE-FILE. 317 361 START CUSTOMER-INVOICE-FILE 362 KEY IS GREATER THAN COMP-KEY 318 363 INVALID KEY SET NO-MORE-INVOICES-EXIST TO TRUE. 364 READ-CUSTOMER-INVOICE-RECORD. 319 365 READ CUSTOMER-INVOICE-FILE NEXT RECORD 32 366 AT END SET NO-MORE-INVOICES-EXIST TO TRUE. 321 367 IF CUST OF CUSTOMER-MASTER-RECORD 368 IS NOT EQUAL TO CUST OF CUSTOMER-INVOICE-RECORD THEN 322 369 SET NO-MORE-INVOICES-EXIST TO TRUE 37 ELSE 371 NEXT SENTENCE. 372 CUSTOMER-MASTER-FILE-UPDATE. 323 373 MOVE FILE-DATE TO LSTDAT OF CUSTOMER-MASTER-RECORD. 324 374 MOVE AMPAID OF SUBFILE1-I 375 TO LSTAMT OF CUSTOMER-MASTER-RECORD. 325 376 SUBTRACT AMPAID OF SUBFILE1-I 377 FROM ARBAL OF CUSTOMER-MASTER-RECORD. 326 378 REWRITE CUSTOMER-MASTER-RECORD. 379 REWRITE-DISPLAY-SUBFILE-RECORD. 327 38 MOVE AMPAID OF SUBFILE1-I TO AMPAID OF SUBFILE1-O. 328 381 MOVE CUST OF SUBFILE1-I TO CUST OF SUBFILE1-O. 329 382 SET WRITE-DISPLAY TO TRUE. 33 383 SET SUBFILE1-FORMAT TO TRUE. 331 384 MOVE CORR INDICATOR-AREA TO SUBFILE1-O-INDIC. 332 385 REWRITE SUBFILE PAYMENT-UPDATE-DISPLAY-RECORD 386 FORMAT IS 'SUBFILE1'. 387 NO-CUSTOMER-INVOICE-ROUTINE. 333 388 IF STSCDE OF SUBFILE1-I IS EQUAL TO '1' THEN 334 389 IF ACPPMT OF SUBFILE1-I IS EQUAL TO ' NO' THEN 335 39 SET DO-NOT-DISPLAY-FIELD
COPYNAME
CHG DATE
227
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 391 DO-NOT-DISPLAY-OVER-PAYMENT 392 DO-NOT-REVERSE-FIELD-IMAGE 393 DO-NOT-MAKE-FIELD-BLINK 394 DO-NOT-DISPLAY-ACCEPT-PAYMENT 395 PROTECT-INPUT-FIELD 396 TO TRUE 336 397 MOVE SPACES TO ECPMSG OF SUBFILE1-O 337 398 MOVE ZEROES TO OVRPMT OF SUBFILE1-O 338 399 MOVE ' ' TO STSCDE OF SUBFILE1-O 339 4 PERFORM REWRITE-DISPLAY-SUBFILE-RECORD 4 1 ELSE 34 4 2 PERFORM CUSTOMER-MASTER-FILE-UPDATE 341 4 3 SET MAKE-FIELD-BLINK 4 4 DISPLAY-FIELD 4 5 DO-NOT-REVERSE-FIELD-IMAGE 4 6 OVER-PAYMENT-NOT-DISPLAYED 4 7 DISPLAY-OVER-PAYMENT 4 8 DISPLAY-EXCEPTION 4 9 DO-NOT-DISPLAY-ACCEPT-PAYMENT 41 PROTECT-INPUT-FIELD 411 TO TRUE 342 412 MOVE ARBAL TO OVRPMT OF SUBFILE1-O 343 413 MOVE MESSAGE-THREE TO ECPMSG OF SUBFILE1-O 344 414 MOVE ' ' TO STSCDE OF SUBFILE1-O 345 415 PERFORM REWRITE-DISPLAY-SUBFILE-RECORD 416 ELSE 346 417 SET REVERSE-FIELD-IMAGE 418 DISPLAY-FIELD 419 DO-NOT-PROTECT-INPUT-FIELD 42 DO-NOT-DISPLAY-OVER-PAYMENT 421 DISPLAY-EXCEPTION 422 DISPLAY-ACCEPT-PAYMENT 423 DISPLAY-ACCEPT-HEADING 424 DISPLAY-ACCEPT-MESSAGE 425 DO-NOT-MAKE-FIELD-BLINK 426 TO TRUE 347 427 MOVE ZEROS TO OVRPMT OF SUBFILE1-O 348 428 MOVE MESSAGE-TWO TO ECPMSG OF SUBFILE1-O 349 429 MOVE '1' TO STSCDE OF SUBFILE1-O 35 43 PERFORM REWRITE-DISPLAY-SUBFILE-RECORD. 431 PAYMENT-UPDATE. 351 432 SUBTRACT AMPAID OF CUSTOMER-INVOICE-RECORD 433 FROM ORDAMT OF CUSTOMER-INVOICE-RECORD 434 GIVING AMOUNT-OWED. 352 435 SUBTRACT AMOUNT-PAID 436 FROM AMOUNT-OWED 437 GIVING INVOICE-BALANCE. 353 438 IF INVOICE-BALANCE IS LESS THAN . 1 THEN 354 439 MOVE 2 TO OPNSTS OF CUSTOMER-INVOICE-RECORD 355 44 MOVE ORDAMT OF CUSTOMER-INVOICE-RECORD 441 TO AMPAID OF CUSTOMER-INVOICE-RECORD 356 442 SUBTRACT AMOUNT-OWED 443 FROM AMOUNT-PAID 444 ELSE 357 445 ADD AMOUNT-PAID TO AMPAID OF CUSTOMER-INVOICE-RECORD 358 446 SET NO-MORE-PAYMENT-EXIST TO TRUE. 359 447 REWRITE CUSTOMER-INVOICE-RECORD. 36 448 IF NO-MORE-PAYMENT-EXIST THEN 449 NEXT SENTENCE 45 ELSE 361 451 PERFORM READ-CUSTOMER-INVOICE-RECORD. 452 INITIALIZE-SUBFILE-RECORD. 362 453 MOVE SPACES TO CUST OF SUBFILE1-O. 363 454 MOVE SPACES TO ECPMSG OF SUBFILE1-O. 364 455 MOVE ' ' TO STSCDE OF SUBFILE1-O. 365 456 MOVE ZEROS TO AMPAID OF SUBFILE1-O. 366 457 MOVE ZEROS TO OVRPMT OF SUBFILE1-O. 367 458 ADD 1 TO REL-NUMBER. 368 459 MOVE CORR INDICATOR-AREA TO SUBFILE1-O-INDIC. 369 46 WRITE SUBFILE PAYMENT-UPDATE-DISPLAY-RECORD 461 FORMAT IS 'SUBFILE1'. 462 CLEAN-UP-ROUTINE. 37 463 CLOSE CUSTOMER-INVOICE-FILE 464 CUSTOMER-MASTER-FILE 465 PAYMENT-UPDATE-DISPLAY-FILE. 371 466 STOP RUN. E N D O F S O U R C E
COPYNAME
CHG DATE
This is the initial display that is written to the work station to prompt you to enter the customer number and payment:
228
Customer Payment Update Prompt Customer ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ Payment __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________
Date
5/24/94
Customer Payment Update Prompt Customer 345 4 5 36 125 22799 419 1 1 495 133 569 Payment 2 3 25 2 45 75 5 25 35 4
Date
5/24/94
Payments that would result in overpayments or that have incorrect customer numbers are left on the display and appropriate messages are added:
229
Customer Payment Update Prompt Accept Payment _____ _____ _____ _____ Customer 4 5 125 419 1 1 133 Payment 3 2 75 5 35 Exception Message NO INVOICES EXIST FOR CUSTOMER NO INVOICES EXIST FOR CUSTOMER NO INVOICES EXIST FOR CUSTOMER CUSTOMER DOES NOT EXIST NO INVOICES EXIST FOR CUSTOMER
Date
5/24/94
YES)
Customer Payment Update Prompt Accept Payment NO YES NO NO Customer 4 5 125 419 1 1 133 Payment 3 2 75 5 35 Exception Message NO INVOICES EXIST FOR CUSTOMER NO INVOICES EXIST FOR CUSTOMER NO INVOICES EXIST FOR CUSTOMER CUSTOMER DOES NOT EXIST NO INVOICES EXIST FOR CUSTOMER
Date
5/24/94
YES)
230
Customer Payment Update Prompt Accept Payment Customer 125 1 1 5 Payment 2 Exception Message CUSTOMER HAS AN OVERPAYMENT OF CUSTOMER DOES NOT EXIST
Date
5/24/94
58.5
231
232
LINAGE Clause
When the LINAGE clause is specified for a file assigned to PRINTER, all spacing and paging controls are handled internally by compiler generated code. Paper positioning is done only when the first WRITE statement is run. The paper in the printer is positioned to a new physical page, and the LINAGE-COUNTER is set to 1. When the printer file is shared and other programs have written records to the file, the COBOL WRITE statement is still considered to be the first WRITE statement. Paper positioning is handled by the COBOL/400 compiler even though it is not the first WRITE statement for that file. All spacing and paging for WRITE statements is controlled internally. The physical size of the page is ignored when paper positioning is not properly defined for the COBOL/400 compiler. For a file that has a LINAGE clause and is assigned to PRINTER, paging consists of spacing to the end of the logical page (page body) and then spacing past the bottom and top margins.
233
Use of the LINAGE clause degrades performance. The LINAGE clause should be used only as necessary. If the physical paging is acceptable, the LINAGE clause is not necessary. The LINAGE clause should not be used for files assigned to FORMATFILE.
FORMATFILE Files
Externally described printer files must be assigned to a device of FORMATFILE. The term FORMATFILE is used because the FORMAT phrase is valid in WRITE statements for the file, and the data formatting is specified in the DDS for the file. When you have specified a device of FORMATFILE, you can obtain formatting of printed output in two ways: 1. Choose the formats to print and their order by using appropriate values in the FORMAT phrases specified for WRITE statements. For example, use one format once per page to produce a heading, and use another format to produce the detail lines on the page. 2. Choose the appropriate options to be taken when each format is printed by setting indicator values and passing these indicators through the INDICATOR phrase for the WRITE statement. For example, fields may be underlined, blank lines may be produced before or after the format is printed, or the printing of certain fields may be skipped. The use of external descriptions for printer files has the following advantages over program descriptions: Multiple lines can be printed by one WRITE statement. When multiple lines are written by one WRITE statement and the END-OF-PAGE condition is reached, the END-OF-PAGE imperative statement is processed after all of the lines are printed. It is possible to print lines in the overflow area, and onto the next page before the END-OF-PAGE imperative statement is processed. Figure 75 on page 235 shows an example of an occurrence of the END-OF-PAGE condition through FORMATFILE. Optional printing of fields based on indicator values is possible. Editing of field values is easily defined. Maintenance of print formats, especially those used by multiple programs, is easier. Use of the ADVANCING phrase for FORMATFILE files causes a compilation error to be issued. Advancing of lines is controlled in a FORMATFILE file through DDS keywords, such as SKIPA and SKIPB, and through the use of line numbers. For FORMATFILE files, the LINAGE clause is invalid.
234
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. FRMTFILE. 3 3 AUTHOR. PROGRAMMER NAME. 4 4 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 5 DATE-WRITTEN. 2/ 2/89. 8 8 DATE-COMPILED. 5/24/94 14:29:31 . 7 7 ENVIRONMENT DIVISION. 8 8 CONFIGURATION SECTION. 9 9 SOURCE-COMPUTER. IBM-AS4 . 1 1 OBJECT-COMPUTER. IBM-AS4 . 11 11 INPUT-OUTPUT SECTION. 12 12 FILE-CONTROL. 13 13 SELECT PERSREPT ASSIGN TO FORMATFILE-PERSREPT-SI 1 14 14 ORGANIZATION IS SEQUENTIAL. 15 15 SELECT PERSFILE ASSIGN TO DATABASE-PERSFILE 16 16 ORGANIZATION IS INDEXED 17 17 ACCESS MODE IS SEQUENTIAL 18 18 RECORD IS EXTERNALLY-DESCRIBED-KEY. 19 19 DATA DIVISION. 2 2 FILE SECTION. 21 21 FD PERSREPT 22 22 LABEL RECORDS ARE STANDARD. 23 23 1 PERSREPT-REC. 24 24 COPY DDS-ALL-FORMATS-O OF PERSREPT. 2 25 + 1 5 PERSREPT-RECORD PIC X(13 ). + 2 OUTPUT FORMAT:HEADING FROM FILE PERSREPT OF LIBRARY XMPLIB + 3 26 + 4 5 HEADING-O REDEFINES PERSREPT-RECORD. 27 + 5 6 ORDERTYPE PIC X(15). + 6 OUTPUT FORMAT:DETAIL FROM FILE PERSREPT OF LIBRARY XMPLIB + 7 28 + 8 5 DETAIL-O REDEFINES PERSREPT-RECORD. 3 29 + 9 6 NAME PIC X(3 ). 3 + 1 6 EMPLNO PIC S9(6). 31 + 11 6 BIRTHDATE PIC X(6). 32 + 12 6 ADDRESS1 PIC X(35). 33 + 13 6 MARSTAT PIC X(1). 34 + 14 6 SPOUSENAME PIC X(3 ). 35 + 15 6 ADDRESS2 PIC X(2 ). 36 + 16 6 NUMCHILD PIC S9(2). 37 25 FD PERSFILE 38 26 LABEL RECORDS ARE STANDARD. 39 27 1 PERSFILE-REC. 4 28 COPY DDS-ALL-FORMATS-O OF PERSFILE. 41 + 1 5 PERSFILE-RECORD PIC X(13 ). + 2 I-O FORMAT:PERSREC FROM FILE PERSFILE OF LIBRARY XMPLIB + 3 + 4 THE KEY DEFINITIONS FOR RECORD FORMAT PERSREC + 5 NUMBER NAME RETRIEVAL TYPE ALTSEQ + 6 1 EMPLNO ASCENDING SIGNED NO 42 + 7 5 PERSREC REDEFINES PERSFILE-RECORD. 43 + 8 6 EMPLNO PIC S9(6). 44 + 9 6 NAME PIC X(3 ). 45 + 1 6 ADDRESS1 PIC X(35). 46 + 11 6 ADDRESS2 PIC X(2 ). 47 + 12 6 BIRTHDATE PIC X(6). 48 + 13 6 MARSTAT PIC X(1). 49 + 14 6 SPOUSENAME PIC X(3 ). 5 + 15 6 NUMCHILD PIC S9(2). 51 29 WORKING-STORAGE SECTION. 52 3 77 HEAD-ORDER PIC X(15) 53 31 VALUE "EMPLOYEE NUMBER". 54 32 1 PERSREPT-INDICS. 55 33 COPY DDS-ALL-FORMATS-O-INDIC OF PERSREPT. 4 56 + 1 5 PERSREPT-RECORD. + 2 OUTPUT FORMAT:HEADING FROM FILE PERSREPT OF LIBRARY XMPLIB + 3 + 4 6 HEADING-O-INDIC. + 5 OUTPUT FORMAT:DETAIL FROM FILE PERSREPT OF LIBRARY XMPLIB + 6 57 + 7 6 DETAIL-O-INDIC. 58 + 8 7 IN 1 PIC 1 INDIC 1. 34 59 35 77 EOF-FLAG PIC X(1) 6 36 VALUE " ". 61 37 88 NOT-END-OF-FILE VALUE " ".
COPYNAME
CHG DATE 2/ 1/94 3/22/94 1/27/94 1/27/94 2/ 4/94 3/ 1/94 1/27/94 1/27/94 1/27/94 1/27/94 1/27/94 1/27/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 2/ 4/94 1/27/94 1/27/94 2/ 4/94 2/ 4/94 2/ 4/94
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
235
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 62 38 88 END-OF-FILE VALUE "1". 63 39 77 MARRIED PIC X(1) 64 4 VALUE "M". 41 65 42 PROCEDURE DIVISION. 43 FIRST-SECT SECTION. 44 FIRST-PARA. 66 45 OPEN INPUT PERSFILE 46 OUTPUT PERSREPT. 67 47 PERFORM HEADING-LINE. 68 48 PERFORM PROCESS-RECORD UNTIL END-OF-FILE. 69 49 CLOSE PERSFILE 5 PERSREPT. 7 51 STOP RUN. 52 53 PROCESS-RECORD. 71 54 READ PERSFILE AT END SET END-OF-FILE TO TRUE. 73 55 IF NOT-END-OF-FILE THEN 74 56 PERFORM PRINT-RECORD. 5 57 58 PRINT-RECORD. 75 59 MOVE CORR PERSREC TO DETAIL-O. 6 76 6 IF MARSTAT IN PERSFILE-REC IS EQUAL MARRIED THEN 7 77 61 MOVE B"1" TO IN 1 IN DETAIL-O-INDIC 62 ELSE 78 63 MOVE B" " TO IN 1 IN DETAIL-O-INDIC. 79 64 WRITE PERSREPT-REC FORMAT IS "DETAIL" 8 65 INDICATORS ARE DETAIL-O-INDIC 8 66 AT EOP PERFORM HEADING-LINE. 9 67 HEADING-LINE. 81 68 MOVE HEAD-ORDER TO ORDERTYPE 82 69 WRITE PERSREPT-REC FORMAT IS "HEADING". 7 E N D O F S O U R C E
COPYNAME
CHG DATE
1 2 3 4 5 6 7 8 9
The externally described printer file is assigned to device FORMATFILE. The Format 2 COPY statement is used to copy the fields for the printer file into the program. Note that, although the fields in format DETAIL will be printed on three separate lines, they are defined in one record. COPY-DDS is used to copy the indicators used in the printer file into the program. Paragraph PROCESS-RECORD processes PRINT-RECORD for each employee record. All fields in the employee record are moved to the record for format DETAIL. If the employee is married, indicator 01 is turned on; if not, the indicator is turned off, preventing the spouses name field in DETAIL from being printed. Format DETAIL is printed with indicator 01 passed to control printing. If the number of lines per page has been exceeded, END-OF-PAGE occurs. The format HEADING is printed on a new page.
236
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 2 2 23 2 4 25 2 6 27 28 29 30 3 1 3 2 33 3 4 35 3 6 37 38 39 40 4 1 4 2 43 4 4 45 4 6 47 48 49 50 5 1 5 2 5 3 5 4 55 5 6 57 5 8 5 9 60 6 1 6 2 6 3 6 4 65 6 6 67 6 8 6 9 70 7 1 7 2 7 3 7 4 75 7 6 77 7 8 7 9 80
A* A A* A A A A A A A A A A A A A A A A A A A A A A A A A A A
P H Y S I CA L R
F I LE
DD S
F OR
P E R S ON N E L
F I LE
IN
F OR MA T F I L E
E X AMP L E
6S 30 35 20 6 1 30 2S
Figure 76 (Part 1 of 2). DDS Example of the Use of Externally Described Printer Files Assigned to a Device of FORMATFILE
237
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A* A* A A A A A A A A A A A* A A* A A A A A A A* A A A A A A A* A A A A A A
PR I NT ER
F I LE
DD S
F OR
F OR MA T F I L E
E X AMP L E I ND A R A R E F ( P E R S F I L E ) S K I P B ( 1 ) S P AC E A ( 3 ) 1 5 ' P E R S ON N E L L I S T I NG ' U ND E R L I N E 3 3 ' - OR D E R E D B Y ' 46 8 0 D A T E E D T CD E ( Y ) 9 3 T I ME 1 1 5 ' P AG E : ' + 1 P AGN B R E D T CD E ( 3 ) S P AC E A ( 3 ) 1 ' N AME : ' 1 1 U ND E R L I N E 5 5 ' E MP L O Y E E N UMB E R : ' 73 8 7 ' DA T E OF B I R T H : ' 1 0 3 S P AC E A ( 1 ) 1 ' AD D R E S S : ' 11 5 5 ' MA R I T A L S T A T U S : ' 73 8 7 ' S P OU S E ' ' S N AME : ' 103 1 1 S P AC E B ( 1 ) 5 5 ' CH I L D R E N : ' 7 3 E D T CD E ( 3 )
H E AD I NG
OR D E R T Y P E
15
L I NE
R DE T A I L 1 N AME E MP L NO B I R T HD A T E R R R
L I NE
2 AD D R E S S 1 MA R S T A T R R
01 01 L I NE 3
S P OU S E N AME R AD D R E S S 2 N UMC H I L D R R
Figure 76 (Part 2 of 2). DDS Example of the Use of Externally Described Printer Files Assigned to a Device of FORMATFILE
1 2 3
INDARA specifies that a separate indicator area is to be used for the file. HEADING is the format name that provides headings for each page. SKIPB(1) and SPACEA(3) are used to: 1. Skip to line 1 of the next page before format HEADING is printed. 2. Leave 3 blank lines after format HEADING is printed.
4 5
DATE, TIME, and PAGNBR are used to have the current date, time and page number printed automatically when format HEADING is printed. DETAIL is the format name used to print the detail line for each employee in the personnel file.
238
6 7
SPACEA(3) causes three lines to be left blank after each employee detail line. SPACEA(1) causes a blank line to be printed after the field BIRTHDATE is printed. As a result, subsequent fields in the same format are printed on a new line. 01 means that these fields are printed only if the COBOL program turns indicator 01 on and passes it when format DETAIL is printed. EDTCDE(3) is used to remove leading zeros when printing this numeric field.
8 9
239
240
Processing Methods for DISK and DATABASE Files COBOL Indexed Files
An indexed file is a file whose access path is built on key values. The user must create a keyed access path for an indexed file by using DDS. To write standard ANSI X3.23-1985 COBOL programs that access an indexed file, you must create the file with certain characteristics. The following table lists these characteristics and what controls them:
Characteristic The file must be a physical file. The file cannot have records with duplicate key values. The file cannot be a shared file. A key must be defined for the file. Keys must be in ascending sequence. Keys must be contiguous within the record. Key fields must be alphanumeric. They cannot be numeric only. The value of the key used for sequencing must include all 8 bits of every byte. A starting position for retrieving records cannot be specified. Select/omit level keywords cannot be used for the file. Control The CL command CRTPF The DDS keyword UNIQUE The CL command CRTPF DDS DDS DDS DDS DDS The CL command OVRDBF DDS
An indexed file is identified by the ORGANIZATION IS INDEXED clause of the SELECT statement.
241
The key fields identify the records in an indexed file. The user specifies the key field in the RECORD KEY clause of the SELECT statement. The RECORD KEY data item must be defined within a record description for the indexed file. If there are multiple record descriptions for the file, only one need contain the RECORD KEY data name. However, the same positions within the record description that contain the RECORD KEY data item are accessed in the other record descriptions as the KEY value for any references to the other record descriptions for that file. An indexed file can be accessed sequentially, randomly by key, or dynamically.
242
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 7 7 FILE-CONTROL. 8 8 SELECT FILE-1 ASSIGN TO DISK-FILE1 9 9 ACCESS IS DYNAMIC RECORD KEY IS FULL-NAME IN FILE-1 1 1 ORGANIZATION IS INDEXED. 11 11 DATA DIVISION. 12 12 FILE SECTION. 13 13 FD FILE-1 LABEL RECORDS ARE STANDARD. 14 14 1 RECORD-DESCRIPTION. 15 15 3 FULL-NAME. 16 16 5 LAST-AND-FIRST-NAMES. 17 17 7 LAST-NAME PIC X(2 ). 18 18 7 FIRST-NAME PIC X(2 ). 19 19 5 MIDDLE-NAME PIC X(2 ). 2 2 3 LAST-FIRST-MIDDLE-INITIAL-NAME REDEFINES FULL-NAME 21 21 PIC X(41). 22 22 3 REST-OF-RECORD 23 / 23 24 PROCEDURE DIVISION. 25 START-PROGRAM. 24 26 OPEN INPUT FILE-1. 27 28 POSITION THE FILE STARTING WITH RECORDS THAT HAVE A LAST NAME OF 29 "SMITH" 25 3 MOVE "SMITH" TO LAST-NAME. 26 31 START FILE-1 KEY IS EQUAL TO LAST-NAME 27 32 INVALID KEY DISPLAY "NO DATA IN SYSTEM FOR " LAST-NAME 28 33 GO-TO ERROR ROUTINE. 34 35 36 37 38 POSITION THE FILE STARTING WITH RECORDS THAT HAVE A LAST NAME OF 39 "SMITH" AND A FIRST NAME OF "ROBERT" 29 4 MOVE "SMITH" TO LAST-NAME. 3 41 MOVE "ROBERT" TO FIRST-NAME. 31 42 START FILE-1 KEY IS EQUAL TO LAST-AND-FIRST-NAMES 32 43 INVALID KEY DISPLAY "NO DATA IN SYSTEM FOR " 44 LAST-AND-FIRST-NAMES 33 45 GO-TO ERROR ROUTINE. 46 47 48 49 5 POSITION THE FILE STARTING WITH RECORDS THAT HAVE A LAST NAME OF 51 "SMITH", AND A FIRST NAME OF "ROBERT", AND A MIDDLE INITIAL OF "M" 34 52 MOVE "SMITH" TO LAST-NAME. 35 53 MOVE "ROBERT" TO FIRST-NAME. 36 54 MOVE "M" TO MIDDLE-NAME. 37 55 START FILE-1 KEY IS EQUAL TO LAST-AND-FIRST-MIDDLE-INITIAL-NAME 38 56 INVALID KEY DISPLAY "NO DATA IN SYSTEM FOR " 57 LAST-FIRST-MIDDLE-INITIAL-NAME 39 58 GO-TO ERROR ROUTINE. 59 6 61 ERROR-ROUTINE. 4 62 STOP-RUN.
COPYNAME
CHG DATE
Figure 78 and Figure 79 show an example of generic START statements using an externally described file.
243
SEQNBR 1 2 3 4 5 6 7 8 9 1 11 12
DATA DESCRIPTION SOURCE ... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ... ... 8 A UNIQUE A R RDE TEXT('RECORD DESCRIPTION') A FNAME 2 TEXT('FIRST NAME') A MINAME 1 TEXT('MIDDLE INITIAL NAME') A MNAME 19 TEXT('REST OF MIDDLE NAME') A LNAME 2 TEXT('LAST NAME') A PHONE 1 TEXT('PHONE NUMBER') A DATA 4 TEXT('REST OF DATA') A K LNAME A K FNAME A K MINAME A K MNAME
DATE
Figure 78. Generic START Statements Using an Externally Described File -- DDS
244
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 7 7 FILE-CONTROL. 8 8 SELECT FILE-1 ASSIGN TO DATABASE-NAMES 9 9 ACCESS IS DYNAMIC RECORD KEY IS EXTERNALLY-DESCRIBED-KEY 1 1 ORGANIZATION IS INDEXED. 11 11 DATA DIVISION. 12 12 FILE SECTION. 13 13 FD FILE-1 LABEL RECORDS ARE STANDARD. 14 14 1 RECORD-DESCRIPTION 15 15 COPY DDS-RDE IN NAMES-PUBS. 17 + 1 + 2 FROM FILE NAMES OF LIBRARY XMPLIB + 3 RECORD DESCRIPTION 18 + 4 5 RDE. + 5 RECORD KEY FOR INDEXED FILE, KEY' 2 KEY FIELD NAME FNAME . 19 + 6 6 FNAME PIC X(2 ). + 7 FIRST NAME + 8 RECORD KEY FOR INDEXED FILE, KEY' 3 KEY FIELD NAME MINAME . 2 + 9 6 MINAME PIC X(1). + 1 MIDDLE INITIAL NAME + 11 RECORD KEY FOR INDEXED FILE, KEY' 4 KEY FIELD NAME MNAME . 21 + 12 6 MNAME PIC X(19). + 13 REST OF MIDDLE NAME + 14 RECORD KEY FOR INDEXED FILE, KEY' 1 KEY FIELD NAME LNAME . 22 + 15 6 LNAME PIC X(2 ). + 16 LAST NAME 23 + 17 6 PHONE PIC S9(1 ). COMP-3 + 18 PHONE NUMBER 24 + 19 6 DATA-DDS PIC X(4 ). + 2 REST OF DATA 25 16 66 MIDDLE-NAME RENAMES MINAME THRU MNAME. 17 / 26 18 PROCEDURE DIVISION. 19 START PROGRAM. 27 2 OPEN INPUT FILE-1. 21 22 POSITION THE FILE STARTING WITH RECORDS THAT HAVE A LAST NAME 23 OF "SMITH" 28 24 MOVE "SMITH" TO LNAME. 29 25 START FILE-1 KEY IS EQUAL TO LNAME 3 26 INVALID KEY DISPLAY "NO DATA IN SYSTEM FOR " LNAME 31 27 GO TO ERROR-ROUTINE. 28 . 29 . 3 . 31 32 POSITION THE FILE STARTING WITH RECORDS THAT HAVE A LAST NAME 33 OF "SMITH" AND A FIRST NAME OF "ROBERT" 32 34 MOVE "SMITH" TO LNAME. 33 35 MOVE "ROBERT" TO FNAME. 34 36 START FILE-1 KEY IS EQUAL TO LNAME, FNAME 35 37 INVALID KEY DISPLAY "NO DATA IN SYSTEM FOR " 38 LNAME " " FNAME 36 39 GO TO ERROR-ROUTINE. 4 . 41 . 42 . 43 44 POSITION THE FILE STARTING WITH RECORDS THAT HAVE A LAST NAME OF 45 "SMITH", A FIRST NAME OF "ROBERT", AND A MIDDLE INITIAL OF "M" 32 46 MOVE "SMITH" TO LNAME. 33 47 MOVE "ROBERT" TO FNAME. 33 48 MOVE "M" TO MINAME. 34 49 START FILE-1 KEY IS EQUAL TO LNAME, FNAME, MINAME 35 5 INVALID KEY DISPLAY "NO DATA IN SYSTEM FOR " 51 LNAME SPACE FNAME SPACE MINAME 42 52 GO TO ERROR-ROUTINE. 53 54 55 ERROR-ROUTINE. 56 STOP-RUN.
COPYNAME
CHG DATE
RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE RDE
245
246
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
F OR MA T A F L DA OR D E R N F L DB OR D E R N 14 5S 101
P F I L E ( OR D D T L P ) T E X T ( ' ACC E S S P A T H 0
F OR
I ND E X E D
F I LE ' )
Figure 80. Using Data Description Specifications to Define the Access Path for an Indexed File
Data description specifications must be used to create the access path for a program-described indexed file. In the DDS for the record format FORMATA for the logical file ORDDTLL, the field ORDERN, which is five digits long, is defined as the key field. The definition of ORDERN as the key field establishes the keyed access for this file. Two other fields, FLDA and FLDB, describe the remaining positions in this record as character fields. The program-described input field ORDDTLL is described in the FILE-CONTROL section in the SELECT clause as an indexed file.
247
The COBOL descriptions of each field in the FD entry must agree with the corresponding description in the DDS file. The RECORD KEY data item must be defined as a five-digit numeric integer beginning in position 15 of the record.
I n t er n at i on al B u s i n e s s Mac h i n es
Fi l e Programmer Date
GX2 1-98 91-0 UM/05 0* Pr i nt ed i n U. S . A. * Number of s heet s per pad may var y s l i ghtl y. Page of
Conditioning
Location U s ag e ( b / O/ I / B/ H/ M/ N/ P ) /
Condition Name
Length
Functi ons
Form Type
Sequence Number
Indi cator
Indi cator
Indi cator
Not (N)
Not (N)
Li ne
Pos
9 10 11 12 13 14 15 16 17 18 19 20 2 1 22 2 3 2 4 25 2 6 27 2 8 29 30 3 1 32 3 3 3 4 35 3 6 37 3 8 39 40 4 1 42 4 3 4 4 45 4 6 47 4 8 49 5 0 5 1 52 5 3 5 4 5 5 5 6 57 5 8 59 6 0 6 1 62 6 3 6 4 6 5 6 6 67 6 8 69 7 0 7 1 72 7 3 7 4 7 5 7 6 77 7 8 79 8 0
A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
F OR MA T F L DA OR D E R N I T EM F L DB OR D E R N I T EM 14 5S 5 96
P F I L E ( OR D D T L P ) T E X T ( ' ACC E S S P A T H 0
F OR
I ND E X E D
F I LE ' )
K K
Figure 81. Data Description Specifications for Defining the Access Path (a Composite Key) of an Indexed File
In this example, the data description specifications define two key fields for the record format FORMAT in the logical file ORDDTLL. For the two fields to be used as a composite key for a program-described indexed file, the key fields must be contiguous in the record. The COBOL description of each field must agree with the corresponding description in the DDS file. A 10-character item beginning in position 15 of the record must be defined in the RECORD KEY clause of the file-control entry. The COBOL
248
descriptions of the DDS fields ORDERN and ITEM would be subordinate to the 10-character item defined in the RECORD KEY clause.
For a COBOL file with an organization of RELATIVE, the Reorganize Physical File Member (RGZPFM) CL command can: Remove all deleted records from the file. Because COBOL initializes all relative file records to deleted records, any record that has not been explicitly written will be removed from the file. The relative record numbers of all records after the first deleted record in the file will change. Change the relative record numbers if the file has a key and the arrival sequence is changed to match a key sequence (with the KEYFILE parameter). In addition, a Change Physical File (CHGPF) CL command bearing the REUSEDLT option can change the order of retrieved or written records when the file is operated on sequentially, because it allows the reuse of deleted records.
249
Characteristic The file must be a physical file. The file cannot be a shared file. No key can be specified for the file. The file must have a file type of DATA. Field editing cannot be used. Line and position information cannot be specified. Spacing and skipping keywords cannot be specified. Indicators cannot be used. System-supplied functions such as date, time, and page number cannot be used. Select/omit level keywords cannot be used for the file. Records in the file cannot be reused.
Control The CL command CRTPF The CL command CRTPF DDS The CL command CRTPF DDS DDS DDS DDS DDS DDS The CL command CRTPF
To preserve the sequence of records in a file that you open in I/O (update) mode, do not change the file so that you can reuse the records in it. That is, do not use a Change Physical File (CHGPF) CL command bearing the REUSEDLT option. Note: The COBOL/400 compiler does not check that the device associated with the external file is of the type specified in the device portion of assignmentname. The device specified in the assignment-name must match the actual device to which the file is assigned. See the ASSIGN Clause section of the COBOL/400 Reference for more information.
250
File is empty
To extend a file boundary beyond the current number of records, but remaining within the file size, use the INZPFM command to add deleted records before processing the file. You need to do this if you receive a file status of 0Q, and you still want to add more records to the file. Any attempt to extend a relative file beyond its current size results in a boundary violation. To recover from a file status of 9Q, use the CHGPF command as described in the associated run-time message text. Lengthy delays are normal when there remains an extremely large number of records (over 1 000 000) to be initialized to deleted records when the CLOSE statement runs. When the first OPEN statement for the file is not OPEN OUTPUT, relative files should be cleared and initialized with deleted records before they are used. See the discussion of the CLRPFM and INZPFM commands in the CL Reference for more information.
251
The RECORDS parameter of the INZPFM command must specify *DLT. Overrides are applied when the clear and initialize operations are processed by COBOL, but not when they are processed with CL commands. Lengthy delays in OPEN OUTPUT processing are normal for extremely large relative files (over 1 000 000 records) that you access in dynamic or random mode.
SELECT CLAUSE ORG ACC DEV OPEN READ WRITE START REWRITE DELETE CLOSE FORMAT KEY IS S S ANY INPUT X X S S ANY OUTPUT X(F1) X A1 S S ANY I-O X X X S S ANY EXTEND X X I S D/DB INPUT X X X B1 C1 I S D/DB OUTPUT X(F1) X B1 C1 I S D/DB I-O X X X X X B1 C1 I R D/DB INPUT X X B1 D1 I R D/DB OUTPUT X(F1) X B1 D1 I R D/DB I-O X X X X X B1 D1 I D D/DB INPUT X X X B1 D1 I D D/DB OUTPUT X(F1) X B1 D1 I D D/DB I-O X X X X X X B1 D1 R S D/DB INPUT X X X C1 R S D/DB OUTPUT X(G1) X C1 R S D/DB I-O X X X X X C1 R R D/DB INPUT X X E1 R R D/DB OUTPUT X(G1) X E1 R R D/DB I-O X X X X X E1 R D D/DB INPUT X X X E1 R D D/DB OUTPUT X(G1) X E1 R D D/DB I-O X X X X X X E1 T S W I-O X X X H1 T D W I-O X(K1) X(K1) X X I1 J1 ORG: ACC: DEV: S = Sequential S = Sequential ANY = Any Device R = Relative R = Random D = DISK I = Indexed D = Dynamic DB = DATABASE T = TRANSACTION W = WORKSTATION
The following paragraphs explain the keys used in Figure 82. X A1 B1 The combination is allowed. The FORMAT phrase is required for FORMATFILE files with multiple formats, and is not allowed for all other device files. The FORMAT phrase is optional for DATABASE files, and not allowed for DISK files. If the FORMAT phrase is not specified, the default format name of the file is used. The default format name of the file is the first format name defined in the file. The special register, DB-FORMAT-NAME, can be used to retrieve the format name used on the last successful I/O operation. C1 The SELECT clause KEY phrase is ignored except for the START statement. If the KEY phrase is not specified on the START statement, the RECORD KEY phrase or the RELATIVE KEY phrase in the SELECT clause is used and KEY = is assumed.
252
D1
The SELECT clause KEY phrase is used except for the START statement. If the KEY phrase is not specified on the START statement, the RECORD KEY phrase in the SELECT clause is used and KEY = is assumed. NEXT, PRIOR, FIRST, or LAST can be specified only for the READ statement for DATABASE files with DYNAMIC access. If NEXT, PRIOR, FIRST, or LAST is specified, the SELECT clause KEY phrase is ignored.
E1
The SELECT clause RELATIVE KEY phrase is used. The NEXT phrase can be specified only for the READ statement for a file with DYNAMIC access mode. If NEXT is specified, the SELECT clause KEY phrase is ignored. The RELATIVE KEY data item is updated with the relative record number for files with sequential access on READ operations.
F1 G1
A physical file opened for output is cleared. A physical file opened for output is cleared and initialized to deleted records. There are some exceptions depending on the file size and the options specified. For more information, refer to Table 4 on page 251. The FORMAT phrase is required for the WRITE statement. The FORMAT phrase is required to distinguish between the subfile records and the subfile control record. The WRITE FORMAT IS control-record-formatname displays the subfile, but a READ FORMAT IS control-record-formatname is required to allow data to be entered and to cause the operator input for the subfile records on the display to be placed in the subfile. The SELECT clause RELATIVE KEY phrase is used for READ, WRITE, and REWRITE statements that use the SUBFILE phrase, except that the READ SUBFILE NEXT MODIFIED uses the current system relative record number rather than the RELATIVE KEY data item. The RELATIVE KEY data item is updated with the relative record number for subfile records for READ statements with the NEXT MODIFIED clause. The SUBFILE phrase is required when an I/O operation deals with a particular record rather than an entire file.
H1 I1
J1
K1
253
254
1 2 3 4 5 6 7 8 9 1 11 12 13 14 15 16 17
Note: Do not use the Reclaim Resource (RCLRSC) Command in this situation. It cancels all programs higher in the program stack so that the STOP RUN statement in the program will cause a run-time exception. For more information about QCMDEXC, see the CL Programmers Guide. End of General-Use Programming Interface
255
256
5763CB1 V3R M5 AS/4 COBOL Source XMPLIB/CORR STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. CORRPHRASE. 3 3 AUTHOR. PROGRAMMER NAME. 4 4 INSTALLATION. TORONTO COBOL DEVELOPMENT CENTRE. 5 5 DATE-WRITTEN. 5/24/91. 6 6 DATE-COMPILED. 5/24/94 11: 9:11 . 7 7 ENVIRONMENT DIVISION. 8 8 CONFIGURATION SECTION. 9 9 SOURCE-COMPUTER. IBM-AS4 . 1 1 OBJECT-COMPUTER. IBM-AS4 . 11 11 DATA DIVISION. 12 12 WORKING-STORAGE SECTION. 13 13 1 GROUP1. 14 14 5 ITEM1 PIC 99 VALUE 1. 15 15 5 ITEM2 PIC 99 VALUE 2. 16 16 5 ITEM3 PIC X(1 ) VALUE "GREEN". 17 17 5 ITEM4 PIC X(1 ) VALUE "BLUE". 18 18 1 GROUP2. 19 19 5 ITEM1 PIC 99 VALUE 8. 2 2 5 ITEM2 PIC 99 VALUE 9. 21 21 5 ITEM3 PIC XXBX(8) VALUE SPACES. 22 22 5 ITEM4 PIC X(1 ) VALUE SPACES. 23 23 1 GROUP3. 24 24 5 SPECIAL PIC XX. 25 25 PROCEDURE DIVISION. 26 MAINLINE. 26 27 ADD CORRESPONDING GROUP1 TO GROUP2. CORRESPONDING items for statement 26: ITEM1 ITEM2 End of CORRESPONDING items for statement 26 27 28 SUBTRACT CORRESPONDING GROUP1 FROM GROUP2. CORRESPONDING items for statement 27: ITEM1 ITEM2 End of CORRESPONDING items for statement 27 28 29 MOVE CORRESPONDING GROUP1 TO GROUP2. CORRESPONDING items for statement 28: ITEM1 ITEM2 ITEM3 ITEM4 End of CORRESPONDING items for statement 28 29 3 MOVE CORRESPONDING GROUP3 TO GROUP2. CORRESPONDING items for statement 29: No CORRESPONDING items found End of CORRESPONDING items for statement 29 3 31 STOP RUN. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages XMPLIB/CORR STMT 29 MSGID: LBL 336 SEVERITY: 1 SEQNBR: 3 Message . . . . : No CORRESPONDING items found. Statement ignored. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 31 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : 1 LBL 9 1 Program CORR created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
257
IBM Extension
LIKE Clause
The LIKE clause allows you to define the PICTURE, USAGE, SIGN, and BLANK WHEN ZERO characteristics of a data name by copying them from a previously defined data name. LIKE can only refer to a data name or index name, and such names must be uniquely qualified if they have been previously defined. It also allows you to change the length of the data name you define. This clause is particularly helpful because you can use it to define identifiers in the Working-Storage Section of your program that have the same attributes as variables that you define using the COPY statement. To create data name DEPTH with the same attributes as data name HEIGHT, write: DEPTH LIKE HEIGHT To create data name PROVINCE with the same attributes as data name STATE, except 1 byte longer, write: PROVINCE LIKE STATE (+1) This example shows how you can create data item WS-KEY3 with the same attributes as data item KEY3 in the Working-Storage Section:
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 14 15 16 17 + + + + + + + + + + + + + FILE SECTION. FD FILE1. 1 FILE1-REC. COPY DDS-ALL-FORMATS OF COPYDDS2. 5 COPYDDS2-RECORD PIC X(2 ). I-O FORMAT: RECORD1 FROM FILE COPYDDS2 OF LIBRARY COPYLIB
1 2 3 4 THE KEY DEFINITIONS FOR RECORD FORMAT RECORD1 5 NUMBER NAME RETRIEVAL TYPE 6 1 KEY1-DDS ASCENDING 7 KEYNAME ORIGINATES FROM PHYSICAL FILE 8 5 RECORD1 REDEFINES COPYDDS2-RECORD. 9 6 KEY3 PIC X(8). 1 6 FILLER REDEFINES KEY3. 11 7 KEY1-DDS PIC X(4). 12 7 FILLER PIC X(4). 13 6 DATA1 PIC X(12). 18 WORKING-STORAGE SECTION. 19 1 WS-KEY3 LIKE KEY3. PICTURE IS X(8)
The LIKE clause cannot be used in conjunction with the REDEFINES, SIGN, USAGE, or PICTURE clauses. If you use any of these clauses with the LIKE clause, a duplication error occurs. Similarly, BLANK WHEN ZERO can only be specified in conjunction with the LIKE clause if the BLANK WHEN ZERO attribute has not been inherited by the LIKE clause.
258
A valid LIKE clause has the format of one of the following: data-name-1 LIKE-clause xxxxx. data-name-1 xxxxx LIKE-clause. data-name-1 xxxxx LIKE-clause xxxxx. The xxxxx is one or a combination of the following clauses: JUSTIFIED, SYNCHRONIZED, BLANK WHEN ZERO, VALUE, OCCURS. The following show what the LIKE clause can do: 1 INCOME. 5 ANNUAL-WAGES PIC 9(6)V9(2) COMP-3. 1 YTD-WAGES LIKE ANNUAL-WAGES. PICTURE IS 9(6)V9(2) USAGE IS PACKED-DECIMAL
RATES. 5 MONTHLY-RATE PIC 9(3). 66 GROSS-RATE RENAMES MONTHLY-RATE. 1 NET-RATE LIKE GROSS-RATE. PICTURE IS 9(3)
VALUE "JONES".
1 1
EMPLOYEE-NUMBER PIC X(6). DEPARTMENT-MEMBERS. 5 DEPT-EMPLOYEE-NUMBER LIKE EMPLOYEE-NUMBER OCCURS 1 TIMES. PICTURE IS X(6) Note: DEPARTMENT-MEMBERS in the above example is 60 bytes long.
5 TENANT-NAME PIC X(2 ) OCCURS 1 RENEWAL-RECORD. 5 RENEWAL-MONTH PIC X(3). 5 RENEWAL-NAME LIKE TENANT-NAME. PICTURE IS X(2 ) 1
TIMES.
259
The PICTURE portion of the generated comment is shown in a concise format. Note: A numeric field with the BLANK WHEN ZERO attribute is considered to be a numeric edited field. 1 ORDER-DETAILS. 5 ORDER-TYPE PIC XX. 5 ORDER-CODE LIKE ORDER-TYPE. PICTURE IS X(2)
FASTENINGS. 5 NAILS PIC 9V99 5 RIVETS LIKE NAILS. PICTURE IS 9V9(2) BLANK WHEN ZERO
MORTGAGE-PAYMENT. 5 MORTGAGE-TOTAL PIC S999V99 SIGN IS LEADING SEPARATE. 5 MORTGAGE-INTEREST LIKE MORTGAGE-TOTAL. PICTURE IS S9(3)V9(2) SIGN IS LEADING SEPARATE
PROFIT. 5 GROSS-PROFIT PIC 999(3)PP(5). 5 NET-PROFIT LIKE GROSS-PROFIT. PICTURE IS 9(5)P(6) You can use an integer to increase or decrease the length of the field. The following example shows how to increase the field length of WEEKLY-AMOUNT: 1 WEEKLY-AMOUNT PIC 9(3). 1 ANNUAL-AMOUNT LIKE WEEKLY-AMOUNT (+3). PICTURE IS 9(6) You should also be aware of the following: Any field that has attributes of BLANK WHEN ZERO is considered to be an edited field If an integer of zero is specified, an informational message is generated. Only the integer portion of the field length can be increased or decreased. You cannot change the number of decimal places in a data item. The default attributes, SIGN IS TRAILING and USAGE IS DISPLAY, are never printed as comments following a LIKE operation. When you use the LIKE clause, the normal data name qualification rules apply to the parent data name; however, the referenced data name must be uniquely qualified if it has previously been defined more than once. For example:
260
COMBINATIONS. 5 PHENOTYPE PIC XX. 5 GENOTYPE LIKE PHENOTYPE. PICTURE IS X(2) 1 PHENOTYPE-TRAITS. 5 PHENOTYPE PIC X(3 ). 5 PHENO-GROUP LIKE PHENOTYPE OF COMBINATIONS. PICTURE IS X(2) If you do not uniquely qualify the parent data name, the compiler assigns it a picture clause of X(2), and you receive an error message. The use of the LIKE clause can sometimes result in group items that are not valid. For example, if you define a COMP-4 group item and then use the LIKE clause to define a COMP-3 item that is subordinate to it, an error will result. The following example is valid: 77 1 SWITCHES-IN-STOCK PIC S99. PARTS-ON-ORDER SIGN IS LEADING SEPARATE. 5 SWITCHES-ON-ORDER LIKE SWITCHES-IN-STOCK. PICTURE IS S9(2)
Note: SWITCHES-ON-ORDER has the same SIGN attribute (SIGN IS TRAILING) as SWITCHES-IN-STOCK. In the case of B LIKE A where A is a group item, B cannot be subordinate to A. In all other cases, B will be defined as an alphanumeric item with a length in bytes equal to the length of group A. GARAGE-1. 5 STD-PARKING-1 PIC 9(3). 1 GARAGE-2. 5 STD-PARKING-2 PIC 9(3) COMP-3. 77 VACANCIES-1 LIKE GARAGE-1. PICTURE IS X(3) 77 VACANCIES-2 LIKE GARAGE-2. PICTURE IS X(2) STD-PARKING-1 is a zoned numeric field, so VACANCIES-1 requires 3 bytes of storage. STD-PARKING-2 is a packed numeric field, so VACANCIES-2 requires only 2 bytes of storage. You can use the LIKE clause with the USAGE IS POINTER clause: 1 CUSTOMER-RECORD. 5 CUST-NAME 5 CUST-ADDR-POINTER 5 CUST-STATS-POINTER USAGE IS POINTER 5 CUST-NUMBER PIC X(16). POINTER. LIKE CUST-ADDR-POINTER. PIC S9(8). 1
Note: You cannot use the LIKE clause to change the length of a pointer. For additional information about the LIKE clause, see the COBOL/400 Reference. End of IBM Extension
261
Reference Modification
Reference modification allows you to reference substrings of a data item. You simply specify the position within the data item at which you want the substring to start, and the length of the substring. The length is optional: if you omit it, it automatically extends to the end of the data item. You can write both the starting position and the length value as integer literals, data items, or arithmetic expressions. The starting position must be at least 1, and cannot be greater than the length of the referenced data item. The length must be at least 1. The result of adding the starting position to the length specification, then subtracting 1, must fall between 1 and the total length of the referenced data item, inclusive. When the length value is greater than the total length of the data item, an error results. For additional information on reference modification, see the COBOL/400 Reference. The *RANGE generation option produces code to detect out-of-range reference modification conditions, and to flag violations with a run-time message. Suppose you want to retrieve the current time from the system, and display its value in an expanded format. You can retrieve it with the ACCEPT statement, which returns the hours, minutes, seconds, and hundredths of seconds in the format: HHMMSSss However, you may want to view the current time in the format: HH:MM:SS Without reference modification, you must define the following data items: 1 TIME-GROUP. INTERESTING-FIELDS. 1 HOURS 1 MINUTES 1 SECONDS 5 UNINTERESTING-FIELDS. 1 HUNDREDTHS-OF-SECONDS 1 EXPANDED-TIME-GROUP. 5 INTERESTING-FIELDS. 1 HOURS 1 FILLER 1 MINUTES 1 FILLER 1 SECONDS 5
The following code would retrieve the time value, convert it to its expanded format, and display the new value:
262
ACCEPT TIME-GROUP FROM TIME MOVE CORRESPONDING INTERESTING-FIELDS OF TIME-GROUP TO INTERESTING-FIELDS OF EXPANDED-TIME-GROUP DISPLAY "CURRENT TIME IS: " EXPANDED-TIME-GROUP With reference modification, you do not need to provide names for the subfields that describe the time elements. The only data definition you must have is: 1 REFMOD-TIME-ITEM PIC X(8).
The code to retrieve and expand the time value appears as follows: ACCEPT REFMOD-TIME-ITEM FROM TIME DISPLAY "CURRENT TIME IS: " REFMOD-TIME-ITEM (1:2) ":" REFMOD-TIME-ITEM (3:2) ":" REFMOD-TIME-ITEM (5:2) The following example shows a reference beginning at character position 1, for a length of 2, thus retrieving the portion of the time value that corresponds to the number of hours: REFMOD-TIME-ITEM (1:2) The following example shows a reference beginning at character position 3, for a length of 2, thus retrieving the portion of the time value that corresponds to the number of minutes: REFMOD-TIME-ITEM (3:2) The following example shows a reference beginning at character position 5, for a length of 2, thus retrieving the portion of the time value that corresponds to the number of seconds: REFMOD-TIME-ITEM (5:2)
99. X
The OCCURS DEPENDING ON object of the NAME-PORTION table is set to 8 so that only the first eight occurrences of the table are referenced, even though the entire 17 bytes of NAME-PORTION are filled in.
263
8WILLIAMS THOMAS J Suppose you want to change the value in the item NAME-PORTION without changing the portion of the item that is defined beyond the currently defined length. You might try coding: MOVE NEW-NAME-GROUP TO NAME-GROUP in which the contents of NEW-NAME-GROUP are: 5SMITH MICHAEL According to the rules for the MOVE statement, the entire contents of the receiving field NAME-GROUP would be replaced. This problem can be avoided by using reference modification in the MOVE statement: MOVE NEW-NAME-GROUP TO NAME-GROUP ( 1 :LENGTH OF NAME-GROUP ) By specifying the reference modification with the LENGTH OF special register, the length of NAME-GROUP is now determined by the value in the NAME-LENGTH variable. The new value of NAME-GROUP will be: 5SMITH THOMAS J
The program then counts the number of leading spaces, and, using arithmetic expressions in a reference modification expression, moves the right-justified characters into another (left-justified) field: MOVE SPACES TO LEFTY MOVE ZERO TO I INSPECT RIGHTY TALLYING I FOR LEADING SPACE IF I IS LESS THAN 3 THEN MOVE RIGHTY ( I + 1 : 3 - I ) TO LEFTY END-IF
264
The MOVE statement transfers characters from RIGHTY, beginning at the position computed in I + 1, for a length that is computed in 30 I, into the field LEFTY.
You can change both the third and fourth bytes of the first element of TABLE-ELEMENT to the value ?? with the following MOVE statement: MOVE "??" TO TABLE-ELEMENT ( 1 ) ( 3 : 2 ) This statement will move the value ?? into table element number 1, beginning at character position 3, for a length of 2. ANY-TABLE would look like this before the change: ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJ It would look like this after the change: AB??EFGHIJ ABCDEFGHIJ ABCDEFGHIJ
De-editing
De-editing allows you to move a numeric-edited data item into a numeric or numeric-edited receiving data item. The compiler accomplishes this by first establishing the unedited value of the numeric-edited item. It then moves the unedited value to the receiver. De-editing can occur in operations such as MOVE and INITIALIZE. A VALUE clause does not de-edit. Note that unedited numeric values can involve signs. Suppose that you use a character field to contain a numeric value that displays on the terminal, and also to contain a value that the computer operator supplies. Suppose that this field has the following definition: One character position for a sign (to contain a space if the numeric field is positive or zero, or a minus sign if the numeric field is negative); Six digit positions, in which leading zeros are represented by spaces;
265
A decimal point; Two decimal-digit positions. The data item that you use to define this field would look like this: 1 NUM-EDIT PIC Z(6).9(2) USAGE IS DISPLAY.
You could initialize this field using this statement: MOVE ZEROS TO NUM-EDIT and when it displays on the terminal, it would contain the value .00.
Later, the computer operator might use this field for data entry. If the operator puts 123.45 into the field, you can obtain the numeric value of the field by moving it into a data item defined as: 1 NUMERIC-ITEM This statement: MOVE NUM-EDIT TO NUMERIC-ITEM causes de-editing to take place, whereby the numeric item receives the numeric value of the numeric-edited field NUM-EDIT. As a result, the numeric item contains the value +123.45. PIC S9(6)V9(2) USAGE IS PACKED-DECIMAL.
De-editing Examples
Table 5 and Table 6 show examples of COBOL/400 de-editing.
Table 5. Moving Numeric-edited Items into Numeric Receivers
Source Picture $+++,+++.++ Source Value $ +123.45 Receiving Picture S9(5)V9(5) USAGE IS DISPLAY S9(5)V9(5) USAGE IS BINARY S9(5)V9(5) USAGE IS PACKED-DECIMAL Receiving Value +123.45
$+++,+++.++
$ 1,234.56
1234.56
*****.999+
**123.450
123.45
012345.00
266
Sign Test
The compiler validates signs in numeric-edited source items according to the following rules.
PICTURE Definition Fixed + Fixed CR DB Allowable Contents + or or or CR or DB
If these rules are disobeyed, a sign error occurs, and the program stops.
Float Test
If the source has a string of floating characters, this test verifies the correctness of leading floating characters in the data field. The rules for the float test are: If the source PICTURE clause contains floating $ symbols, the first non-blank character in the relevant portion of the source field (positions 2 through 7 in the example) must be a $, and its location must be correct according to the rules for PICTURE clause editing. (See the COBOL/400 Reference for more information about these rules.) For example: Location of a Leading Floating Character 1 A PIC +$$B,$$$. . . / Note that "b" represents one space / PIC String: +$$B,$$$ / Position indexes: 12345678 MOVE 1 TO A. / A = "+bbbbb$1" MOVE 12 TO A. / A = "+bbbb$12" MOVE 123 TO A. / A = "+bbb$123" MOVE 1234 TO A. / A = "+$1b,234"
/ / / / / / /
In this example, the $ must be located at position 2, 5, 6, or 7. If the source PICTURE clause contains floating + symbols, the first non-blank character in the relevant portion of the source field must be + or , and its location must be correct according to the rules for PICTURE clause editing.
267
If the source PICTURE clause contains floating symbols, the relevant portion of the source field must start with: One or more contiguous spaces, the last of which must be correctly located according to the rules for PICTURE clause editing One or more contiguous spaces, with a immediately following it. The location of the must be correct according to the rules for PICTURE clause editing. A . If these rules are disobeyed, a float error occurs, and the program stops.
Segmentation
Use of segmentation increases the compile and run times of the COBOL program. The segmentation feature is provided only for compatibility with other systems. You do not have to be concerned with storage management when using COBOL/400 programs.
268
A new function, MGTFUNC has been added to the COBOL run-time routine, QRLMAIN to prevent this deactivation by causing the main COBOL program to be treated as a subprogram. Because this fix depends on the size of MGT, it is recommended that the run-time routine, QLRMAIN be called from the main COBOL program with MGTFUNC = 9, as shown in the following example: 1 mgtstruc. 3 FILLER PIC X(277). 3 mgtfunc pic 9(2) comp-4 value 9. TEST-VAR PIC X(1 ) value spaces. if test-var = spaces then display 'spaces' move 'faked' to test-var call 'QLRMAIN' using mgtstruc else display 'not spaces ' test-var. Notes: 1. The 1 mgtstruc must be on a 16 byte boundary. If a boundary error occurs, add 77 aa PIC X. in front of the 1. 2. Because the call to QLRMAIN changes the main COBOL program to a subprogram, you should use the EXIT PROGRAM command and not STOP RUN, which may cause errors. 3. RCLRSC will deactivate the main program (now a subprogram)
77
Debugging
COBOL source language debugging is provided to help the COBOL programmer debug a program that is not functioning as expected. Use of this facility increases the compile and run times of a COBOL program.
*NORANGE Option
This GENOPT parameter option of the CRTCBLPGM command removes the runtime checks for subscript and reference modification ranges. This option can improve performance when: You make frequent references to tables, and the subscripts always reference elements that are in the tables You use reference modification often. Note: The *RANGE option generates code for checking subscript ranges. For example, it ensures that you are not attempting to access the 21st element of a 20-element array. The *NORANGE option does not generate code to check subscript or reference modification ranges. These options do not eliminate the zero subscript checking performed by the operating system. If zero subscripts occur, the operating system will not permit their use and issues message MCH0603.
269
*DUPKEYCHK Option
This GENOPT parameter option of the CRTCBLPGM command indicates that duplicate key checking for INDEXED files will be performed. Using DUPKEYCHK while reading INDEXED files can adversely affect performance.
Relative Files
You can experience lengthy delays if you open or close relative files in which very large volumes of records are being initialized to deleted records. See Table 4 on page 251 for more information.
Indicators
If you use indicators in a separate indicator area (INDARA keyword specified in DDS) instead of in the record area, the use of the OCCURS clause to specify a table with up to 99 indicators can improve performance. See Figure 60 on page 155 for more information.
Commitment Control
Generally, the use of commitment control increases the run time of a COBOL program. In addition, the record locking that results from the use of commitment control by a job may cause delays for other users attempting to access the same file.
Initializing Variables
You can reduce program run time by choosing not to initialize program variables that have no value clauses associated with them. You can specify no initialization by specifying NOSTDINZ for the GENOPT parameter of the CRTCBLPGM command, or by specifying NOSTDINZ in the PROCESS statement. The compiler then initializes only those variables that have value clauses declared. An additional benefit to this option is that you can also compile larger programs with a greater number of variables. If you specify NOSTDINZ, you must ensure that all data items contain valid data before you attempt to manipulate the items. If an item does not contain valid data, decimal data errors can occur.
Blocking Records
You can use record blocking to improve your run-time performance. The key benefits for blocking are realized when you read multiple records sequentially, such as a random read followed by sequential reads. For information on blocking, refer to Unblocking Input Records and Blocking Output Records on page 102.
270
Program Loops
When a program repeatedly processes the same series of instructions, and it is apparent that this will continue indefinitely, the program is in a loop. To identify loops, you can use information known about the program itself, as follows: Time: If the actual run time is substantially exceeding the expected run time, the program could be in a loop. I/O operations: If no input/output operations are taking place and I/O is expected to be occurring repeatedly, the program is probably in a loop.
271
272
273
274
CALL RUN UNIT A LEVEL PGMA n Main Program COBOL PGMB PGMC n + 1 COBOL Non-COBOL PGMD PGME PGMF n + 2 COBOL COBOL Non-COBOL
PROGRAM RUNNING STATEMENT STATEMENT PGMA PGMB PGMD PGME EXIT PROGRAM 1 2 2 2 STOP RUN 3 3 3 3
1 2 3
No operation is processed because the statement is processed in a main program. Processing continues with the next statement in PGMA. Control returns to the caller of the program that processes the EXIT PROGRAM statement. Run unit A ends. For all programs in the run unit, open files are closed. Storage is freed for all programs in the run unit. Control returns to the program that is at call level n-1. If n=1, the following considerations apply: Run unit A operates as a job step. See the CL Programmers Guide for more information. For batch jobs, the STOP RUN statement ends the job. For interactive jobs, control returns to the system and the system ends the job step.
275
CALL LEVEL PGMA Non-COBOL RUN UNIT B RUN UNIT C PGMB PGMC Main Main Program COBOL Program COBOL PGMD PGME PGMF Non-COBOL COBOL COBOL n
n + 1
n + 2
PROGRAM RUNNING STATEMENT PGME PGME PGMB PGMC (RUN (RUN PGMF STATEMENT UNIT B) UNIT C) EXIT PROGRAM 1 1 2 2 2 STOP RUN 3 4 3 4 4
1 2 3
No operation is processed because the statement is processed in a main program. Processing continues with the next statement in the main program. Control returns to the caller of the program that processes the EXIT PROGRAM statement. Run unit B ends. All open files in run unit B are closed. Storage is freed for all programs in run unit B. Control returns to the caller of the main program for the run unit (PGMA). Run unit C ends. All open files in run unit C are closed. Storage is freed for all programs in run unit C. Control returns to the caller of the main program for the run unit (PGMA).
276
CALL LEVEL PGMA Non-COBOL RUN UNIT B PGMB PGMC Main Program COBOL Non-COBOL RUN UNIT E RUN UNIT F PGMD PGME PGMF Main Non-COBOL COBOL Program COBOL
n + 1
n + 2
PROGRAM RUNNING STATEMENT PGME PGME PGMB (RUN (RUN PGMF STATEMENT UNIT B) UNIT E) EXIT PROGRAM 1 2 1 1 STOP RUN 3 3 4 5
Figure 87. Example of a Run Unit with a Shared Program that is Both a Subprogram and a Main Program
1 2 3
No operation is processed because the statement is processed in a main program. Processing continues with the next statement in the main program. Control returns to the caller of the program that processes the EXIT PROGRAM statement. Run unit B ends. All open files in run unit B are closed. Storage is freed for all programs in run unit B. Control returns to the caller of the main program for the run unit (PGMA).
277
Run unit E ends. All open files in run unit E are closed. Storage is freed for PGME. Control returns to the caller of the main program for the run unit (PGMC). Run unit F ends. All open files in run unit F are closed. Storage is freed for PGMF. Control returns to the caller of the main program for the run unit (PGMC).
CALL LEVEL PGMA Non-COBOL n
RUN UNIT B
n+2 n+1
PGMD non-COBOL RUN UNIT E PGM QLRCHGCM PGME Main Program API 2 COBOL PGMF COBOL
n+4 n+3
PROGRAM RUNNING STATEMENT PGMC PGME PGMF PGMB (RUN (RUN STATEMENT UNIT B) UNIT E) EXIT PROGRAM 1 2 1 2 STOP RUN 3 3 4 4
1 2
No operation is processed because the statement is processed in a main program. Processing continues with the next statement in the main program. Control returns to the caller of the program that processes the EXIT PROGRAM statement.
278
Run unit B can only end after run unit E completes a STOP RUN. When run unit B ends, all open files in run unit B are closed. Storage is freed for all programs in run unit B, and control returns to the caller of the main program (PGMA). Run unit E ends. All open files in run unit E are closed. Storage is freed for all programs in run unit E. Control returns to PGMD in run unit B.
Concurrent run units are achieved by using the QLRCHGCM API. Refer to the System Programmers Interface Reference for more information on this API.
Initialization of Storage
The first time a COBOL program in a run unit is called, its storage is initialized. Storage is initialized again under the following conditions: The run unit is terminated, then reinitiated. The program is canceled (using the CANCEL statement for COBOL, the FREE operation for the RPG/400* programming language, or the Reclaim Resource (RCLRSC) command), and then called again. If a non-COBOL program is named in a CANCEL statement, its name must conform to the rules for formation of a COBOL program name.
279
If you want to pass the address of a record area to a called program, specify: CALL . . . BY REFERENCE ADDRESS OF record-name. The subprogram receives the ADDRESS OF special register for the recordname you specify. You must define the record name as a level-01 or level-77 item in the Linkage Section of the called and calling programs. A separate ADDRESS OF special register is provided for each record in the Linkage Section. If you do not want the definition of the argument of the CALL statement in the calling program and the definition of the parameter in the called subprogram to share the same memory, specify: CALL . . . BY CONTENT identifier. If you want to pass a literal value to a called program, specify: CALL . . . BY CONTENT literal. The called program cannot change the value of the literal. The literal cannot be numeric. If you want to pass the length of a data item, specify: CALL . . . BY CONTENT LENGTH OF identifier. The calling program passes the length of identifier from its LENGTH OF special register. When literals are passed BY CONTENT, the called program cannot change their values. If you want to pass both a data item and its length to a subprogram, specify a combination of BY REFERENCE and BY CONTENT. For example: CALL 'ERRPROC' USING BY REFERENCE A BY CONTENT LENGTH OF A. Data items in a calling program can be described in the Linkage Section of all the programs it calls directly or indirectly. In this case, storage for these items is allocated in the highest calling program. That is, program A calls program B, which calls program C. Data items in program A can be described in the Linkage Sections of programs B and C, so that one set of data can be made available to all three programs.
280
In the called program, the code for parts and the part number are combined into one data item (PARTID). In the called program, a reference to PARTID is the only valid reference to them.
281
Call by Identifier
A system pointer that associates an identifier with an object is set the first time you use the identifier in a CALL statement. Important for compatibility! If you carry out a call by an identifier to a program that you subsequently delete or rename, you must use the CANCEL statement to null the system pointer associated with the identifier. This ensures that when you next use the identifier to call your program, the associated system pointer will be set again.
The following example shows how to apply the CANCEL statement to an identifier: MOVE "ABCD" TO IDENT-1. CALL IDENT-1. CANCEL IDENT-1. If you apply the CANCEL statement directly to the literal "ABCD", you do not null the system pointer associated with IDENT-1. Instead, you can continue to call program ABCD simply by using IDENT-1 in your CALL statement. The value of the system pointer also changes if you change the value of the identifier and perform a call using this new value.
282
Pointer data items are defined explicitly with the USAGE IS POINTER clause, and are implicit when using an ADDRESS OF special register or the ADDRESS OF an item. If a group item is described with the USAGE IS POINTER clause, the elementary items within the group item are pointer items. The group itself is not a pointer data item, and cannot be used in the syntax where a pointer data item is allowed. The USAGE clause of an elementary item cannot contradict the USAGE clause of a group to which the item belongs. Pointer data items can be part of a group that is referred to in a MOVE statement or an input/output statement; however, if a pointer data item is part of a group, there is no conversion of pointer values to another form of internal representation when the statement is executed.
In the above example, AVAR is an 01-level data item, so the ADDRESS OF AVAR is the ADDRESS OF special register. Because a special register is an actual storage area, the SET statement moves the contents of ADDRESS OF AVAR into pointer data item APTR.
283
In the above example, if the SET statement used ADDRESS OF CVAR, no special register exists. Instead, the pointer data item APTR is assigned the calculated address of CVAR.
In the above example, APTR is a pointer data item. The 77-level item, therefore, is placed on a 16-byte boundary. The group item AB is an 01-level item and is automatically placed on a 16-byte boundary. Within the group item AB, BPTR is not on a 16-byte boundary. To align it properly, the compiler inserts a 6-byte FILLER item after ALPHA-NUM. Finally, CPTR requires a FILLER of 2 bytes to align its first occurrence. Because ALPHA-NUM-THREE is only 5 bytes long, another 11-byte FILLER must be added to the end of ARRAY-1 to align all subsequent occurrences of CPTR. When a pointer is defined in the File Section, and a file does not have blocking in effect, each 01-level item will be on a 16-byte boundary. If a file has blocking in effect, only the first record of a block is guaranteed to be on a 16-byte boundary. Thus pointer data items should not be defined for files with blocking in effect. For more information on blocking, refer to Unblocking Input Records and Blocking Output Records on page 102.
284
For example: WORKING-STORAGE SECTION. 1 AB. 5 ALPHA-NUM PIC X(16). 5 APTR REDEFINES ALPHA-NUM USAGE POINTER. 5 BPTR USAGE POINTER. 5 CPTR REDEFINES BPTR USAGE POINTER.
Figure 92. REDEFINES and Aligned Pointer Data Items
In the above example, both APTR and CPTR are pointer data items that redefine 16-byte aligned items. In the following example, the redefined item would result in a severe compiler error: WORKING-STORAGE SECTION. 1 EF. 5 ALPHA-NUM PIC X(5). 5 HI. 1 ALPHA-NUM-TWO PIC X(11). 1 APTR USAGE POINTER. 5 BPTR REDEFINES HI USAGE POINTER.
Figure 93. REDEFINES and Aligned Pointer Data Items - Incorrect Method
In the above example, APTR is aligned on a 16-byte boundary. That is, the COBOL/400 compiler did not need to add FILLER items to align APTR. The group item HI is not on a 16-byte boundary, and so neither is pointer data item BPTR. Because the COBOL/400 compiler cannot add FILLER items to place BPTR on a 16-byte boundary, a severe error will result. In the following example, similar to the above, the COBOL/400 compiler is able to place the pointer data item on a 16-byte boundary: WORKING-STORAGE SECTION. 1 EF. 5 ALPHA-NUM PIC X(5). 5 HI. 1 ALPHA-NUM-TWO PIC X(11). 1 APTR USAGE POINTER. 1 ALPHA-NUM-THREE PIC X(5). 5 KL REDEFINES HI. 1 BPTR USAGE POINTER.
Figure 94. REDEFINES and Unaligned Pointer Data Items - Correct Method
In the above example, group item KL is not on a 16-byte boundary; however, the compiler adds an 11-byte FILLER before pointer data item BPTR to ensure that it falls on a 16-byte boundary.
285
A record containing pointers can be written to a file; however, on subsequent reading of that record, the pointer data items equal NULL.
In the above example, pointer APTR is set to NULL in the Working-Storage section. The comparison in the procedure division will be true and the display statement is executed. On the AS/400 system, the initial value of a pointer data item with or without a VALUE clause of NULL, equals NULL.
In the above example, the length of group item AB is moved to variable BVAR. BVAR has a value of 20 because BPTR is 16 bytes long, and both variables BVAR and CVAR are 2 bytes long. CVAR receives a value of 16. You can also use the LENGTH OF special register to set up data structures within user spaces, or to increment addresses received from another program. To see an
286
example of a program that uses the LENGTH OF special register to define data structures within user spaces, refer to Figure 99 on page 291.
287
3. The data items are properly aligned 4. The data items are alphanumeric or group items. Of the conditions listed above, determining if two data items are properly aligned can be the most difficult. If the items being moved are 01-level items, or are part of an 01-level item, they must be on the same offset relative to a 16-byte boundary for a pointer MOVE to occur. (A warning is issued if this is not true.) The following example shows three data structures, and the results when a MOVE statement is issued: WORKING-STORAGE SECTION. 1 A. 5 B PIC X(1 ). 5 C. 1 D PIC X(6). 1 E POINTER. 1 A2. 5 B2 PIC X(6). 5 C2. 1 D2 PIC X(1 ). 1 E2 POINTER. 1 A3. 5 B3 PIC X(22). 5 C3. 1 D3 PIC X(1 ). 1 E3 POINTER. PROCEDURE DIVISION. MOVE A to A2. 1 MOVE A to A3. 1 MOVE C to C2. 2 MOVE C2 to C3. 3
1 2
This results in a pointer move because the offset of each group item to be moved is zero. Pointer integrity is maintained. This results in a non-pointer move, because the offsets do not match. The offset of group item C is 10, and the offset of group item C2 is 6. Pointer integrity is not maintained. This results in a pointer move, because the offset of group item C2 is 6, and the offset of C3 relative to a 16-byte boundary is also 6. (When the offset is greater than 16, the offset relative to a 16-byte boundary is calculated by dividing the offset by 16. The remainder is the relative offset. In this case, the offset was 22, which, when divided by 16, leaves a remainder, or relative offset, of 6.) Pointer integrity is maintained. If a group item contains a pointer, and the compiler cannot determine the offset relative to a 16-byte boundary, the compiler issues a warning message, and the pointer move is attempted. However, pointer integrity may not be maintained. The compiler cannot determine the offset if the item is defined in the Linkage Section, or if the item is referencemodified with an unknown starting position. You must ensure that pointer alignment is maintained, or MCH0602 may result.
288
The COBOL/400 compiler places all 01-level items on a 16-byte boundary whether or not they contain pointer data items. If one of the items in a MOVE statement is an 01-level item with a pointer, and the other a 77-level Working-Storage item, the 77-level Working-Storage item is forced to a 16-byte boundary.
289
WORKING-STORAGE SECTION. 1 E. 5 5 K
77
LINKAGE SECTION. 1 3 B PIC X(3). C. 1 FILLER PIC X(13). 1 D POINTER. C2. 4 5 FILLER PIC X(13). 5 D2 POINTER. A. 5 5
PROCEDURE DIVISION USING A C2. CALL "C" USING BY CONTENT A, C2, 5 E(5: ), 6 E(K: ), 7 8
F.
In the previous example, Program A passes two group items to Program B. 1 is an 01-level group item, with an offset of zero. 2 is an 05-level group item, and has an offset of 3. Because the items are passed by reference, pointer integrity is maintained for both group items A and C. Program B passes five items to another program, C. The items are passed by content to Program C. Because they are passed by content, Program C receives a copy of the items, and pointer integrity is not maintained in all cases. 3 Because this item is defined in the Linkage Section, it has an unknown offset. The compiler assumes it is 16-byte aligned, and in this case, when A is passed, pointer integrity of D is maintained, but a compiler warning message is issued on the CALL. 4 This item contains a pointer, and a pointer move is accomplished by 5 . However, because the item is defined in the Linkage Section and the offset is unknown, pointer integrity is not maintained. The compiler attempts to move C2 to a 16-byte aligned area, and a compiler warning message is issued. 6 Because E contains a pointer, a pointer move is accomplished. The offset can be calculated because the reference modification start position is a numeric literal. In this case, pointer integrity is maintained, and the item is placed at an offset of 4 from the 16-byte boundary. 7 Because E contains a pointer, a pointer move is attempted. Because E is reference-modified with an unknown starting position (K), the compiler cannot calculate the offset, and assumes it is aligned on a 16-byte boundary. A compiler warning message is issued. If the value of K causes E to be aligned on a 16-byte boundary, pointer integrity is maintained. For this to occur, K must be 1 or 17. 8 F is an item defined in the Working-Storage Section, and contains no pointers, so no pointer moves are expected.
290
A A A A A A A A A A A
- POINTACUST
8S
TEXT('CUSTOMER MASTER RECORD') TEXT('CUSTOMER NUMBER') ALIAS(FS_CUST_NUMBER) TEXT('CUSTOMER NAME') ALIAS(FS_CUST_NAME) TEXT('CUSTOMER ADDRESS') ALIAS(FS_CUST_ADDRESS) VARLEN
291
5763CB1 V3R M5 1 IBM SAA COBOL/4 TESTER/POINTA AS4 SYS 5/ 1/94 18: 1:14 Program . . . . . . . . . . . . . . : POINTA Library . . . . . . . . . . . . . : TESTER Source file . . . . . . . . . . . . : QLBLSRC Library . . . . . . . . . . . . . : TESTER Source member . . . . . . . . . . . : POINTA 5/ 1/94 17:55:27 Generation severity level . . . . . : 29 Text 'description' . . . . . . . . . : BLANK Source listing options . . . . . . . : NONE Generation options . . . . . . . . . : NONE Conversion options . . . . . . . . . : NONE Message limit: Number of messages . . . . . . . . : NOMAX Message limit severity . . . . . . : 29 Print file . . . . . . . . . . . . . : QSYSPRT Library . . . . . . . . . . . . . : LIBL FIPS flagging . . . . . . . . . . . : NOFIPS NOSEG NODEB NOOBSOLETE SAA flagging . . . . . . . . . . . . : NOFLAG Extended display options . . . . . . : Flagging severity . . . . . . . . . : Replace program . . . . . . . . . . : YES Target release . . . . . . . . . . . : CURRENT User profile . . . . . . . . . . . . : USER Authority . . . . . . . . . . . . . : LIBCRTAUT Compiler . . . . . . . . . . . . . . : IBM SAA COBOL/4 Customer Information Display 1 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/POINTA AS4 SYS 5/ 1/94 18: 1:14 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 1 PROCESS extaccdsp varchar 2 2 2 ID DIVISION. CBT 1 4 5 6 7 8 9 1 11 12 13 14 15 16 17 18 19 2 21 22 23 1 2 3 4 5 6 7 8 9 1 11 12 13 14 15 24 25 26 27 28 29 3 31 32 33 This program reads in a file of variable length records into a user space. It then shows the records on the display. PROGRAM-ID. pointa. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. CONSOLE IS CRT, CRT STATUS IS ws-crt-status. 3 INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT cust-file ASSIGN TO DATABASE-pointacu ORGANIZATION IS SEQUENTIAL FILE STATUS IS ws-file-status. DATA DIVISION. FILE SECTION. FD cust-file. 1 fs-cust-record. copy in field names turning underscores to dashes and using alias names COPY DDR-ALL-FORMATS-I OF pointacu. 5 POINTACU-RECORD PIC X(13 ). I-O FORMAT:FSCUST FROM FILE POINTACU OF LIBRARY TESTER CUSTOMER MASTER RECORD 5 FSCUST REDEFINES POINTACU-RECORD. 6 FS-CUST-NUMBER PIC S9(8). CUSTOMER NUMBER 6 FS-CUST-NAME PIC X(2 ). CUSTOMER NAME 6 FS-CUST-ADDRESS. 4 (Variable length field) 49 FS-CUST-ADDRESS-LENGTH PIC S9(4) COMP-4. 49 FS-CUST-ADDRESS-DATA PIC X(1 ). CUSTOMER ADDRESS WORKING-STORAGE SECTION. 1 ws-file-status. 5 ws-file-status-1 PIC X. 88 ws-file-stat-good VALUE " ". 88 ws-file-stat-at-end VALUE "1". 5 ws-file-status-2 PIC X. 1 ws-crt-status. 5 5 ws-status-1 PIC 9(2). 88 ws-status-1-ok VALUE . 88 ws-status-1-func-key VALUE 1.
Page
Page
3 4 5 6 7 8 9 1 11 12 13 14 15 16
17 18 + + + 19 + 2 + + 21 + + 22 + + 23 + 24 + 25 + 26 + + 27 28 29 3 31 32 33 34 35 36
<-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS <-ALL-FMTS
Figure 100 (Part 1 of 7). Example Using Pointers to Access User Spaces
292
Customer Information Display 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/POINTA AS4 SYS 5/ 1/94 18: 1:14 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 37 34 88 ws-status-1-error VALUE 9. 38 35 5 ws-status-2 PIC 9(2). 39 36 88 ws-func- 3 VALUE 3. 4 37 88 ws-func- 7 VALUE 7. 41 38 88 ws-func- 8 VALUE 8. 42 39 5 ws-status-3 PIC 9(2). 43 4 1 ws-params. 6 44 41 5 ws-space. 45 42 1 ws-space-name PIC X(1 ) VALUE "MYSPACE". 46 43 1 ws-space-lib PIC X(1 ) VALUE "QTEMP". 47 44 5 ws-attr PIC X(1 ) VALUE "PF". 48 45 5 ws-init-size PIC S9(5) VALUE 32 BINARY. 49 46 5 ws-init-char PIC X VALUE SPACE. 5 47 5 ws-auth PIC X(1 ) VALUE " ALL". 51 48 5 ws-text PIC X(5 ) VALUE 52 49 "Customer Information Records". 53 5 5 ws-replace PIC X(1 ) VALUE " YES". 54 51 5 ws-err-data. 7 55 52 1 ws-input-l PIC S9(6) BINARY VALUE ZERO. 56 53 1 ws-output-l PIC S9(6) BINARY VALUE ZERO. 57 54 1 ws-exception-id PIC X(7). 58 55 1 ws-reserved PIC X(1). 59 56 1 ws-exception-data PIC X(87). 6 57 5 ws-space-ptr POINTER. 8 61 58 5 ws-map-ptr POINTER. 59 62 6 77 ws-accept-data PIC X. 63 61 88 ws-acc-create-space VALUE "Y", "y". 64 62 88 ws-acc-delete-space VALUE "Y", "y". 65 63 88 ws-acc-no-space VALUE "N", "n". 64 66 65 77 ws-prog-indicator PIC X VALUE "G". 67 66 88 ws-prog-continue VALUE "G". 68 67 88 ws-prog-end VALUE "C". 69 68 88 ws-prog-loop VALUE "L". 69 7 7 77 ws-line PIC S99. 71 error message line 71 72 77 ws-error-msg PIC X(5 ) VALUE SPACES. 73 more address information indicator 72 74 77 ws-plus PIC X. 75 length of address information to display 73 76 77 ws-temp-size PIC 9(2). 77 74 78 77 ws-current-rec PIC S9(4) VALUE 1. 75 79 77 ws-old-rec PIC S9(4) VALUE 1. 76 8 77 ws-old-space-ptr POINTER. 81 max number of lines to display 77 82 77 ws-displayed-lines PIC S99 VALUE 2 . 83 line on which to start displaying records 78 84 77 ws-start-line PIC S99 VALUE 5. 85 variables to create new record in space 79 86 77 ws-addr-inc PIC S9(4) PACKED-DECIMAL. 8 87 77 ws-temp PIC S9(4) PACKED-DECIMAL. 81 88 77 ws-temp-2 PIC S9(4) PACKED-DECIMAL. 89 pointer to previous record 82 9 77 ws-cust-prev-ptr POINTER VALUE NULL. 83 91 LINKAGE SECTION. 84 92 1 ls-header-record. 9 85 93 5 ls-hdr-cust-ptr USAGE POINTER. 94 number of records read in from file 86 95 5 ls-record-counter PIC S9(3) BINARY. 87 96 5 FILLER PIC X(14). 1 88 97 1 ls-user-space. 11 89 98 5 ls-customer-rec. 99 pointer to previous customer record 9 1 1 ls-cust-prev-ptr USAGE POINTER. 91 1 1 1 ls-cust-rec-length PIC S9(4) BINARY. 92 1 2 1 ls-cust-name PIC X(2 ). 93 1 3 1 ls-cust-number PIC S9(8).
Page
Figure 100 (Part 2 of 7). Example Using Pointers to Access User Spaces
293
Customer Information Display 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/POINTA AS4 SYS 5/ 1/94 18: 1:14 STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 1 4 total length of this record including filler bytes 1 5 to make sure next record on 16 byte boundary 94 1 6 1 ls-cust-address-length PIC S9(4) BINARY. 95 1 7 5 ls-cust-address-data PIC X(116). 1 8 1 9 Size of ls-user-space is 16 more than actually needed. This 11 allows the start address of the next record 111 record to be established without exceeding the declared size 112 The size is 16 bigger to allow for pointer alignment 113 96 114 PROCEDURE DIVISION. 115 note no need for "USING" entry on PROC... DIV. 116 DECLARATIVES. 117 cust-file-para SECTION. 118 USE AFTER ERROR PROCEDURE ON cust-file. 119 cust-file-para-2. 97 12 MOVE "Error XX on file pointacu" TO ws-error-msg. 98 121 MOVE ws-file-status TO ws-error-msg(7:2). 122 END DECLARATIVES. 123 main-section section. 124 main-proc. 125 keep reading initial display until entered data correct 99 126 SET ws-prog-loop to TRUE. 1 127 PERFORM initial-display THRU read-initial-display 128 UNTIL NOT ws-prog-loop. 129 if want to continue with program and want to create 13 customer information area, fill the space with 131 records from the customer file 1 1 132 IF ws-prog-continue and 133 ws-acc-create-space THEN 1 2 134 PERFORM read-customer-file 1 3 135 MOVE 1 TO ws-current-rec 136 set ptr to header record 1 4 137 SET ADDRESS OF ls-header-record TO ws-space-ptr 138 set to first customer record in space 1 5 139 SET ADDRESS OF ls-user-space TO ls-hdr-cust-ptr 14 END-IF. 1 6 141 IF ws-prog-continue THEN 1 7 142 PERFORM main-loop UNTIL ws-prog-end 143 END-IF. 144 end-program. 1 8 145 PERFORM clean-up. 1 9 146 STOP RUN. 147 initial-display. 12 11 148 DISPLAY "Create Customer Information Area" AT 118 WITH 149 BLANK SCREEN REVERSE-VIDEO 15 "Create customer information area (Y/N)=> <=" 151 AT 1 15 152 "F3=Exit" AT 22 2. 111 153 IF ws-error-msg NOT = SPACES THEN 112 154 DISPLAY ws-error-msg at 23 2 with beep highlight 113 155 MOVE SPACES TO ws-error-msg 156 END-IF. 157 read-initial-display. 13 114 158 ACCEPT ws-accept-data AT 1 56 WITH REVERSE-VIDEO 159 ON EXCEPTION 115 16 IF ws-status-1-func-key THEN 116 161 IF ws-func- 3 THEN 117 162 SET ws-prog-end TO TRUE 163 ELSE 118 164 MOVE "Invalid Function Key" TO ws-error-msg 165 END-IF 166 ELSE 119 167 MOVE "Unknown Error" TO ws-error-msg 168 END-IF 169 NOT ON EXCEPTION
Page
Figure 100 (Part 3 of 7). Example Using Pointers to Access User Spaces
294
Customer Information Display 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/POINTA 12 17 IF ws-acc-create-space THEN 121 171 PERFORM create-space THRU get-space 122 172 SET ws-prog-continue TO TRUE 173 ELSE 123 174 IF NOT ws-acc-no-space THEN 124 175 MOVE "Invalid Character Entered" TO ws-error-msg 176 ELSE 125 177 SET ws-prog-continue TO TRUE 126 178 PERFORM get-space 179 END-IF 18 END-IF 181 END-ACCEPT. 182 create-space. 127 183 CALL "QUSCRTUS" 14 184 USING ws-space, ws-attr, ws-init-size, 185 ws-init-char, ws-auth, ws-text, 186 ws-replace, ws-err-data. 187 check for errors in creating space 188 get-space. 128 189 CALL "QUSPTRUS" USING ws-space, ws-space-ptr. 15 19 set header record to beginning of space 129 191 SET ADDRESS OF ls-header-record 16 192 ADDRESS OF ls-user-space 17 193 TO ws-space-ptr. 194 set first customer record after header record 13 195 SET ADDRESS OF ls-user-space TO 18 196 ADDRESS OF ls-user-space(LENGTH OF ls-header-record 19 197 + 1:1). 198 save ptr to first record in header record 131 199 SET ls-hdr-cust-ptr TO ADDRESS OF ls-user-space. 2 delete-space. 132 2 1 CALL "QUSDLTUS" USING ws-space, ws-err-data. 2 2 2 read-customer-file. 2 3 read all records from customer file and move into space 133 2 4 OPEN INPUT cust-file. 134 2 5 IF ws-file-stat-good THEN 135 2 6 READ cust-file AT END CONTINUE 136 2 7 END-READ 137 2 8 PERFORM VARYING ls-record-counter FROM 1 BY 1 2 9 UNTIL not ws-file-stat-good 138 21 SET ls-cust-prev-ptr TO ws-cust-prev-ptr 211 Move information from file into space 139 212 MOVE fs-cust-name TO ls-cust-name 14 213 MOVE fs-cust-number TO ls-cust-number 141 214 MOVE fs-cust-address-length TO ls-cust-address-length 142 215 MOVE fs-cust-address-data(1:fs-cust-address-length) 216 TO ls-cust-address-data(1:ls-cust-address-length) 217 Save ptr to current record 143 218 SET ws-cust-prev-ptr TO ADDRESS OF ls-user-space 219 Make sure next record on 16 byte boundary 144 22 ADD LENGTH OF ls-customer-rec 21 221 ls-cust-address-length TO 1 GIVING ws-addr-inc 145 222 DIVIDE ws-addr-inc BY 16 GIVING ws-temp 223 REMAINDER ws-temp-2 146 224 SUBTRACT ws-temp-2 FROM 16 GIVING ws-temp 225 Save total record length in user space 147 226 ADD ws-addr-inc TO ws-temp GIVING ls-cust-rec-length 148 227 SET ADDRESS OF ls-user-space 228 TO ADDRESS OF ls-user-space(ls-cust-rec-length + 1:1) 229 Get next record from file 149 23 READ cust-file AT END CONTINUE 15 231 END-READ 232 END-PERFORM 233 At the end of the loop have one more record than really 234 have 151 235 SUBTRACT 1 FROM ls-record-counter 236 END-IF. 152 237 CLOSE cust-file. 238 239 main-loop. 22 24 write the records to the display until F3 entered
AS4
SYS
Page
Figure 100 (Part 4 of 7). Example Using Pointers to Access User Spaces
295
Customer Information Display 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/POINTA 153 241 DISPLAY "Customer Information" AT 124 WITH 242 BLANK SCREEN REVERSE-VIDEO 243 "Cust Customer Name Customer" 244 AT 3 5 245 " Address" 246 "Number" AT 4 5 247 "F3=Exit" AT 22 2. 248 if a pending error put on the display 154 249 IF ws-error-msg NOT = SPACES THEN 155 25 DISPLAY ws-error-msg at 23 2 with beep highlight 156 251 MOVE SPACES TO ws-error-msg 252 END-IF. 253 if in the middle of the list put F7 on the display 157 254 IF ws-current-rec > 1 THEN 23 158 255 DISPLAY "F7=Back" AT 224 256 END-IF. 257 save the current record 159 258 MOVE ws-current-rec TO ws-old-rec. 16 259 SET ws-old-space-ptr TO ADDRESS OF ls-user-space. 24 26 move each record to the display 161 261 PERFORM VARYING ws-line FROM ws-start-line BY 1 262 UNTIL ws-line > ws-displayed-lines or 263 ws-current-rec > ls-record-counter 264 if address is greater than display width show "+" 162 265 IF ls-cust-address-length > 4 THEN 163 266 MOVE "+" TO ws-plus 164 267 MOVE 4 TO ws-temp-size 268 ELSE 165 269 MOVE ls-cust-address-length TO ws-temp-size 166 27 MOVE SPACE TO ws-plus 271 END-IF 167 272 DISPLAY ls-cust-number at line ws-line column 5 273 ls-cust-name ls-cust-address-data with 274 size ws-temp-size ws-plus at line 275 ws-line column 78 276 get next record in the space 168 277 ADD 1 TO ws-current-rec 169 278 SET ADDRESS OF ls-user-space 279 TO ADDRESS OF ls-user-space 28 (ls-cust-rec-length + 1:1) 281 END-PERFORM. 282 if can go forward put F8 on the display 17 283 IF ws-current-rec < ls-record-counter THEN 23 171 284 DISPLAY "F8=Forward" AT 225 285 END-IF. 286 check to see if continue, exit, or get next records or 287 previous records 172 288 ACCEPT ws-accept-data WITH SECURE 25 289 ON EXCEPTION 173 29 IF ws-status-1-func-key THEN 174 291 IF ws-func- 3 THEN 175 292 SET ws-prog-end TO TRUE 293 ELSE 176 294 IF ws-func- 7 THEN 177 295 PERFORM back-screen 296 ELSE 178 297 IF ws-func- 8 THEN 179 298 PERFORM forward-screen 299 ELSE 18 3 MOVE "Invalid Function Key" TO ws-error-msg 181 3 1 MOVE ws-old-rec TO ws-current-rec 182 3 2 SET ADDRESS OF ls-user-space TO ws-old-space-ptr 3 3 END-IF 3 4 END-IF 3 5 ELSE 183 3 6 MOVE "Unknown Error" TO ws-error-msg 184 3 7 MOVE ws-old-rec TO ws-current-rec 185 3 8 SET ADDRESS OF ls-user-space TO ws-old-space-ptr 3 9 END-IF 31 NOT ON EXCEPTION 186 311 MOVE ws-old-rec TO ws-current-rec 187 312 SET ADDRESS OF ls-user-space TO ws-old-space-ptr 313 END-ACCEPT. 314 clean-up. 315 do clean up for program
AS4
SYS
Page
Figure 100 (Part 5 of 7). Example Using Pointers to Access User Spaces
296
Customer Information Display 5763CB1 V3R M5 1 AS/4 COBOL Source TESTER/POINTA 316 keep reading end display until entered data correct 188 317 SET ws-prog-loop to TRUE. 189 318 PERFORM end-display THRU read-end-display 26 319 UNTIL NOT ws-prog-loop. 32 end-display. 19 321 DISPLAY "Delete Customer Information Area" AT 118 WITH 27 322 BLANK SCREEN REVERSE-VIDEO 323 "Delete customer information area (Y/N)=> <=" 324 AT 1 15 325 "F3=Exit" AT 22 2. 191 326 IF ws-error-msg NOT = SPACES THEN 192 327 DISPLAY ws-error-msg at 23 2 with beep highlight 193 328 MOVE SPACES TO ws-error-msg 329 END-IF. 33 read-end-display. 194 331 ACCEPT ws-accept-data AT 1 56 WITH REVERSE-VIDEO 332 ON EXCEPTION 195 333 IF ws-status-1-func-key THEN 196 334 IF ws-func- 3 THEN 197 335 SET ws-prog-end TO TRUE 336 ELSE 198 337 MOVE "Invalid Function Key" TO ws-error-msg 338 END-IF 339 ELSE 199 34 MOVE "Unknown Error" TO ws-error-msg 341 END-IF 342 NOT ON EXCEPTION 2 343 IF ws-acc-delete-space THEN 2 1 344 PERFORM delete-space 2 2 345 SET ws-prog-continue TO TRUE 346 ELSE 2 3 347 IF NOT ws-acc-no-space THEN 2 4 348 MOVE "Invalid Character Entered" TO ws-error-msg 349 ELSE 2 5 35 SET ws-prog-continue TO TRUE 351 END-IF 352 END-IF 353 END-ACCEPT. 354 back-screen. 28 2 6 355 IF ws-old-rec <= 1 THEN 2 7 356 MOVE "Top of customer records" TO ws-error-msg 2 8 357 MOVE ws-old-rec TO ws-current-rec 29 2 9 358 SET ADDRESS OF ls-user-space TO ws-old-space-ptr 359 ELSE 21 36 MOVE ws-old-rec TO ws-current-rec 29 211 361 SET ADDRESS OF ls-user-space TO ws-old-space-ptr 212 362 PERFORM VARYING ws-line FROM ws-start-line BY 1 363 UNTIL ws-line > ws-displayed-lines or 364 ws-current-rec <= 1 365 Back up one record at a time 213 366 SET ws-cust-prev-ptr TO ls-cust-prev-ptr 214 367 SET ADDRESS OF ls-user-space TO ws-cust-prev-ptr 3 215 368 SUBTRACT 1 FROM ws-current-rec 369 END-PERFORM 37 END-IF. 371 forward-screen. 31 372 if current record greater or equal to the max records 373 print error, have reached max records 216 374 IF ws-current-rec >= ls-record-counter 217 375 MOVE "No more customer records" TO ws-error-msg 218 376 MOVE ws-old-rec TO ws-current-rec 219 377 SET ADDRESS OF ls-user-space TO ws-old-space-ptr 378 ELSE 22 379 MOVE ws-current-rec TO ws-old-rec 221 38 SET ws-old-space-ptr TO ADDRESS OF ls-user-space 381 END-IF. E N D O F S O U R C E Customer Information Display 5763CB1 V3R M5 1 AS/4 COBOL Messages TESTER/POINTA STMT 15 MSGID: LBL 65 SEVERITY: SEQNBR: 19 Message . . . . : Blocking/Deblocking for file 'CUST-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S
AS4
SYS
Page
AS4
SYS
Page
Figure 100 (Part 6 of 7). Example Using Pointers to Access User Spaces
297
Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) 1 1 Source records read . . . . . . . . : 381 Copy records read . . . . . . . . . : 15 Copy members processed . . . . . . : 1 Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program POINTA created in library TESTER. E N D O F C O M P I L A T I O N
Terminal(4 -99)
Figure 100 (Part 7 of 7). Example Using Pointers to Access User Spaces
1 3
The compiler directive TITLE is used to create this title that appears at the beginning of each page. CRT STATUS IS specifies a data name into which a status value is placed after the termination of an extended ACCEPT statement. In this example, the STATUS key value is used to determine which function key was pressed.
fs-cust-address is a variable-length field. To see meaningful names here rather than FILLER, specify *VARCHAR for the CVTOPT parameter of the CRTCBLPGM command, or VARCHAR in the PROCESS statement, as shown in 2 . For more information about variable-length fields, refer to Declaring Data Items Using CVTOPT Data Types on page 130.
CRT STATUS as mentioned in 3 is defined here. The ws-params structure contains the parameters used when calling the APIs to access user spaces.
5 6 7
ws-err-data is the structure for the error parameter for the user space APIs. Note that the ws-input-l is zero, meaning that any exceptions are signalled to the program, and not passed in the error code parameter. For more information on error code parameters, refer to the System Programmers Interface Reference. ws-space-ptr defines a pointer data item set by the API QUSPTRUS. This points to the beginning of the user space, and is used to set the addresses of items in the Linkage Section.
The first data structure (ls-header-record) to be defined in the user space. FILLER is used to maintain pointer alignment, because it makes Isheader-record a multiple of 16 bytes long. The second data structure (ls-user-space) to be defined in the user space.
9 1 11 12 13
initial-display shows the Create Customer Information Area display. This display is shown in Figure 101 on page 300. read-initial-display reads the first display, and determines if the user chooses to continue or end the program. If the user continues the program by pressing Enter, then the program checks ws-accept-data to see if the customer information area is to be created.
QUSCRTUS is an API used to create user spaces.
14
298
15 16 17 18 19 2 21
QUSPTRUS is an API used to return a pointer to the beginning of a user space. Maps the first data structure (ls-header-record) over the beginning of the user space. Maps the second data structure (ls-user-space) over the beginning of the user space. Uses ADDRESS OF special register Uses ADDRESS OF, not the ADDRESS OF special register, because it is reference modified. QUSDLTUS is an API used to delete a user space. The following four arithmetic statements calculate the total length of each record, and ensure that each record is a multiple of 16 bytes in length.
22 23 24 25
main-loop puts up the Customer Information display. Refer to Figure 102 on page 300.
These statements determine if the program should display function keys F7 and F8. Saves a pointer to the first customer record on the display. This ACCEPT statement waits for input from the Customer Information display. Based on the function key pressed, it calls the appropriate paragraph to display the next set of records (forward-screen), or the previous set of records (back-screen), or sets an indicator to end the routine if F3 is pressed. The clean up routine displays the Delete Customer Information Area display until an appropriate key is pressed. This statement puts up the Delete Customer Information Area display. Each record contains a pointer to the previous customer record. The ADDRESS OF special register points to the current customer record. By changing the ADDRESS OF special register, the current customer record is changed.
26 27 28
back-screen moves the current record pointer backward one record at a time 3 , by moving the pointer to the previous customer record into the pointer to the current customer record (ADDRESS OF). Before moving backward one record at a time, the program sets the current customer record to the first record currently displayed 29 .
31
forward-screen sets ws-old-space-ptr (which points to the first record in the display) to point to the current record (which is after the last record displayed.)
A user space always begins on a 16-byte boundary, so the method illustrated here ensures that all records are aligned. ls-cust-rec-length is also used to chain the records together.
299
F3=Exit
If you specify Y to create the user space, the program reads the customer records from the file and puts the information in the user space. The records are chained together. When you press enter from the previous display, the Customer Information display appears:
Customer Information Cust Number 1 2 3 4 5 6 7 8 9 1 11 12 13 14 15 16 F3=Exit Customer Name Bakery Unlimited Window World Jons Clothes Pizza World Marv's Auto Body Jack's Snacks Video World Pat's Daycare Mary's Pies Carol's Fashions Grey Optical Fred's Forage Dave's Trucking Doug's Music Anytime Copiers Rosa's Ribs Customer Address
3 Bake Way, North York 15 Eglinton Ave E., North York, Ontario 1 1 Park St, North Bay, Ontario, Canada 254 Main Street, Toronto, Ontario 9 George St, Peterborough, Ontario, Cana 23 North St, Timmins, Ontario, Canada 14 Robson St, Vancouver, B.C, Canada 8 Kingston Rd, Pickering, Ontario, Canad 3 Front St, Toronto, Ontario, Canada 19 Spark St, Ottawa, Ontario, Canada 5 Lundy's Lane, Niagara Falls, Ont. Cana 33 Dufferin St, Toronto, Ontario, Canada 15 Water St, Guelph, Ontario, Canada 1 1 Queen St. Toronto, Ontario, Canada 3 Warden Ave, Scarborough, Ontario, Ca 44 Avenue Rd, Toronto, Ontario, Canada F8=Forward
+ + + + + + +
If there are more than 16 records in the user space (based on the starting line in ws-start-line), the program enables the F8=Forward key, to allow the user to page
300
forward in the list. Once the user has rolled forward, the F7=Backward key is enabled to allow the user to page backward in the list, as shown in the following display:
Customer Information Cust Number 17 18 19 2 21 22 Customer Name Picture It Paula's Flowers Mom's Diapers Chez Francois Vetements de Louise Good Eats Customer Address
33 Kingston Rd, Ajax, Ontario, Canada 144 Pape Ave, Toronto, Ontario, Canada 1 1 Ford St, Toronto, Ontario, Canada 12 2 Rue Ste Anne, Montreal, PQ, Canada 892 Rue Sherbrooke, Montreal E, PQ, Cana 355 Lake St, Port Hope, Ontario, Canada
F3=Exit
F7=Back
When the user exits from the above display, the option to delete the user space is presented, as shown in the following display:
F3=Exit
301
The first item in each record (except for the last record) points to the next record. The first item in the last record, in order to indicate that it is the last record, contains a null value instead of an address. The high-level logic of an application that processes these records might look something like this: OBTAIN ADDRESS OF FIRST RECORD IN CHAINED LIST FROM ROUTINE CHECK FOR END OF THE CHAINED LIST DO UNTIL END OF THE CHAINED LIST PROCESS RECORD GO ON TO THE NEXT RECORD END Figure 106 on page 303 contains an outline of the processing program, LISTS, used in this example of processing a chained list.
302
IDENTIFICATION DIVISION. PROGRAM-ID. LISTS. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 PTR-FIRST POINTER VALUE IS NULL. 77 DEPT-TOTAL PIC 9(4) VALUE IS . LINKAGE SECTION. 1 SALARY-REC. 2 PTR-NEXT-REC 2 NAME 2 DEPT 2 SALARY 1 DEPT-X
PROCEDURE DIVISION USING DEPT-X. FOR EVERYONE IN THE DEPARTMENT RECEIVED AS DEPT-X, GO THROUGH ALL OF THE RECORDS IN THE CHAINED LIST BASED ON THE ADDRESS OBTAINED FROM THE PROGRAM CHAIN-ANCH AND ACCUMULATE THE SALARIES. IN EACH RECORD, PTR-NEXT-REC IS A POINTER TO THE NEXT RECORD IN THE LIST; IN THE LAST RECORD, PTR-NEXT-REC IS NULL. DISPLAY THE TOTAL. CALL "CHAIN-ANCH" USING PTR-FIRST SET ADDRESS OF SALARY-REC TO PTR-FIRST PERFORM WITH TEST BEFORE UNTIL ADDRESS OF SALARY-REC = NULL IF DEPT = DEPT-X THEN ADD SALARY TO DEPT-TOTAL ELSE CONTINUE END-IF SET ADDRESS OF SALARY-REC TO PTR-NEXT-REC END-PERFORM DISPLAY DEPT-TOTAL GOBACK.
Upon return from the call to CHAIN-ANCH, PTR-FIRST contains the address of the first record in the chained list. PTR-FIRST is initially defined as having a null value as a logic check. If an error occurs with the call, and PTR-FIRST never receives the value of the address of the first record in the chain, a null value remains in PTR-FIRST and, according to the logic of the program, the records will not be processed.
303
NULL is a figurative constant used to assign the value of a non-valid address to pointer items. It can be used in the VALUE IS NULL clause, in the SET statement, and as an operand in a relation condition with a pointer data item. The Linkage Section of the calling program contains the description of the records in the chained list. It also contains the description of the department code that is passed through the USING phrase of the CALL statement. LINKAGE SECTION. 1 SALARY-REC. 2 PTR-NEXT-REC 2 NAME 2 DEPT 2 SALARY 1 DEPT-X
To base the record description SALARY-REC on the address contained in PTR-FIRST, use a SET statement: CALL "CHAIN-ANCH" USING PTR-FIRST SET ADDRESS OF SALARY-REC TO PTR-FIRST
(logic for end of chain) If you have not reached the end of the list, process the record and move on to the next record. In the program LISTS, this test for the end of the chained list is accomplished with a do while structure: PERFORM WITH TEST BEFORE UNTIL ADDRESS OF SALARY-REC = NULL IF DEPT = DEPT-X THEN ADD SALARY TO DEPT-TOTAL ELSE CONTINUE END-IF SET ADDRESS OF SALARY-REC TO PTR-NEXT-REC END-PERFORM
304
. . .
Within the Procedure Division, base the address of SALARY-REC on the address of REAL-SALARY-REC: SET ADDRESS OF SALARY-REC TO ADDRESS OF REAL-SALARY-REC SALARY-REC is now based on the address of RECORD-A + 16.
Data Areas
A data area is an object used to communicate data such as variable values between programs within a job and between jobs. A data area can be created and declared to a program before it is used in that program or job. For information on how to create and declare a data area, see the CL Programmers Guide.
305
When a job is submitted, the submitting jobs local data area is copied into the submitted jobs local data area. If there is no submitting job, the local data area is initialized to blanks. A COBOL program can access the local data area for its job with the ACCEPT and DISPLAY statements, using a mnemonic name associated with the function-name LOCAL-DATA. There is only one local data area associated with each job. Even if several work stations are acquired by a single job, only one local data area exists for that job. There is not a local data area for each work station.
File Considerations
You can pass a file name as a parameter in a COBOL program, but you cannot use that file in the called program. If a file is defined in both a calling program and a called program, it is treated as two separate files. The contents of the record area and the current record pointer in each program are independent, unless shared files are specified in CL commands. See the Data Management Guide for further information on shared files. The following statements affect file status differently: An EXIT PROGRAM statement does not change the status of any of the files in a run unit. A STOP RUN statement closes all of the files in a run unit.
306
IBM Extension A GOBACK statement issued from a main program closes all of the files in a run unit. A GOBACK statement issued from a subprogram does not change the status of any of the files in a run unit. End of IBM Extension A CANCEL statement does not change the status of any of the files in the program that is canceled. It does free the storage that contains information about the file. If the program has files that are open when the CANCEL statement is processed, those files are closed when that program is cancelled. The program can no longer use the file. If the canceled program is called again, the program considers the file closed. If the program opens the file, a new linkage to the file is established. This can cause additional system storage to be used.
307
308
Segmentation Concepts
Although it is not required, the Procedure Division of a source program is often written as a consecutive group of sections, each of which is made up of a series of related operations that perform a particular function. Thus, the entire Procedure Division is made up of a number of logical subdivisions. Segmentation allows the programmer to physically divide the Procedure Division into segments, each of which has specific physical and logical attributes. When Segmentation is used, the entire Procedure Division must be divided into sections. Each section must then be classified as to its physical and logical attributes. Classification is specified by means of segment numbers. All sections given the same segment number make up one program segment. Segment numbers must be integers from 0 through 99.
Program Segments
There are three types of program segments; fixed permanent, fixed overlayable, and independent.
Fixed Segments
Fixed-permanent segments and fixed-overlayable segments make up the fixed portion, the part of the Procedure Division that is logically treated as if it were always physically present in main storage. Fixed-portion segment numbers must be integers from 0 through 49. A fixed-permanent segment is always made available in its last-used state. A fixed-overlayable segment is logically always in main storage during program processing; therefore, it is always available in its last-used state. Any overlay of such a segment is transparent to the user. Thus, a fixed-overlayable segment is logically identical with a fixed-permanent segment.
Independent Segments
Logically, an independent segment can overlay and be overlaid by other segments during a programs run. An independent segment is made available in its initial state the first time control is passed to it (explicitly or implicitly) during a programs run.
309
An independent segment is made available in its initial state during subsequent transfers of control when: The transfer is the result of an implicit transfer of control between consecutive statements that are in different segments (that is, when control drops through into the independent segment from the physically preceding segment). The transfer is the result of an implicit transfer from a SORT or MERGE statement in one segment to a SORT input procedure or SORT/MERGE output procedure in an independent segment. An explicit transfer of control from a section with a different segment number takes place (as, for example, during the transfer of control in a PERFORM n TIMES statement). An independent segment is made available in its last-used state during subsequent transfers of control when: With the exception of the two preceding kinds of implied transfers, an implicit transfer from a section with a different priority takes place (as, for example, when control is returned to the independent segment from a Declarative procedure). An explicit transfer results from an EXIT PROGRAM or GOBACK statement. Independent segments must be assigned segment numbers 50 through 99.
Segmentation Logic
In a segmented program, the sections are classified by a system of segment numbers according to the following criteria:
Frequency of ReferenceMuch-referenced sections, or those that must be available for reference at all times, should be placed within fixed permanent segments. Less frequently used sections can be within either fixed overlayable or independent segments, depending on the program logic. Frequency of UseThe more frequently a section is used, the lower its segment number; the less frequently it is referred to, the higher its segment number. Logical RelationshipsSections that frequently communicate with each other should be given identical segment numbers.
Segmentation Control
Except for specific transfers of control, the logical sequence and the physical sequence of program instructions are the same. The compiler inserts any instructions necessary to initialize a segment. It is not necessary to transfer control to the beginning of a segment, or to the beginning of a section within a segment. Instead, control can be transferred to any paragraph in the Procedure Division.
310
Procedure Division segment numbers, which group sections into segments. The segment numbering scheme also allows specifications of independent segments, fixed-permanent segments, and (in conjunction with the SEGMENT-LIMIT clause) of fixed-overlayable segments.
SegmentationEnvironment Division
In the OBJECT-COMPUTER paragraph, the SEGMENT-LIMIT clause allows the user to reclassify fixed permanent segments while retaining the properties of fixed portion segments for the reclassified segments. Format SEGMENT-LIMITsegment-number . IS
The SEGMENT-LIMIT clause allows the programmer to specify certain permanent segments as capable of being overlaid by independent segments without losing the logical properties of fixed portion segments. segment-number must be an integer ranging in value from 1 through 49. When the SEGMENT-LIMIT clause is specified: Fixed-permanent segments are those with segment numbers from 0 up to, but not including, the segment number specified. Fixed-overlayable segments are those with segment numbers from the segment number specified through 49. For example, if SEGMENT-LIMIT IS 25 is specified, sections with segment numbers 0 through 24 are fixed-permanent segments, and sections with segment numbers 25 through 49 are fixed-overlayable segments. When the SEGMENT-LIMIT clause is omitted, all sections with segment numbers 0 through 49 are fixed-permanent segments.
SegmentationProcedure Division
In the Procedure Division of a segmented program, section classification is specified through segment numbers in the section headers. The segment number must be an integer from 0 through 99. Format section-nameSECTION. segment-number
All sections with the same segment number make up one program segment. Such sections need not be contiguous in the source program.
Appendix A. Segmentation Feature
311
Segments with segment numbers 0 through 49 are in the fixed portion of the program. Declarative sections can be assigned only these segment numbers. Segments with segment numbers from 50 through 99 are independent segments. If the segment number is omitted from the section header, the segment number is assumed to be 0.
SegmentationSpecial Considerations
When segmentation is used, there are restrictions on the ALTER, PERFORM, SORT, and MERGE statements. There are also special considerations for calling and called programs.
ALTER Statement
A GO TO statement in an independent segment must not be referred to by an ALTER statement in a different segment. All other uses of the ALTER statement are valid and are performed, even if the GO TO statement referred to is in a fixedoverlayable segment.
PERFORM Statement
A PERFORM statement in the fixed portion can have in its range, in addition to any Declarative procedures, the processing of which is caused within that range, only one of the following: Sections and/or paragraphs in the fixed portion Sections and/or paragraphs contained within a single independent segment. A PERFORM statement in an independent segment can have within its range, in addition to any Declarative procedures, the processing of which is caused within that range, only one of the following: Sections and/or paragraphs in the fixed portion Sections and/or paragraphs wholly contained in the same independent segment as the PERFORM statement.
312
Compile-Time Switch
In the SOURCE-COMPUTER paragraph of the Configuration Section, the WITH DEBUGGING MODE clause acts as a compile-time switch. Format SOURCE-COMPUTER.. computer name DEBUGGING MODE WITH
The WITH DEBUGGING MODE clause serves as a compile-time switch for the debugging statements written in the source program. When WITH DEBUGGING MODE is specified, all debugging sections and debugging lines are compiled as specified in this appendix. When WITH DEBUGGING MODE is omitted, all debugging sections and debugging lines are treated as documentation.
313
Run-Time Switch
The run-time switch dynamically activates the debugging code that is generated when WITH DEBUGGING MODE is specified. Two commands are provided to control the run-time switch. To set the run-time switch on, enter the command: STRCBLDBG and press F4. You see the following display:
Start COBOL Debug (STRCBLDBG) Type choices, press Enter. Program . . . . . . . . . . . . Library . . . . . . . . . . . LIBL Name Name, LIBL, CURLIB
F5=Refresh
F12=Cancel
STRCBLDBG PGM(program-name) LIBL/ CURLIB/ library-name/ Job: B,I Pgm: B,I REXX: B,I Exec
This command is allowed in interactive and batch processing, and in CL programs. General-Use Programming Interface You can use this command in QCMDEXC. End of General-Use Programming Interface
314
To set the run-time switch off, enter the command: ENDCBLDBG and press F4. You see the following display:
End COBOL Debug (ENDCBLDBG) Type choices, press Enter. Program . . . . . . . . . . . . Library . . . . . . . . . . . LIBL Name Name, LIBL, CURLIB
F5=Refresh
F12=Cancel
ENDCBLDBG PGM(program-name) LIBL/ CURLIB/ library-name/ Job: B,I Pgm: B,I REXX: B,I Exec
This command is allowed in interactive and batch processing, and in CL programs. General-Use Programming Interface You can use this command in QCMDEXC. End of General-Use Programming Interface The default for the run-time switch is off. When debugging mode is specified through the run-time switch, all the debugging sections and debugging lines (D in column 7) compiled into the program are activated.
315
You must enter the STRCBLDBG command for each COBOL program (main program or called program) to be debugged in the next COBOL run unit. At the end of the run unit, all run-time switches that are on are set off. If a switch must be set off before starting a COBOL run unit, use the ENDCBLDBG command. Runtime switches for up to 15 programs can be on at once. When the STRCBLDBG or ENDCBLDBG command is issued in a CL program, concatenation expressions can be used for all parameter values. See the CL Programmers Guide for more information about concatenation expressions. When debugging mode is suppressed, through the run-time switch, any USE FOR DEBUGGING Declarative procedures are inhibited. All debugging lines (D in column 7) remain in effect. Recompilation of the source program is not required to activate or deactivate the run-time switch. When WITH DEBUGGING MODE is not specified in the SOURCE-COMPUTER paragraph, the run-time switch has no effect on the running of the program.
Identifier-1 cannot be reference modified. When specified, all debugging sections must be written immediately after the DECLARATIVES header. Except for the USE FOR DEBUGGING sentence there must be no reference to any non-declarative procedure within the debugging procedure. Note that the USE FOR DEBUGGING declarative causes all subsequent statements to be ignored up to a valid USE AFTER EXCEPTION/ERROR statement, or END DECLARATIVES delimiter. Entire programs can be ignored because of this. Automatic running of a debugging section is not caused by a statement appearing in a debugging section.
316
A debugging section for a specific operand is processed only once as the result of the running of a single statement, no matter how many times the operand is specified in the statement. An exception to this rule is that each specification of a subscripted or indexed identifier where the subscripts or indexes are different causes the calling of the debugging Declarative. For a PERFORM statement that causes repeated running of a procedure, any associated procedure name debugging Declarative section is run only once for each processing of the procedure. For debugging purposes, each separate occurrence of an imperative verb within an imperative statement begins a separate statement. Statements appearing outside the debugging sections must not refer to procedure names defined within the debugging sections. Except for the USE FOR DEBUGGING sentence itself, statements within a debugging Declarative section can only refer to procedure names defined in a different USE procedure through the PERFORM statement. Procedure names within debugging Declarative sections must not appear in USE FOR DEBUGGING sentences. Table 7 defines the points during program run time when the USE FOR DEBUGGING procedures are processed. Identifier-n, file-name-n, and procedure-name-n refer to the first and all subsequent specifications of that type of operand in one USE FOR DEBUGGING sentence. Any particular identifier, file name, or procedure name can appear in only one USE FOR DEBUGGING sentence, and only once in that sentence. An identifier in a USE FOR DEBUGGING sentence: Must be specified without the subscripting or indexing normally required if it contains an OCCURS clause or is subordinate to an entry containing an OCCURS clause. (A SEARCH or SEARCH ALL statement that refers to such an identifier does not call the USE FOR DEBUGGING procedures.) Must not be a special register. When ALL PROCEDURES is specified in a USE FOR DEBUGGING sentence, procedure-name-1, procedure-name-2, procedure-name-3, and so on, must not be specified in any USE FOR DEBUGGING sentence. The ALL PROCEDURES phrase can be specified only once in a program. When a USE FOR DEBUGGING operand is used as a qualifier, such a reference in the program does not activate the debugging procedures. References to the DEBUG-ITEM special register can be made only from within a debugging Declarative procedure.
317
Note: Operands acted upon but not explicitly named in such statements as ADD, MOVE, or SUBTRACT CORRESPONDING never cause activation of a USE FOR DEBUGGING procedure when such statements are run. If identifier-n is specified in a phrase that is not processed, the associated debugging section is not run.
318
1 DEBUG-ITEM. 2 DEBUG-LINE 2 FILLER 2 DEBUG-NAME 2 FILLER 2 DEBUG-SUB-1 2 FILLER 2 DEBUG-SUB-2 2 FILLER 2 DEBUG-SUB-3 2 FILLER 2 DEBUG-CONTENTS
PICTURE PICTURE PICTURE PICTURE PICTURE LEADING PICTURE PICTURE LEADING PICTURE PICTURE LEADING PICTURE PICTURE
IS X(6). IS X VALUE SPACE. IS X(3 ). IS X VALUE SPACE. IS S9999 SIGN IS SEPARATE CHARACTER. IS X VALUE SPACE. IS S9999 SIGN IS SEPARATE CHARACTER. IS X VALUE SPACE. IS S9999 SIGN IS SEPARATE CHARACTER. IS X VALUE SPACE. IS X(n).
The DEBUG-ITEM special register provides information about the conditions causing the running of a debugging section. Before each debugging section is processed, DEBUG-ITEM is filled with spaces. The contents of the DEBUG-ITEM subfields are then updated according to the rules for the MOVE statement, with one exception: DEBUG-CONTENTS is updated as if the move were an alphanumeric-to-alphanumeric elementary move without conversion of data from one form of internal representation to another. After updating, each field contains: DEBUG-LINE: The compiler-generated statement number, right justified and padded on the left with zeros. For example, 000112. DEBUG-NAME: The first 30 characters of the name causing the debugging section to run. All qualifiers are separated by the word OF (subscripts or indexes are not entered in DEBUG-NAME). DEBUG-SUB-1, DEBUG-SUB-2, DEBUG-SUB-3: If the DEBUG-NAME is subscripted or indexed, the occurrence number of each level is entered in the respective DEBUG-SUB-n. If the item is not subscripted or indexed, these fields remain spaces. DEBUG-CONTENTS: Data is moved into DEBUG-CONTENTS as shown in Table 8. DEBUG-CONTENTS is the same size as the largest identifier in the program.
319
DEBUG-CONTENTS Contains Contents of identifier-n when control passes to debug section. For READ: contents of record retrieved. Other references: spaces. procedure-name-n in TO PROCEED TO phrase
file-name-n
file-name-n
file-name-n
procedure-name-n ALTER reference GO TO procedurename-n procedure-name-n in SORT/MERGE INPUT/OUTPUT PROCEDURE PERFORM statement transfer of control procedure-name-n in a USE procedure Implicit transfer from previous sequential procedure First entry into first non-declarative procedure
SORT INPUT SORT OUTPUT MERGE OUTPUT as applicable PERFORM LOOP USE PROCEDURE
This PERFORM statement Statement causing USE procedure running Previous statement processed in previous sequential procedure (see note) Line number of first statement in the procedure
procedure-name-n procedure-name-n
procedure-name-n
FALL THROUGH
START PROGRAM
Note: If this paragraph is preceded by a section header and control is passed through the section header, the statement number refers to the section header.
320
Debugging Lines
Debugging lines can help determine the cause of an error. A debugging line is any line in a source program with a D coded in column 7 (the continuation area). If a debugging line contains nothing but spaces in Area A and Area B, it is considered a blank line. Each debugging line must be written so that a syntactically correct program results whether the debugging lines are compiled into the program or syntax-checked, but are treated as documentation. Successive debugging lines are permitted. Debugging lines can be continued. However, each continuation line must contain a D in column 7, and characterstrings must not be broken across two lines. Debugging lines can be specified only after the OBJECT-COMPUTER paragraph. When the WITH DEBUGGING MODE clause is specified in the SOURCE-COMPUTER paragraph, all debugging lines are compiled as part of the object program. When the WITH DEBUGGING MODE clause is omitted, all debugging lines are syntax-checked, but are treated as documentation.
321
322
323
The Report Writer and Communication modules of ANSI X3.23-1985 COBOL are not supported by the COBOL/400 compiler. The level of support provided by the COBOL/400 compiler is represented in the table below. The table: Shows the level of COBOL/400 compiler support for each functional processing module of the ANSI X3.23-1985 COBOL standard Describes each module. Following is an explanation of the notation used within the table:
A 3-character code that identifies the module. In this example, the Segmentation module, is referenced. 2 The level of this module supported by the COBOL/4 compiler. In this example, support is provided for the higher of the two levels of the Segmentation module. SEG ,2 The range of levels of support defined by the ANSI X3.23-1985 COBOL standard. A level of means a minimum standard COBOL does not need to support this module to conform to the standard.
Module Description Contains the language elements necessary for internal processing of data within the four basic divisions of a program and the capability for defining and accessing tables. Provides access to file records by the established sequence in which they were written to the file. Provides access to records in either a random or sequential manner. Each record is uniquely identified by an integer that represents the records logical position in the file. Provides access to records in either random or sequential manner. Each record in an indexed file is uniquely identified by a record key. Allows a COBOL program to communicate with other programs through transfers of control and access to common data items. Orders one or more files of records, or combines two or more identically ordered files according to user-specified keys. Allows insertion of predefined COBOL text into a program at compile time.
324
Module Description Provides semiautomatic production of printed reports. Provides the ability to access, process, and create messages or portions of messages; also allows communication through a Message Control System with local and remote communication devices. Allows you to specify statements and procedures for debugging. Provides the overlaying at object time of Procedure Division sections.
325
326
COBOL/400 Messages
This appendix provides a general description of messages that IBM supplies with the COBOL/400 licensed program.
Interactive Messages
In an interactive environment, messages are displayed on the work station display. They can appear on the current display as a result of the running of the program or in response to your keyed input to prompts, menus, command entry displays, or Application Development Tools (Appl Dev Tools). The messages can also appear on request, as a result of a display command or an option on a menu. The messages for the COBOL/400 licensed program begin with an LSC, LBE, or LBL prefix. The LSC messages are issued by the COBOL/400 syntax checker when the Source Entry Utility (SEU) is used to enter your COBOL/400 source. For example, you see the following display after incorrectly entering the program name in the PROGRAM-ID paragraph.
Columns . . . : 1 71 Edit XMPLIB/QLBLSRC SEU==> TESTPR FMT CB ......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Beginning of data .1 IDENTIFICATION DIVISION. .2 PROGRAM-ID. #TESTPR. .7 ENVIRONMENT DIVISION. .9 SOURCE-COMPUTER. IBM-AS4 . End of data
F3=Exit F4=Prompt F5=Refresh F9=Retrieve F16=Repeat find F17=Repeat change # not in COBOL character set. Line rejected.
327
LBE messages provide you with additional information about system operation during run time. For example, you might see the following display if you have a run-time error:
Display Program Messages Job 11111/PGMRS/E34 started on 3/ 4/9 at 14:35: 2 in subsystem QINTER in Message CPF41 1 in XMPLDUMP in COBOLEX (C D F G).
If you move the cursor to the line on which message number CPF4101 is indicated and press either the HELP key or F1, the LBE message information is displayed as shown:
Additional Message Information Message ID . Message type Date sent . . From program To program . . . . . . . . . . . . . . . . . . . . . . . . . . : : : : : LBE72 INQUIRY 3/ 4/9 QLREXHAN EXT Severity . . . . . . : Time sent . . . . . : Instruction . . . . : Instruction . . . . : 99 14:37:15
Message . . . . : Message CPF41 1 in XMPLDUMP in COBOLEX (C D F G). Cause . . . . . : Message CPF41 1 was detected in COBOL statement .OPEN (MI instruction 7E) in program XMPLDUMP in COBOLEX. Recovery . . . : Enter a G to continue the program at the next MI instruction, or a C if no dump is wanted, a D if a dump of the COBOL identifiers is wanted, or and F to dump both the COBOL identifiers and the compiler-generated variables. The message text for CPF41 1 follows: File SALES in library LIBL not found or inline data file missing. Possible choices for replying to message . . . . . . . . . . . . . . . : C -- No formatted dump is given D -- A dump of the COBOL identifiers is given F -- A dump of all variables is given G -- To continue the program at the next MI instruction. Bottom Press Enter to continue. F3=Exit F1 =Display messages in job log F12=Cancel
LBE messages 7900 to 7999 are used as headings for information printed during a COBOL/400 formatted dump.
328
The LBL messages are described under Compilation Messages below. Responding to Messages on page 329 explains how to display second-level message text and how to reply to messages.
Compilation Messages
LBL messages are printed in the program listing when errors are found during program compilation. The LBL messages include the message issued when Federal Information Processing Standard (FIPS) flagging is requested; for more information on the FIPS messages, refer to page 331 in this appendix.
Program Listings
In the compiler output, the COBOL/400 messages listing follows the source listing. The COBOL/400 messages listing gives the message identifier, severity, text, usually the location of the error, and the messages summary. For more information about Program Listings, see Source Listing on page 41.
Responding to Messages
In an interactive environment, a message is indicated by one or several of these conditions: A brief message (called first-level text) on the message line Reverse image highlighting of the input field in error A locked keyboard The sound of an alarm (if the alarm option is installed). The following paragraphs briefly describe some methods of responding to error messages; more information is available in the New Users Guide and the Application Development Tools publications. If the necessary correction is obvious from the initial display, you can press the Error Reset key (if the keyboard is locked), enter the correct information, and continue your work. If the message requires that you choose a reply (such as C to cancel, D to dump COBOL identifiers, F to dump all variables, or G to resume processing at the next COBOL statement), the reply options are shown in parentheses in the first-level message text. For an example, see Figure 110 on page 328. If the information on the initial information display does not provide sufficient data for you to handle the error, you can press the HELP key (after positioning the cursor to the message line, if required) to get a second-level display with additional information about how to correct this error. To return to the initial display, press the Enter key; then press the Error Reset key (if the keyboard is locked), and make your correction or response. If the error occurs when you are compiling or running a program, you might need to modify your COBOL/400 source statements or control language (CL) commands. Refer to the SEU Users Guide and Reference for information on how to change the statements.
329
Severity Levels
The COBOL/400 licensed program provides the following message severity levels: Severity 00 Meaning Informational: This level is used to convey information to the user. No error has occurred. Informational messages are listed only when the FLAG (00) option is specified. Warning: This level indicates that an error was detected but is not serious enough to interfere with the running of the program. Error: This level indicates that an error was made, but the compiler is taking a recovery that might yield the desired code. Severe Error: This level indicates that a serious error was detected. Compilation is completed, but running of the program cannot be attempted. Unrecoverable: This level usually indicates a user error that forces termination of processing. Unrecoverable: This level usually indicates a compiler error that forces termination of processing. Action: Some manual action is required, such as entering a reply, changing printer forms, or replacing diskettes.
10 20 30
40 50 99
Note: 00, 10, and 20 messages are suppressed when the FLAG(30) option of the PROCESS statement is used or the CRTCBLPGM command specifies FLAG(30) and is not overridden by the PROCESS statement. See Using the PROCESS Statement to Specify Compiler Options on page 32 for further information.
330
The compiler always attempts to provide full diagnostics of all source text in the program, even when errors have been detected. If the compiler cannot continue on a given statement, the message states that the compiler cannot continue and that it will ignore the rest of the statement. When this error occurs, the programmer should examine the entire statement. The OS/400 message facility is used to produce all messages. The COBOL/400 compiler messages reside in the message file, QLBLMSG, and the run-time messages reside in the message file, QLBLMSGE. Substitution variables and valid reply values are determined by the program sending the message, not by the message description stored in the message file. However, certain elements of a message description can be changed: for example, the text, severity level, default response, or dump list. To effect such changes, you need to define another message description using an Add Message Description (ADDMSGD) command, place the modified description in a user-created message file,1 and specify that file in the Override Message File (OVRMSGF) command. Using the OVRMSGF command allows the compiler to retrieve messages from the specified file. See the ADDMSGD and OVRMSGF commands in the CL Reference for additional information.
CAUTION: Overriding an IBM-supplied message with a user-created message can produce results you do not anticipate. If reply values are not retained, the program might not respond to any replies. Changing default replies on *NOTIFY type messages could affect the ability of the program to run in unattended mode. Changing the severity could cancel a job not previously canceled. Be cautious when overriding IBM-supplied messages with user-created messages.
If an IBM-supplied message must be changed and replaced in its message file, call your service representative. Appendix D. COBOL/400 Messages
331
Table 10 on page 332 shows the 1985 ANSI Standard COBOL processing modules included in each of the subsets of 1986 FIPS COBOL. Following is an explanation of the notation used within the table:
A 3-character code that identifies the module. In this example, the Segmentation module, is referenced. 2 The level of this module supported by the 1986 FIPS COBOL standard. In this example, support is provided for the higher of the two levels of the Segmentation module. SEG ,2 The range of levels of support defined by the ANSI X3.23-1985 COBOL standard. A level of means a minimum standard COBOL does not need to support this module to conform to the standard.
Table 10. 1985 American National Standard COBOL and 1986 FIPS Levels
1985 ANSI Module Name Nucleus Sequential I-O Relative I-O Indexed I-O Source-Text Manipulation Sort-Merge Inter-Program Communication Report Writer Segmentation Debug Communications High FIPS 2 NUC 1,2 2 SEQ 1,2 2 REL 0,2 2 INX 0,2 2 STM 0,2 1 SRT 0,1 2 IPC 1,2 0, or 1 RPW 0,1 0,1 or 2 SEG 0,2 0,1 or 2 DEB 0,2 0,1 or 2 COM 0,2 Intermediate FIPS 1 NUC 1,2 1 SEQ 1,2 1 REL 0,2 1 INX 0,2 1 STM 0,2 1 SRT 0,1 1 IPC 1,2 0, or 1 RPW 0,1 0,1 or 2 SEG 0,2 0,1 or 2 DEB 0,2 0,1 or 2 COM 0,2 Minimum FIPS 1 NUC 1,2 1 SEQ 1,2 0 REL 0,2 0 INX 0,2 0 STM 0,2 0 SRT 0,1 1 IPC 1,2 0, or 1 RPW 0,1 0,1 or 2 SEG 0,2 0,1 or 2 DEB 0,2 0,1 or 2 COM 0,2
Note: The COBOL/400 compiler supports the Segmentation and Debug optional modules. Elements that are specified in the COBOL/400 source program and that are not included in 1986 FIPS COBOL are flagged as described in Appendix C, Level of Language Support on page 323.
332
SAA Flagging
You can choose to perform SAA flagging to determine if the COBOL/400 functions that you are using are portable to other SAA COBOL environments. Flagging is performed on those COBOL/400 functions that are outside of SAA COBOL, such as: COBOL/400 extensions COBOL/400 compiler limits Non-SAA reserved words Compiler options. In this way, you can write programs that conform to the SAA COBOL definition. For an example of SAA flagging in a compiler listing, see Figure 12 on page 47. To perform SAA flagging through the CRTCBLPGM CL command, specify SAAFLAG(*FLAG). To perform SAA flagging through a PROCESS statement, specify SAAFLAG. To compile a program to conform to the SAA definition, using the CRTCBLPGM command, specify the following: OPTION( QUOTE NOSEQUENCE NONUMBER) GENOPT( CRTF DUPKEYCHK SYNC) SAAFLAG( FLAG) If you use the PROCESS statement, specify the following: QUOTE, NOSEQUENCE, NONUMBER, CRTF, DUPKEYCHK, SYNC, SAAFLAG. For more information about specifying the option for SAA flagging, see the SAAFLAG parameter on page 25, and the Using the PROCESS Statement to Specify Compiler Options on page 32. For information about compiler limits, see the Compiler Limits appendix in the COBOL/400 Reference.
333
334
335
If the FOOTING phrase is not specified, no end-of-page condition independent of the page overflow condition exists. The NO REWIND phrase cannot be specified in a CLOSE statement having the REEL/UNIT phrase. The CANCEL and STOP RUN statements close all open files. When a receiving item is a variable-length data item and contains the object of the DEPENDING ON phrase, the maximum length of the item will be used. Within the VARYING ... AFTER phrase of the PERFORM statement, identifier-2 is augmented before identifier-5 is set. Any subscripts for identifier-4 in the DIVIDE statement REMAINDER phrase are evaluated after the result of the DIVIDE operation is stored in identifier-3 of the GIVING phrase. The phrase ADVANCING PAGE and END-OF-PAGE must not both be in a single WRITE statement. The picture character-string of an alphabetic item can contain only the symbol A. No editing is allowed for the alphabetic data category. Note: An alphabetic character is a letter or a space character. When a data item described by a PICTURE containing the character P is referenced, the digit positions specified by P are considered to contain zeros in the following operations: Any operation requiring a numeric sending operand A MOVE statement where the sending operand is numeric and its PICTURE character-string contains the symbol P A MOVE statement where the sending operand is numeric edited and its PICTURE character-string contains the symbol P and the receiving operand is numeric or numeric edited A comparison operation where both operands are numeric. The literal in the CURRENCY SIGN clause cannot be a figurative constant. If the COPY statement appears in a comment-entry, it is considered part of the comment-entry. The following special cases of exponentiation are defined: If an expression having a zero value is raised to a negative or zero power, the size error condition exists. If the evaluation of the exponentiation yields both a positive and a negative real number, the positive number is returned. If no real number exists as the result of the evaluation, the size error condition exists. When the figurative constant ALL literal is not associated with another data item, the length of the string is the length of the literal.
336
DBCS Literals: The COBOL compiler recognizes DBCS characters in DBCS literals when you use the GRAPHIC option on the PROCESS statement.
Note: The GRAPHIC option on the PROCESS statement is not to be confused with the *GRAPHIC value in the CVTOPT parameter of the CRTCBLPGM command and the CVTGRAPHIC option on the PROCESS statement, which are used to specify double-byte graphic data from a DDS description. For more information on specifying graphic data, refer to DBCS-Graphic Fields on page 133.
DBCS/SBCS Literals: The COBOL compiler recognizes DBCS characters in DBCS/SBCS (mixed) literals, when you are on a DBCS system and the GRAPHIC option on the PROCESS statement is not specified.
337
How to Specify a DBCS Literal: When you specify a DBCS literal, keep in mind the following:
The format for a DBCS literal is: " EK1K2 F" A quotation mark opens and closes the literal. A shift-out character ( E) immediately follows the initial quotation mark and occupies 1 byte. A shift-out character is a control character (hex 0E) that indicates the start of a string of double-byte characters. A shift-in character ( F) immediately precedes the final quotation mark and occupies 1 byte. A shift-in character is a control character (hex 0F) that indicates the end of a string of double-byte characters. All DBCS characters appear between the shift-out and shift-in characters. Only DBCS characters may appear in the literal (null strings are valid). The maximum length of a DBCS literal is 80 DBCS characters, including the shift control characters. (These counted together are equivalent in length to one DBCS character.) The shift control characters are part of the literal, and take part in all operations. See How to Continue DBCS Literals on a New Line on page 339 for information on how to extend DBCS literals.
How to Specify a DBCS/SBCS Literal: When you specify a DBCS/SBCS literal, keep in mind the following:
DBCS/SBCS literals can take many different forms. The following is only one possible example: "SINGLE EK1K2K3 FBYTES" USAGE DISPLAY must be either explicit or implicit. A quotation mark opens and closes the literal. EBCDIC characters can appear before or after any DBCS string in the mixed literal. All DBCS strings appear between shift-out and shift-in characters. Double all SBCS quotation marks that occur within the literal. DBCS quotation marks within the literal do not require doubling. You can use null DBCS strings (shift-out and shift-in characters without any DBCS characters) only when the literal contains at least one SBCS character. The shift-out and shift-in characters cannot be nested. The shift control characters are part of the literal, and take part in all operations.
338
DBCS/SBCS literals cannot continue across lines. They are restricted to the space of AREA B on one line.
Other Considerations Quotation Marks: Although the preceding discussion uses the term a quotation mark to describe the character that identifies a literal, the character actually used can vary depending upon the option specified on the CRTCBLPGM CL command, or on the PROCESS statement. If you specify the APOST option, an apostrophe (') is used. Otherwise, a quotation mark (") is used. In this appendix, a quotation mark refers to both an apostrophe and a quotation mark. The character that you choose does not affect the rules for specifying a literal. Shift Characters: The shift-out and shift-in characters separate EBCDIC characters from DBCS characters. They are part of both the DBCS and the DBCS/SBCS literal. Therefore, the shift code characters participate in all operations when they appear in either DBCS or DBCS/SBCS literals.
PIC X(12)
339
The value of DBCS1 is "0EK1K2K3K4K50F". The shift-in character, quotation mark, and shift-out character used to continue a line are not counted in the length of the DBCS literal. The first shift-out and final shift-in characters are counted.
Identification Division
You can put comment entries that contain DBCS characters in any portion of the Identification Division except the PROGRAM-ID paragraph. The program name specified in the PROGRAM-ID paragraph must be alphanumeric.
Environment Division
Configuration Section
You can use DBCS characters in comment entries only in the Configuration Section paragraph. All function-names, mnemonic-names, condition-names, and alphabetnames must be specified with alphanumeric characters. For the SOURCE-COMPUTER and the OBJECT-COMPUTER entry, use the alphanumeric computer name: IBM-AS400 You cannot use DBCS or DBCS/SBCS literals in the Configuration Section. Instead, use alphanumeric literals to define an alphabet-name and the literal in the CURRENCY SIGN clause of the SPECIAL-NAMES paragraph. There is no DBCS alphabet. Use the EBCDIC character set instead.
340
Input-Output Section
Specify all data names, file names, and assignment names using alphanumeric characters. You can use DBCS characters in comments. For indexed files, the data name in the RECORD KEY clause can refer to a DBCS or DBCS/SBCS data item within a record. The number of fields in the record, plus the number of positions occupied by the record key, together cannot be greater than 120. Note: Each DBCS character occupies two positions, and the shift control characters each occupy one position. Ensure that both the data description of the key and the key position within the file match those specified when you created the file. You cannot use DBCS and DBCS/SBCS data as the RELATIVE KEY in relative files.
Data Division
File Section
For the FD (File Description) Entry, you can use DBCS or DBCS/SBCS data items or literals in the VALUE OF clause. The DATA RECORDS clause can refer to data items only. Because the COBOL/400 compiler treats both the VALUE OF clause and the DATA RECORDS clause in the File Section as documentation, neither clause has any effect when you run the program. However, the COBOL compiler checks all literals in the VALUE OF clause to make sure they are valid. For magnetic tapes, the system can only read DBCS characters from, or write DBCS characters to, the tape in the EBCDIC format. The system cannot perform tape functions involving a tape in the ASCII format. Define the alphabet-name in the CODE-SET clause as NATIVE. Use alphanumeric characters to specify the alphabet-name.
Working-Storage Section
REDEFINES Clause: The existing rules for redefining data also apply to data that contains DBCS characters. When you determine the length of a redefining or redefined data item, remember that each DBCS character is twice as long as an alphanumeric character.
Also, ensure that redefined data items contain the shift control characters when and where necessary.
OCCURS Clause: Use this clause to define tables for storing DBCS or DBCS/SBCS data. If you specify the ASCENDING/DESCENDING KEY phrase, COBOL assumes the contents of the table are in the EBCDIC program collating sequence. The shift control characters in DBCS and DBCS/SBCS data take part in the collating sequence.
For more information about handling tables that contain DBCS characters, see Table HandlingSEARCH Statement on page 348.
Appendix F. Supporting International Languages with Double-Byte Character Sets
341
JUSTIFIED RIGHT Clause: Use the JUSTIFIED RIGHT clause to align DBCS or DBCS/SBCS data at the rightmost position of an elementary receiving field. If the receiving field is shorter than the sending field, COBOL truncates the rightmost characters. If the receiving field is longer than the sending field, COBOL pads (fills) the unused space on the left of the receiving field with blanks.
The JUSTIFIED clause does not affect the initial setting in the VALUE clause.
VALUE Clause: You can use DBCS or DBCS/SBCS literals to specify an initial value for a data item that is not numeric, or to define values for level-88 conditionname entries.
Any shift control characters in the literal are considered part of the literals picture string, except when used to continue a new line. When you continue a DBCS literal, the compiler does not include the shift-in character in column 71 or 72, or the initial quotation mark (") and shift-out character on the continued line as part of the DBCS literal. Make certain, however, that the DBCS literal does not exceed the size of the data item specified in the PICTURE clause, otherwise truncation occurs. Note: DBCS/SBCS mixed literals cannot be continued to a new line. When you use literals that contain DBCS characters in the VALUE clause for level-88 condition-name entries, COBOL treats the DBCS characters as alphanumeric. Therefore, follow the rules for specifying alphanumeric data, including allowing a THROUGH option. This option uses the normal EBCDIC collating sequence, but remember that shift control characters in DBCS and DBCS/SBCS data take part in the collating sequence.
PICTURE Clause: Use the PICTURE symbol X to define DBCS and DBCS/SBCS data items. Because DBCS characters are twice as long as alphanumeric, and are enclosed within shift control characters, you would define a DBCS data item containing n DBCS characters as
PICTURE X(2n+2) A DBCS/SBCS data item containing m SBCS characters, and one string of n DBCS characters would be defined as PICTURE X(m+2n+2) You can use all edited alphanumeric PICTURE symbols for DBCS and DBCS/SBCS data items. The editing symbols have the same effect on the DBCS data in these items as they do on alphanumeric data items. Check that you have obtained the desired results.
RENAMES Clause: Use this clause to specify alternative groupings of elementary data items. The existing rules for renaming alphanumeric data items also apply to DBCS and DBCS/SBCS data items.
342
Procedure Division
Declaratives
An identifier in the USE FOR DEBUGGING sentence of the DECLARATIVES section can refer to a DBCS or a DBCS/SBCS data item. You cannot use DBCS characters for file names or procedure names in the USE FOR DEBUGGING sentence.
Conditional Expressions
Because condition-names (level-88 entries) can refer to data items that contain DBCS characters, you can use the condition-name condition to test this data. (See VALUE Clause on page 342.) Follow the rules listed in the COBOL/400 Reference for using conditional variables and condition-names. You can use DBCS or DBCS/SBCS data items or literals as the operands in a relation condition. Because COBOL treats DBCS data as alphanumeric, all comparisons occur according to the rules for alphanumeric operands. Keep the following in mind: The system does not recognize the mixed content. The system uses the shift codes in comparisons of DBCS and DBCS/SBCS data. The system compares the data using either the EBCDIC collating sequence, or a user-defined sequence. In a comparison of DBCS or DBCS/SBCS items with similar items of unequal size, the smaller item is padded on the right with EBCDIC spaces. See SPECIAL-NAMES Paragraph section in the COBOL/400 Reference for more information. You can use class conditions and switch status conditions as described in the COBOL/400 Reference.
Input/Output Statements
ACCEPT Statement: The input data received from a device by using a Format 1 ACCEPT statement can include DBCS or DBCS/SBCS data. All DBCS and DBCS/SBCS data must be identified by the proper syntax. The input data, including shift control characters, replaces the existing contents of the identifier. COBOL does not perform editing or error checking on the data.
If you use the Format 3 ACCEPT statement to get OPEN-FEEDBACK information about a file, that information includes a field showing whether the file has DBCS or DBCS/SBCS data. Information received from the local data area by a Format 4 ACCEPT statement can include DBCS or DBCS/SBCS character strings. Information received replaces the existing contents. COBOL does not perform any editing or checking for errors. This also applies to information received from the PIP data area by a Format 5 ACCEPT statement. Using the Format 6 ACCEPT statement, you can get the attributes of a work station display and its keyboard. For display stations that can display DBCS characters,
Appendix F. Supporting International Languages with Double-Byte Character Sets
343
the system sets the appropriate value in the ATTRIBUTE-DATA data item. You cannot use DBCS characters to name a device. If you use an extended (Format 7) ACCEPT statement for field-level work station input, you must ensure that DBCS data is not split across lines. COBOL does not perform any editing or checking for errors.
DISPLAY Statement: You can specify DBCS or DBCS/SBCS data items or literals in the DISPLAY statement. You can mix the types of data. DBCS and DBCS/SBCS data, from either data items or literals, is sent as it appears to the program device or local data area that is the target named on the DISPLAY statement.
Because COBOL does not know the characteristics of the device on which data is being displayed, you must make sure that the DBCS and DBCS/SBCS data is correct. It may be necessary to specify the extended display option *NOUNDSPCHAR (or the equivalent process statement parameter option) when the program is compiled, to ensure that a workstation can handle DBCS data correctly. Note: ALL is a valid option for mixed literals. If you use an extended (Format 3) DISPLAY statement for field-level work station output, you must ensure that DBCS data is not split across lines.
| | |
READ Statement: You can use DBCS or DBCS/SBCS data items as the RECORD KEY for an indexed file. See Input-Output Section on page 341 for more information. INTO Phrase: You can read a record into a DBCS or a DBCS/SBCS data item using the INTO phrase. This phrase causes a MOVE statement (without the CORRESPONDING option) to be performed. The compiler moves DBCS and DBCS/SBCS data in the same manner that it moves alphanumeric data. It does not make sure that this data is valid. REWRITE Statement: Use the FROM phrase of this statement to transfer DBCS or DBCS/SBCS data from a DBCS or a DBCS/SBCS data item to an existing record. The FROM phrase causes both types of data to be moved in the same manner as the INTO phrase with the READ statement. (See READ Statement.) START Statement: If you use DBCS characters in the key of an indexed file, specify a corresponding data item in the KEY phrase of the START statement.
One of the following must be true: The data item must be the same as the data item specified in the RECORD KEY clause of the FILE-CONTROL paragraph. The data item has the same first character as the record key and is not longer than the record key. You can specify valid operators (such as EQUAL, GREATER THAN, NOT LESS THAN) in the KEY phrase. The system can follow either the EBCDIC or a userdefined collating sequence.
344
WRITE Statement: Use the FROM phrase of this statement to write DBCS or DBCS/SBCS data to a record. This phrase moves the data in the same manner as the REWRITE statement. (See REWRITE Statement.)
You must include the shift control characters when you write the data into a device file.
The INSPECT statement would be coded as follows: INSPECT SUBJECT-ITEM REPLACING ALL DBCS-CHARACTER-1 BY DBCS-CHARACTER-2 AFTER INITIAL SHIFT-OUT. Note: Using the AFTER INITIAL SHIFT-OUT phrase helps you to avoid the risk of accidentally replacing two consecutive alphanumeric characters that have the same EBCDIC values as DBCS-CHARACTER-1 (in cases where SUBJECT-ITEM contains DBCS/SBCS data).
345
You can also use the INSPECT statement to determine if a data item contains DBCS characters, so that appropriate processing can occur. For example: 1 1 1 SUBJECT-FIELD TALLY-FIELD SHIFTS 5 SHIFT-OUT 5 SHIFT-IN PICTURE PICTURE VALUE " PICTURE PICTURE X(5 ). 9(3) COMP. E F". X. X.
In the Procedure Division you might enter the following: MOVE ZERO TO TALLY-FIELD. INSPECT SUBJECT-FIELD TALLYING TALLY-FIELD FOR ALL SHIFT-OUT. IF TALLY-FIELD IS GREATER THAN ZERO THEN PERFORM DBCS-PROCESSING ELSE PERFORM A-N-K-PROCESSING.
MOVE Statement: All DBCS characters are moved as alphanumeric character strings. The system does not convert the data or examine it.
You can move DBCS/SBCS literals to group items and alphanumeric items. If the length of the receiving field is different from that of the sending field, COBOL does one of the following: Truncates characters from the sending item if it is longer than the receiving item. This operation can reduce data integrity. Pads the sending item with blanks if it is shorter than the receiving item. To understand more about the effect of editing symbols in the PICTURE clause of the receiving data item, see the COBOL/400 Reference.
SET Statement (Condition-Name Format): When you set the condition name to TRUE on this statement, COBOL moves the literal from the VALUE clause to the associated data item. You can move a literal with DBCS characters. STRING Statement: You can use the STRING statement to construct a data item that contains DBCS or DBCS/SBCS subfields. All data in the source data items or literals, including shift control characters, is moved to the receiving data item, onehalf of a DBCS character at a time. UNSTRING Statement: The UNSTRING statement treats DBCS data and DBCS/SBCS data the same as alphanumeric data. The UNSTRING operation is performed on one-half of a DBCS character at a time.
Data items can contain both alphanumeric and DBCS characters within the same field. Use the DELIMITED BY phrase to locate double-byte and alphanumeric subfields within a data field. Identify the data items containing shift control characters, and use those data items as identifiers on the DELIMITED BY phrase. See the following examples for more information on how to do this. Use the POINTER variable to continue scanning through subfields of the sending field.
346
After the system performs the UNSTRING operation, you can check the delimiters stored by the DELIMITER IN phrases against the shift control character values to see which subfields contain DBCS and which contain alphanumeric characters. The following example shows how you might set up fields to prepare for the unstring operation on a character string that contain DBCS/SBCS data: 1 1 SUBJECT-FIELD FILLER. 5 UNSTRING-TABLE 1 RECEIVER 1 DELIMTR 1 COUNTS SHIFTS 5 SHIFT-OUT 5 SHIFT-IN PICTURE X(4 ) OCCURS 4 TIMES. PICTURE X(4 ). PICTURE X. PICTURE 99 COMP. VALUE " E F". PICTURE X. PICTURE X.
Code the UNSTRING statement as follows: UNSTRING SUBJECT-FIELD DELIMITED BY SHIFT-OUT OR SHIFT-IN INTO RECEIVER (1) DELIMITER IN DELIMTR (1) COUNT IN COUNTS (1) INTO RECEIVER (2) DELIMITER IN DELIMTR (2) COUNT IN COUNTS (2) INTO RECEIVER (3) DELIMITER IN DELIMTR (3) COUNT IN COUNTS (3) INTO RECEIVER (4) DELIMITER IN DELIMTR (4) COUNT IN COUNTS (4) ON OVERFLOW PERFORM UNSTRING-OVERFLOW-MESSAGE. This UNSTRING statement divides a character string into its alphanumeric and DBCS parts. Assuming that the data in the character string is valid, a delimiter value of shift-out indicates that the corresponding receiving field contains alphanumeric data, while a value of shift-in indicates that corresponding receiving field has DBCS data. You can check the COUNT data items to determine whether each receiving field received any characters. The following figure is an example that shows the results of the UNSTRING operation just described: SUBJECT-FIELD = ABC EK1K2K3 FD EK4K5K6 RECEIVER (1) = ABC DELIMTR (1) = RECEIVER (2) = K1K2K3 DELIMTR (2) = RECEIVER (3) = D DELIMTR (3) = RECEIVER (4) = K4K5K6 DELIMTR (4) =
F E F E F
= = = =
3 6 1 6
SUBJECT-FIELD = EK1K2K3 RECEIVER (1) = (blanks) RECEIVER (2) = K1K2K3 RECEIVER (3) = ABC RECEIVER (4) = K4
FABC EK4 F
= = = =
E F E F
= = 6 = 3 = 2
347
SORT/MERGE
You cannot perform a DBCS alphabet sort using COBOL. However, you can use DBCS or DBCS/SBCS data items as keys in a SORT or MERGE statement. The sort operation orders data according to the collating sequence specified in the SORT, MERGE, or SPECIAL NAMES paragraph. The system orders any shift control characters contained in DBCS and DBCS/SBCS keys. Use the RELEASE statement to transfer records containing DBCS characters from an input/output area to the initial phase of a sort operation. The system performs the FROM phrase with the RELEASE statement in the same way it performs the FROM phrase with the WRITE statement. (See WRITE Statement on page 345.) You can also use the RETURN statement to transfer records containing DBCS characters from the final phase of a sort or merge operation to an input/output area. The system performs the INTO phrase with the RETURN statement in the same manner that it performs the INTO phrase with the READ statement. (See READ Statement on page 344.)
Compiler-Directing Statements
COPY Statement
You can use the COPY statement to copy source text that contains DBCS characters into a COBOL program. When you do, make sure that you specify the member name, file name, and library name using alphanumeric data, and that you specify these names according to the rules stated in the COBOL/400 Reference. Use the Format 2 COPY statement to copy fields defined in the data description specifications (DDS). DBCS and DBCS/SBCS data items (the value in column 35 of the DDS form is O) are copied into a COBOL program in the PICTURE X(n) format. The compiler listing does not indicate that these fields contain DBCS characters, unless a field is a key field. In those cases, the system prints an O in the comment table for keys. DBCS-graphic data items are copied into a COBOL program in the PICTURE X(N) format. The compiler listing indicates that these fields contain graphic data. See
348
DBCS-Graphic Fields on page 133 for a description of the DBCS-graphic data type. You can put DBCS characters in text comments that are copied from DDS if the associated DDS field has comments. If you specify the REPLACING phrase of the COPY statement, consider the following: Pseudo-text can contain any combination of DBCS and alphanumeric characters. You can use literals with DBCS or DBCS/SBCS content. Identifiers can refer to data items that contain DBCS characters.
TITLE Statement
You can use DBCS/SBCS literals as the literal in the TITLE statement.
FIPS Flagger
Enhancements to the COBOL language that let you use DBCS characters are flagged (identified) by the FIPS (Federal Information Processing Standard) flagger provided by the compiler as IBM extensions.
349
The user has specified the required attribute for the output printer, using the IGCDTA parameter of the OVRPRTF command, before compiling the program. Note: The IGCDTA parameter is only available on DBCS systems, and it cannot be defined or displayed on non-DBCS systems. You can, however, create objects with DBCS attributes on a non-DBCS system by copying them from a DBCS system. You should check for possible incompatibilities if you do this. The compiler may use characters from your source program as substitution parameters in compiler and syntax checker messages. The system does not check or edit the substitution parameters. If you do not specify DBCS characters properly, the system may print or display parts of messages incorrectly. End of IBM Extension
350
351
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. CRTSEQ. 3 3 4 ENVIRONMENT DIVISION. 4 5 CONFIGURATION SECTION. 5 6 SOURCE-COMPUTER. IBM-AS4 . 6 7 OBJECT-COMPUTER. IBM-AS4 . 7 8 SPECIAL-NAMES. CONSOLE IS TYPEWRITER. 8 9 INPUT-OUTPUT SECTION. 9 1 FILE-CONTROL. 1 11 SELECT INPUT-FILE ASSIGN TO DISK-FILEA 11 12 FILE STATUS IS INPUT-FILE-STATUS. 12 13 SELECT OUTPUT-FILE ASSIGN TO DISK-FILEB 13 14 FILE STATUS IS OUTPUT-FILE-STATUS. 14 15 DATA DIVISION. 15 16 FILE SECTION. 16 17 FD INPUT-FILE LABEL RECORDS STANDARD. 17 18 1 INPUT-RECORD. 18 19 5 INPUT-EMPLOYEE-NUMBER PICTURE 9(6). 19 2 5 INPUT-EMPLOYEE-NAME PICTURE X(28). 2 21 5 INPUT-EMPLOYEE-CODE PICTURE 9. 21 22 5 INPUT-EMPLOYEE-SALARY PICTURE 9(6)V99. 22 23 FD OUTPUT-FILE LABEL RECORDS STANDARD. 23 24 1 OUTPUT-RECORD. 24 25 5 OUTPUT-EMPLOYEE-NUMBER PICTURE 9(6). 25 26 5 OUTPUT-EMPLOYEE-NAME PICTURE X(28). 26 27 5 OUTPUT-EMPLOYEE-CODE PICTURE 9. 27 28 5 OUTPUT-EMPLOYEE-SALARY PICTURE 9(6)V99. 28 29 WORKING-STORAGE SECTION. 29 3 77 INPUT-FILE-STATUS PICTURE XX. 3 31 77 OUTPUT-FILE-STATUS PICTURE XX. 31 32 1 INPUTEND PICTURE X VALUE SPACE. 32 33 88 THE-END-OF-INPUT VALUE "E". 33 34 1 DISP-RECORD. 34 35 5 OP-NAME PICTURE X(7). 35 36 5 FILLER PICTURE XX VALUE SPACE. 36 37 5 FILE-NAME PICTURE X(11). 37 38 5 FILLER PICTURE XX VALUE SPACE. 38 39 5 FILLER PICTURE X(14) 39 4 VALUE "FILE STATUS IS". 4 41 5 FILLER PICTURE XX VALUE SPACE. 41 42 5 SK PICTURE XX. 42 43 PROCEDURE DIVISION. 44 DECLARATIVES. 45 I-O-ERROR SECTION. 46 USE AFTER STANDARD ERROR PROCEDURE ON INPUT-FILE, 47 OUTPUT-FILE. 48 I-O-ERROR-PARA. 49 5 DUMMY DECLARATIVES TO ENSURE CONTROL IS RETURNED TO THIS 51 PROGRAM WHEN AN ERROR OCCURS DURING FILE PROCESSING. 52 ERROR HANDLING IS DONE AFTER EACH I/O STATEMENT. 53 54 END DECLARATIVES. 55 MAIN-PROGRAM SECTION. 56 OPEN-FILES. 43 57 OPEN INPUT INPUT-FILE 58 OUTPUT OUTPUT-FILE. 44 59 IF INPUT-FILE-STATUS NOT = " " 45 6 MOVE "OPEN" TO OP-NAME 46 61 MOVE "INPUT-FILE" TO FILE-NAME 47 62 MOVE INPUT-FILE-STATUS TO SK 48 63 PERFORM ERROR-OUT-1 THROUGH ERROR-OUT-2. 49 64 IF OUTPUT-FILE-STATUS NOT = " " 5 65 MOVE "OPEN" TO OP-NAME 51 66 MOVE "OUTPUT-FILE" TO FILE-NAME 52 67 MOVE OUTPUT-FILE-STATUS TO SK 53 68 PERFORM ERROR-OUT-1 THROUGH ERROR-OUT-2. 54 69 PERFORM BUILD-FILE UNTIL THE-END-OF-INPUT. 7 CLOSE-FILES. 55 71 CLOSE INPUT-FILE 72 OUTPUT-FILE. 56 73 STOP RUN. 74 BUILD-FILE.
COPYNAME
CHG DATE
5/24/94 5/24/94
Figure 112 (Part 1 of 2). Example of a Sequential File of Employee Salary Records
352
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 57 75 READ INPUT-FILE INTO OUTPUT-RECORD 58 76 AT END SET THE-END-OF-INPUT TO TRUE. 59 77 IF INPUT-FILE-STATUS NOT = " " 6 78 MOVE "WRITE" TO OP-NAME 61 79 MOVE "OUTPUT-FILE" TO FILE-NAME 62 8 MOVE OUTPUT-FILE-STATUS TO SK 63 81 PERFORM ERROR-OUT-1 THROUGH ERROR-OUT-2 64 82 GO TO CLOSE-FILES. 65 83 WRITE OUTPUT-RECORD. 66 84 IF OUTPUT-FILE-STATUS NOT = " " 67 85 MOVE "WRITE" TO OP-NAME 68 86 MOVE "OUTPUT-FILE" TO FILE-NAME 69 87 MOVE OUTPUT-FILE-STATUS TO SK 7 88 PERFORM ERROR-OUT-1 THROUGH ERROR-OUT-2 71 89 GO TO CLOSE-FILES. 9 ERROR-OUT-1. 72 91 DISPLAY "FILE PROCESSING ERROR" UPON TYPEWRITER. 73 92 DISPLAY DISP-RECORD UPON TYPEWRITER. 74 93 CLOSE INPUT-FILE 94 OUTPUT-FILE. 75 95 STOP RUN. 96 ERROR-OUT-2. 97 EXIT. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 16 MSGID: LBL 65 SEVERITY: SEQNBR: 17 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. 22 MSGID: LBL 65 SEVERITY: SEQNBR: 23 Message . . . . : Blocking/Deblocking for file 'OUTPUT-FILE' will be performed by compiler-generated code. 43 MSGID: LBL 335 SEVERITY: SEQNBR: 54 Message . . . . : Empty paragraph or section precedes 'END DECLARATIVES' paragraph or section. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 3 3 Source records read . . . . . . . . : 97 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program CRTSEQ created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
Figure 112 (Part 2 of 2). Example of a Sequential File of Employee Salary Records
353
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. UPDTSEQ. 3 3 ENVIRONMENT DIVISION. 4 4 CONFIGURATION SECTION. 5 5 SOURCE-COMPUTER. IBM-AS4 . 6 6 OBJECT-COMPUTER. IBM-AS4 . 7 7 INPUT-OUTPUT SECTION. 8 8 FILE-CONTROL. 9 9 SELECT INPUT-FILE ASSIGN TO DISK-FILES 1 1 FILE STATUS IS INPUT-FILE-STATUS. A 11 11 SELECT MASTER-FILE ASSIGN TO DISK-MSTFILEB 12 12 FILE STATUS IS MASTER-FILE-STATUS. B 13 13 14 DATA DIVISION. 14 15 FILE SECTION. 15 16 FD INPUT-FILE LABEL RECORDS STANDARD. 16 17 1 INPUT-RECORD. 17 18 5 INPUT-EMPLOYEE-NUMBER PICTURE 9(6). 18 19 5 INPUT-EMPLOYEE-NAME PICTURE X(28). 19 2 5 INPUT-EMPLOYEE-CODE PICTURE 9. 2 21 5 INPUT-EMPLOYEE-SALARY PICTURE 9(6)V99. 21 22 FD MASTER-FILE LABEL RECORDS STANDARD. 22 23 1 MASTER-RECORD. 23 24 5 MST-EMPLOYEE-NUMBER PICTURE 9(6). 24 25 5 MST-EMPLOYEE-NAME PICTURE X(28). 25 26 5 MST-EMPLOYEE-CODE PICTURE 9. 26 27 5 MST-EMPLOYEE-SALARY PICTURE 9(6)V99. 27 28 WORKING-STORAGE SECTION. 28 29 77 INPUT-FILE-STATUS PICTURE XX. 29 3 77 MASTER-FILE-STATUS PICTURE XX. 3 31 1 INPUTEND PICTURE X VALUE SPACE. 31 32 88 THE-END-OF-INPUT VALUE "E". 32 33 1 MASTEREND PICTURE X VALUE SPACE. 33 34 88 THE-END-OF-MASTER VALUE "E". 34 35 1 ERROR-INFO. 35 36 5 OP-NAME PICTURE X(12). 36 37 5 FILLER PICTURE XX VALUE SPACE. 37 38 5 FILE-NAME PICTURE X(11). 38 39 5 FILLER PICTURE XX VALUE SPACE. 39 4 5 FILLER PICTURE X(14) 4 41 VALUE "FILE STATUS IS". 41 42 5 FILLER PICTURE XX VALUE SPACE. 42 43 5 SK PICTURE XX. 43 44 PROCEDURE DIVISION. 45 DECLARATIVES. 46 INPUT-FILE-ERROR SECTION. 47 USE AFTER STANDARD ERROR PROCEDURE ON INPUT-FILE. C 48 INPUT-FILE-ERROR-PARA. 44 49 MOVE INPUT-FILE-STATUS TO SK. 45 5 MOVE "INPUT-FILE" TO FILE-NAME. 46 51 DISPLAY "FILE PROCESSING ERROR". 47 52 DISPLAY ERROR-INFO. 48 53 DISPLAY "PROCESSING TERMINATED DUE TO I-O ERROR". 49 54 STOP RUN. 55 I-O-FILE-ERROR SECTION. 56 USE AFTER STANDARD ERROR PROCEDURE ON MASTER-FILE. D 57 MASTER-FILE-ERROR-PARA. 5 58 MOVE MASTER-FILE-STATUS TO SK. 51 59 MOVE "MASTER-FILE" TO FILE-NAME. 52 6 DISPLAY "FILE PROCESSING ERROR". 53 61 DISPLAY ERROR-INFO. 54 62 DISPLAY "PROCESSING TERMINATED DUE TO I-O ERROR". 55 63 STOP RUN. 64 END DECLARATIVES. 65 MAIN-PROGRAM SECTION. 66 OPEN-FILES. 56 67 MOVE "OPEN" TO OP-NAME. 57 68 OPEN INPUT INPUT-FILE 69 I-O MASTER-FILE. 7 PROCESSING-LOGIC. 58 71 PERFORM READ-INPUT-FILE. 59 72 PERFORM READ-MASTER-FILE. 6 73 PERFORM PROCESS-FILES UNTIL THE-END-OF-INPUT.
COPYNAME
CHG DATE
5/24/94 5/24/94
354
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 74 CLOSE-FILES. 61 75 MOVE "CLOSE" TO OP-NAME. 62 76 CLOSE MASTER-FILE 77 INPUT-FILE. 63 78 STOP RUN. 79 READ-INPUT-FILE. 64 8 MOVE "READ" TO OP-NAME. 65 81 READ INPUT-FILE 66 82 AT END SET THE-END-OF-INPUT TO TRUE. 83 READ-MASTER-FILE. 67 84 MOVE "READ" TO OP-NAME. 68 85 READ MASTER-FILE 86 AT END 69 87 SET THE-END-OF-MASTER TO TRUE 7 88 MOVE "AT END CLOSE" TO OP-NAME 71 89 CLOSE MASTER-FILE 72 9 MOVE "OPEN EXTEND" TO OP-NAME 73 91 OPEN EXTEND MASTER-FILE. 92 PROCESS-FILES. 74 93 IF THE-END-OF-MASTER 75 94 WRITE MASTER-RECORD FROM INPUT-RECORD 76 95 PERFORM READ-INPUT-FILE 96 ELSE 77 97 IF MST-EMPLOYEE-NUMBER LESS THAN INPUT-EMPLOYEE-NUMBER 78 98 PERFORM READ-MASTER-FILE 99 ELSE 79 1 IF MST-EMPLOYEE-NUMBER = INPUT-EMPLOYEE-NUMBER 8 1 1 MOVE "REWRITE" TO OP-NAME 81 1 2 REWRITE MASTER-RECORD FROM INPUT-RECORD 82 1 3 PERFORM READ-INPUT-FILE 83 1 4 PERFORM READ-MASTER-FILE 1 5 ELSE 84 1 6 DISPLAY "ERROR RECORD -> ", INPUT-EMPLOYEE-NUMBER 85 1 7 PERFORM READ-INPUT-FILE. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 15 MSGID: LBL 65 SEVERITY: SEQNBR: 16 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 1 7 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program UPDTSEQ created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
The example in Figure 113 on page 354 includes: A B C D A FILE STATUS clause so that the program records the status of the most recent I/O request involving INPUT-FILE. A FILE STATUS clause so that the program records the status of the most recent I/O request involving MASTER-FILE. A USE procedure that is run when an I/O error occurs during the processing of INPUT-FILE. A USE procedure that is run when an I/O error occurs during the processing of MASTER-FILE.
File status values and USE procedures play important roles in error handling. For more information, see Chapter 6, COBOL/400 Exception and Error Handling.
355
COPYNAME
CHG DATE
5/24/94 5/24/94
356
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 5 62 MOVE "CLOSE" TO OP-NAME. 51 63 CLOSE INPUT-FILE 64 INDEXED-FILE. 52 65 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 54 66 STOP RUN. 67 LOAD-INDEXED-FILE. 55 68 MOVE INPUT-KEY TO INDEX-KEY. 56 69 MOVE INPUT-NAME TO INDEX-NAME. 57 7 MOVE INPUT-BAL TO INDEX-BAL. 58 71 MOVE SPACES TO INDEX-FLD1. 59 72 MOVE "WRITE" TO OP-NAME. 6 73 WRITE INDEX-RECORD 74 INVALID KEY 61 75 DISPLAY "WRITE FAILED FOR KEY ", INDEX-KEY. 62 76 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 77 READ-INPUT-FILE. 64 78 MOVE "READ" TO OP-NAME. 65 79 READ INPUT-FILE 66 8 AT END SET THE-END-OF-INPUT TO TRUE. 67 81 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 82 ERROR-TERMINATION. 69 83 DISPLAY "I-O ERROR OCCURRED - PROCESS TERMINATING". 7 84 STOP RUN. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 18 MSGID: LBL 65 SEVERITY: SEQNBR: 19 Message . . . . : Blocking/Deblocking for file 'INDEXED-FILE' will be performed by compiler-generated code. 24 MSGID: LBL 65 SEVERITY: SEQNBR: 25 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 2 2 Source records read . . . . . . . . : 84 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program CRTIND created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
357
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. UPDTIND. 3 3 4 ENVIRONMENT DIVISION. 4 5 CONFIGURATION SECTION. 5 6 SOURCE-COMPUTER. IBM-AS4 . 6 7 OBJECT-COMPUTER. IBM-AS4 . 7 8 INPUT-OUTPUT SECTION. 8 9 FILE-CONTROL. 9 1 SELECT MASTER-FILE ASSIGN TO DISK-INDXFILE 1 11 ORGANIZATION IS INDEXED 11 12 ACCESS IS DYNAMIC 12 13 RECORD KEY IS MASTER-KEY 13 14 FILE STATUS IS MASTER-FILE-STATUS. 14 15 SELECT INPUT-FILE ASSIGN TO DISK-FILEH 15 16 FILE STATUS IS INPUT-FILE-STATUS. 16 17 SELECT PRINT-FILE ASSIGN TO PRINTER-QSYSPRT 17 18 FILE STATUS IS PRINT-FILE-STATUS. 18 19 DATA DIVISION. 19 2 FILE SECTION. 2 21 FD MASTER-FILE LABEL RECORDS STANDARD. 21 22 1 MASTER-RECORD. 22 23 5 MASTER-KEY. 23 24 1 MASTER-GEN-FLD PICTURE X(5). 24 25 1 MASTER-DET-FLD PICTURE X(5). 25 26 5 MASTER-FLD1 PICTURE X(1 ). 26 27 5 MASTER-NAME PICTURE X(2 ). 27 28 5 MASTER-BAL PICTURE S9(5)V99. 28 29 FD INPUT-FILE LABEL RECORDS STANDARD. 29 3 1 INPUT-REC. 3 31 5 INPUT-KEY. 31 32 1 INPUT-GEN-FLD PICTURE X(5). 32 33 1 INPUT-DET-FLD PICTURE X(5). 33 34 5 INPUT-NAME PICTURE X(2 ). 34 35 5 INPUT-AMT PICTURE S9(5)V99. 35 36 FD PRINT-FILE LABEL RECORDS OMITTED 36 37 LINAGE 12 LINES FOOTING AT 9. 37 38 1 PRINT-RECORD-1. 38 39 5 PRINT-KEY PICTURE X(1 ). 39 4 5 FILLER PICTURE X(5). 4 41 5 PRINT-NAME PICTURE X(2 ). 41 42 5 FILLER PICTURE X(5). 42 43 5 PRINT-BAL PICTURE $$$,$$9.99-. 43 44 5 FILLER PICTURE X(7). 44 45 5 PRINT-AMT PICTURE $$$,$$9.99-. 45 46 5 FILLER PICTURE X(5). 46 47 5 PRINT-NEW-BAL PICTURE $$$,$$9.99-. 47 48 1 PRINT-RECORD-2 PICTURE X(89). 48 49 WORKING-STORAGE SECTION. 49 5 77 MASTER-FILE-STATUS PICTURE XX. 5 51 77 INPUT-FILE-STATUS PICTURE XX. 51 52 77 PRINT-FILE-STATUS PICTURE XX. 52 53 77 LINES-TO-FOOT PICTURE 99. 53 54 1 PAGE-HEAD. 54 55 5 FILLER PICTURE X(38) VALUE SPACES. 55 56 5 FILLER PICTURE X(13) VALUE "UPDATE REPORT". 56 57 5 FILLER PICTURE X(38) VALUE SPACES. 57 58 1 COLUMN-HEAD. 58 59 5 FILLER PICTURE X(6) VALUE "KEY ID". 59 6 5 FILLER PICTURE X(9) VALUE SPACES. 6 61 5 FILLER PICTURE X(4) VALUE "NAME". 61 62 5 FILLER PICTURE X(21) VALUE SPACES. 62 63 5 FILLER PICTURE X(11) VALUE "CUR BALANCE". 63 64 5 FILLER PICTURE X(6) VALUE SPACES. 64 65 5 FILLER PICTURE X(13) VALUE "UPDATE AMOUNT". 65 66 5 FILLER PICTURE X(4) VALUE SPACES. 66 67 5 FILLER PICTURE X(11) VALUE "NEW BALANCE". 67 68 5 FILLER PICTURE X(4) VALUE SPACES. 68 69 1 PAGE-FOOT. 69 7 5 FILLER PICTURE X(81) VALUE SPACES. 7 71 5 FILLER PICTURE A(6) VALUE "PAGE ". 71 72 5 PG-NUMBER PICTURE 99 VALUE . 73 72 74 1 INPUTEND PICTURE X VALUE SPACE. 73 75 88 THE-END-OF-INPUT VALUE "E".
COPYNAME
CHG DATE
5/24/94 5/24/94
358
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 74 76 1 ERRORFLAG PICTURE X VALUE SPACE. 75 77 88 ERROR-OCCURRED VALUE "1". 76 78 1 ERROR-DATA. 77 79 5 FILLER PICTURE X(21) 78 8 VALUE "STATEMENT FAILING IS ". 79 81 5 OP-NAME PICTURE X(9). 8 82 5 FILLER PICTURE X(16) 81 83 VALUE "FILE STATUS IS". 82 84 5 STATUS-VALUE PICTURE XX. 83 85 1 INPUT-MESSAGE. 84 86 5 FILLER PICTURE X(3 ) 85 87 VALUE "UNEXPECTED ERROR ON INPUT-FILE" . 86 88 1 I-O-MESSAGE. 87 89 5 FILLER PICTURE X(31) 88 9 VALUE "UNEXPECTED ERROR ON MASTER-FILE" . 89 91 1 OUTPUT-MESSAGE. 9 92 5 FILLER PICTURE X(3 ) 91 93 VALUE "UNEXPECTED ERROR ON PRINT-FILE" . 92 94 PROCEDURE DIVISION. 95 DECLARATIVES. 96 INPUT-ERROR SECTION. 97 USE AFTER STANDARD ERROR PROCEDURE ON INPUT. 98 INPUT-ERROR-PARA. 93 99 DISPLAY INPUT-MESSAGE. 94 1 MOVE INPUT-FILE-STATUS TO STATUS-VALUE. 95 1 1 DISPLAY ERROR-DATA. 96 1 2 SET ERROR-OCCURRED TO TRUE. 1 3 I-O-ERROR SECTION. 1 4 USE AFTER STANDARD ERROR PROCEDURE ON I-O. 1 5 I-O-ERROR-PARA. 97 1 6 DISPLAY I-O-MESSAGE. 98 1 7 MOVE MASTER-FILE-STATUS TO STATUS-VALUE. 99 1 8 DISPLAY ERROR-DATA. 1 1 9 SET ERROR-OCCURRED TO TRUE. 11 OUTPUT-ERROR SECTION. 111 USE AFTER STANDARD ERROR PROCEDURE ON OUTPUT. 112 OUTPUT-ERROR-PARA. 1 1 113 DISPLAY OUTPUT-MESSAGE. 1 2 114 MOVE PRINT-FILE-STATUS TO STATUS-VALUE. 1 3 115 DISPLAY ERROR-DATA. 1 4 116 SET ERROR-OCCURRED TO TRUE. 117 END DECLARATIVES. 118 MAIN-PROCESSING SECTION. 119 MAIN-PROCEDURE. 1 5 12 MOVE "OPEN" TO OP-NAME. 1 6 121 OPEN INPUT INPUT-FILE 122 I-O MASTER-FILE 123 OUTPUT PRINT-FILE. 1 7 124 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 1 9 125 PERFORM PAGE-START. 11 126 PERFORM READ-INPUT-FILE. 111 127 PERFORM PROCESS-DATA THRU READ-INPUT-FILE 128 UNTIL THE-END-OF-INPUT. 112 129 PERFORM PAGE-END. 113 13 MOVE "CLOSE" TO OP-NAME. 114 131 CLOSE INPUT-FILE 132 MASTER-FILE 133 PRINT-FILE. 115 134 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 117 135 STOP RUN. 136 137 PROCESS-DATA. 118 138 IF INPUT-DET-FLD EQUAL SPACES 119 139 PERFORM INIT-SEQUENTIAL-PROCESS 14 ELSE 12 141 PERFORM DYNAMIC-PROCESS. 142 READ-INPUT-FILE. 121 143 MOVE "READ" TO OP-NAME. 122 144 READ INPUT-FILE 123 145 AT END SET THE-END-OF-INPUT TO TRUE. 124 146 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 147 148 INIT-SEQUENTIAL-PROCESS.
COPYNAME
CHG DATE
359
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 126 149 MOVE INPUT-GEN-FLD TO MASTER-GEN-FLD. 127 15 MOVE "START" TO OP-NAME. 128 151 START MASTER-FILE 152 KEY IS NOT LESS THAN MASTER-GEN-FLD 153 INVALID KEY 129 154 DISPLAY "MASTER-FILE START FAILED: INVALID KEY ", 155 MASTER-GEN-FLD 13 156 MOVE HIGH-VALUE TO MASTER-GEN-FLD. 131 157 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 133 158 PERFORM SEQUENTIAL-PROCESS 159 UNTIL INPUT-GEN-FLD NOT EQUAL MASTER-GEN-FLD. 16 161 SEQUENTIAL-PROCESS. 134 162 MOVE "READ NEXT" TO OP-NAME. 135 163 READ MASTER-FILE NEXT RECORD 136 164 AT END MOVE HIGH-VALUE TO MASTER-GEN-FLD. 137 165 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 139 166 IF INPUT-GEN-FLD EQUAL MASTER-GEN-FLD 14 167 MOVE MASTER-KEY TO PRINT-KEY 141 168 MOVE MASTER-NAME TO PRINT-NAME 142 169 MOVE MASTER-BAL TO PRINT-NEW-BAL 143 17 PERFORM PRINT-DETAIL. 171 172 DYNAMIC-PROCESS. 144 173 MOVE INPUT-KEY TO MASTER-KEY. 145 174 MOVE "READ" TO OP-NAME. 146 175 READ MASTER-FILE 176 INVALID KEY 147 177 DISPLAY "MASTER-FILE READ FAILED: INVALID KEY ", 178 MASTER-KEY 148 179 MOVE HIGH-VALUE TO MASTER-GEN-FLD. 149 18 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 151 181 IF INPUT-GEN-FLD EQUAL MASTER-GEN-FLD 152 182 MOVE MASTER-KEY TO PRINT-KEY 153 183 MOVE MASTER-NAME TO PRINT-NAME 154 184 MOVE MASTER-BAL TO PRINT-BAL 155 185 MOVE INPUT-AMT TO PRINT-AMT 156 186 ADD INPUT-AMT TO MASTER-BAL 157 187 MOVE MASTER-BAL TO PRINT-NEW-BAL 158 188 PERFORM PRINT-DETAIL 159 189 MOVE "REWRITE" TO OP-NAME 16 19 REWRITE MASTER-RECORD 191 INVALID KEY 161 192 DISPLAY "MASTER-FILE REWRITE FAILED: INVALID KEY ", 193 MASTER-KEY 162 194 MOVE HIGH-VALUE TO MASTER-GEN-FLD. 163 195 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 196 PRINT-DETAIL. 165 197 MOVE "WRITE" TO OP-NAME. 166 198 WRITE PRINT-RECORD-1 199 AT END-OF-PAGE 167 2 PERFORM PAGE-END THROUGH PAGE-START. 168 2 1 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 17 2 2 MOVE SPACES TO PRINT-RECORD-1. 2 3 2 4 PAGE-END. 171 2 5 MOVE "WRITE" TO OP-NAME. 172 2 6 ADD 1 TO PG-NUMBER. 173 2 7 SUBTRACT LINAGE-COUNTER OF PRINT-FILE FROM 12 2 8 GIVING LINES-TO-FOOT. 174 2 9 MOVE SPACES TO PRINT-RECORD-1. 175 21 WRITE PRINT-RECORD-1 211 AFTER ADVANCING LINES-TO-FOOT. 176 212 WRITE PRINT-RECORD-2 FROM PAGE-FOOT 213 BEFORE ADVANCING PAGE. 177 214 IF ERROR-OCCURRED GO TO ERROR-TERMINATION.
COPYNAME
CHG DATE
360
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 215 PAGE-START. 179 216 WRITE PRINT-RECORD-2 FROM PAGE-HEAD 217 AFTER ADVANCING LINES. 18 218 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 182 219 MOVE SPACES TO PRINT-RECORD-2. 183 22 WRITE PRINT-RECORD-2 FROM COLUMN-HEAD 221 AFTER ADVANCING 1 LINE. 184 222 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 186 223 MOVE SPACES TO PRINT-RECORD-2. 224 ERROR-TERMINATION. 187 225 DISPLAY "PROCESS TERMINATING ABNORMALLY". 188 226 STOP RUN. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 28 MSGID: LBL 65 SEVERITY: SEQNBR: 29 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 226 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program UPDTIND created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
361
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. CRTREL. 3 3 4 ENVIRONMENT DIVISION. 4 5 CONFIGURATION SECTION. 5 6 SOURCE-COMPUTER. IBM-AS4 . 6 7 OBJECT-COMPUTER. IBM-AS4 . 7 8 SPECIAL-NAMES. REQUESTOR IS REQUESTOR. 8 9 FILE-CONTROL. 9 1 SELECT RELATIVE-FILE ASSIGN TO DISK-FILED 1 11 ORGANIZATION IS RELATIVE 11 12 ACCESS IS SEQUENTIAL 12 13 FILE STATUS RELATIVE-FILE-STATUS. 13 14 SELECT INPUT-FILE ASSIGN TO DISK-FILEC 14 15 FILE STATUS INPUT-FILE-STATUS. 16 15 17 DATA DIVISION. 16 18 FILE SECTION. 17 19 FD RELATIVE-FILE LABEL RECORDS ARE STANDARD. 18 2 1 RELATIVE-RECORD- 1. 19 21 5 RELATIVE-RECORD OCCURS 5 TIMES INDEXED BY REL-INDEX. 2 22 1 RELATIVE-YEAR PICTURE 99. 21 23 1 RELATIVE-WEEK PICTURE 99. 22 24 1 RELATIVE-UNIT-SALES PICTURE S9(6). 23 25 1 RELATIVE-DOLLAR-SALES PICTURE S9(9)V99. 24 26 FD INPUT-FILE LABEL RECORDS STANDARD. 25 27 1 INPUT-RECORD. 26 28 5 INPUT-YEAR PICTURE 99. 27 29 5 INPUT-WEEK PICTURE 99. 28 3 5 INPUT-UNIT-SALES PICTURE S9(6). 29 31 5 INPUT-DOLLAR-SALES PICTURE S9(9)V99. 3 32 WORKING-STORAGE SECTION. 31 33 77 INPUT-FILE-STATUS PICTURE XX. 32 34 77 RELATIVE-FILE-STATUS PICTURE XX. 33 35 1 WORK-RECORD. 34 36 5 WORK-YEAR PICTURE 99 VALUE . 35 37 5 WORK-WEEK PICTURE 99. 36 38 5 WORK-UNIT-SALES PICTURE S9(6). 37 39 5 WORK-DOLLAR-SALES PICTURE S9(9)V99. 38 4 1 ERROR-INFO. 39 41 5 OP-NAME PICTURE X(5). 4 42 5 FILLER PICTURE X(1 ) 41 43 VALUE " ERROR ON ". 42 44 5 FILE-NAME PICTURE X(13). 43 45 5 FILLER PICTURE X(16) 44 46 VALUE " FILE STATUS IS ". 45 47 5 STATUS-VALUE PICTURE XX. 46 48 1 ERROR-FLAG PICTURE X VALUE SPACE. 47 49 88 ERROR-OCCURRED VALUE "1". 48 5 1 INPUTEND PICTURE X VALUE SPACE. 49 51 88 THE-END-OF-INPUT VALUE "E". 52 5 53 PROCEDURE DIVISION. 54 DECLARATIVES. 55 56 INP-FILE-ERROR SECTION. 57 USE AFTER STANDARD ERROR PROCEDURE ON INPUT-FILE. 58 INPUT-FILE-ERROR. 51 59 MOVE "INPUT-FILE" TO FILE-NAME. 52 6 MOVE INPUT-FILE-STATUS TO STATUS-VALUE. 53 61 SET ERROR-OCCURRED TO TRUE. 62 REL-FILE-ERROR SECTION. 63 USE AFTER STANDARD ERROR PROCEDURE ON RELATIVE-FILE. 64 RELATIVE-FILE-ERROR. 54 65 MOVE "RELATIVE-FILE" TO FILE-NAME. 55 66 MOVE RELATIVE-FILE-STATUS TO STATUS-VALUE. 56 67 SET ERROR-OCCURRED TO TRUE. 68 END DECLARATIVES. 69 BEGIN-PROCESSING SECTION. 7 PROCESSING-CONTROL. 57 71 MOVE "OPEN" TO OP-NAME. 58 72 OPEN INPUT INPUT-FILE 73 OUTPUT RELATIVE-FILE. 59 74 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 61 75 SET REL-INDEX TO 1. 62 76 PERFORM READ-INPUT-FILE.
COPYNAME
CHG DATE
5/24/94 5/24/94
362
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 63 77 PERFORM PROCESS-DATA THRU READ-INPUT-FILE 78 UNTIL THE-END-OF-INPUT. 64 79 CLOSE RELATIVE-FILE INPUT-FILE. 65 8 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 67 81 STOP RUN. 82 ERROR-TERMINATION. 68 83 DISPLAY ERROR-INFO UPON REQUESTOR. 69 84 DISPLAY "PROCESSING TERMINATED DUE TO I-O ERROR" 85 UPON REQUESTOR. 7 86 STOP RUN. 87 PROCESS-DATA. 71 88 MOVE INPUT-RECORD TO RELATIVE-RECORD (REL-INDEX). 72 89 IF REL-INDEX NOT = 5 73 9 SET REL-INDEX UP BY 1 91 ELSE 74 92 SET REL-INDEX TO 1 75 93 PERFORM RELATIVE-FILE-WRITE. 94 READ-INPUT-FILE. 76 95 MOVE "READ" TO OP-NAME. 77 96 READ INPUT-FILE 78 97 AT END SET THE-END-OF-INPUT TO TRUE. 79 98 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. 99 RELATIVE-FILE-WRITE. 81 1 MOVE "WRITE" TO OP-NAME. 82 1 1 WRITE RELATIVE-RECORD- 1. 83 1 2 IF ERROR-OCCURRED GO TO ERROR-TERMINATION. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT MSGID: LBL 27 SEVERITY: 1 SEQNBR: Message . . . . : I-O SECTION not found. Assumed present 17 MSGID: LBL 65 SEVERITY: SEQNBR: 19 Message . . . . : Blocking/Deblocking for file 'RELATIVE-FILE' will be performed by compiler-generated code. 24 MSGID: LBL 65 SEVERITY: SEQNBR: 26 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 3 2 1 Source records read . . . . . . . . : 1 2 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : 1 LBL 9 1 Program CRTREL created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
363
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. UPDTREL. 3 3 4 ENVIRONMENT DIVISION. 4 5 CONFIGURATION SECTION. 5 6 SOURCE-COMPUTER. IBM-AS4 . 6 7 OBJECT-COMPUTER. IBM-AS4 . 7 8 INPUT-OUTPUT SECTION. 8 9 FILE-CONTROL. 9 1 SELECT RELATIVE-FILE ASSIGN TO DISK-FILED 1 11 ORGANIZATION IS RELATIVE 11 12 ACCESS IS SEQUENTIAL 12 13 RELATIVE KEY INPUT-WEEK 13 14 FILE STATUS STATUS-VALUE. 14 15 SELECT INPUT-FILE ASSIGN TO DISK-FILES2 15 16 FILE STATUS STATUS-VALUE. 17 16 18 DATA DIVISION. 17 19 FILE SECTION. 18 2 FD RELATIVE-FILE LABEL RECORDS STANDARD. 19 21 1 RELATIVE-RECORD PICTURE X(1 5). 2 22 FD INPUT-FILE LABEL RECORDS STANDARD. 21 23 1 INPUT-RECORD. 22 24 5 INPUT-YEAR PICTURE 99. 23 25 5 INPUT-WEEK PICTURE 99. 24 26 5 INPUT-UNIT-SALES PICTURE S9(6). 25 27 5 INPUT-DOLLAR-SALES PICTURE S9(9)V99. 26 28 WORKING-STORAGE SECTION. 29 27 3 1 INPUTEND PICTURE X VALUE SPACE. 28 31 88 THE-END-OF-INPUT VALUE "E". 29 32 1 WORK-RECORD. 3 33 5 FILLER PICTURE X(21). 31 34 5 CURRENT-WORK-YEARS PICTURE X(84). 32 35 5 NEW-WORK-YEAR. 33 36 1 WORK-YEAR PICTURE 99. 34 37 1 WORK-WEEK PICTURE 99. 35 38 1 WORK-UNIT-SALES PICTURE S9(6). 36 39 1 WORK-DOLLAR-SALES PICTURE S9(9)V99. 37 4 66 WORK-OUT-RECORD RENAMES 38 41 CURRENT-WORK-YEARS THROUGH NEW-WORK-YEAR. 39 42 1 ERROR-MESSAGE. 4 43 5 OP-NAME PICTURE X(7). 41 44 5 FILLER PICTURE X(1 ) 42 45 VALUE " ERROR ON ". 43 46 5 FILE-NAME PICTURE X(13). 44 47 5 FILLER PICTURE X(16) 45 48 VALUE " FILE STATUS IS ". 46 49 5 STATUS-VALUE PICTURE X(2). 5 47 51 PROCEDURE DIVISION. 52 DECLARATIVES. 53 I-O-ERROR SECTION. 54 USE AFTER STANDARD ERROR PROCEDURE ON RELATIVE-FILE, 55 INPUT-FILE. 56 ERROR-PROCEDURE. 48 57 DISPLAY ERROR-MESSAGE. 49 58 DISPLAY "PROCESSING TERMINATING". 5 59 STOP RUN. 6 END DECLARATIVES. 61 MAIN-PROCEDURE SECTION. 62 BEGIN-PROCESSING. 51 63 MOVE "OPEN" TO OP-NAME. 52 64 MOVE "INPUT-FILE" TO FILE-NAME. 53 65 OPEN INPUT INPUT-FILE. 54 66 MOVE "RELATIVE-FILE" TO FILE-NAME. 55 67 OPEN I-O RELATIVE-FILE. 56 68 PERFORM READ-FILES. 57 69 PERFORM UPDATE-RELATIVE-FILE THRU READ-FILES 7 UNTIL THE-END-OF-INPUT. 58 71 MOVE "CLOSE" TO OP-NAME. 59 72 MOVE "INPUT-FILE" TO FILE-NAME. 6 73 CLOSE INPUT-FILE. 61 74 MOVE "RELATIVE-FILE" TO FILE-NAME. 62 75 CLOSE RELATIVE-FILE. 63 76 STOP RUN.
COPYNAME
CHG DATE
5/24/94 5/24/94
364
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 77 UPDATE-RELATIVE-FILE. 64 78 MOVE "REWRITE" TO OP-NAME. 65 79 MOVE "RELATIVE-FILE" TO FILE-NAME. 66 8 REWRITE RELATIVE-RECORD FROM WORK-OUT-RECORD. 81 READ-FILES. 67 82 MOVE "READ" TO OP-NAME. 68 83 MOVE "RELATIVE-FILE" TO FILE-NAME. 69 84 READ RELATIVE-FILE INTO WORK-RECORD 7 85 AT END SET THE-END-OF-INPUT TO TRUE. 71 86 MOVE "INPUT-FILE" TO FILE-NAME. 72 87 READ INPUT-FILE INTO NEW-WORK-YEAR 73 88 AT END SET THE-END-OF-INPUT TO TRUE. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 2 MSGID: LBL 65 SEVERITY: SEQNBR: 22 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 88 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program UPDTREL created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
365
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. RTRVREL. 3 3 4 ENVIRONMENT DIVISION. 4 5 CONFIGURATION SECTION. 5 6 SOURCE-COMPUTER. IBM-AS4 . 6 7 OBJECT-COMPUTER. IBM-AS4 . 7 8 SPECIAL-NAMES. REQUESTOR IS REQUESTOR. 8 9 INPUT-OUTPUT SECTION. 9 1 FILE-CONTROL. 1 11 SELECT RELATIVE-FILE ASSIGN TO DISK-FILED 11 12 ORGANIZATION IS RELATIVE 12 13 ACCESS IS DYNAMIC 13 14 RELATIVE KEY INPUT-WEEK 14 15 FILE STATUS IS RELATIVE-FILE-STATUS. 15 16 SELECT INPUT-FILE ASSIGN TO DISK-FILEF 16 17 FILE STATUS IS INPUT-FILE-STATUS. 17 18 SELECT PRINT-FILE ASSIGN TO PRINTER-QSYSPRT 18 19 FILE STATUS IS PRINT-FILE-STATUS. 2 19 21 DATA DIVISION. 2 22 FILE SECTION. 21 23 FD RELATIVE-FILE LABEL RECORDS STANDARD. 22 24 1 RELATIVE-RECORD- 1. 23 25 5 RELATIVE-RECORD OCCURS 5 TIMES INDEXED BY REL-INDEX. 24 26 1 RELATIVE-YEAR PICTURE 99. 25 27 1 RELATIVE-WEEK PICTURE 99. 26 28 1 RELATIVE-UNIT-SALES PICTURE S9(6). 27 29 1 RELATIVE-DOLLAR-SALES PICTURE S9(9)V99. 28 3 FD INPUT-FILE LABEL RECORDS STANDARD. 29 31 1 INPUT-RECORD. 3 32 5 INPUT-WEEK PICTURE 99. 31 33 5 END-WEEK PICTURE 99. 32 34 FD PRINT-FILE LABEL RECORDS OMITTED. 33 35 1 PRINT-RECORD. 34 36 5 PRINT-WEEK PICTURE 99. 35 37 5 FILLER PICTURE X(5). 36 38 5 PRINT-YEAR PICTURE 99. 37 39 5 FILLER PICTURE X(5). 38 4 5 PRINT-UNIT-SALES PICTURE ZZZ,ZZ9. 39 41 5 FILLER PICTURE X(5). 4 42 5 PRINT-DOLLAR-SALES PICTURE $$$$,$$$,$$$.99. 41 43 WORKING-STORAGE SECTION. 42 44 77 RELATIVE-FILE-STATUS PICTURE XX. 43 45 77 INPUT-FILE-STATUS PICTURE XX. 44 46 77 PRINT-FILE-STATUS PICTURE XX. 45 47 77 HIGH-WEEK PICTURE 99 VALUE 53. 46 48 77 OP-NAME PICTURE X(9). 47 49 1 INPUTEND PICTURE X(9). 48 5 88 THE-END-OF-INPUT VALUE "E". 49 51 PROCEDURE DIVISION. 52 DECLARATIVES. 53 RELATIVE-FILE-ERROR SECTION. 54 USE AFTER STANDARD ERROR PROCEDURE ON RELATIVE-FILE. 55 RELATIVE-ERROR-MSG. 5 56 DISPLAY OP-NAME, " ERROR ON RELATIVE-FILE ". 51 57 DISPLAY "FILE STATUS VALUE IS ", RELATIVE-FILE-STATUS. 52 58 DISPLAY "PROCESSING TERMINATED ". 53 59 STOP RUN. 6 INPUT-FILE-ERROR SECTION. 61 USE AFTER STANDARD ERROR PROCEDURE ON INPUT-FILE. 62 INPUT-ERROR-MSG. 54 63 DISPLAY OP-NAME, " ERROR ON INPUT-FILE ". 55 64 DISPLAY "FILE STATUS VALUE IS ", INPUT-FILE-STATUS. 56 65 DISPLAY "PROCESSING TERMINATED ". 57 66 STOP RUN. 67 PRINT-FILE-ERROR SECTION. 68 USE AFTER STANDARD ERROR PROCEDURE ON PRINT-FILE. 69 PRINT-ERROR-MSG. 58 7 DISPLAY OP-NAME, " ERROR ON PRINT-FILE ". 59 71 DISPLAY "FILE STATUS VALUE IS ", PRINT-FILE-STATUS. 6 72 DISPLAY "PROCESSING TERMINATED ". 61 73 STOP RUN. 74 END DECLARATIVES.
COPYNAME
CHG DATE
5/24/94 5/24/94
366
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S 75 MAIN-PROCEDURE SECTION. 76 MAIN-PROCESSING. 62 77 MOVE "OPEN" TO OP-NAME. 63 78 OPEN INPUT INPUT-FILE RELATIVE-FILE 79 OUTPUT PRINT-FILE. 64 8 MOVE SPACES TO PRINT-RECORD. 65 81 PERFORM READ-INPUT-FILE. 66 82 PERFORM CONTROL-PROCESS THRU READ-INPUT-FILE 83 UNTIL THE-END-OF-INPUT. 67 84 MOVE "CLOSE" TO OP-NAME. 68 85 CLOSE RELATIVE-FILE 86 INPUT-FILE 87 PRINT-FILE. 69 88 STOP RUN. 89 CONTROL-PROCESS. 7 9 IF (END-WEEK = SPACES OR END-WEEK = ) 71 91 PERFORM RANDOM-PROCESS 92 ELSE 72 93 PERFORM SEQUENTIAL-PROCESS. 94 READ-INPUT-FILE. 73 95 MOVE "READ" TO OP-NAME. 74 96 READ INPUT-FILE 75 97 AT END SET THE-END-OF-INPUT TO TRUE. 98 RANDOM-PROCESS. 76 99 MOVE "READ" TO OP-NAME. 77 1 READ RELATIVE-FILE 78 1 1 INVALID KEY MOVE HIGH-WEEK TO RELATIVE-WEEK(1). 79 1 2 IF RELATIVE-WEEK(1) NOT EQUAL HIGH-WEEK 8 1 3 PERFORM PRINT-SUMMARY VARYING REL-INDEX FROM 1 BY 1 1 4 UNTIL REL-INDEX > 5. 1 5 SEQUENTIAL-PROCESS. 81 1 6 MOVE "READ" TO OP-NAME. 82 1 7 READ RELATIVE-FILE 83 1 8 INVALID KEY MOVE HIGH-WEEK TO RELATIVE-WEEK(1). 84 1 9 PERFORM READ-REL-SEQ 11 UNTIL RELATIVE-WEEK(1) GREATER THAN END-WEEK. 111 112 READ-REL-SEQ. 85 113 PERFORM PRINT-SUMMARY VARYING REL-INDEX FROM 1 BY 1 114 UNTIL REL-INDEX > 5. 86 115 MOVE "READ NEXT" TO OP-NAME. 87 116 READ RELATIVE-FILE NEXT RECORD 88 117 AT END MOVE HIGH-WEEK TO RELATIVE-WEEK(1). 118 PRINT-SUMMARY. 89 119 MOVE RELATIVE-YEAR (REL-INDEX) TO PRINT-YEAR. 9 12 MOVE RELATIVE-WEEK (REL-INDEX) TO PRINT-WEEK. 91 121 MOVE RELATIVE-UNIT-SALES (REL-INDEX) TO PRINT-UNIT-SALES. 92 122 MOVE RELATIVE-DOLLAR-SALES(REL-INDEX) TO PRINT-DOLLAR-SALES. 93 123 MOVE "WRITE" TO OP-NAME. 94 124 WRITE PRINT-RECORD AFTER ADVANCING 2 LINES. E N D O F S O U R C E 5763CB1 V3R M5 AS/4 COBOL Messages STMT 28 MSGID: LBL 65 SEVERITY: SEQNBR: 3 Message . . . . : Blocking/Deblocking for file 'INPUT-FILE' will be performed by compiler-generated code. E N D O F M E S S A G E S Message Summary Total Info( -4) Warning(5-19) Error(2 -29) Severe(3 -39) Terminal(4 -99) 1 1 Source records read . . . . . . . . : 124 Copy records read . . . . . . . . . : Copy members processed . . . . . . : Sequence errors . . . . . . . . . . : Highest severity message issued . . : LBL 9 1 Program RTRVREL created in library XMPLIB. E N D O F C O M P I L A T I O N
COPYNAME
CHG DATE
367
COPYNAME
CHG DATE
368
5763CB1 V3R M5 91 524 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 47 5 FD YTD-SALES-FILE-IN 48 51 LABEL RECORDS STANDARD 49 52 DATA RECORD YTD-SALES-IN. 5 53 1 YTD-SALES-IN. 51 54 5 EMPL-NO PIC 9(6). 52 55 5 DEPT PIC 9(2). 53 56 5 SALES PIC 9(7)V99. 54 57 5 NAME-ADDR PIC X(61). 55 58 5 MONTH PIC X(2). 56 59 FD YTD-SALES-FILE-OUT 57 6 LABEL RECORDS STANDARD 58 61 DATA RECORD YTD-SALES-OUT. 59 62 1 YTD-SALES-OUT. 6 63 5 EMPL-NO PIC 9(6). 61 64 5 DEPT PIC 9(2). 62 65 5 SALES PIC 9(7)V99. 63 66 5 NAME-ADDR PIC X(61). 64 67 5 MONTH PIC X(2). 65 68 FD PRINTER-OUT 66 69 LABEL RECORDS OMITTED 67 7 DATA RECORD PRINT-LINE. 68 71 1 PRINT-LINE. 69 72 5 RECORD-LABEL PIC X(25). 7 73 5 DISK-RECORD-DISPLAY PIC X(8 ). 71 74 WORKING-STORAGE SECTION. 72 75 1 SALES-FILE-IN-EOF-STATUS PIC X VALUE "F". 73 76 88 SALES-FILE-IN-END-OF-FILE VALUE "T". 74 77 1 SALES-FILE-OUT-EOF-STATUS PIC X VALUE "F". 75 78 88 SALES-FILE-OUT-END-OF-FILE VALUE "T". 76 79 1 YTD-SALES-OUT-EOF-STATUS PIC X VALUE "F". 77 8 88 YTD-SALES-OUT-END-OF-FILE VALUE "T". 78 81 PROCEDURE DIVISION. 82 OPEN-PRINTER-FILE SECTION. 83 5-PRINTER-FILE. 79 84 OPEN OUTPUT PRINTER-OUT. 85 LIST-SORT-LIST-CURRENT-SALES SECTION. 86 1 -LIST-SORT-CURRENT-SALES. 8 87 SORT WORK-FILE 88 ON ASCENDING KEY DEPT OF SALES-RECORD 89 ON DESCENDING KEY SALES OF SALES-RECORD 9 INPUT PROCEDURE SCREEN-DEPT 91 GIVING CURRENT-SALES-FILE-OUT. 92 2 -LIST-SORTED-SALES. 81 93 OPEN INPUT CURRENT-SALES-FILE-OUT. 82 94 PERFORM 1 -PRINT-SALES-FILE-OUT 95 THRU 11 -END-PRINT-SALES-FILE-OUT 96 UNTIL SALES-FILE-OUT-END-OF-FILE. 83 97 CLOSE CURRENT-SALES-FILE-OUT. 98 UPDATE-YEARLY-REPORT SECTION. 99 4 -MERGE-CURRENT-PREVIOUS. 84 1 MERGE WORK-FILE 1 1 ON ASCENDING KEY DEPT OF SALES-RECORD 1 2 ON ASCENDING KEY EMPL-NO OF SALES-RECORD 1 3 ON ASCENDING KEY MONTH OF SALES-RECORD 1 4 USING YTD-SALES-FILE-IN 1 5 CURRENT-SALES-FILE-IN 1 6 GIVING YTD-SALES-FILE-OUT. 1 7 4 -PRINT-YTD-SALES-OUT. 85 1 8 OPEN INPUT YTD-SALES-FILE-OUT. 86 1 9 PERFORM 12 -READ-PRINT-YTD-SALES-OUT 11 UNTIL YTD-SALES-OUT-END-OF-FILE. 87 111 CLOSE YTD-SALES-FILE-OUT 112 PRINTER-OUT. 88 113 STOP RUN. 114 SCREEN-DEPT SECTION. 115 6 -S-D-1. 89 116 OPEN INPUT CURRENT-SALES-FILE-IN 9 117 PERFORM 7 -READ-SELECT-DEPT THRU 8 -END-READ-SELECT-DEPT 118 UNTIL SALES-FILE-IN-END-OF-FILE. 91 119 CLOSE CURRENT-SALES-FILE-IN. 92 12 GO TO 9 -END-S-D-1. 121 7 -READ-SELECT-DEPT. 93 122 READ CURRENT-SALES-FILE-IN 94 123 AT END MOVE "T" TO SALES-FILE-IN-EOF-STATUS 95 124 GO TO 8 -END-READ-SELECT-DEPT.
COPYNAME
CHG DATE
369
5763CB1 V3R M5 91 524 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 96 125 MOVE "UNSORTED CURRENT SALES ", 126 TO RECORD-LABEL OF PRINT-LINE. 97 127 MOVE CURRENT-SALES-IN TO DISK-RECORD-DISPLAY. 98 128 WRITE PRINT-LINE. 99 129 IF ON-SITE-EMPLOYEE 1 13 MOVE CURRENT-SALES-IN TO SALES-RECORD 1 1 131 RELEASE SALES-RECORD. 132 8 -END-READ-SELECT-DEPT. 133 EXIT. 1 2 134 9 -END-S-D-1. 135 END-SCREEN-DEPT SECTION. 136 1 -PRINT-SALES-FILE-OUT. 1 3 137 READ CURRENT-SALES-FILE-OUT 1 4 138 AT END MOVE "T" TO SALES-FILE-OUT-EOF-STATUS 1 5 139 GO TO 11 -END-PRINT-SALES-FILE-OUT. 1 6 14 MOVE "SORTED CURRENT SALES " 141 TO RECORD-LABEL OF PRINT-LINE. 1 7 142 MOVE CURRENT-SALES-OUT TO DISK-RECORD-DISPLAY. 1 8 143 WRITE PRINT-LINE. 144 11 -END-PRINT-SALES-FILE-OUT. 145 EXIT. 1 9 146 12 -READ-PRINT-YTD-SALES-OUT. 11 147 READ YTD-SALES-FILE-OUT 111 148 AT END MOVE "T" TO YTD-SALES-OUT-EOF-STATUS 112 149 GO TO 13 -END-READ-PRT-YTD-SALES-OUT. 113 15 MOVE "MERGED YTD SALES ", 151 TO RECORD-LABEL OF PRINT-LINE. 114 152 MOVE YTD-SALES-OUT TO DISK-RECORD-DISPLAY. 115 153 WRITE PRINT-LINE. 154 13 -END-READ-PRT-YTD-SALES-OUT. 155 EXIT. E N D O F S O U R C E
COPYNAME
CHG DATE
370
C D E
Previous status code. Beginning of Module Global Table (MGT).3 Last exception code. Invocation number of current program. Qualified program name and library. Beginning of the Program Global Table (PGT).4 Invocation number of the main COBOL program. Job date (YYMMDD). Beginning of user fields. Invalid zoned field printed in hexadecimal.
The Module Global Table (MGT) defines a common area for the module. The table is used to pass information to run-time subroutines. The Program Global Table (PGT) is a communication area for the entire COBOL run unit. There is only one PGT for the run unit.
371
5763CB1 V3R M5 AS/4 COBOL Source STMT SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN 1 1 IDENTIFICATION DIVISION. 2 2 PROGRAM-ID. XMPLDUMP. 3 3 AUTHOR. PROGRAMMER NAME. 4 4 INSTALLATION. COBOL DEVELOPMENT CENTRE. 5 5 DATE-WRITTEN. 11/27/88. 6 6 DATE-COMPILED. 5/24/94 12:21:54. 7 7 ENVIRONMENT DIVISION. 8 8 CONFIGURATION SECTION. 9 9 SOURCE-COMPUTER. IBM-AS4 . 1 1 OBJECT-COMPUTER. IBM-AS4 . 11 11 INPUT-OUTPUT SECTION. 12 12 FILE-CONTROL. 13 13 SELECT FILE-1 ASSIGN TO DISK-SALES. 14 14 DATA DIVISION. 15 15 FILE SECTION. 16 16 FD FILE-1 17 17 LABEL RECORDS ARE STANDARD. 18 18 1 RECORD-1. 19 19 5 R-TYPE PIC X(1). 2 2 5 R-AREA-CODE PIC 9(2). 21 21 88 R-NORTH-EAST VALUES 15 THROUGH 3 . 22 22 5 R-SALES-CAT-1 PIC S9(5)V9(2) COMP-3. 23 23 5 R-SALES-CAT-2 PIC S9(5)V9(2) COMP-3. 24 24 5 FILLER PIC X(1). 25 25 26 WORKING-STORAGE SECTION. 26 27 1 W-SALES-VALUES. 27 28 5 W-CAT-1 PIC S9(8)V9(2). 28 29 5 W-CAT-2 PIC S9(8)V9(2). 29 3 5 W-TOTAL PIC S9(8)V9(2). 31 3 32 1 W-EDIT-VALUES. 31 33 5 FILLER PIC X(8) VALUE "TOTALS: ". 32 34 5 W-EDIT-1 PIC Z(7)9.9(2)-. 33 35 5 FILLER PIC X(3) VALUE SPACES. 34 36 5 W-EDIT-2 PIC Z(7)9.9(2)-. 35 37 5 FILLER PIC X(3) VALUE SPACES. 36 38 5 W-EDIT-TOTAL PIC Z(7)9.9(2)-. 39 37 4 1 END-FLAG PIC X(1) VALUE SPACE. 38 41 88 END-OF-INPUT VALUE "Y". 42 39 43 PROCEDURE DIVISION. 44 45 OPEN THE INPUT FILE, CLEAR TOTALS, CALL MAIN PROCESS THEN 46 DISPLAY THE RESULTS AND END THE RUN. 47 48 P-START. 4 49 OPEN INPUT FILE-1. 41 5 MOVE ZEROS TO W-SALES-VALUES. 42 51 PERFORM P-MAIN UNTIL END-OF-INPUT. 52 43 53 MOVE W-CAT-1 TO W-EDIT-1. 44 54 MOVE W-CAT-2 TO W-EDIT-2. 45 55 MOVE W-TOTAL TO W-EDIT-TOTAL. 46 56 DISPLAY W-EDIT-VALUES. 47 57 STOP RUN. 58 59 6 READ THE INPUT FILE PROCESSING ONLY THOSE RECORDS FOR THE 61 NORTH EAST AREA. WHEN END-OF-INPUT REACHED, SET THE FLAG 62 63 P-MAIN. 48 64 READ FILE-1 AT END SET END-OF-INPUT TO TRUE. 5 65 IF R-NORTH-EAST AND NOT END-OF-INPUT 51 66 ADD R-SALES-CAT-1 TO W-CAT-1, W-TOTAL 52 67 ADD R-SALES-CAT-2 TO W-CAT-2, W-TOTAL. E N D O F S O U R C E MCH12 2 exception in program XMPLDUMP in QTEMP at MI instruction number Last I-O operation was at statement 48. B LBE79 3-Information pertaining to file FILE-1. C LBE79 5-File is open. LBE79 6-Last I-O operation completed for file was READ. LBE79 7-Last file status for file was 4. LBE791 -Last extended file status for file was.
COPYNAME
CHG DATE 3/ 7/94 3/22/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/ 7/94 3/22/94 3/ 7/94 3/ 7/94 3/ 7/94 2/17/94 3/ 7/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 3/ 7/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94 2/17/94
372
FORMATTED DATA DUMP FOR PROGRAM XMPLDUMP.QTEMP 13:39: 8 5/24/94 NAME OFFSET ATTRIBUTES VALUE D .ADBUF 48 POINTER(SPP) NULL .ADBUFVL B9 CHAR(68) ' ' B9 VALUE IN HEX ' 'X BB8 +41 ' 'X .ADDEV 4B4 CHAR(1 ) ' ' ' 'X .ADENV 493 CHAR(1) 'I' .ADFILE 4C POINTER(SPP) NULL .ADFUNC 49 CHAR(1) ' ' ' 'X .ADLN 494 BINARY(2) .ADMID 496 BINARY(2) .ADPGM 49B CHAR(1 ) 'XMPLDUMP ' .ADRLN 498 BINARY(2) .ADRTN 47 POINTER(IP) NULL .ADRTYP 49A CHAR(1) ' ' ' 'X .ADTOD 4A5 CHAR(15) ' ' ' 'X .ADTYP 491 BINARY(2) .BINSUB 558 BINARY(4) .BIN2 55C BINARY(2) .BPCA 4B CHAR(32767) ' A T D 1 <HHH D12 <HHH D15 <H' 5 A +91 'HH D15 <HHH D22 <HHH D99 <HHH ' 564 +181 ' D 1 <HHH D23 <HHH D25 <HHH ' 4B VALUE IN HEX '8 3DC19EB7 A4 1 A3 19 E4 4 4 4 4 4 4 4 C4F F14444444C88'X 4D8 +41 '88888C4 4 4 1 1 4 C4F1F24444444C8888888C4 4 4 1 2 'X 5 +81 ' 4 C4F1F54444444C8888888C4 4 4 1 3 4 C4F1F54444444C8888888C4 4 'X 528 +121 '4 1 4 4 C4F2F24444444C8888888C4 4 4 1 5 4 C4F9F9'X 55 +161 '4444444C8888888C4 4 4 1 6 4 C4F F14444444C8888888C4 4 4 1 'X 578 +2 1 ' 7 4 C4F2F34444444C8888888C4 4 4 1 8 4 C4F2F54444444C88'X 5A +241 '88888C4 4 4 1 9 'X .BPCACTR 4C BINARY(2) 1 .BPCAFB 4C6 BINARY(2) 14 .BPCAMXR 4C2 BINARY(2) 163 .BPCARCD 4B POINTER(SPP) SPACE OFFSET 1632 ' 66 'X OBJECT SALES COBOLEX SALESFILE .BPCARIO 4C4 BINARY(2) 25 .BP 1CA 4B CHAR(32767) ' A T D 1 <HHH D12 <HHH D15 <H' 5 A +91 'HH D15 <HHH D22 <HHH D99 <HHH ' 564 +181 ' D 1 <HHH D23 <HHH D25 <HHH ' 4B VALUE IN HEX '8 3DC19EB7 A4 1 A3 19 E4 4 4 4 4 4 4 4 C4F F14444444C88'X 4D8 +41 '88888C4 4 4 1 1 4 C4F1F24444444C8888888C4 4 4 1 2 'X 5 +81 ' 4 C4F1F54444444C8888888C4 4 4 1 3 4 C4F1F54444444C8888888C4 4 'X 528 +121 '4 1 4 4 C4F2F24444444C8888888C4 4 4 1 5 4 C4F9F9'X 55 +161 '4444444C8888888C4 4 4 1 6 4 C4F F14444444C8888888C4 4 4 1 'X 578 +2 1 ' 7 4 C4F2F34444444C8888888C4 4 4 1 8 4 C4F2F54444444C88'X 5A +241 '88888C4 4 4 1 9 'X .BP 1CTR 4C BINARY(2) 1 .BP 1FB 4C6 BINARY(2) 14 .BP 1MXR 4C2 BINARY(2) 163 .BP 1RCD 4B POINTER(SPP) SPACE OFFSET 1632 ' 66 'X OBJECT SALES COBOLEX SALESFILE .BP 1RIO 4C4 BINARY(2) 25 .BSTRING NOT ADDRESSABLE .BUFFER NOT ADDRESSABLE .BUFPTR 77 POINTER(SPP) NULL .CALERP 58 POINTER(SPP) SPACE OFFSET 1376 ' 56 'X OBJECT PSSA .CALLOWR C7 CHAR(27) ' ETAOINSHRDLUCMFWYPVBGKQJXZ' '4 85A381968995A288998493A4839486A6A897A58287929891A7A9'X .CALPHAB C2 CHAR(53) ' ETAOINSHRDLUCMFWYPVBGKQJXZETAOINSHRDLUCMFWYPVBGKQJXZ' C2 VALUE IN HEX '4 C5E3C1D6C9D5E2C8D9C4D3E4C3D4C6E6E8D7E5C2C7D2D8D1E7E985A381968995A288998493A483'X C48 +41 '9486A6A897A58287929891A7A9'X .CALUPPR C55 CHAR(27) ' ETAOINSHRDLUCMFWYPVBGKQJXZ' .CIMBSGN BDA CHAR(6 ) ' 123456789 JKLMNOPQR STUVWXYZ ABCDEFGHI STUVWXYZ' BDA VALUE IN HEX 'F F1F2F3F4F5F6F7F8F9D D1D2D3D4D5D6D7D8D9A A1A2A3A4A5A6A7A8A9B B1B2B3B4B5B6B7B8B9'X C 2 +41 'C C1C2C3C4C5C6C7C8C9E E1E2E3E4E5E6E7E8E9'X .CNUMERC C16 CHAR(1 ) ' 123456789' .CPADCHR C8B CHAR(1) ' ' .CRCLEAR D POINTER(SYP) OBJECT QLRCLEAR CONTEXT QSYS .CSEPSGN BD8 CHAR(2) '+-' .DBUGRTN 45 POINTER(IP) NULL .DEVPTR 73 POINTER(SPP) SPACE OFFSET 324 ' 144'X OBJECT SALES COBOLEX SALESFILE .DISPPOS CB BINARY(2) .DISPPTR CA POINTER(SPP) NULL .DLINENO 552 CHAR(6) ' ' ' 'X .DMCACIN 87 BINARY(2) 121 .DMCACQR 872 BINARY(2) 66
373
.DMCDELT .DMCDROP .DMCFDEL .DMCFEOD .DMCFRCE .DMCGET .DMCGETD .DMCGETK .DMCLINK .DMCODP
3BD 178 17A 2 2C 31A 374 2C 2E8 31 338 36 388 3B 166 874 3E9 168 16A 158 15A 15C 7A5 5A B4 28 5 78 A C8 F 1 162 16 15E 17 16E 16C 17C 17E 164
.DMCOFFS .DMCPTGT .DMCPUT .DMCPUTD .DMCRLSE .DMCRSTD .DMCSPDD .DMCSPTB .DMCTBLE .DMCUPD .DMPBDMJ .DMPBDSE .DMPCDFO .DMPCDFP .DMPDBFB .DMPDBFL .DMPDENT
1C6 79 19 144 144 19E 144 16C 194 1C6 22 1C6 1EE 216 23E 248 2A2 248 27 298 2C 2CA 324 2CA 2F2 31A 342 34C 3A6 34C 374 39C
CHAR(1) ' ' BINARY(2) 13 BINARY(2) 17 BINARY(4) 7 4 CHAR(298) ' R A A +91 ' TY +181 ' 3 CPF ' VALUE IN HEX ' 8 8 'X +41 ' 1 99 F 4B 8 3DC19EB7 6F 8 3DC19EB7 6F 'X +81 '48 A3E8 11 19'X +121 ' E 'X +161 ' 'X +2 1 ' F3 1 'X +241 ' FF C3D7C6 5CE 'X BINARY(2) 69 BINARY(2) 71 CHAR(1) ' ' ' 'X BINARY(2) 111 BINARY(2) 69 BINARY(2) 77 BINARY(2) 14 BINARY(2) 69 BINARY(2) CHAR(32767) 'E M M F A +91 ' A +181 'LES COBOLEX SALESFILE A' VALUE IN HEX '85 2 14D4 14D4 B 14 1C6 28 2C 'X +41 ' 14 3DC19EB7 DFF'X +81 ' 8 3DC 36 AE 8 'X +121 ' 3DC19EB7 189B 19 C 'X +161 ' C 4B C4C2E2C1D3C5E24 4 4 4 4 C3D6C2F3F8C5E74 4 4 'X +2 1 ' E E2C1D3C5E2C6C9D3C54 1 4 'X +241 ' 11C1'X BINARY(4) 32 BINARY(2) 69 BINARY(2) 69 BINARY(2) 69 BINARY(2) 69 BINARY(2) 69 BINARY(2) 69 BINARY(2) BINARY(2) 1 BINARY(2) 69 NOT ADDRESSABLE NOT ADDRESSABLE BINARY(2) 144 POINTER(SPP) NULL NOT ADDRESSABLE CHAR(1) ' ' ' 'X CHAR(13 ) DIMENSION(25 ) (1) 'DATABASE ? +91 ' ' VALUE IN HEX 'C4C1E3C1C2C1E2C54 4 3 2 E 45 45 45 45 45 45 6F 45'X +41 ' 45 45 45 BFD 45 45 D 11 1 'X +81 2 LINES OF ZEROES SUPPRESSED (2) ' SALESFILE +91 ' ' VALUE IN HEX ' 9 1 1E2C1D3C5E2C6C9D3C54 'X +41 ' E 'X +81 ' 'X +121 ' 11 'X (3) ' R +91 ' R AA ' VALUE IN HEX ' 22 1 48 4 'X +41 ' 1 11 2 3 3 'X +81 ' 1 99 E DFF 18 1 99 B B1 8181 'X +121 ' 'X (4) ' R A A TY +91 ' ' VALUE IN HEX ' 8 8 1 99 F 4B 8 'X +41 ' 3DC19EB7 6F 8 3DC19EB7 6F 48 'X +81 ' A3E8 11 19 E 'X +121 ' 'X (5) ' +91 ' CPF T ' VALUE IN HEX ' 'X +41 ' 'X +81 ' F3 1 FF C3D7C6 5CE 3C'X
' '
' DBSA'
'
'
'
'
3 '
374
3C4 3CE 428 3CE 3F6 41E 446 45 4AA 45 478 4A 4C8 4D2 52C 4D2 4FA 522 54A 554 5AE 554 57C 5A4 5CC 5D6 63 5D6 5FE 626 64E 658 658 68 6A8 6D 14 E 149 14EA 149 14B8 14E .DMPDEVN .DMPDIOF .DMPDRN .DMPDSEK .DMPDVNM .DMPENT 1E6
+121 (6) +91 VALUE IN HEX +41 +81 +121 (7) +91 VALUE IN HEX +41 +81 +121 (8) +91 VALUE IN HEX +41 +81 +121 (9) +91 VALUE IN HEX +41 +81 +121 (1 ) +91 VALUE IN HEX +41 +81 +121 (11) VALUE IN HEX +41 +81 +121 (12-38) (39) +91 VALUE IN HEX +41 +81
.DMPFBAC
.DMPFBAT .DMPFBCL .DMPFBCT .DMPFBDC .DMPFBDE .DMPFBDU .DMPFBFN .DMPFBH1 .DMPFBH2 .DMPFBIB .DMPFBLN .DMPFBLO .DMPFBLP .DMPFBLS
EA BC 117 74
' A3 'X ' ' SALESFILE 2A248' ' 1 'X ' 'X ' 11 E 1E2C1D3C5E2C6'X 'C9D3C54 F2C1F2F4F8'X '33FF 3CF U & ' A T D ' 'F3F3C6C6F F3C3C6 E 1 1 'X ' A4 5 'X ' 8 3DC19EB7 A4 1 A3 19 E'X '4 4 4 4 4 4 4 4 C4F 'X '1 <HHH D12 <HHH D15 <HHH D15 <HHH ' D22 <HHH D99 <' 'F14444444C8888888C4 4 4 1 1 4 C4F1F24444444C8888888C4 4 4 1 'X ' 2 4 C4F1F54444444C8888888C4 4 4 1 3 4 C4F1F54444444C'X '8888888C4 4 4 1 4 4 C4F2F24444444C8888888C4 4 4 1 5 'X ' 4 C4F9F94444444C'X 'HHH D 1 <HHH D23 <HHH D25 <HHH ' D88 <HHH D99 <HHH ' '8888888C4 4 4 1 6 4 C4F F14444444C8888888C4 4 4 1 7 'X ' 4 C4F2F34444444C8888888C4 4 4 1 8 4 C4F2F54444444C8888888C4 'X '4 4 1 9 4 C4F8F84444444C8888888C4 4 4 1 A 4 C4F9'X 'F94444444C8888888C4 'X ' D22 <HHH D 1 <HHH D66 <HHH '2 <HHH D77 <HHH ' '4 4 1 B 4 C4F2F24444444C8888888C4 4 4 1 C 4 C4F 'X 'F14444444C8888888C4 4 4 1 D 4 C4F6F64444444C8888888C4 4 4 1 'X ' E 4 C4F2F24444444C8888888C4 4 4 1 F 4 C4F7F74444444C'X '8888888C4 4 4 1 'X ' H25 < ' ' 1 4 C8F2F5F F F F F F F F 4 4 4C 1 11 4 4 4 4 4 4 4 4 'X '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 'X '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 'X '4 4 4 4 4 4 4 4 4 4 'X ' ' ' ' ' '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 'X '4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 'X 2 LINES OF ZEROES SUPPRESSED CANNOT DUMP - SPACE ADDRESSING OR BOUNDARY ALIGNMENT EXCEPTION CHAR(1 ) ' ' ' 'X NOT ADDRESSABLE NOT ADDRESSABLE NOT ADDRESSABLE CHAR(1 ) 'DATABASE ' CHAR(13 ) 'DATABASE ? +91 ' ' VALUE IN HEX 'C4C1E3C1C2C1E2C54 4 3 2 E 45 45 45 45 45 45 6F 45'X +41 ' 45 45 45 BFD 45 45 D 11 1 'X +81 2 LINES OF ZEROES SUPPRESSED CHAR(32767) 'DBSALES COBOLEX SALESFILE AR NU +91 '& T DATABASE +181 ' ? ' VALUE IN HEX 'C4C2E2C1D3C5E24 4 4 4 4 C3D6C2F3F8C5E74 4 4 'X +41 ' E E2C1D3C5E2C6C9D3C54 1 4 11C1'X +81 'D9 D5A4 5 A3 19 3E 'X +121 ' 1 1 2 1 1C4C1E3C1C2C1E2C54 4 'X +161 ' 3 2 E 45 45 45 45 45 45 6F 45 45 45 45 BFD 45 45'X +2 1 ' D 11 1 'X +241 ' 'X CHAR(2) 'AR' BINARY(2) BINARY(2) CANNOT DUMP - SPACE ADDRESSING OR BOUNDARY ALIGNMENT EXCEPTION BINARY(2) CHAR(5 ) DIMENSION(32) CANNOT DUMP - SPACE ADDRESSING OR BOUNDARY ALIGNMENT EXCEPTION CHAR(1) ' ' ' 'X CHAR(1 ) 'SALES ' NOT ADDRESSABLE NOT ADDRESSABLE BINARY(4) 41 CHAR(1 ) 'COBOLEX ' BINARY(2) POINTER(SPP) NULL NOT ADDRESSABLE
'
'
'
'
D2'
'
'
' '
375
.DMPFBL1 .DMPFBL2 .DMPFBMF .DMPFBMN .DMPFBND .DMPFBOB .DMPFBOF .DMPFBOL .DMPFBPO .DMPFBQN .DMPFBRC .DMPFBRW .DMPFBSC .DMPFBSF .DMPFBSL .DMPFBSN .DMPFBTY .DMPFBUF .DMPFBVL .DMPIOFB
DC DE 123 E 8 3A EE 1 D F4 11F 124 FB F7 1 2 C6 D DA B 1 3 1C6 22 27A 1C6 1EE 216 23E 266 28E 2B6 1C6 22 1C6 1EE 216 23E 142 B
.DMPIOFS
.DMPKYLN .DMPNDEV .DMPOFBS .DMPRCD .DMPRCDN .DMPRDUP .DMPRFMT .DMPRRN .DMPSRC .EXCODE .EXMSGID .EXPARMS .EXPTR .FCLPP .FCLSTC .FCLSTC# .FCLSTP .FCLSTP# .FCPARM .FCPARMP .FCPTR .FIB
1DA
D3 D35 D3 D4 6DF 6DC 6D 6FF 6EA 5B 5D 5A 8A 8FA 954 8A 8C8 8F 918 94 968 62C 8E9 6E8 6C 8BE 955 961 8C4
BINARY(2) 14 BINARY(2) CHAR(1) ' ' ' 'X CHAR(1 ) 'SALESFILE ' BINARY(2) CANNOT DUMP - SPACE ADDRESSING OR BOUNDARY ALIGNMENT EXCEPTION BINARY(4) CHAR(1 ) ' ' ' 'X CHAR(3) ' ' ' 'X BINARY(4) 992 CHAR(1 ) ' ' ' 'X BINARY(4) 17 BINARY(2) CHAR(1) 'N' CHAR(1 ) ' ' ' 'X CHAR(1 ) ' ' ' 'X BINARY(2) CHAR(2) 'DB' CHAR(1 ) 'U & ' 'A4 5 'X NOT ADDRESSABLE CHAR(32767) ' SALESFILE +91 ' +181 ' R R AA ' VALUE IN HEX ' 9 1 1E2C1D3C5E2C6C9D3C54 +41 ' E +81 ' +121 ' 11 22 1 +161 ' 48 4 1 11 2 3 +2 1 '3 1 99 E DFF 18 1 99 B B1 8181 +241 ' 'X CHAR(144) ' SALESFILE +91 ' ' VALUE IN HEX ' 9 1 1E2C1D3C5E2C6C9D3C54 +41 ' E +81 ' +121 ' 11 'X NOT ADDRESSABLE BINARY(2) 1 CHAR(17126) DIMENSION(2) CANNOT DUMP - SPACE ADDRESSING OR BOUNDARY ALIGNMENT EXCEPTION NOT ADDRESSABLE NOT ADDRESSABLE NOT ADDRESSABLE CHAR(1 ) 'SALESFILE ' NOT ADDRESSABLE NOT ADDRESSABLE CHAR(1) ' ' ' 'X CHAR(4) ' ' ' 'X CHAR(12) ' ' ' 'X POINTER(SPP) SPACE OFFSET 3376 ' D3 'X OBJECT PSSA CHAR(3) ' ' ' 'X CHAR(12) ' ' ' 'X CHAR(12) ' PU ' ' D 3D7E44 6 2 1FF'X CHAR(21) ' ' ' 'X CHAR(21) ' ' ' 9 2 A 2 B 2 C 2 FF'X CHAR(22) ' ' POINTER(SPP) SPACE OFFSET 1456 ' 5B 'X OBJECT PSSA POINTER(SYP) OBJECT QLREXHAN CONTEXT QSYS CHAR(32767) 'FILE-1 4 +91 ' A +181 ' ' VALUE IN HEX 'C6C9D3C56 F14 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 8 3 1F F4F F +41 ' 4 4 4 4 4 4 4 4 4 4 4 1 1 1 C +81 '8 3DC 36 AE +121 ' 8 3DC19EB7 89 +161 '4 4 4 4 4 4 4 4 4 4 1 +2 1 2 LINES OF ZEROES SUPPRESSED CHAR(8) ' ' ' 'X NOT ADDRESSABLE BINARY(2) 1 BINARY(2) CHAR(8) ' ' '16 4 FF'X CHAR(1) ' ' ' 'X CHAR(22) ' ' ' 'X CHAR(1 ) ' ' ' 'X CHAR(2) ' 4'
' ' 'X 'X 'X 'X 'X 'X ' 'X 'X 'X
376
.FIBCFS1 .FIBCFS2 .FIBCHAN .FIBCKID .FIBCOP .FIBCRP .FIBCTID .FIBCTL .FIBCUR .FIBCURK
.FIBDEVC .FIBDEVI .FIBDEVN .FIBFLGS .FIBFMT .FIBFN .FIBK#LN .FIBK#R# .FIBK#RK .FIBK#TP .FIBKCGK .FIBKCGR .FIBKCPD .FIBKCTL .FIBKDLN .FIBKDM# .FIBKDTP .FIBKEY .FIBKFLN .FIBKFMT .FIBKFTP .FIBKKEY
.FIBKKLN .FIBKKTP .FIBKLEN .FIBKSTC .FIBKSTE .FIBKSTL .FIBKSTT .FIBLBO .FIBLFT .FIBLIN .FIBLINE .FIBLTO .FIBMBRN .FIBOFMT .FIBOFS .FIBOFS1 .FIBOKEY
.FIBOKLN .FIBOLDK
.FIBOP .FIBOP1 .FIBOP2 .FIBOP3 .FIBOP4 .FIBORG .FIBORRN .FIBOTP .FIBPTR .FIBP1 .FIBRECS .FIBREL .FIBRLPT
8C4 94C 92 955 8C 8E4 957 75 8C 634 68E 634 65C 8E5 94A 94 8BF 8DA 8A 62D 62F 631 62C 6 6 8 61 618 628 62A 627 8CA 61B 61D 61A 636 69 636 65E 634 633 8CE 62C 631 62D 62F 8D 8CC 8CA 8D2 8CE 9D6 9CC 8C6 8C6 953 9AD 953 97B 951 951 9AB 951 979 7A1 7A1 7A2 7A3 7A4 8E7 951 8EB 3B 93 8ED 6B
CHAR(1) CHAR(4) POINTER(SPP) ZONED(2, ) CHAR(4) CHAR(1) CHAR(1 ) POINTER(SPP) CHAR(6) CHAR(123) +91 VALUE IN HEX +41 BINARY(2) BINARY(2) CHAR(1 ) CHAR(1) CHAR(1 ) CHAR(3 ) BINARY(2) BINARY(4) BINARY(2) CHAR(1) CHAR(8) CHAR(8) CHAR(8) BINARY(2) BINARY(2) BINARY(2) CHAR(1) BINARY(4) BINARY(2) CHAR(1 ) CHAR(1) CHAR(121) +91 VALUE IN HEX +41 BINARY(2) CHAR(1) BINARY(2) CHAR(1) CHAR(1) BINARY(2) BINARY(2) BINARY(2) BINARY(2) BINARY(2) BINARY(2) BINARY(2) CHAR(1 ) CHAR(1 ) CHAR(2) CHAR(1) CHAR(121) +91 VALUE IN HEX +41 BINARY(2) CHAR(123) +91 VALUE IN HEX +41 CHAR(4) CHAR(1) CHAR(1) CHAR(1) CHAR(1) BINARY(2) BINARY(4) BINARY(2) POINTER(SPP)
' ' ' ' NULL ' ' ' ' ' ' NULL ' 4' ' ' ' 3 LINES OF ZEROES SUPPRESSED 1 ' ' ' ' 'FILE-1
'
'X
' 'X ' 3 1'X ' 'X ' ' 3 ' 1F F4'X
'X
' 'X
' F'X
1 ' ' ' ' ' ' ' 3 LINES OF ZEROES SUPPRESSED ' ' ' ' ' '
'SALESFILE ' ' ' ' ' F ' ' ' ' ' 3 LINES OF ZEROES SUPPRESSED ' ' ' 3 ' ' ' ' ' 1
'
'X
' ' 'X LINES OF ZEROES SUPPRESSED ' ' ' ' ' ' 3 ' 3'X ' 'X ' 'X ' 1'X 1'X
1 SPACE OFFSET 22 8 ' OBJECT PSSA POINTER(SPP) SPACE OFFSET 12 ' OBJECT SALES COBOLEX BINARY(2) 12 NOT ADDRESSABLE POINTER(SPP) NULL
377
.FIBROLC .FIBROLE .FIBROLL .FIBRSL .FIBRVAL .FIBSPC .FIBTAPE .FIBTLEN .FIBUBTO .FIBUFCB .FIBURTN .FIBUSAV .FIBUSE# .FIBVERB .FSKA .FSKB .FSPA .FSPB .FSTKS .FWTRCD .F 1ACC .F 1ALTS .F 1CFS2 .F 1CHAN .F 1COP .F 1CRP .F 1CUR .F 1DEVC .F 1DEVI .F 1DEVN .F 1FLGS .F 1FMT .F 1FN .F 1MBRN .F 1OFMT .F 1OFS .F 1OKLN .F 1OLDK
8CA 6C8 6CB 9 8F 91 5F 8D8 8C8 7 C 7 2 711 7 7 6E5 6C3 8E9 8BE 94C 92 8C 8E4 8C 8E5 94A 94 8BF 8DA 8A 9D6 9CC 8C6 951 953 9AD 953 97B 8E7 8EB 93 8ED 8CA 9 8F 91 8D8 8C8 86 84 78 85 3A
.IP
C9
NOT ADDRESSABLE NOT ADDRESSABLE NOT ADDRESSABLE NOT ADDRESSABLE NOT ADDRESSABLE CHAR(14) ' ' CHAR(8) ' ' BINARY(4) POINTER(IP) NULL POINTER(SPP) SPACE OFFSET 2528 ' OBJECT PSSA POINTER(SPP) NULL POINTER(IP) NULL BINARY(2) BINARY(2) 4 BINARY(2) BINARY(2) BINARY(2) BINARY(2) BINARY(2) BINARY(4) BINARY(2) 1 CHAR(1) ' ' CHAR(4) ' ' POINTER(SPP) NULL CHAR(4) ' ' CHAR(1) ' ' CHAR(6) ' 4' BINARY(2) BINARY(2) 1 CHAR(1 ) ' ' CHAR(1) ' ' CHAR(1 ) ' ' CHAR(3 ) 'FILE-1 CHAR(1 ) 'SALESFILE ' CHAR(1 ) ' ' CHAR(2) ' ' BINARY(2) CHAR(121) ' +91 ' VALUE IN HEX ' +41 3 LINES OF ZEROES SUPPRESSED BINARY(2) 1 BINARY(2) 1 POINTER(SPP) SPACE OFFSET 12 ' OBJECT SALES COBOLEX BINARY(2) 12 CHAR(14) ' ' POINTER(IP) NULL POINTER(SPP) SPACE OFFSET 2528 ' OBJECT PSSA POINTER(SPP) NULL BINARY(2) CHAR(2) ' ' POINTER(SPP) SPACE OFFSET 1952 ' OBJECT PSSA POINTER(SYP) OBJECT QDBGETM CONTEXT QSYS POINTER(SPP) NULL POINTER(SPP) SPACE OFFSET 224 ' OBJECT PSSA POINTER(IP) STMT 48 OBJECT XMPLDUMP CONTEXT QTEMP POINTER(IP) STMT 52 OBJECT XMPLDUMP CONTEXT QTEMP POINTER(SYP) OBJECT QLRMAIN CONTEXT QSYS CHAR(16) 'COBOL MGT . LR' G CHAR(8) ' ' BINARY(4) BINARY(4) DIMENSION(2 ) (4 -2 ) POINTER(SYP) NULL CHAR(1) ' ' CHAR(7) ' ' H POINTER(SPP) SPACE OFFSET 22 8 '
' '11
'X 4 FF'X
9E 'X
' '
8C 'X INSTR # 4F
INSTR #
65
'
'X
8A 'X
378
.MGTFUNC .MGTIND
.MGTINVC .MGTLIB .MGTMSGI .MGTMSGN .MGTMSGR .MGTMSGS .MGTMSGT .MGTNAME .MGTNEXT .MGTOSZ .MGTOVFL .MGTPACK .MGTPARM .MGTPASA .MGTPASC .MGTPCS .MGTPFM .MGTPGM .MGTPGT .MGTPLVL .MGTPROG .MGTPTP .MGTPTR .MGTRST .MGTSEG .MGTSEPT
345 323 329 32A 342 31A 41A 3F2 3F 3E 3C 3D 31 24 323 325 34F 4 27 27 37 327 2A 26 361 41 38 46 2B 35F 28
BINARY(2) CHAR(1) (1-7) (8) (9-32) BINARY(2) CHAR(1 ) CHAR(7) BINARY(2) POINTER(SPP) POINTER(IP) POINTER(SPP) CHAR(1 ) POINTER(SPP) CHAR(1) CHAR(1) PACKED(31, ) POINTER(SPP) POINTER(SPP) CHAR(16) POINTER(SPP) CHAR(1) POINTER(SYP) POINTER(SPP) BINARY(2) CHAR(1 ) POINTER(SPP) POINTER(SPP) POINTER(IP) BINARY(2) POINTER(SPP)
OBJECT PSSA 2 DIMENSION(32) ' ' '1' ' ' 3 I 'QTEMP ' ' ' NULL NULL NULL 'XMPLDUMP NULL ' ' ' '
'
'X
'
' NULL SPACE OFFSET 576 OBJECT PASA ' ' NULL ' ' OBJECT XMPLDUMP J CONTEXT QTEMP SPACE OFFSET 5952 OBJECT PSSA 'XMPLDUMP ' SPACE OFFSET OBJECT PSSA SPACE OFFSET OBJECT PSSA NULL ' 168 'X '8 3DC 37
'X
178 'X
'
174 'X
2864 56 '
'
B3 'X 23 'X
.MGTSOSZ .MGTSPCD .MGTSW .MGTTYPE .MGTUPTR .MGT9 1 .NULLCL .ODPBPTR .ODPDBAS .ONSAVE .PBPDUM .PBP 3
CHAR(1) CHAR(1) CHAR(1) CHAR(1) POINTER(SPP) CHAR(1) CHAR(1) POINTER(SPP) POINTER(SPP) CHAR(32) VALUE IN HEX POINTER(IP) POINTER(IP)
.PERFCTR .PGT
55 174 179A 17F4 174 1768 179 17B8 17E 18 8 183 177 177 1771 178F 179 174 176 175
BINARY(2) CHAR(32767) +91 +181 VALUE IN HEX +41 +81 +121 +161 +2 1 +241 CHAR(1) (1) (2) (3-32) BINARY(2) CHAR(16) POINTER(SPP) POINTER(SPP)
.PGTIND
SPACE OFFSET ' 'X OBJECT QINSEPT CONTEXT QSYS ' ' ' ' ' ' '8 'X 'I' SPACE OFFSET 1984 ' 7C 'X OBJECT E34 PGMRS 11111 '1' ' ' 'FF'X SPACE OFFSET ' 'X OBJECT SALES COBOLEX SALESFILE SPACE OFFSET 7 4 ' 2C 'X OBJECT SALES COBOLEX SALESFILE ' ' ' 'X NULL STMT 42 INSTR # 3 OBJECT XMPLDUMP CONTEXT QTEMP 1 K 'PGT . 1 ' QTEMP XMPLDUMP . ' 'D7C7E34 F F 4BF 4 4 4 4 4 4 4 4 8 3DC 36 33 ' F F1F F F F F F F F F F F F F F F F F F F F F F F F F F F F ' 3 4D 4B 1 4 1D8E3C5D4D74 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 '4 4 4 2 1E2C1D4D7C4E4D4D74 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 38 ' 4B 1 ' ' 1 'X DIMENSION(32) ' ' '1' ' ' 3 L 'PGT . ' NULL SPACE OFFSET 56 ' 23 'X OBJECT PSSA
.' '
379
.PNP
.PTABLE .PTHSIZE .PTNUM .PTSEG .P 2 1 .QLRDISP .QLRXHAN .RCDFDBK .RETURNP .RTNPTR .RUNRTN .SAVKKEY
B4 B4 B68 B3 B37 B39 B3B CD CC D5 88 82 56 83 7A7 8 1 7A7 7CF 43 59 D1 D12 D1 D2 D62 D6 D6C D8 D6 BD4 BD6 CD CD B7 B7 4F 4F 51 51 53 53 9E A3A A94 9E A 8 A3 A58 A8 AA8 AD A98 A99 A6 A8E A8E A8F 9F A8C A2 A82 A6A A6C A6A A76 A76 A78 A3 A
CHAR(48) VALUE IN HEX +41 CHAR(16) BINARY(2) BINARY(2) CHAR(1) PACKED(2, ) POINTER(SYP) POINTER(SYP) POINTER(SPP) POINTER(IP) POINTER(SPP) POINTER(IP) CHAR(121) +91 VALUE IN HEX +41 POINTER(SPP) POINTER(SPP) BINARY(2) CHAR(1 ) CHAR(12) POINTER(SPP) CHAR(1 ) BINARY(2) CHAR(1 ) POINTER(SPP)
.SEPTP .SIZERP .SUBLEN .SUBNAME .SUBTXT .SUBTXTA .SUB2FST .SUB2LEN .SUB2SCD .SUB2TP .SUB2TXT .TC 1 .TC 2 .TMPN 1 .T .T .T .T1 .T2 .T3 .UCB 1 2 3
' T T '4 3D 3E33C 61A4 ' 'X 'PT 1. ' 'D7E34 F F14BF 16 1 ' ' 25 OBJECT QLRADRTN CONTEXT QSYS OBJECT QLREXHAN CONTEXT QSYS NULL NULL SPACE OFFSET 576 ' 168 'X OBJECT PASA NULL ' ' ' ' 3 LINES OF ZEROES SUPPRESSED NULL SPACE OFFSET 1376 ' 56 'X OBJECT PSSA ' ' ' ' SPACE OFFSET OBJECT PSSA ' ' ' ' D1 'X '
' 'X
'X 'X
3344
'
'X
.UCBCLMG .UCBEDOP .UCBFILE .UCBFLGS .UCBFLG1 .UCBFLG2 .UCBIBR@ .UCBINDX .UCBIOF@ .UCBLAST .UCBLBID .UCBLIB .UCBLIBS .UCBMBID .UCBMBRS .UCBMLIB .UCBNXT@ .UCBOBR@
' ' ' 'X SPACE OFFSET 3424 ' D6 'X OBJECT PSSA CHAR(22) ' ' ' 'X CHAR(2) ' ' ' 'X CHAR(2) ' ' ' 'X CHAR(32) ' ' VALUE IN HEX ' 25F 'X NOT ADDRESSABLE PACKED(7,2) 88888.88 PACKED(7,2) 88888.88 CHAR(32) ' ' VALUE IN HEX ' 'X CHAR(32) ' ' VALUE IN HEX ' 'X CHAR(32) ' ' VALUE IN HEX ' 'X CHAR(32767) ' A A A A A W +91 ' SALES LIBL +181 ' " 311111 8 6222' VALUE IN HEX '8 3DC19EB7 3E 8 3DC19EB7 89 8 'X +41 ' 3DC19EB7 89 8 3DC19EB7 49 8 3DC19EB7 5A6'X +81 ' 'X +121 ' E2C1D3C5E24 4 4 4 4 FFB55CD3C9C2D34 4 4 4 4 FFB94 4 4 4 4 4 4 4 'X +161 '4 4 4 4 4 4 4 4 4 4 4 4 1 12 F F1F F 1654A2 2 'X +2 1 ' 1 C 148 38 3C8 3A8 6 7FFF 15F 3 F 'X +241 'F F F3F1F1F1F1F1F F8F F F6F2F2F2'X CHAR(1) ' ' '2 'X CHAR(1) ' ' ' 'X CHAR(1 ) 'SALES ' CHAR(2) ' ' ' 12 'X CHAR(1) ' ' ' 1'X CHAR(1) ' ' '2 'X POINTER(SPP) SPACE OFFSET 12 ' 4B 'X OBJECT SALES COBOLEX SALESFILE BINARY(2) 1 POINTER(SPP) SPACE OFFSET 454 ' 1C6'X OBJECT SALES COBOLEX SALESFILE CHAR(1 ) ' ' BINARY(2) -75 CHAR(1 ) ' LIBL ' CHAR(12) ' LIBL ' 'FFB55CD3C9C2D34 4 4 4 4 'X BINARY(2) -71 CHAR(12) ' ' 'FFB94 4 4 4 4 4 4 4 4 4 'X CHAR(1 ) ' ' POINTER(SPP) NULL POINTER(SPP) SPACE OFFSET 12 ' 4B 'X
' '
380
.UCBODP@ .UCBOPF@ .UCBPARM .UCBRLEN .UCBRLVR .UCBSEP@ .UFCBPTR .UFLGSAV .USERTN .USEWRK@ .U 1CLMG .U 1FLGS .U 1IBF@ .U 1OBF@ .U 1SEQO .U 1UFCB .VALT 1
9E A1 AB AB2 A9 A4 72 CF 5E D9 A98 A8E 9F A ABF 9E B7 B7 662 7D 7D1 7C 7C2 7D8 7C 81A 7C 7E8 7CE 7D8 7D9 7DA 7DB 7DC 7DD 7DE 7DF B28 B29 66 66B B13 B 4 AF 661 AC9 AC7 663
POINTER(SPP) POINTER(SPP) BINARY(2) BINARY(2) CHAR(4) POINTER(SPP) POINTER(SPP) CHAR(2) POINTER(IP) POINTER(SPP) CHAR(1) CHAR(2) POINTER(SPP) POINTER(SPP) CHAR(1) POINTER(SPP)
CHAR(32) VALUE IN HEX 'X .V 5622 CHAR(1) .WCBCNLS CHAR(1) .WCBJDAT CHAR(7) .WCBLURC BINARY(2) .WCBPINF BINARY(2) .WCBSWTC CHAR(8) ' ' .WCBUDTA CHAR(32767) ' 89 623 +91 2 LINES OF BLANKS SUPPRESSED VALUE IN HEX ' 2 F F F8F9F F6F2F3F F F F F F F F 'X +41 6 LINES OF ZEROES SUPPRESSED .WCBURC CHAR(2) ' ' ' 'X .WCBU CHAR(1) ' ' .WCBU1 CHAR(1) ' ' .WCBU2 CHAR(1) ' ' .WCBU3 CHAR(1) ' ' .WCBU4 CHAR(1) ' ' .WCBU5 CHAR(1) ' ' .WCBU6 CHAR(1) ' ' .WCBU7 CHAR(1) ' ' END-FLAG CHAR(1) ' ' N END-OF-INPUT CHAR(1) 'Y' FILE-1 CHAR(12) 'H25 ' FILLER CHAR(1) ' ' FILLER CHAR(3) ' ' FILLER CHAR(3) ' ' FILLER CHAR(8) 'TOTALS: ' R-AREA-CODE ZONED(2, ) 25 R-NORTH-EAST PACKED(2, ) 3 R-NORTH-EAST PACKED(2, ) 15 R-SALES-CAT-1 PACKED(7,2) INVALID DATA 'F F F F 'X O R-SALES-CAT-2 667 PACKED(7,2) INVALID DATA 'F F F F 'X R-TYPE 66 CHAR(1) 'H' RECORD-1 66 CHAR(12) 'H25 ' W-CAT-1 AD ZONED(1 ,2) 311111. 8 W-CAT-2 ADA ZONED(1 ,2) 622222.16 W-EDIT-TOTAL B16 CHAR(12) ' ' W-EDIT-VALUES AF CHAR(5 ) 'TOTALS: ' W-EDIT-1 AF8 CHAR(12) ' ' W-EDIT-2 B 7 CHAR(12) ' ' W-SALES-VALUES AD CHAR(3 ) ' 311111 8 62222216 93333324' W-TOTAL AE4 ZONED(1 ,2) 933333.24 STATIC STORAGE FOR PROGRAM XMPLDUMP.QTEMP BEGINS AT OFFSET 23 IN THE PROGRAM STATIC STORAGE AREA (PSSA) AUTOMATIC STORAGE FOR PROGRAM XMPLDUMP.QTEMP BEGINS AT OFFSET 16C IN THE PROGRAM AUTOMATIC STORAGE AREA (PASA)
OBJECT SALES SPACE OFFSET OBJECT SALES SPACE OFFSET OBJECT SALES 1 12 ' 1 ' NULL SPACE OFFSET OBJECT PSSA ' ' NULL NULL ' ' ' ' SPACE OFFSET OBJECT SALES SPACE OFFSET OBJECT SALES ' ' SPACE OFFSET OBJECT SALES 'HHH '8888888F '5' ' ' ' 89 623' M 2
2528
'
12 12
'2 'X ' 12 'X 4B 'X SALESFILE 4B 'X SALESFILE '8 'X 'X SALESFILE '
'
381
382
Bibliography
For additional information about topics related to COBOL/400 programming on the AS/400 system, refer to the following IBM AS/400 publications:
Communications: Management Guide, SC41-0024 Short title: Communications Management Guide Device Configuration Guide, SC41-8106 Short title: Device Configuration Guide Software Installation, SC41-3120 Short title: Software Installation System Programmers Interface Reference, SC41-8223 Short title: System Programmers Interface Reference Database Guide, SC41-9659 Short title: DDS Reference Data Description Specifications Coding Form, SX41-9891 Short title: DDS Coding Form Communications: Intersystem Communications Function Programmers Guide, SC41-9590 Short title: ICF Programmers Guide System Operation, SC41-3203 Short title: System Operation Basic Security Guide, SC41-0047 and Security Reference, SC41-8083 Short titles: Basic Security Guide and Security Reference Distributed Data Management Guide, SC41-9600 Short title: DDM Guide Database Guide, SC41-9659 Short title: Database Guide Utilities: Interactive Data Definition Utility Users Guide, SC41-9657 Short title: IDDU Users Guide System Programmers Interface Reference, SC41-8223 Short title: System Programmers Interface Reference
CICS/400 Application Programming Guide, SC33-0822 Short title: CICS/400 Application Programming Guide Communications: Remote Work Station Guide, SC41-0002 Short title: Remote Work Station Guide Advanced Backup and Recovery Guide, SC41-8079 Short title: Advanced Backup and Recovery Guide Programming: Control Language Programmers Guide, SC41-8077 Short title: CL Programmers Guide New Users Guide, SC41-8211 Short title: New Users Guide Programming: Control Language Reference, SC41-0030 Short title: CL Reference Publications Guide, GC41-9678 Short title: Publications Guide Programming: Work Management Guide, SC41-8078 Short title: Work Management Guide Systems Application Architecture* Structured Query Language/400 Reference, SC41-9608 Short title: SQL/400* Reference Data Management Guide, SC41-9658 Short title: Data Management Guide COBOL/400 Reference, SC09-1813 Short title: COBOL/400 Reference American National Standard Programming Language COBOL, ANSI X3.23-1985, ISO 1989-1985 Short title: American National Standard Programming Language COBOL, ANSI X3.23-1985, ISO 1989-1985
For information about Common Programming Interface (CPI) COBOL, refer to the following publication:
383
384
Glossary of Abbreviations
Abbreviation Appl Dev Tools Meaning Application Development Tools Explanation Consisting of programs for the AS/400 system, such as the Screen Design Aid (SDA) and the Source Entry Utility (SEU). An organization consisting of producers, consumers, and general interest groups, that establishes the procedures by which accredited organizations create and maintain voluntary industry standards in the United States. Abbreviation ASCII Meaning American National Standard Code for Information Interchange Explanation The code developed by American National Standards Institute for information exchange among data processing systems, data communications systems, and associated equipment. The ASCII character set consists of 8-bit characters, consisting of 7-bit control characters and symbolic characters, plus one paritycheck bit.
ANSI
385
Abbreviation CICS
Explanation An IBM licensed program that enables transactions entered at remote work stations to be processed concurrently by user-written application programs. The licensed program includes functions for building, using, and maintaining databases, and for communicating with CICS on other operating systems. The set of all commands with which a user requests system functions.
Abbreviation DBCS
Explanation A set of characters in which each character is represented by 2 bytes. Languages such as Japanese, Chinese, and Korean, which contain more symbols than can be represented by 256 code points, require double-byte character sets. Because each character requires 2 bytes, the typing, displaying, and printing of DBCS characters requires hardware and programs that support DBCS. Four double-byte character sets are supported by the system: Japanese, Korean, Simplified Chinese, and Traditional Chinese. Contrast with singlebyte character set.
CL
Control Language
386
Abbreviation DDM
Explanation A function of the operating system that allows an application program or user on one system to use data files stored on remote systems. The systems must be connected by a communications network, and the remote systems must also be using DDM. A description of the users database or device files that is entered into the system in a fixed form. The description is then used to create files. A coded character set consisting of 256 eight-bit characters. An official standard to improve the utilization and management of computers and data processing in business.
Abbreviation ICF
Explanation A function of the operating system that allows a program to communicate interactively with another program or system. Data provided to the computer or data resulting from computer processing. A function that compares the record format-level identifiers of a file to be opened with the file description that is part of a compiled program to determine if the record format for the file changed since the program was compiled.
I/O
Input/Output
LVLCHK
Level Checking
DDS
EBCDIC
FIPS
Glossary of Abbreviations
387
Abbreviation ODT
Explanation A table built at compile time by the system to keep track of objects declared in the program. The program objects in the table include variables, constants, labels, operand lists and exception descriptions. The table resides in the compiled program object. The AS/400 operating system. A function of the AS/400 Application Development Tools licensed program that helps the user design, create, and maintain displays and menus. A function of the AS/400 Application Development Tools licensed program that is used to create and change source members.
Abbreviation SQL/400
Explanation An IBM licensed program supporting the relational database that is used to put information into a database and to get and organize selected information from a database. An external program switch that performs the functions of a hardware switch. Eight switches are provided: UPSI 0 - 7.
UPSI
OS/400
Operating System/400
SDA
Note: The abbreviations for OS/400 commands do not appear here. Refer to the CL Reference for OS/400 commands and their usage.
SEU
388
Numerics
8-byte binary items, and performance 268
A
abnormal program termination 52 about this manual xi ACCEPT statement 103, 177, 343 access mode 173, 241, 249 DYNAMIC 246 RANDOM 246 access path description 128 example for indexed files 247 file processing 250, 251 specifications 105 *ACCUPDALL option 26 *ACCUPDNE option 26 ACQUIRE statement 178 ADDMSGD (Add Message Description) command 331 ADDRESS OF special register 280, 287 description 287 difference from calculated ADDRESS OF addresses incrementing using pointers 305 passing between programs 303 ADM/400 ADVANCING phrase 233 for FORMATFILEs 234 ADVANCING PAGE phrase 336 ALCOBJ (Allocate Object) command 93 ALIAS keyword 111 alias name 113 alias, definition 111 *ALL option 27 Allocate Object (ALCOBJ) command 93 alphabet-name, definition 335 alphabetic character, definition 336
287
B
batch compiles 36 batch jobs, representation of DBCS data in binary items, and performance 268 *BLANK option 19 BLANK WHEN ZERO defining with LIKE clause 258 *BLK option 23 348
389
block, description 102 blocking output records 102 Boolean data types 20, 144, 176 Boolean literal, definition 20 boundary definition 95 record 23 violation 73, 251 breakpoints as an OS/400 function 55 considerations for using 63 description 57 displaying table elements 60 displaying variables 60 example 57 traces, differences between 64 use of 57, 62 browsing a compiler listing See source entry utility (SEU) BY CONTENT, definition 279 BY REFERENCE, definition 279
C
calculation operations on fixed-length fields 132 call by identifier 282 CALL statement BY CONTENT identifier 280 BY CONTENT LENGTH OF identifier BY CONTENT literal 280 BY CONTENT, implicit MOVE 289 by identifier 282 BY REFERENCE ADDRESS OF record-name 280 BY REFERENCE identifier 279 recursive, description 273 to QCMDEXC 255 using pointers 289 within a segmented program 312 called program definition 273 calling programs BY CONTENT 279 BY REFERENCE 279 definition 273 from a non-COBOL program 268 to begin at another entry point using pointers 289 within a segmented program 312
280
calling the COBOL compiler 15 CANCEL statement 282, 307, 336 with non-COBOL programs 279 *CBL statement 38 CCSIDs (Coded Character Set IDentifiers) 137 CDRA (Character Data Representation Architecture) 137 Change Debug (CHGDBG) command 55 *CHANGE option 27 Change Program Variable (CHGPGMVAR) command 63 change/date (CHGDATE) field 43 changes from ANSI 74 COBOL 335336 changing the value of variables 63 Character Data Representation Architecture (CDRA) 137 characters, double-byte 337 characters, replaced in field name 113 checking DBCS literals 339 checking work station validity 140 CHGDBG (Change Debug) command 55 CHGPGMVAR (Change Program Variable) command 63 choices, shown in syntax 3 CICS (Customer Information Control System) statements 13 CICSCBL member type 13 CICSSQLCBL member type 13 CL (control language) commands for running programs 7 for testing programs 55 issuing using QCMDEXC in a program 255 clauses ACCESS MODE 173 ASSIGN 143, 172 CONTROL-AREA 174 CURRENCY clause 12 DECIMAL-POINT clause 12 FILE STATUS 103, 173 INDICATOR 145 JUSTIFIED 342 LIKE 145 LINAGE 233 OCCURS 145, 341 ORGANIZATION 172 ORGANIZATION IS INDEXED 241 PICTURE 144, 267, 342 RECORD KEY 129 REDEFINES 335, 341 RELATIVE KEY 173
390
clauses (continued) RENAMES 342 REPLACING identifier-1 BY identifier-2 clause 12 SAME AREA 335 SAME RECORD AREA 335 SEGMENT-LIMIT 310 SORT-MERGE AREA 335 syntax, notation for 3 USAGE 144 VALUE 145, 342 WITH DEBUGGING MODE 313 CLOSE operation 23 CLOSE statement 179, 336 closing files with the CANCEL statement 336 code optimizing 22 CODE/400 Coded Character Set Identifiers (CCSIDs) 137 coding errors 56 coding form 6, 11 coding formats provided by SEU 11 coding tables 263 command summary listing 39 command syntax, using 3 commands Add Message Description (ADDMSGD) 331 Allocate Object (ALCOBJ) 93 Change Debug (CHGDBG) 55 Change High Level Language Pointer (CHGHLLPTR) 63 Change Pointer (CHGPTR) 63 Change Program Variable (CHGPGMVAR) 63 Create Authorization List (CRTAUTL) 27 Create COBOL Program (CRTCBLPGM) See Create COBOL Program command Display Program Variable (DSPPGMVAR) 63 Display Trace Data (DSPTRCDTA) 65 End COBOL Debug (ENDCBLDBG) 315, 316 Grant Object Authority (GRTOBJAUT) 27 Monitor Message (MONMSG) 16 Override Message File (OVRMSGF) 331 Override to Diskette File (OVRDKTF) 90 Start COBOL Debug (STRCBLDBG) 314, 316 Start Debug (STRDBG) 55 Start Source Entry Utility (STRSEU) See source entry utility comments with DBCS characters 340 COMMIT statement 95, 96 commitment boundary, definition 95
commitment control 82, 94, 98 example 97 locking level 95 common keys 129 Common Programming Interface (CPI) support 325 communication module 325 communications, interactive interprogram considerations 273, 349 recovery 83 with other programs 139 with remote systems 139 with work station users 139 COMP-3 items, and performance 268 compile-time errors 56 compiler failure 16 compiler options See also PROCESS statement also parameters, CRTCBLPGM command *ACCUPDALL 26 *ACCUPDNE 26 *ALL 27 and syntax checking with SEU 12 *APOST 20 as specified in PROCESS statement 32 *ATR 21 authorization-list-name option 27 batch compiling 36 *BLANK 19 *BLK 23 *CHANGE 27 check for sequence errors 19 check subscript ranges at run time 21 compiler options listing 37, 40 count verb usage 19 create cross-reference listing 19, 21, 47 create Data Division map 20 create object code 19 create source listing 19, 41 *CRTF 22 *CURLIB 18, 25 *CURRENT 26, 31 *DATETIME 24 *DDSFILLER 22 *DEB1 25 *DEB2 25 delimiter for nonnumeric and Boolean literals 20 *DFRWRT 25 *DUMP 21
Index
391
compiler options (continued) *DUPKEYCHK 22 *EXCLUDE 27 *EXTACCDSP 23 file-name option 24 *FLAG 25, 37 *FS21DUPKY 23 *GEN 19 *GRAPHIC option 24 *HIGH 25 include attributes for the IRP 21 *INTERMEDIATE 25 *INZDLT 23 *LIBCRTAUT 27 *LIBL 18, 24 library-name option 18, 25 *LINENUMBER 20 *LIST 21 list compiler options in effect 37, 41 *LSTDBG 21 *MAP 20, 37 maximum-severity-level option 24 message-limit option *MINIMUM 25 *NOATR 21 *NOBLK 23 *NOCRTF 22 *NODATETIME option 24 *NODDSFILLER 22 *NODEB 25 *NODFRWRT 25 *NODUMP 21 *NODUPKEYCHK 22 *NOEXTACCDSP 23 *NOFIPS 25 *NOFLAG 25 *NOFS21DUPKY 23 *NOGEN 19 *NOINZDLT 23 *NOLIST 21 *NOLSTDBG 21 *NOMAP 20 *NOMAX 24 *NONUMBER 19 *NOOBSOLETE 25 *NOOPTIMIZE 22 *NOOPTIONS 20 *NOPATCH 21 *NOPRINT 21 *NOPRTCORR 20
compiler options (continued) *NORANGE 22 *NOSECLVL 20 *NOSEG 25 *NOSEQUENCE 19 *NOSOURCE 19 *NOSRCDBG 20 *NOSTDERR 22 *NOSTDINZ 23 *NOSYNC 22 *NOUNDSPCHR 25 *NOUNREF 22 *NOVARCHAR 23 *NOVBSUM 19 *NOXREF 19, 21 *NUMBER 19 *OBSOLETE 25 *OPTIMIZE 22 optimizing source code 22 *OPTIONS 20, 37 overview 6 *OWNER 26 parameters of the CRTCBLPGM command 1831 *PATCH 21 *PGM 18 *PGMID 18 *PRINT 21 PROCESS statement, using to specify 32 program listings, DBCS characters in 349 program-name 18 *PRTCORR 20 *PRV 26, 31 QLBLSRC (default source file) 18 QSYSPRT (default printer file) option 24 *QUOTE 20 *RANGE 21 release-level option 26, 31 *SECLVL 20 *SEG1 25 *SEG2 25 *SEQUENCE 19 severity-level option 19, 26 *SOURCE 18, 19, 37 source-file-member-name option 19 source-file-name option 18 specifying *SRCDBG 20 *SRCMBRTXT 19 *STDERR 23
392
compiler options (continued) *STDINZ 23 suppressing second-level messages 20 suppressing source listing 41 *SYNC 22 text-description 19 *UNDSPCHR 25 *UNREF 22 *USE 27 use compiler-generated sequence numbers use user-supplied sequence numbers 19 *USER 26 V2R1M0 value for release-level option 31 V2R1M1 value for release-level option 31 V2R2M0 value for release-level option 31 *VARCHAR 23 *VBSUM 19, 37 *XREF 19, 21, 37 compiler output See also messages browsing 39 See also source entry utility command summary listing 39 compiler output 36, 37 cross-reference listing 47 CRTCBLPGM options 37 Data Division map 44 description 37 examples 37 FIPS messages listing 46 listing descriptions 37 listing options 40 messages 329 options listing 39, 40 program listings, DBCS characters in 349 suppressing source listing 41 compiling COBOL programs abnormal compiler termination 16 compiler-detected errors 56 example listing 39 exceeding internal size limits 15 failed attempts 16 for extended ACCEPT/DISPLAY 23 for the previous release 31 invoking the compiler 15 messages 329 multiple programs 36 output 37 redirecting files 90 TGTRLS, using 31
20
CONCAT keyword 122 Configuration Section, description 10, 340 conforming to ANSI standards 332 constant, NULL figurative 286 contents of DEBUG-ITEM special register 319 contiguous items, definition 242 contiguous key fields, multiple 242 control returning 274 transferring 273 CONTROL-AREA clause 174175 control language commands See CL commands control of segmentation 310 *CONTROL statement 38 COPY DDS, use with indicators 118 control, returning from a called program 274 control, transferring to another program 273 CoOperative Development Environment/400 copies of ANSI standard available xiii COPY statement and DBCS characters 348 and externally described data 113 and floating-point 127 changes from ANSI 74 COBOL 335 data field structures 116 DD, DDR, DDS, or DDSR 112 DDS results 110, 118 description 112 example of data structures generated by 204 examples of key generation 121 format-1 COPY statement 36 in File Section 114 key fields 242 listing source statements 38 outside File Section 114 PROCESS statement containing COPY statement 37 suppressing source statements 38 use with PROCESS statement 36 use with TRANSACTION files 139 with ALL-FORMATS 114 COPYNAME field 43 corresponding options, PROCESS and CRTCBLPGM 32 CORRESPONDING phrase 256 counting verbs in a source program 19, 43, 49 CPI (Common Programming Interface) support 325
Index
393
Create Authorization List (CRTAUTL) command 27 Create COBOL Program (CRTCBLPGM) command AUT parameter 27 CVTOPT parameter 23, 34 description of 6 DUMP parameter 27 entering from CL program 28 entering from command line 28 EXTDSPOPT parameter 35 FLAG parameter 26, 35 FLAGSTD parameter 25, 35, 37 GENLVL parameter 19, 32 GENOPT parameter 21, 34 ITDUMP (n) parameter 27 MSGLMT parameter 24 OPTION parameter 19, 33, 37 parameters, description of 1831 PGM parameter 18 prompt displays, using 16 PRTFILE parameter 24 REPLACE parameter 26 SAAFLAG parameter 25, 35, 37 SRCFILE parameter 18 SRCMBR parameter 18 syntax of 29 TEXT parameter 19 TGTRLS parameter 26 USRPRF parameter 26 creating files indexed files 351, 356 relative files 351, 361 sequential files 351 cross-reference listing and breakpoints 57 CRTCBLPGM options 19, 21 description of listing 48 example 47 testing, using in 61 CRTAUTL (Create Authorization List) command 27 CRTCBLPGM command See Create COBOL Program command *CRTF option 22 *CURLIB option 18, 25 *CURRENT option 26, 31 Customer Information Control System (CICS) statements 13
CVTOPT parameter
23, 34
D
data area description 305 local 305 PIP 306 data class type (TYPE) field 45 data communications file 139, 172 data description entry for Boolean data 144 data description specifications (DDS) command attention (CA) keys 140 CONCAT keyword 122 Create File commands 105 date fields 132 DD option, description 113 DDR option, description 113 DDS option, description 113 DDSR option, description 113 definition 140 description 106 display management 140 examples CONCAT keyword 122 for a display device file 141 for field reference file 107 for subfile record format 159, 161 formats, data structures generated by 204 key generation 121 keyed access path for an indexed file 247 RENAME keyword 124 specifications for a database file 110 specifying a record format 109 SST keyword 126 work station programs 200, 231 externally described files 104, 242 FORMATFILE files 234 function keys 140 function of 140 graphic data fields 133 incorporate description in program 108 key fields 242 multiple device files 162 program-described files 104 RENAME keyword 124 SAA fields 132 SST keyword 126 subfiles 156 suffixes 123 time fields 132
394
data description specifications (DDS) (continued) timestamp fields 132 TRANSACTION files 139 use of keywords 107 variable-length fields 131 work station validity checking 140 Data Division arguments for calling program 280 Boolean data facilities 176 DBCS characters 341 description 10 map of, compiler option 20, 44 transaction files 173, 175 data errors with de-editing, handling 267 data field 10 data field structures 116 data item attributes of 46 defining as a pointer 283 in subprogram linkage 281 passing, with its length 280 substring reference 262 data items, unreferenced 22 data types 130 date 132 graphic 133 restrictions for SAA data types 132 time 132 timestamp 132 data, passing BY CONTENT and BY REFERENCE 280 in groups 281 database files See also disk files DATABASE file considerations 241 DATABASE versus DISK 241 DISK file considerations 241 processing methods 241 date data type 132 date-last-modified area 10 *DATETIME option 24 DBCS support See double-byte character set support DBCS-graphic data type 133 DD name 113 DDR name 113 DDS See data description specifications DDS name 113
*DDSFILLER option 22 DDSR name 113 de-editing 265 definition 265 examples 266 *DEB1 option 25 *DEB2 option 25 debugging programs 55, 313 breakpoints considerations for using 63 description 57 changing variable contents 63 compile-time switch 313 Data Division map and IRP listing, using 61 debug module 325 DEBUG-CONTENTS 319 DEBUG-ITEM special register 319 DEBUGGING MODE as compile-time switch 313 declaratives, running of 316 description 6, 55, 269 displaying table elements 60 displaying variables 60 ENDCBLDBG (End COBOL Debug) command 315, 316 features available 313 file status 103 formatted dump 67 functions for 55 line, definition 321 lines of a source program 321 OS/400 functions for 55 overview 6 run-time switch 67, 314 STRCBLDBG (Start COBOL Debug) command 314, 316 traces considerations for using 66 description 64 USE FOR DEBUGGING procedures 316 default source file (QLBLSRC) 10, 18 default values, indication of 16 DEFINED field 48 delays, reducing length of on initialization 251 deleted records, initializing files with 23, 251 delimiting SQL statements 12 descending file considerations 253 descending key sequence, definition 253 description and reference numbers flagged field 46
Index
395
designing your program 9 destination of compiler output 36 device control information 142 device dependence 89 examples 90 device files and I/O 89 DATABASE file considerations 241 DISK file considerations 241 multiple 162 single 162 device independence 89 *DFRWRT option 25 diagnostic levels 330 diagnostic messages 48 diagrams, syntax 29 direct files See relative files disclaimers examples patents ix sending information to IBM US government users disk files 241 processing methods 252 displacement (DISP) field 45 display device DDS for 140 record format 140, 141 display device file 140 display format data, definition 140 DISPLAY statement 344 Display Trace Data (DSPTRCDTA) command 65 displaying a compiler listing 39 displays CRTCBLPGM prompt display 17 data description specifications (DDS) for 140 display program messages 328 ENDCBLDBG prompt display 315 for sample programs order inquiry 216, 217 payment update 228, 229, 230 transaction inquiry 205 SEU display messages 327 STRCBLDBG prompt display 314 subfiles 157 distributed data management (DDM) 387 DIVIDE statement 336 divisions of programs Data Division 20, 173, 175, 341
divisions of programs (continued) Environment Division 171, 310, 311, 340 Identification Division 10 optional 10 Procedure Division 176, 311, 343348 required 10 do while structure, testing for end of chained list 304 double spacing 38 double-byte character set (DBCS) support 337350 ACCEPT statement 343 and alphanumeric data 346 checking 339 comments with DBCS characters 340 communications between programs 349 definition 386 enabling in COBOL programs 337 graphic 348 in the Data Division 341 in the Environment Division 340 in the Identification Division 340 in the Procedure Division 343348 open 348 PROCESS statement 337, 345 representation of DBCS data in batch jobs 348 searching for in a table 348 sorting 348 specifying DBCS literals 337, 338 DROP statement 179 DSPTRCDTA (Display Trace Data) command 65 *DUMP option 21 DUMP parameter for CRTCBLPGM command 27 dump, formatted 371 *DUPKEYCHK option 22, 270 duplication errors 258 dynamic access mode 158, 173, 249, 253 dynamic file creation 22 dynamic processing, definition 173
E
EBCDIC character, definition 387 editing source programs 9 See also source entry utility (SEU) efficiency considerations 268 efficiency, increased 22 eight-byte binary items, and performance
268
396
EJECT statement 38 elementary pointer data items 287 embedded SQL 12 End COBOL Debug (ENDCBLDBG) command 315, 316 end of chained list, testing for 304 END-OF-PAGE phrase 336 END-READ phrase 187, 190 END-REWRITE phrase 192 END-WRITE phrase 199 ending a called program 274 entering CRTCBLPGM from CL program 28 entering CRTCBLPGM from command line 28 entering source programs 9, 11 entering your program See source entry utility (SEU) Environment Division and DBCS characters 340 and transaction files 171 SEGMENT-LIMIT clause 310, 311 error checking for de-editing, run time 267 error handling 69 APIs 53, 70 nonstandard 77 overview 69 standard 76 error recovery, example 82 errors ADVANCING phrase with FORMATFILE files 234 duplication 258 errors to avoid 56 errors, in syntax See syntax errors examples access path for indexed file 247 breakpoint 57 COBOL and files 105 commitment control 94, 98 compiler options listing 20, 37 COPY DDS results 110, 119 COPY statement in PROCESS statement 37 cross-reference listing 47 Data Division map 44 DDS CONCAT keyword 122 for a display device file 140, 141 for a record format 109 for a record format with ALIAS keyword 111 for field reference file 107 for multiple device files 162
examples (continued) DDS (continued) for subfiles 159, 161 key generation 121 RENAME keyword 124 SST keyword 126 diagnostic messages listing 48 END-OF-PAGE condition 235 entering CRTCBLPGM from command line 28 error recovery 82 externally described printer files 237 file processing indexed files 356, 357 relative files 361, 363 sequential files 351, 353 FIPS messages listing 46 FORMATFILE file 234 formatted dump 371 generic START 242, 243 indicators 146 LENGTH OF special register with pointers 286 length of variable-length field 132 MOVE with pointers 288 multiple device files 165 pointers aligning 284 and LENGTH OF special register 286 and REDEFINES clause 285 and results of MOVE 288 initializing with NULL 286 passing items containing 289 processing chained list 302 program structure 9 record format specifications 107, 110 ROLLING phrase 195 run units multiples, running concurrently 278 multiples, running consecutively 276 single unit 274 with shared program 277 SEU display messages 327 source listing 41 trace 64 using pointers in chained list 302 variable-length graphic data 134 verb usage by count listing 43 work station application programs order inquiry 206 payment update 217 transaction inquiry 200
Index
397
exceptions 16, 52, 71, 81 *EXCLUDE option 27 exclusive-allow-read lock state 93 EXIT PROGRAM statement 274, 306 expressions 264, 343 *EXTACCDSP option 23 EXTDSPOPT parameter of the CRTCBLPGM command 35 EXTEND mode, definition 93 extended ACCEPT and DISPLAY statements 23 extensions, IBM double-byte character set (DBCS) support 337350 flagging 25, 331 format, indication in syntax 5 GOBACK overview 1 reading 5 transaction files 139231 extensions, list of 1 external description adding functions to 130 overriding functions to 130 external file status 70 externally described files 113, 236 adding functions 130 advantages of using for printer files 234 and COPY statement, DD, DDR, DDS, DDSR format 119 considerations for using 105 DDS for 108 description 104 level checking 130 overriding functions 130 printer files, specifying with FORMATFILE 234 EXTERNALLY-DESCRIBED-KEY 242 externally described TRANSACTION files 139142
F
failed I/O and record locking 94 failure of compiler 16 Federal Information Processing Standard (FIPS) 1986 COBOL standard 331 description 331 flagging deviations from 25, 331, 349 FLAGSTD parameter 25, 46 messages 46, 329, 331 options 25 standard modules 331
Federal Information Processing Standard (FIPS) (continued) standards to which the compiler adheres xiii with DBCS characters 349 FIB (file information block) 71 field names -DDS added to 123, 125 additional notes 127 construction of 116 fields attributes BLANK WHEN ZERO 260 defaults 260 SIGN IS TRAILING 260 USAGE IS DISPLAY 260 BLANK WHEN ZERO attribute 260 date 132 fixed length 132 floating-point 127 null-capable 133 time 132 time separator 38 timestamp 132 variable-length 131 character 131 graphic 131, 134 length of, example 132 maximum length 131 restrictions 131 figurative constant QUOTE 20 figurative constant, NULL 286 file and record locking 93, 95 file boundaries 251 file considerations 89, 241, 306 file control entry 89 of Environment Division 171 TRANSACTION file processing entry 171 file descriptions 108, 175 file information block (FIB) 71 file locking 93 file-name option 24 file operations for printer file 233 file organization 250 file processing See files file redirection 90, 92 file status 0Q 251 9N 83 9Q 251
398
file status (continued) after I/O 83 coded examples 353 from message monitors 73 how it is set 72 internal and external 70 obtaining 103 statements that affect 306 FILE STATUS clause 103 files See also disk files, externally described files, program-described files, source files access paths 250 attributes of 45 closing 336 creation of indexed 351, 356 relative 351, 361 sequential 351 DATABASE 241 DATABASE versus DISK 241 description 351 DISK 241 examples indexed files 356, 357 relative files 361, 363 sequential files 351, 353 external description 105 FORMATFILE 234 indexed organization 241 keys 129 logical 246 methods of 251 on AS/400 systems 89, 351 preserving sequence of records 250 PRINTER 233 processing methods 241 redirecting access to 90 relative 249 relative organization 249 retrieval of, relative 351, 365 sample programs 351367 sequential 249 sequential organization 249 specific 233 techniques for processing 351367 TRANSACTION 139 files unavailable at OPEN time 22 FILLER floating-point fields 127
FIPS flagging See Federal Information Processing Standard FIPS-ID field 46 FIPS violations flagged, total 47 fixed length graphic fields 133 *FLAG option 25, 37 FLAG parameter for CRTCBLPGM command 26, 35 FLAGSTD parameter for CRTCBLPGM command 25, 35, 46 float test, de-editing 267 floating-point fields 127 FOOTING phrase 336 format (record) level structures 115 format-1 COPY statement 36 format-2 COPY statement 16 format names, additional notes 127 FORMAT phrase 181, 186, 189, 191 FORMATFILE files description 234 sample program 234 formats, using SEU See source entry utility formatted dump 55, 67, 371 *FS21DUPKY option 23 function keys and CONTROL-AREA clause 175 specifying with DDS See transaction files functional processing modules 323
G
*GEN option 19 general-use programming interfaces description ix error-handling 70 QCMDEXC 28, 255 generation of I/O formats 118 generation of keys 121 generation of message monitors 73 generic START statement 242 GENLVL parameter for CRTCBLPGM command 19, 32 GENOPT parameter for CRTCBLPGM command 21, 34 GIVING phrase 335, 336 GO TO statement 312 GOBACK statement 307
Index
399
Grant Object Authority (GRTOBJAUT) command 27 graphic data types 133 restrictions 133 *GRAPHIC option 24 group level names 116 group structures, aligning pointers within GRTOBJAUT (Grant Object Authority) command 27
284
H
handling data errors, de-editing 267 *HIGH option 25 highlights 2, 351 hyphen, produced when copying ALIAS names 113
I
I/O formats 118 IBM extensions double-byte character set (DBCS) support 337350 flagging 25, 331 format, indication in syntax 5 GOBACK overview 1 reading 5 transaction files 139231 ICF See intersystem communications function Identification Division and DBCS characters 340 description 10 identifier call by 282 defining in Working-Storage section 258 unreferenced 22 increasing efficiency 22 INDARA keyword 118 independence, device 89 independent segments 309 indexed files creation 351, 356 description 241 key fields 241 processing methods for types DISK and DATABASE 241 updating 351, 357
indexed files, definition 356 indexed I-O module 324 indicator structures 117 indicators and ASSIGN clause 143 and Boolean data items 144 and COPY statement 114, 118 associated with command keys 140 data description entries 144 description 115, 142 example, using in programs 146 in a separate indicator area 143, 145, 270 in the record area 143, 146 INDARA DDS keyword 143 INDICATOR clause 145 INDICATORS phrase 145 performance considerations 270 sample programs 146 special considerations for 144 structures 116 TRANSACTION file processing 142 using 144 industry standards xiii initialization of storage 279 initializing files with deleted records 251 initializing pointers 286 with NULL figurative constant 286 input field 140, 189 input records 102 input spool 91, 92 input verbs, processing of since Version 1, Release 3 80 Input-Output formats 118 input-output verbs, processing of since Version 1, Release 3 80 INSPECT statement 345 inter-program module 324 *INTERMEDIATE option 25 intermediate representation of program (IRP) cross-reference listing 21 how to list 21 how to list attributes 21 how to use 57 sample listing 62 internal file status 70 internal name (I-NAME) field 45 internal size limits 15 International Standards Organization (ISO) xiii interprogram calls using pointers 289
400
interprogram communication considerations 273 intersystem communications function (ICF) ACCESS MODE clause 173 ASSIGN clause 172 communications 156 CONTROL-AREA clause 174 FILE STATUS clause 173 multiple and single device files 162 ORGANIZATION clause 172 RELATIVE KEY clause 173 using to specify subfiles 156 INTO phrase 186, 335 introduction to COBOL/400 1 invalid characters 113 DDR and DDSR options 113 INVALID KEY phrase 190, 192, 199 role since Version 1, Release 3 80 *INZDLT option 23, 251 I-O feedback 55, 103, 343 I-O flags 371 I-O operation 371 I/O verbs, processing of since Version 1, Release 3 80 IRP (intermediate representation of program) See intermediate representation of program (IRP) ITDUMP parameter for CRTCBLPGM command 27 items grouped by level 47
keys (continued) validity 242 keywords DDS 111, 122, 124, 126 in syntax diagrams 2 INDARA 118
L
language elements See program structure last-used state, description 274 LDA (local data area) 305 length (LENGTH) field 45 length of records in source file 10 LENGTH OF special register 280, 286 length of statement, maximum 11, 12 level checking 130 level of data item (LVL) field 44 level of language support 323, 324, 331 *LIBCRTAUT option 27 *LIBL option 18, 24 libraries, test 55 library-name option 18, 25 LIKE clause description 258 format of 259 PICTURE portion 260 limitations 89 TGTRLS parameter 31 limits, internal, size 15 LINAGE clause 233 *LINENUMBER option 20 linkage items, setting the address of 287 Linkage Section describing data to be received 281 parameters for a called program 280 *LIST option 21 listings browsing See source entry utility command summary 39 compiler options in effect 20 cross-reference 47 Data Division map 44, 61 DBCS characters in 349 default output file 24 example, source listing 19, 41, 43 examples of 40 FIPS messages 46 messages description 48
J
job failure, recovery 82 JUSTIFIED clause 342
K
key fields contiguous, multiple 242 descending keys 253 for indexed files 241 name, -DDS added to 123, 125 partial keys 242 program-defined 246 keyed read 91 keyed sequence 129, 241, 250, 253 keys common 129 floating-point 127 generation of 121 record 129
Index
401
listings (continued) messages (continued) example 48 from COBOL/400 compiler 329 minimum record length 24 options 40 scanning for syntax errors 39 specifying output file for 24 verb usage by count 19, 43 literals, DBCS 338340, 348 literals, delimiting 20 local data area (LDA), definition 305 lock level (*CS), under commitment control 95 high, under commitment control 95 low, under commitment control 95 lock state 93 locking, file and record 93 logic of segmentation 310 logical file considerations 246 logical operators 2 looking at a compiler listing See source entry utility (SEU) loops in a program 271 *LSTDBG option 21
M
main program, description 273 major/minor return codes 75 *MAP option 20, 37 maximum record length, dynamically created files 22 maximum-severity-level option 24 maximum source statement length 11, 12 member type See source member type members 92 memory management See segmentation MERGE statement 312, 335, 348, 368 message files 331 message-limit option 24 message monitor generation 73 messages Application Development Tools 327 compilation 329 compile-time 327 diagnostic 48 field on diagnostic messages listing 49 FIPS 329
messages (continued) interactive 327 responding to in an interactive environment 329 run-time 328 and standard error handling 69 SAA, flagged 47 severity levels 19, 24, 330 statistics 49 types 327 methodology for entering programs 9 migrating ANSI 74 COBOL programs 335 to ANSI 85 COBOL 335 to COBOL/400 language 335 *MINIMUM option 25 mismatched records, reducing occurrence 281 module global table (MGT), definition 371 Monitor Message (MONMSG) command 16 monitoring exceptions 16 monitoring operations monitors, message 73 MONMSG (Monitor Message) command 16 MOVE statement 319, 346 CORRESPONDING phrase 256 using pointers 287 MSGID and severity level field 49 MSGLMT parameter 24 multiple contiguous key fields 242 multiple device files 162170, 178, 184, 190 multiple members 92
N
name, assignment 89, 143, 172, 341 names defined when GENOPT(*NOUNREF) specified 15 NAMES field 48 NEXT MODIFIED phrase 189 NO DATA phrase 186 role since Version 1, Release 3 80 NO LOCK phrase, and performance 94, 270 NO REWIND phrase 336 *NOATR option 21 *NOBLK option 23 *NOCRTF option 22 *NODATETIME option 24 *NODDSFILLER option 22 *NODEB option 25
402
*NODFRWRT option 25 *NODUMP option 21 *NODUPKEYCHK option 22 *NOEXTACCDSP option 23 *NOFIPS option 25 *NOFLAG option 25 *NOFS21DUPKY option 23 *NOGEN option 19 *NOGRAPHIC option 24 *NOINZDLT option 23 *NOLIST option 21 *NOLSTDBG option 21 *NOMAP option 20 *NOMAX option 24 nonnumeric literals 20 nonstandard error handling 77 nonstandard language extensions See IBM extensions *NONUMBER option 19 *NOOBSOLTE option 25 *NOOPTIMIZE option 22 *NOOPTIONS option 20 *NOPATCH option 21 *NOPRINT option 21 *NOPRTCORR option 20 *NORANGE option 22, 269 *NOSECLVL option 20 *NOSEG option 25 *NOSEQUENCE option 19 *NOSOURCE option 19 *NOSRCDBG option 20 *NOSTDERR option 23 *NOSTDINZ option 23 *NOSYNC option 22 NOT AT END phrase 187, 190 role since Version 1, Release 3 80 NOT INVALID KEY phrase 190, 192, 199 role since Version 1, Release 3 80 notation, syntax 2 notices description ix patents ix revision bars ix *NOUNDSPCHR option 25 *NOUNREF option 22 *NOVARCHAR option 23 *NOVBSUM option 19 *NOXREF option 19, 21 nucleus module 324
null-capable fields 133 NULL figurative constant 286 null values 133, 304 *NUMBER option 19 numeric items and performance 268 moving with de-editing 265 numeric usage clauses 116
O
Object Definition Table (ODT) 22 object names, OS/400 16 object program compiler options, specifying 21 optimizing, specifying at compile-time 22 output from compiler 15 specifying authority to 27 subscript range checking 21 object program, definition 6 *OBSOLETE option 25 OCCURS clause 341 ODP (open data path) 94 ODT (Object Definition Table) 22 offset, relative to 16-byte boundary 289 open data path (ODP) 94 OPEN operation, increasing speed of 94 OPEN statement 180 OPEN type 93 OPEN-FEEDBACK 343 operation, more efficient 22 operators, arithmetic and logical 2 *OPTIMIZE option 22 optimizing code 22 OPTION parameter for CRTCBLPGM command 19, 37 optional clauses 3 optional divisions 10 optional items, syntax 3 optional processing modules 324 options data formats, *NORANGE option 269 for the PROCESS statement 36 listing 40 of CRTCBLPGM command parameters 1831 segmentation 311 OPTIONS listing 40 *OPTIONS option 20, 33, 37
Index
403
order of clauses 3 ORGANIZATION clause 172 ORGANIZATION IS INDEXED clause 241 OS/400 operating system and messages 331 breakpoint commands 57 device control information 142 device independence and device dependence 89 functions for debugging 55 input/output 142 internal size limits 15 object names 16 security, maintaining while testing 55 testing, functions for 55 output compiler 37 compiler, displaying 39 output field 140 output file, definition 351 output spool 91 output verbs, processing of since Version 1, Release 3 80 Override Message File (OVRMSGF) command 331 Override to Diskette File (OVRDKTF) command 90 overriding messages 331 overriding program-specified files 92 overview 6 OVRDKTF command 90 OVRMSGF command 331 *OWNER option 26
P
packed decimal items 268 paper positioning 233 parameters of CRTCBLPGM command 18 See also Create COBOL Program (CRTCBLPGM) command parameters, describing in the called program partial key, referring to 242 parts of a COBOL program See program structure parts of a program 9 passing addresses between programs 303 passing data 279 in groups 281
280
passing data item and its length 280 *PATCH option 21 PERFORM statement 312, 336 performance considerations 268 I/O operations 102 permanent segment 309 *PGM option 18 PGM parameter for CRTCBLPGM command 18 *PGMID option 18 phrases ADVANCING 233 ADVANCING PAGE 336 AT END 187, 190 CORRESPONDING 20 END-OF-PAGE 336 END-REWRITE 192 END-WRITE 199 FOOTING 336 FORMAT 181, 186, 189, 191 GIVING 335, 336 INDICATORS 145, 181 INTO 186, 335 INVALID KEY 190, 192, 199 NEXT MODIFIED 189 NO DATA 186 NO REWIND 336 NOT AT END 187, 190 NOT INVALID KEY 190, 192, 199 REEL/UNIT 336 RELATIVE KEY 335 REMAINDER 336 ROLLING 195 STARTING 194 SUBFILE 182 TERMINAL 182, 187, 190, 192, 193, 198 USING 335 PICTURE clause 267, 342 and performance 268 defining with LIKE clause 258 PICTURE definitions 116 PIP (program initialization parameters) data area 306 description 306 pointer alignment, definition 283 pointer data items definition 282 elementary items 287 pointers aligning on boundaries 01-level items 284 77-level items 284
404
pointers (continued) aligning on boundaries (continued) automatically using FILLER 284 with blocking in effect 284 and REDEFINES clause 284 assigning null value 304 defining 283 defining alignment 283 definition 282 description 282 examples accessing user space 291 processing chained list 302 in CALL statement 289 in File Section 284 in Linkage Section 281 in MOVE statement 287 restrictions 287 in records 286 in tables 284 in Working-Storage 284 initializing 286 length of 282 manipulating data items 283 moving between group items 289 null value 304 processing a chained list 302 reading 285 writing 285 portability considerations See segmentation position of PROCESS statement 32 preface xi prestart job 306 previous release, compiling for 31 *PRINT option 21 printer file, default 24 printing based on indicators 234 editing field values 234 in overflow area 234 maintaining print formats 234 multiple lines 234 output from job with WRITE statement paging 233 paper positioning 233 spacing 233 procedure branching statements 348 Procedure Division and DBCS characters 343
233
Procedure Division (continued) and transaction files 176 changes from ANSI 74 COBOL 335 description 10 segmentation 311 specifying debugging in 316 subdivisions in 309 USE FOR DEBUGGING declarative 316 using SET statement to specify address 287 PROCESS statement 337 allowable options for 32 compiler options specified in 32 compiler output 37 considerations blocking output records 102 commitment control considerations 94 DATABASE files 241 device dependencies 89 DISK files 241 file and record locking 93 overriding program-specified files 92 overview 255 processing methods for types DISK and DATABASE 241 program-described and externally described files 104 spooling 91 unblocking input records 102 COPY statement, using with 36, 37 description 32 format of 32 options 36 position of statement 32 rules for 32 scope of options with CRTCBLPGM command 36 specifying compiler options 40 techniques file processing 351 indexed file creation 356 indexed file updating 357 relative file creation 361 relative file retrieval 365 relative file updating 363 sequential file creation 351 sequential file updating and extension 353 using to specify compiler options 32 processing methods for DATABASE files 241 processing methods for DISK files 241
Index
405
processing of I/O verbs since Version 1, Release 3 80 program control returning 274 transferring 273 program-described files considerations for using 105 description 104 externally described by DDS with Create File commands 104 TRANSACTION files 139 program global table (PGT), definition 371 program initialization parameters (PIP) data area See PIP data area program listings, DBCS characters in 349 program loops 271 program-name 18 program object compiler options, specifying 21 optimizing, specifying at compile-time 22 output from compiler 15 specifying authority to 27 subscript range checking 21 program parts 9 program patch area 21 program segments 309 program size 22 program stack, definition 273 program structure Data Division 175 Data Division map 44 data field 116 Environment Division 171 example 9, 10 format (record) level 115 Identification Division 10 indicator 116, 117 level of language support 325 Procedure Division 176 required and optional divisions 10 skeleton program 9 program syntax, debugging line 321 program template 21 program termination abnormal 52 and the CALL statement 312 file considerations 273 initialization 279 returning control 274 STOP RUN statement 274
program termination (continued) with the CANCEL statement 336 program variables changing 63 pointers 63 program-defined key fields 246 programming considerations 255 programming notes number of entries in Object Definition Table (ODT) 15, 22 prompts, using SEU See source entry utility *PRTCORR option 20 example listing 256 PRTFILE parameter for CRTCBLPGM command 24 *PRV option 26, 31 punctuation 2 purpose of this manual xi
Q
QCMDEXC, using in a program 28, 255 QLBLMSG compile-time message file 331 QLBLMSGE run-time message file 331 QLBLSRC (default source file) 10, 18 QLRCHGCM API 70 QLRRTVCE API 70 QLRSETCE API 53, 70 QRLMAIN MGTFUNC 269 QSYSPRT (default printer file) option 24 quadruple spacing 38 *QUOTE option 20 QUOTE, figurative constant, value of 20
R
random processing, definition 365 *RANGE option 21 reference modification 262 READ statement 344 changes in the use of ANSI 74 COBOL description 182 format, nonsubfile 186187 format, subfile 189190 indicators 145, 146 processing facilities 181182 FORMAT phrase 181
335
406
READ WITH NO LOCK 93, 95 record boundary 23 record format composition for display device 140 DDS for subfiles 159, 161 example, record format specification 105, 107, 110 fields 140 indicators 142 specification, use of DDS keywords in 107 subfiles 157 RECORD KEY clause 129 EXTERNALLY-DESCRIBED-KEY 129 record keys 129 RECORD KEYS, valid 242 record length of source file 10 records blocking output 102 containing pointers 286 locking and failed I/O 94 and performance 270 by COBOL 93 updating database records 93 preserving sequence of 250 reducing mismatches 281 unblocking input 102 recovery 82 example 84 procedure in program 83 with multiple acquired devices 83 with one acquired device 83 transaction files 83 with commitment control 82 recursive call, definition 273 REDEFINES Clause 341 for ALL-FORMATS or I/O phrases 119 pointer data item as subject or object 284 redefinition of formats 119 redefinition, group level name 116 redirecting files 90, 92 REEL/UNIT phrase 336 reference modification and *RANGE option 22 and INSPECT statement 264 calculating offset 289 description 262 left-justification 264 retrieving time value 262
reference numbers 19, 43, 49 REFERENCES field 48 references to other manuals xi referring to a partial key 242 register 319 reinitialization, avoiding 119 related printed information relative files and performance 270 creating 351, 361 definition 249 for OPEN OUTPUT 270 in COBOL 249 initializing for output 251 retrieval of 351, 365 sequential access 23 updating 351, 363 relative I-O module 324 RELATIVE KEY clause 173 RELATIVE KEY phrase 335 relative key, definition 158 release-level option 26, 31 RELEASE statement 348 releasing a record read for update 93 REMAINDER phrase 336 remote systems, communications between 139, 306 RENAME keyword 124 RENAMES clause 342 REPLACE parameter for CRTCBLPGM command 26 REPLACING, in format 2 COPY 127 reply modes 52 report writer module 325 required clauses 3 divisions 10 items, in syntax 3 reserved word list, and extended ACCEPT/DISPLAY 23 reserved word, -DDS added to 123, 127 responding to messages in an interactive environment 329 restrictions 89 return codes 75 return of control from called program 274 RETURN statement 348 REUSEDLT option See reusing deleted records
Index
407
reusing deleted records indexed files 242 relative files 249 sequential files 250 Revoke Object Authority (RVKOBJAUT) command 27 REWRITE statement and DBCS 344 description 191 for program-described transaction files 191 for TRANSACTION file 191 format 191, 192 indicators 145, 146 processing facilities 181, 182 ROLLBACK statement 95 boundary 95 ROLLING phrase 195 run time common errors 56 debugging 67, 314 debugging switch 313 error handling, de-edit 267 messages 328 and standard error handling 69 monitoring exceptions 16 program termination 52 redirecting files 90 subscript range checks, specifying 21 switch 67, 314, 315 run unit definition 36, 273 examples multiples, running consecutively 276 single run unit 274 with a shared program 277, 278 running COBOL/400 programs description 51 system reply list and reply modes 52 RVKOBJAUT (Revoke Object Authority) command 27
S
S in PICTURE clause 268 SAA Common Programming Interface (CPI) support 325 SAA CPI (Common Programming Interface) support 325 SAA data types
SAA flagging 47, 333 SAAFLAG parameter for CRTCBLPGM command 25, 35 screens See displays SEARCH statement 348 searching DBCS characters in a table 348 *SECLVL option 20 SECTION field 45 security maintaining while testing 55 specifying authority to object program 27 *SEG1 option 25 *SEG2 option 25 SEGMENT-LIMIT clause 310 segment-numbers 309311 segmentation 268, 309312, 325, 368 segmented program 309 SELECT statement, EXTERNALLY-DESCRIBED-KEY 121 separate indicator area (SI) attribute 143 sequence combining numbers 20 errors, checking for 19 number 10 of records, preserving 250 sequence error indicator (S) 43 *SEQUENCE option 19 sequential access mode 23, 173, 187, 189, 249, 251 sequential files creation 249, 351 definition 249 in COBOL 249 updating and extension 351, 353 sequential I-O module 324 service marks x SET statement 346 SEU (source entry utility) browsing a compiler listing 39 editing source programs 6, 9, 11 entering source programs 6, 9, 11 errors coding errors 56 common errors 56 detected by compiler 56 listing 48 messages at run time 328 formats, using 11 prompts and formats 11
408
SEU (source entry utility) (continued) Start Source Entry Utility (STRSEU) command 9 syntax-checking 1113, 327 TYPE parameter 9 severity-level 19, 26 severity level of messages 19, 24, 330 shared files 93 shared-for-read 93 shared-for-read lock state 93 shared-for-update 93 shared-no-update 93 shared ODP (open data path) 94 shared records 93 shift-in character, definition 338 shift-out character, definition 338 SIGN clause, defining with LIKE clause 258 sign in PICTURE clause, and performance 268 sign test, de-editing 267 single device files 162 size limits, internal 15 skeleton program 9 SKIP statement 38 SKIP1 statement 38 SKIP2 statement 38 SKIP3 statement 38 slash (/) 12, 38 SORT statement 312, 348, 368 sort-merge module 324 SORT/MERGE statement 348 Source Entry Utility See SEU source file default 10 fields 10 logical structure, specifying 172 program, suppressing listing 41 record length 10 source file format description 10 program segments 309 record length 10 source-file-member-name 19 source-file-name 18 source language debugging 313 source listing, example 41 source member type CICSCBL 13 CICSSQLCBL 13 compiling 16
source member type (continued) specifying 9, 11 SQLCBL 13 syntax-checking 11, 13 SOURCE NAME field 44 *SOURCE option 19, 37 source program compiling 15, 313 counting verbs used 19 DEBUG-ITEM special register 319 debugging lines 321 definition 2 editing source programs See SEU (source entry utility) entering source programs See SEU (source entry utility) listing 19, 41 WITH DEBUGGING MODE switch and compilation 313 source text manipulation module 324 space pointer, definition 282 spacing 38 special registers ADDRESS OF 280 LENGTH OF 280 implicit definition 286 in Procedure Division 286 SPECIAL-NAMES paragraph 12, 233, 335 specific file processing 233 spooling 91, 92 SQL (Structured Query Language) statements 12 SQLCBL member type 13 *SRCDBG option 20 SRCFILE parameter for CRTCBLPGM command 18 SRCMBR parameter for CRTCBLPGM command 18 *SRCMBRTXT option 19 SST keyword 126 stacks, shown in syntax 3 standard error handling 69, 76 standard, ANSI X3.23-1985 xiii Start COBOL Debug (STRCBLDBG) command 314, 316 Start Debug (STRDBG) command 55 Start Source Entry Utility (STRSEU) command 9 START statement 242, 344 STARTING phrase 194 starting the compiler 15
Index
409
statement length, maximum 11, 12 statement number (STMT) field 44, 49 statement number, compiler-generated (STMT) 43 statements ACCEPT 103, 177, 343 ACQUIRE 178 ALTER 312 arithmetic, in DBCS processing 345 breakpoints 57 CALL 312 CANCEL 336 CLOSE 179, 336 COMMIT 95 compiler output 37 COPY 104, 114, 335, 348 DISPLAY 344 DIVIDE 336 DROP 179 EJECT 38 in syntax diagrams 3 INSPECT 345 MERGE 312, 335, 348, 368 MOVE 319, 346 OPEN 180 PERFORM 312, 336 PROCESS 32, 337 READ 182, 335, 344 RELEASE 348 RETURN 335, 348 REWRITE 191, 344 ROLLBACK 95 SEARCH 348 SET 346 SKIP 38 SORT 312, 368 START 344 START, generic 242 STOP 348 STRING 346 UNSTRING 346 USE 199 WRITE 193, 336, 345 *STDERR option 22 *STDINZ option 23 STOP RUN statement 274, 306 STOP statement 348 storage optimization See segmentation
storage, initialization of 279 storage, using less 22 STRCBLDBG (Start COBOL Debug) command 314, 316 STRDBG (Start Debug) command 55 STRING statement 346 STRSEU (Start Source Entry Utility) command 9 structure, program See program structure Structured Query Language (SQL) statements 12 subfield contents, DEBUG-ITEM special register 319 subfiles 156158, 182 subprogram 36, 273 linkage 281 subscript range checking, specifying 21 subscript ranges 21 subscripting 265 substitution character (X3F) in data 137 suffix -DDS added to key field name 123, 125 added to reserved word 123, 127 summary of changes changes made in Version 2 Release 1.1 changes made in Version 2 Release 2 support for ANSI X3.23-1985 standard 323 suppressing source listing 41 suppression of messages 330 switch, run-time 67, 314, 315 symbols used in syntax 3 *SYNC option 22 syntax arrows 3 checking, in SEU 11, 12, 39 checking, unit of 11 debugging lines 321 diagrams, using 3 keywords in 2 notation 2 of CRTCBLPGM command 29 optional items 3 punctuation 2 required and optional clauses 3 required items 3 stacks 3 symbols 3 system override considerations 92 system reply list 52
410
T
table items, attributes of 46 table, reference modification 263 target release 26, 31 template, program 21 TERMINAL phrase 182, 187, 190, 192, 193, 198 termination, program 52, 336 testing COBOL/400 programs and debugging 55 breakpoints 57, 63 changing variable contents 63 Data Division map and IRP listing, using 61 displaying table elements 55, 60 displaying variables 60 file status 103 formatted dump 67 OS/400 functions for 55 overview 6 security, maintaining 55 test libraries 55 traces 64, 66 text-description 19 TEXT parameter for CRTCBLPGM command 19 TGTRLS parameter for CRTCBLPGM command 26, 31 time data type 132 time value, retrieving 262 time-separation characters 38 timestamp data type 132 TITLE statement 38 tools for entering source programs 9 traces as an OS/400 function 55 considerations 66 description 64 example 64 using 64 tracing a loop 271 trademarks x transaction files ACCESS MODE clause 173 and subfiles 158 ASSIGN clause 172 Boolean data facilities 176 CONTROL-AREA clause 174 data description specifications (DDS) for 139, 140 Data Division considerations 173, 175 defining 139 description 139
transaction files (continued) display management 140 Environment Division considerations 171 externally described 139 file control entry and Environment Division 171 file description entry and Environment Division 175 FILE STATUS clause 173 file status, setting of 71 major return code 71 minor return code 71 ORGANIZATION clause 172 organization of 172 Procedure Division considerations 176 processing externally described 142 program-described RELATIVE KEY clause 173 return codes 71 sample programs, work station 200 transferring control to another program 273 transferring program control 273 triple spacing 38
U
UFCB (user file control block) 71 unattended mode, running the program 331 unblocking input records 102 underscores, removed from end of field name 113 underscores, translated to hyphens 113 *UNDSPCHR option 25 unit of syntax checking 11 *UNREF option 22 unreferenced data items 22 unreferenced identifiers 15 UNSTRING statement 346 updating and extension of sequential files 351, 353 indexed files 351, 357 relative files 351, 363 sequential files 353 UPSI (user program status indicator) switch USAGE clause defining with LIKE clause 258 numeric 116 USAGE IS POINTER 282 with transaction files 144
Index
411
USE FOR DEBUGGING declarative 316, 317 in the Procedure Division 316 using the procedures 317 *USE option 27 USE procedure role since Version 1, Release 3 80 USE statement coded examples 353, 354 description 199 EXCEPTION/ERROR for TRANSACTION file 199 format 199 user file control block (UFCB) 71 *USER option 26 user profile 26 user program status indicator (UPSI) switch user spaces accessing using APIs 291 using a subfile for display 156158 using double-byte characters 337 using less storage 22 USING phrase 335 using REPLACING in format 2 COPY statement 127 using the COBOL/400 language See COBOL/400 language USRPRF parameter for CRTCBLPGM command 26
W
where DBCS characters can be used 340 WITH DEBUGGING MODE switch and compilation 313 work stations communications between 139 sample programs order inquiry 206 payment update 217 transaction inquiry 200 validity checking 140 Working-Storage section defining identifiers 258 WRITE statement and DBCS 345 changes from ANSI 74 COBOL 336 description 193 for program-described transaction files 193 for TRANSACTION file 193 format, nonsubfile 193195 format, subfile 198199 indicators 145, 146 processing facilities 181182
X
X3F (substitution character) in data *XREF option 19, 21, 37 137
V
V2R1M0 option 31 V2R1M1 option 31 V2R2M0 option 31 valid RECORD KEYS 242 validity checking 140 VALUE clause 342 VALUE IS NULL 304 value of figurative constant QUOTE 20 *VARCHAR option 23 variable-length fields 131 defining 131 example of 131, 134 length of, example of 132 maximum length of 131 restrictions 131 variables, changing values while testing 63 *VBSUM option 19, 37 verbs usage by count listing 43
412