Hp bladesystem management pack for microsoft system center essentials 2007 user guide (73 pages)
Summary of Contents for Compaq COBOL AAQ2G1FTK
Page 1
Compaq COBOL User Manual Order Number: AA–Q2G1F–TK October 2000 This manual provides information to help you develop Compaq COBOL programs for the OpenVMS Alpha and Compaq Tru64 UNIX platforms. Revision/Update Information: Operating System and Version: OpenVMS Alpha Version 6.2 or higher;...
Developing Programs on Tru64 UNIX ......1.2.1 Creating a Compaq COBOL Program on Tru64 UNIX ... . . 1.2.2 Compiling a Compaq COBOL Program on Tru64 UNIX .
Page 4
1.3.3 Linking a Compaq COBOL Program ......The LINK Command ........
Page 5
2.7.2 Standard and Native Arithmetic ......2.7.2.1 Using the /MATH_INTERMEDIATE Qualifier ....2.7.2.2 Using the /ARITHMETIC Qualifier .
Page 6
4.3.7 Assigning Index Values Using the SET Statement ....4.3.7.1 Assigning an Integer Index Value with a SET Statement ..4.3.7.2 Incrementing an Index Value with the SET Statement .
Page 7
X/Open Standard Record Locking ......8.4.1 Compaq Standard Record Locking ......8.4.2 8.4.3...
Page 8
10.5.5 10.6 Programming a Linage-File Compaq COBOL Report ....10.6.1 Defining the Logical Page in a Linage-File Report ....
Page 9
10.8.8 Defining the Source for a Print Field ......10.8.9 Specifying Multiple Reports ....... . . 10.8.10 Generating and Controlling Report Headings and Footings .
Page 10
Calling COBOL Programs from C ......12.7 Calling Non-COBOL Programs from Compaq COBOL ....12.7.1 Calling a Fortran Program .
Page 11
REFORMAT Error Messages ........15 Optimizing Your Compaq COBOL Program Specifying Optimization on the Compiler Command Line .
Page 12
OpenVMS VAX ........B.3.2 Compaq COBOL Specific Qualifiers and Flags ....B.3.3 Qualifiers Only on Compaq COBOL for OpenVMS VAX .
Page 13
OpenVMS Debugger (OpenVMS) ....... . Notes on Compaq COBOL Support ......
Page 14
D Porting to Compaq COBOL from Other Compilers Porting Assistance ......... . .
Page 15
6–1 Sample Record Description ....... . . Determining Fixed-Length Record Size ......6–2 6–3 Determining Fixed-Length Record Size for Files with Multiple Record...
Page 16
X/Open Standard Record Locking ......8–5 Automatic Record Locking (Compaq Standard) ....8–6 Sample Program Using Manual Record Locking (Compaq Standard) .
Page 17
10–10 Sample Program EX1010 ........Printing Labels Four-Up ........10–11 10–12 Printing Labels Four-Up in Sort Order .
Page 18
Source Code Used in the Sample Debug Sessions ....Figures Commands for Developing Compaq COBOL Programs on Tru64 1–1 UNIX ..........
Page 19
Other File Name Suffixes ........1–2 Compaq COBOL Command Flags on Tru64 UNIX ....1–3 Main Tools for Program Development and Testing .
Page 20
Available Character Attributes by Terminal Type ....11–1 11–2 Compaq COBOL Characters Returned for Cursor Positioning, Program Function, Function, Keypad, and Keyboard Keys ..11–3 Key Functions for the EDITING Phrase .
This manual provides information to help you develop Compaq COBOL programs for the OpenVMS Alpha and Compaq Tru64 UNIX platforms. Compaq COBOL is the new name for DEC COBOL and for DIGITAL COBOL. Compaq COBOL, unmodified, refers to the COBOL language on three platforms:...
Page 24
• Appendix A contains a list of Compaq COBOL specificatons and limits on the Tru64 UNIX and OpenVMS Alpha systems. • Appendix B describes compatibility and portability issues between Compaq COBOL for OpenVMS VAX and Compaq COBOL on the Tru64 UNIX and OpenVMS Alpha systems.
Page 25
027 for Version 2.7. On the Tru64 UNIX operating system, the release notes are in: /usr/lib/cmplrs/cobol/relnotes Compaq COBOL Installation Guide for OpenVMS Alpha Systems This manual provides information on how to install Compaq COBOL on the...
Page 26
Convention . . . Format special-character words quotation mark apostrophe user input xxvi Meaning Braces used in a general format enclose lists from which you must choose only one item. For example: SEQUENTIAL RANDOM DYNAMIC Brackets used in a general format enclose optional items from which you can choose none or one.
Page 27
Compaq extensions to the 1985 ANSI COBOL Standard are color coded in blue or gray. Note that the term extension in this manual means a Compaq extension to the ANSI COBOL Standard. (Some of these extensions are included in the X/Open CAE Standard for the COBOL language.)
Page 28
Compaq Tru64 UNIX was formerly known as DEC OSF/1 or as DIGITAL UNIX. Compaq COBOL was formerly known as DIGITAL COBOL or DEC COBOL. Compaq COBOL for OpenVMS VAX was formerly known as VAX COBOL or as DIGITAL VAX COBOL.
Page 29
Compaq cannot prevent problems that originate in application code. For more information, see Section 1.6. New Features Consult the Index for entries under Version 2.7 – what’s new since V2.5. They will point you to information added since Version 2.5 of Compaq COBOL. xxix...
Computer Corporation. It operates comfortably in the Compaq common language environment; it is based on GEM, which is the highly advanced code generator and optimizer that Compaq uses in its family of languages, which includes COBOL, C, C++, FORTRAN 77, FORTRAN 90, BASIC, Ada, and PASCAL. In addition to standard COBOL features, Compaq COBOL includes extensions that make new application development efficient and effective, with features helpful in...
COBOL statement at a time, determines the VAX instructions to be constructed to execute that statement, and then moves on to the next one. This tactic works well for a CISC architecture like the VAX. Compaq COBOL for OpenVMS VAX does ‘‘peephole’’ optimization.
1.1.2 Tuning OpenVMS Alpha for Large Compaq COBOL Compiles The recommendations that follow were determined by compiling one set of very large Compaq COBOL modules on OpenVMS Alpha. While your results may vary, the principles are generally applicable. For more detailed information on OpenVMS Alpha tuning, see the OpenVMS System Manager’s Manual,...
Developing Compaq COBOL Programs 1.1 Compaq COBOL and Alpha Architecture System Resources COPY files referenced). Alternatively, multiply 25 times the number of lines in the program (including all COPY files). The resulting figure can then be used as a starting point for the system generation parameter VIRTUALPAGECNT.
Page 35
1.1 Compaq COBOL and Alpha Architecture System Resources More physical memory can also be made available to a process (if it is present on the machine) by adjusting the system generation parameter WSMAX and the corresponding WSEXTENT (in AUTHORIZE). Approach such adjustments...
See Section 1.3.2.4 for additional information. 1.1.3 Choosing a Reference Format You need to choose a reference format before you set out to write a Compaq COBOL program, and you must be aware of the format at compile time. The Compaq COBOL compiler accepts source code written in either terminal or ANSI reference format.
The REFORMAT utility allows you to convert a terminal format program to ANSI format and vice versa. You can also use REFORMAT to match the formats of Compaq COBOL source files and library files when their formats are not the same. See Chapter 14 for a description of the REFORMAT utility.
Developing Compaq COBOL Programs 1.2 Developing Programs on Tru64 UNIX Figure 1–1 Commands for Developing Compaq COBOL Programs on Tru64 UNIX COMMANDS % vi prog1.cob Use the file type of cob to indicate the file contains a Compaq COBOL program.
COPY statement. Special Considerations for Routines Named ‘‘main’’ If you have a program or routine named ‘‘main,’’ declared either in a Compaq COBOL or other module, your application may not work correctly. The Compaq COBOL library contains a routine named ‘‘main,’’ which initializes the run-time environment for the CALL by data name statements, extended ACCEPT and DISPLAY statements, and some error handling.
Compaq COBOL compiler. It accepts a list of command flags and file names and causes one or more processors (compiler, assembler, or linker) to process each file.
For a complete list of Compaq COBOL flags, see Table 1–2. For more information about the Compaq COBOL flags, access the reference (man) page for COBOL at the Tru64 UNIX system prompt.
Page 44
3. The -xref to generate a data file that the Compaq FUSE Database Manager uses to create a static analysis database file. This improves the performance of the Compaq FUSE Call Graph Browser and the Compaq FUSE Cross-Referencer, which use the database file for their operations.
4. Any copy file that contains a PROGRAM-ID or END PROGRAM statement for a program must contain that entire program. When compiled in the Compaq FUSE environment (using the compiler options certain Compaq COBOL programs may fail, with this fatal diagnostic result:...
file, whether you specify one source file or multiple source files separated by blanks. The one executable image file. 1–16 Developing Compaq COBOL Programs , which contains the main program mainprog.cob calc option prevents linking and retains the array_calc.o...
The following examples show the use of the followed by a description of the output files that it produces. % cobol -V aaa.cob bbb.cob ccc.cob The Compaq COBOL source files into temporary object files. The temporary object files are passed to the linker. The the compiler to create the listing files...
Developing Compaq COBOL Programs 1.2 Developing Programs on Tru64 UNIX % cobol -V *.cob Compaq COBOL source files with file names that end with .cob are compiled into temporary object files, which are then passed to the linker produces the a.out file.
If the compiler creates a listing file, it writes the messages to the listing file. 1.2.3 Linking a Compaq COBOL Program on Tru64 UNIX Once your program has compiled successfully, the system passes the resulting object file (which has the suffix .o by default) to the linker to create an executable image file.
When processing a C source file ( need to specify the appropriate C libraries using the 1–20 Developing Compaq COBOL Programs string flag specifies an additional file name that is added to locate. The standard COBOL library file...
COBOL command would have otherwise passed to shared library, all symbols must be resolved. For more information about the standard list of libraries used by Compaq COBOL, see Section 1.2.3.2. Developing Compaq COBOL Programs 1.2 Developing Programs on Tru64 UNIX...
Linker messages are descriptive, and you do not normally need additional information to determine the specific error. The general format for follows: message-text 1–22 Developing Compaq COBOL Programs , be aware of the following restrictions: setuid setgid shell command, but only systemwide inlib command.
The simplest form of the run command to execute a program is to type its file name at the operating system prompt, as follows: % myprog.out In addition to normal IO accesses, your Compaq COBOL programs can read command-line arguments and access (read and write) environment variables. 1.2.4.1 Accessing Command-Line Arguments Command-line arguments allow you to provide information to a program at run time.
ACCEPT and DISPLAY statements in the Procedure Division to parse the command line and access the arguments. Detailed information about command- line argument capability is in the ACCEPT and DISPLAY sections in the Compaq COBOL Reference Manual. 1.2.4.2 Accessing Environment Variables You can read and write environment variables at run time through your Compaq COBOL program.
For information about topics usually considered during application design, specification, and maintenance, see your operating system documentation, appropriate reference pages, or appropriate commercially published documentation. Developing Compaq COBOL Programs 1.2 Developing Programs on Tru64 UNIX Arguments Developing Compaq COBOL Programs 1–25...
• To create shared libraries on Tru64 UNIX systems, use command. For more information, refer to Section 1.2.3.4 and the DIGITAL UNIX Programmer’s Guide. 1–26 Developing Compaq COBOL Programs Tool and Description sccs to manage source files. For more information, see the Tru64 UNIX documentation on programming support tools or the appropriate reference page.
1.3.1 Creating a Compaq COBOL Program on OpenVMS Alpha To create and modify a Compaq COBOL program, you must invoke a text editor. The default editor for OpenVMS Alpha is the DEC Text Processing Utility (DECTPU). Other editors, such as EDT or the Language-Sensitive Editor (LSE), may be available on your system.
DECTPU editor and creates the source file PROG_1.COB: $ EDIT PROG_1.COB The file type .COB is used to indicate that you are creating a Compaq COBOL program. COB is the default file type for all Compaq COBOL programs. The COPY Statement, Dictionaries and Libraries...
Common Data Dictionary Language (CDDL) or Common Dictionary Operator (CDO). For more information about using Oracle CDD/Repository and creating and maintaining text libraries, refer to the Compaq COBOL Reference Manual and Using Oracle CDD/Repository on OpenVMS Systems. 1.3.2 Compiling a Compaq COBOL Program on OpenVMS Alpha To compile your program, use the COBOL command.
Specifies an input source file that contains the program or module to be compiled. You are not required to specify a file type; the Compaq COBOL compiler assumes the default file type COB. If you do not provide a file specification with the COBOL command, the system prompts you for one.
1.3.2.4 Separately Compiled Programs If a compilation unit consists of multiple separately compiled programs (SCPs), by default the Compaq COBOL compiler produces a single object file that consists of a single module with multiple embedded procedures. This object file can be inserted into an object library.
/CONDITIONALS=(character,...) or /NOCONDITIONALS /CONVERT=[NO]LEADING_BLANKS or /NOCONVERT /COPY_LIST or /NOCOPY_LIST /CROSS_REFERENCE= ALPHABETICAL DECLARED or /NOCROSS_REFERENCE This is the default keyword when using the named option with no keywords. 1–32 Developing Compaq COBOL Programs Default /NOALIGNMENT /NOANALYSIS_DATA /NOANSI_FORMAT /ARCHITECTURE=GENERIC GENERIC HOST EV56 EV67...
Page 63
This is the default keyword when using the named option with no keywords. Developing Compaq COBOL Programs Default /DEBUG=TRACEBACK /DEBUG=ALL /DEBUG=(TRACEBACK,SYMBOLS) /NODEPENDENCY_DATA /NODIAGNOSTICS /NODISPLAY_FORMATTED /NOFIPS ,... /NOFLAGGER /FLOAT=D_FLOAT /GRANULARITY=QUADWORD /NOHELP /NOINCLUDE /NOKEEP /NOLIST /LIST (batch) (continued on next page) Developing Compaq COBOL Programs 1–33...
Page 64
GENERIC HOST TUNE= EV56 EV67 PCA56 or /NOOPTIMIZE This is the default keyword when using the named option with no keywords. /OPTIMIZE=0 is functionally equivalent to /NOOPTIMIZE. 1–34 Developing Compaq COBOL Programs Default /NOMACHINE_CODE ,... /NOMAP /MATH_INTERMEDIATE=FLOAT CIT3 CIT4 FLOAT...
The /CONDITIONALS qualifier is listed in Table 1–4. For more information about the /CONDITIONALS qualifier, invoke the online Help facility for Compaq COBOL at the system prompt. For more information about the WITH DEBUGGING MODE clause, refer to the Compaq COBOL Reference Manual.
Page 67
The text of the message Although most compiler messages are self-explanatory, some require additional explanation. The online HELP facility for Compaq COBOL contains a list and descriptions of these Compaq COBOL compiler messages. Use the HELP COBOL Compiler Messages command to access this list.
1.3 Developing Programs on OpenVMS Alpha 1.3.2.9 Using Compiler Listing Files A compiler listing file provides information that can help you debug or document your Compaq COBOL program. It consists of the following sections: • Program listing The program listing section contains the source code plus line numbers generated by the compiler.
1.3.3 Linking a Compaq COBOL Program After you compile a Compaq COBOL source program or module, use the LINK command to combine your object modules into one executable image that the OpenVMS Alpha operating system can execute. A source program or module cannot run until it is linked.
1.3.3.3 Specifying Modules Other than Compaq COBOL Modules When you link Compaq COBOL modules with other modules, your application will not work correctly if a non Compaq COBOL module contains a LIB$INITIALIZE routine that: 1. Is invoked before the Compaq COBOL LIB$INITIALIZE routine (COB_ NAME_START) and 1–40 Developing Compaq COBOL Programs...
CALL, ACCEPT, or DISPLAY statements are performed. The order in which LIB$INITIALIZE routines are invoked is determined during the link and is shown in the image map. To ensure that the Compaq COBOL LIB$INITIALIZE routine is invoked first, change your link command to the following: $ LINK/EXE=name SYS$SHARE:STARLET/INCL=COB_NAME_START,your_modules...
Page 72
This search sequence occurs for each reference that remains unresolved. System-Supplied Object Module Libraries All Compaq COBOL programs reference system-supplied object module libraries when they are linked. These libraries contain routines that provide I/O and other system functions. Additionally, you can use your own libraries to provide application-specific object modules.
Allows you to modify one or more sections of a large application without having to relink the entire program The following list describes one way to create and install a Compaq COBOL program as a shareable image: 1. Create the main program used to call the subprogram (as a shareable image).
Page 74
Example 1–2 shows the main program CALLER.COB and the two subprograms (SUBSHR1.COB and SUBSHR2.COB). Only the subprograms are installed as shareable images. 1–44 Developing Compaq COBOL Programs...
$! Create the main program and subprograms to be installed as $! shareable images. In this example CALLER.COB is the main program. $! SUBSHR1.COB and SUBSHR2.COB are the subprograms to be installed $! as shareable images. Developing Compaq COBOL Programs (continued on next page) Developing Compaq COBOL Programs 1–45...
Page 76
Symbol vectors, if used according to the coding conventions, can also provide upward compatibility. For more information about symbol vectors, refer to the OpenVMS Linker Utility Manual. 1–46 Developing Compaq COBOL Programs Image...
For a complete list of linker options, see the OpenVMS System Messages and Recovery Procedures Reference Manual. Developing Compaq COBOL Programs 1.3 Developing Programs on OpenVMS Alpha SEAWEED Developing Compaq COBOL Programs 1–47...
MYPROG.EXE to be in the current directory. When you run your application it makes calls to the Compaq COBOL Run- Time Library (RTL) installed on your system. If your application is run on a...
ACCEPT and DISPLAY sections in the Compaq COBOL Reference Manual. 1.3.4.2 Accessing System Logicals at Run Time You can read and write system logicals at run time through your Compaq COBOL program. Example 1–4 allows the user to specify a file specification by putting the directory in the value of the logical COBOLPATH and the file name in a command-line...
/DEBUG qualifier when you compiled and linked your program. The following example executes the image MYPROG.EXE without invoking the debugger: $ RUN MYPROG/NODEBUG See Appendix C for more information about debugging programs. 1–50 Developing Compaq COBOL Programs Note...
You can use the OpenVMS Debugger and the traceback facility to help you locate errors that occur during program execution. For a description of Compaq COBOL run-time messages, use the HELP COBOL Run-Time Messages command.
Incorrectly positioning these fields can produce faulty data. In the following example, a program references the file incorrectly. The field described as P-YEARLY-AMT actually contains P-MONTHLY-AMT data, and vice versa. 1–52 Developing Compaq COBOL Programs PIC S9. PIC X(5). PIC S9(5)V99 COMP-3.
* This is a test for equality PERFORM ABC-ROUTINE UNTIL A-COUNTER = 10. Developing Compaq COBOL Programs 1.4 Program Run Messages PIC X(5). PIC S9(5)V99 COMP-3. PIC S9(5)V99 COMP-3. Developing Compaq COBOL Programs 1–53...
I/O error is to check a file’s I/O status by using file status data items. (See the Compaq COBOL Reference Manual for a list of file status values.) See Chapter 7, Handling Input/Output Exception Conditions for additional information about I/O exception condition handling.
You can use the RMS special registers, which contain the primary and secondary RMS completion codes of an I/O operation, to detect errors. The RMS special registers are as follows: RMS-STS RMS-STV RMS-FILENAME RMS-CURRENT-STS RMS-CURRENT-STV RMS-CURRENT-FILENAME Developing Compaq COBOL Programs 1.4 Program Run Messages Developing Compaq COBOL Programs 1–55...
Developing Compaq COBOL Programs 1.4 Program Run Messages Refer to the Compaq COBOL Reference Manual and the OpenVMS Record Management Services Reference Manual for more information about RMS special registers. Examples 1–5 and 1–6 show how you can use RMS special registers to detect errors.
Page 87
VALUE "Employee File on". VALUE "emp ". VALUE "name". VALUE "address". SOURCE PAGE-COUNTER. SOURCE EMP-ID. SOURCE IS EMP-NAME. SOURCE IS EMP-ADDRESS. TRUE OP-READ OP-OPEN OP-OPEN OP-OPEN OP-OPEN OP-CLOSE RMS-STS OF EMP-FILE IS SUCCESS (continued on next page) Developing Compaq COBOL Programs 1–57...
Page 88
* to implement a single recovery for RMS file errors with multiple files ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FILE-1 ASSIGN TO "SYS$DISK:ART_1.DAT". SELECT FILE-2 ASSIGN TO "SYS$DISK:ART_2.DAT". SELECT FILE-3 ASSIGN TO "SYS$DISK:ART_3.DAT". 1–58 Developing Compaq COBOL Programs (continued on next page)
STOP RUN. END-PROGRAM RMS-CURRENT-SPEC-REGISTERS. 1.5 Using Program Switches You can control program execution by defining switches in your Compaq COBOL program and setting them internally (from within the image) or externally (from outside the image). Switches exist as the environment variable COBOL_SWITCHES (on the Tru64 UNIX operating system) or the logical name COB$SWITCHES (on the OpenVMS Alpha operating system).
To change the status of internal switches during execution, turn them on or off from within your program. However, be aware that this information is not saved between runs of the program. Refer to the Compaq COBOL Reference Manual for more information about setting internal switches. 1.5.2 Setting and Controlling Switches Externally...
Page 91
$ DEFINE COB$SWITCHES " " The order of evaluation for logical name assignments is image, process, group, system. System and group assignments (including Compaq COBOL program switch settings) continue until they are changed or deassigned. Process assignments continue until they are changed, deassigned, or until the process ends.
field that should be a four-digit field. Programmers need to correct all such fields, as Compaq cannot prevent problems that originate in application code. Two-digit year formats used in controlling fields, or as keys in indexed files, can cause program logic to become ambiguous.
Page 93
4-digit ACCEPT FROM DAY YYYYDDD Compaq COBOL offers date functions that can be used in program logic that makes decisions about year order. The full four-digit year handled by the six functions listed should be used in internal program logic decisions that are based on years.
Compaq COBOL Reference Manual. 2.2 Specifying Alignment In Compaq COBOL, all records, and elementary items with level 01 or 77, begin at an address that is a multiple of 8 bytes (a quadword boundary). By default, the Compaq COBOL compiler will locate a subordinate data item at the next unassigned byte location.
SYNCHRONIZED clause in the Compaq COBOL Reference Manual for a complete discussion of alignment.) 2.3 Sign Conventions Compaq COBOL numeric items can be signed or unsigned. Note the following sign conventions: • If you store a signed result in an unsigned item, only the absolute value is stored.
Note that the use of either or both of these qualifiers increases the execution time of the program. See Compaq COBOL online Help (at the OpenVMS Alpha system prompt), or information.
Handling Numeric Data 2.5 Evaluating Numeric Items The length of the literal or arithmetic expression operands (in terms of the number of digits represented) is not significant. Zero is a unique value, regardless of the sign. Unsigned numeric operands are assumed to be positive for comparison. The results of relation tests involving invalid (nonnumeric) data in a numeric item are undefined.
contains an invalid sign value, the NUMERIC class test rejects the item, and program control takes the false path of the IF statement. The ALPHABETIC class test check is not valid for an operand described as numeric. 2.5.4 Success/Failure Tests The success/failure condition tests the return status codes of COBOL and non- COBOL procedures for success or failure conditions.
Handling Numeric Data 2.6 Using the MOVE Statement 2.6 Using the MOVE Statement The MOVE statement moves the contents of one item into another item. The following sample MOVE statement moves the contents of item FIELD1 into item FIELD2: MOVE FIELD1 TO FIELD2. This section considers MOVE statements as applied to numeric and numeric edited data items.
MOVE "00100" TO TOTAL-AMT Literals with leading or trailing zeros have no advantage in space or execution speed in Compaq COBOL, and the zeros are often lost by decimal point alignment. The MOVE statement’s receiving item dictates how the sign will be moved. When the receiving item is a signed numeric item, the sign from the sending item is placed in it.
Page 102
Handling Numeric Data 2.6 Using the MOVE Statement For a complete description of these symbols see the Compaq COBOL Reference Manual. The numeric-edited move operation first converts the sending item to DISPLAY usage and aligns both items on their decimal point locations. The sending item is truncated or zero-filled until it has the same number of digit positions on both...
2.7.1 Temporary Work Items Compaq COBOL allows numeric items and literals with up to 31 decimal digits (see Appendix A for specific limits). Hence it is quite easy to construct arithmetic expressions that produce more than 31 digits.
Programs should not arbitrarily specify sizes significantly larger than the values actually anticipated for the lifetime of the application. Although the generous limits in Compaq COBOL are useful for many applications, specifying 31 digits when 12 would suffice, for example, is likely to add extra processing cycles and complexity that is wasteful.
Page 105
The default is /MATH_INTERMEDIATE=FLOAT (or If you specify /ARITHMETIC=STANDARD (discussed in Section 2.7.2.2), this will force /MATH_INTERMEDIATE=CIT4. Example of Different Arithmetic Results The following example illustrates the different results that you can get with FLOAT, CIT3, and CIT4: IDENTIFICATION DIVISION. PROGRAM-ID.
2.7.5 Using the SIZE ERROR Phrase The SIZE ERROR phrase detects the loss of high-order nonzero digits in the results of Compaq COBOL arithmetic operations. It does this by checking the absolute value of an arithmetic result against the PICTURE character-string of each resultant identifier.
Handling Numeric Data 2.7 Using the Arithmetic Statements The SIZE ERROR phrase cannot be used with numeric MOVE statements. Thus, if a program moves a numeric quantity to a smaller numeric item, it can lose high-order digits. For example, consider the following move of an item to a smaller item: 01 AMOUNT-A PIC S9(8)V99.
Equivalent coding: Statement: Equivalent coding: Statement: Equivalent coding: As in all Compaq COBOL statements, the commas in these statements are optional. 2.7.8 Common Errors in Arithmetic Statements Programmers most commonly make the following errors when using arithmetic statements: • Using an alphanumeric item in an arithmetic statement. The MOVE statement allows data movement between alphanumeric items and certain numeric items, but arithmetic statements require that all items be numeric.
Nonnumeric data in Compaq COBOL is evaluated with respect to a specified collating sequence of the operands. Information to be found in this chapter: • How the compiler stores nonnumeric data (Section 3.1) • Data organization (Section 3.2) • Special characters (Section 3.3) •...
3.2 Data Organization A Compaq COBOL record consists of a set of data description entries that describe record characteristics; it must have an 01 or 77 level number. A data description entry can be either a group item or an elementary item.
In Compaq COBOL, all records, and elementary items with level 01 or 77, begin at an address that is a multiple of 8 bytes (a quadword boundary). By default, the Compaq COBOL compiler will locate a subordinate data item at the next unassigned byte location.
IS <= 3.4.1.1 Classes of Data Compaq COBOL allows comparison of both numeric class operands and nonnumeric class operands; however, it handles each class of data differently. For example, it allows a comparison of two numeric operands regardless of the formats specified in their respective USAGE clauses, but it requires that all other...
ASCII bytes, take part in the comparison, and zeros are not supplied for P characters in the PICTURE character-string. The compiler does not accept a comparison between a noninteger numeric operand and a nonnumeric operand. If you try to compare these two items, you receive a diagnostic message at compile time.
For further information on using class conditions with numeric items, refer to the Compaq COBOL Reference Manual. 3.5 Data Movement Three Compaq COBOL statements (MOVE, STRING, and UNSTRING) perform most of the data movement operations required by business-oriented programs. The MOVE statement simply moves data from one item to another. The STRING statement concatenates a series of sending items into a single receiving item.
receiving item must first be described with the JUSTIFIED clause.) Characters from the middle of the sending item cannot easily be moved to any receiving item without extensive redefinitions of the sending item or a reference modification loop (as with concatenation). The STRING and UNSTRING statements handle concatenation and dispersion more easily than compound moves.
Handling Nonnumeric Data 3.6 Using the MOVE Statement Table 3–2 Nonnumeric Elementary Moves Sending Item Category ALPHABETIC ALPHANUMERIC ALPHANUMERIC EDITED NUMERIC INTEGER (DISPLAY ONLY) NUMERIC EDITED In all valid moves, the compiler treats the sending item as though it had been described as PIC X(n).
3.6.2.1 Edited Moves This section explains the following insertion editing characters: When an item with an insertion editing character in its PICTURE character- string is the receiving item of a nonnumeric elementary MOVE statement, each receiving character position corresponding to an editing character receives the insertion byte value.
Handling Nonnumeric Data 3.6 Using the MOVE Statement Table 3–4 Data Movement with the JUSTIFIED Clause FIELD1 PICTURE Character-String Legend: s = space 3.6.3 Multiple Receiving Items If you write a MOVE statement containing more than one receiving item, the compiler moves the same sending item value to each of the receiving items.
The MOVE CORRESPONDING statement allows you to move multiple items from one group item to another group item, using a single MOVE statement. See the Compaq COBOL Reference Manual for rules concerning the CORRESPONDING phrase. When you use the CORRESPONDING phrase, the compiler performs an independent move operation on each pair of corresponding items from the operands and checks the validity of each.
The following is an example of reference modification: WORKING-STORAGE SECTION. 01 ITEMA PIC X(10) VALUE IS "XYZABCDEFG". MOVE ITEMA(4:3) TO... IDENTIFIER ITEMA (4:3) For more information on reference modification rules, refer to the Compaq COBOL Reference Manual. 3–12 Handling Nonnumeric Data VALUE...
Compaq COBOL allows you to define from 1- to 48-dimension tables. After you have defined a table, you can load it with data. One way to load a table is to use the INITIALIZE statement or the VALUE clause to assign values to the table when you define it (see Figure 4–10).
Handling Tables 4.1 Defining Tables Example 4–1 One-Dimensional Table 01 TABLE-A. 05 ITEM-B PIC X OCCURS 2 TIMES. The organization of TABLE-A is shown in Figure 4–1. Figure 4–1 Organization of the One-Dimensional Table in Example 4–1 Longword number Byte number Level 01 Level 05 Legend: A = TABLE−A...
KEY IS phrase does not cause the data in the table to be placed in ascending or descending order; rather, it allows you to state how you have arranged the data.) For further information about these OCCURS clause options, see the Compaq COBOL Reference Manual.
D = ITEMD 4.1.2 Defining Fixed-Length, Multidimensional Tables Compaq COBOL allows 48 levels of OCCURS nesting. If you want to define a two-dimensional table, you define another one-dimensional table within each element of the one-dimensional table. To define a three-dimensional table, you define another one-dimensional table within each element of the two-dimensional...
4.1.3 Defining Variable-Length Tables To define a variable-length table, use Format 2 of the OCCURS clause (refer to the Compaq COBOL Reference Manual). Options allow you to define single or multiple keys, or indexes, or both. Example 4–6 illustrates how to define a variable-length table.
(on the Tru64 UNIX operating system) or the /ALIGNMENT qualifier (on the OpenVMS Alpha operating system). The Compaq COBOL compiler allocates storage for data items within records according to the rules of the Major-Minor Equivalence technique. This technique ensures that identically defined group items have the same structure, even when their subordinate items are aligned.
4.1.4.1 Using the SYNCHRONIZED Clause By default, the Compaq COBOL compiler tries to allocate a data item at the next unassigned byte location. However, you can align some data items on a 2-, 4-, or 8-byte boundary by using the SYNCHRONIZED clause. The compiler may then have to skip one or more bytes before assigning a location to the next data item.
Handling Tables 4.1 Defining Tables Example 4–8 describes a table containing a COMP SYNC data item. Figure 4–7 illustrates how it is mapped into memory. Example 4–8 Record Description Containing a COMP SYNC Item 01 A-TABLE. 03 GROUP-G OCCURS 4 TIMES. 05 ITEM1 PIC X.
03 GROUP-G OCCURS 4 TIMES. 05 ITEM1 PIC X. 05 ITEM2 PIC 9(5) COMP SYNC. 05 ITEM3 PIC XXX. Note that GROUP-G begins on a 4-byte boundary because of the way Compaq COBOL allocates memory. Figure 4–9 Memory Map for Example 4–10 Longword number...
Handling Tables 4.2 Initializing Values of Table Elements 4.2 Initializing Values of Table Elements You can initialize a table that contains only DISPLAY items to any desired value in either of the following ways: • You can specify a VALUE clause in the record level preceding the record description of the item containing the OCCURS clause.
• SECOND-LEG occurs five times; each occurrence is initialized to 5. Often a table is too long to initialize using a single literal, or it contains numeric, alphanumeric, COMP, COMP-1, COMP-2, or COMP SYNC items that cannot be initialized. In these situations, you can initialize individual items by redefining the group level that precedes the level containing the OCCURS clause.
Once tables have been created using the OCCURS clause, the program must have a method of accessing the individual elements of those tables. Subscripting and indexing are the two methods Compaq COBOL provides for accessing individual table elements. To refer to a particular element within a table, follow the name of that element with a subscript or index enclosed in parentheses.
ITEM3 in the example. Finally, the third subscript applies to the least inclusive level, represented by ITEM5. (Note that Compaq COBOL can have 48 subscripts that follow the pattern in Example 4–15.) In Example 4–16, the subscripts (2,11,3) in the MOVE statements move the third...
Handling Tables 4.3 Accessing Table Elements Because ITEM5 is not subordinate to ITEM2, an occurrence number for ITEM2 is not permitted in the subscript list (when referencing ITEM3, ITEM4, or ITEM5). The ninth occurrence of ITEM2 in the fifth occurrence of A-GROUP will be selected by ITEM2(5,9).
On Tru64 UNIX, see Chapter 1 or the cobol man page for more information about -check flag. On OpenVMS, invoke the online HELP facility for Compaq COBOL at the OpenVMS Alpha system prompt for more information about the /CHECK qualifier.
Often a program requires that the value of an index be stored outside of that item. Compaq COBOL provides the index data item to fulfill this requirement. Index data items are stored as longword COMP items and must be declared with a USAGE IS INDEX phrase in the item description.
4.3.8.1 Implementing a Sequential Search The SEARCH statement allows you to perform a sequential search of a table. The OCCURS clause of the table description entry must contain the INDEXED BY phrase. If more than one index is specified in the INDEXED BY phrase, the first index is the controlling index for the table search unless you specify otherwise in the SEARCH statement.
You can sort an entire table in preparation for a binary search. Use the SORT statement (Format 2, a Compaq extension), described in the Compaq COBOL Reference Manual. During a binary search, the first (or only) index you specify in the INDEXED BY phrase of the OCCURS clause of the table being searched is the controlling index.
A useful variation of the binary search is that of specifying multiple search keys. Multiple search keys allow you to select a specified table element from among several elements that have duplicate low-order keys. An example is a telephone listing where several people have the same last and first names, but different middle initials.
Example 4–20 Using SEARCH and Varying an Index Other than the First Index TAXABLE-INCOME PIC 9(6) VALUE 50000. FED-TAX-DEDUCTION PIC 9(6). PROCEDURE DIVISION. BEGIN. PERFORM MARRIED. DISPLAY FED-TAX-DEDUCTION. STOP RUN. MARRIED. IF TAXABLE-INCOME < 04800 MOVE ZEROS TO FED-TAX-DEDUCTION GO TO END-FED-COMP. SET IND-3 TO 1.
Handling Tables 4.3 Accessing Table Elements Example 4–22 Using SEARCH and Varying an Index not Associated with the Target Table TAXABLE-INCOME PIC 9(6) VALUE 50000. FED-TAX-DEDUCTION PIC 9(6). PROCEDURE DIVISION. BEGIN. PERFORM SINGLE. DISPLAY FED-TAX-DEDUCTION. STOP RUN. SINGLE. IF TAXABLE-INCOME < 02500 GO TO END-FED-COMP.
Example 4–24 shows how to perform a multiple-key, binary search. Example 4–24 A Multiple-Key, Binary Search IDENTIFICATION DIVISION. PROGRAM-ID. MULTI-KEY-SEARCH. DATA DIVISION. WORKING-STORAGE SECTION. 01 DIRECTORY-TABLE. 05 NAMES-NUMBERS. 10 FILLER PIC X(30) VALUE "SMILEY HAPPY 10 FILLER PIC X(30) VALUE "SMITH ALAN 10 FILLER PIC X(30)
Using the STRING, UNSTRING, and INSPECT The STRING, UNSTRING, and INSPECT statements give your Compaq COBOL programs the following capabilities: • Concatenating data using the STRING statement (Section 5.1) • Separating data using the UNSTRING statement (Section 5.2) • Examining and replacing characters using the INSPECT statement (Section 5.3)
Using the STRING, UNSTRING, and INSPECT Statements 5.1 Concatenating Data Using the STRING Statement If FIELD2 is not large enough to hold all three items, the operation stops when it is full. If the operation stops while moving one of the sending items, the compiler ignores the remaining characters of that item and any other sending items not yet processed.
Using the STRING, UNSTRING, and INSPECT Statements 5.1 Concatenating Data Using the STRING Statement Figure 5–1 Results of the STRING Operation AYER MA. 01432 16 spaces ZK−6051−GE A more attractive and readable report can be produced by having the STRING operation produce this line: AYER, MA.
Using the STRING, UNSTRING, and INSPECT Statements 5.1 Concatenating Data Using the STRING Statement Remember, the remainder of the receiving item is not space-filled, as with a MOVE statement. If ADDRESS-LINE is to be printed on a mailing label, for example, the STRING statement should be preceded by the statement: MOVE SPACES TO ADDRESS-LINE.
Using the STRING, UNSTRING, and INSPECT Statements The ON OVERFLOW phrase cannot distinguish the overflow caused by a bad initial value in the pointer from the overflow caused by a receiving item that is too short. Only a separate test preceding the STRING statement can distinguish between the two.
Using the STRING, UNSTRING, and INSPECT Statements 5.1 Concatenating Data Using the STRING Statement 5.1.5 Common STRING Statement Errors The following are common errors made when writing STRING statements: • Using the word TO instead of INTO • Failing to include the DELIMITED BY SIZE phrase •...
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement The compiler-generated code performs the UNSTRING operation by scanning across FIELD1, the sending item, from left to right. When the number of characters scanned equals the number of characters in the receiving item, the scanned characters are moved into that item and the next group of characters is scanned for the next receiving item.
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement Consider the following statement with reference to the corresponding PICTURE character-strings and values in Table 5–3: UNSTRING FIELD1 INTO FIELD2A FIELD2B. FIELD2A is a 3-character alphanumeric item. It receives the first three characters of FIELD1 (ABC) in every operation.
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement Table 5–4 Results of Delimiting with an Asterisk FIELD1 PIC X(6) FIELD2 VALUE IS: PICTURE IS: ABCDEF X(7) XXX JUSTIFIED ****** *ABCDE A***** XXX JUSTIFIED 246*** S9999 12345* S9999 TRAILING SEPARATE...
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement Table 5–5 Results of Delimiting Multiple Receiving Items FIELD1 PIC X(8) VALUE IS: ABC*DEF* ABCDE*FG A*B**** *AB*CD** **ABCDEF A*BCDEFG ABC**DEF A******B Legend: # = space The previous examples illustrate the limitations of a single-character delimiter. To overcome these limitations, a delimiter of more than one character or a delimiter preceded by the word ALL may be used.
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement the delimiter item. It considers the ALL delimiter to be one, two, three, or more adjacent repetitions of the delimiter item. Table 5–7 shows the results of the following UNSTRING operation using an ALL delimiter: UNSTRING FIELD1 DELIMITED BY ALL "*"...
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement 5.2.2.1 Multiple Delimiters The UNSTRING statement scans a sending item, searching for a match from a list of delimiters. This list can contain ALL delimiters and delimiters of various sizes.
Using the STRING, UNSTRING, and INSPECT Statements The compiler then counts the number of characters between the last contiguous asterisk in the first scan and the next asterisk in the second scan, and places the count in COUNT2B. The data between the delimiters of the second scan is moved into FIELD2B.
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement When a sending string is delimited by the end of the sending item rather than by a match on a delimiter, the delimiter string is of zero length and the DELIMITER item is space-filled.
Using the STRING, UNSTRING, and INSPECT Statements PNTR contains the current position of the scanner in the sending item. The second UNSTRING statement uses PNTR to begin scanning the additional sending strings in FIELD1. Because the compiler considers the leftmost character to be character position 1, the value of PNTR can be used to examine the next character.
Using the STRING, UNSTRING, and INSPECT Statements 5.2 Separating Data Using the UNSTRING Statement If the compiler has moved only three sending strings when it reaches the end of FIELD1, it adds 3 to RCOUNT. The first three receiving items (FIELD2A, FIELD2B, and FIELD2C) contain data from the UNSTRING operation, but the last two (FIELD2D and FIELD2E) do not.
Using the STRING, UNSTRING, and INSPECT Statements • Omitting the word INTO (or writing it as TO) before the receiving item list • Repeating the word INTO in the receiving item list as shown in this example: UNSTRING FIELD1 DELIMITED BY SPACE OR TAB INTO FIELD2A DELIMITER IN DELIMA INTO FIELD2B DELIMITER IN DELIMB...
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement 5.3.2 Restricting Data Inspection Using the BEFORE/AFTER Phrase The BEFORE/AFTER phrase acts as a delimiter and can restrict the area of the item being inspected. The following sample statement counts only the zeros that precede the percent sign ( % ) in FIELD1: INSPECT FIELD1 TALLYING TLY...
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement Figure 5–2 Matching Delimiter Characters to Characters in a Field Instruction INSPECT FIELD1...BEFORE "E". INSPECT FIELD1...AFTER "E". INSPECT FIELD1...BEFORE "K". INSPECT FIELD1...AFTER "K". INSPECT FIELD1...BEFORE "AB". INSPECT FIELD1...AFTER "AB".
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement Table 5–10 Values Resulting from Implicit Redefinition Original Altered Value Value } (173) 0 (60) A (101) 1 (61) B (102) 2 (62) C (103) 3 (63) D (104) 4 (64)
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement Table 5–10 (Cont.) Values Resulting from Implicit Redefinition Original Altered Value Value 5 (65) 5 (65) 6 (66) 6 (66) 7 (67) 7 (67) 8 (70) 8 (70) 9 (71)
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement Figure 5–4 Typical REPLACING Phrase INSPECT FIELD1 REPLACING Each argument in an argument list used with either a TALLYING or REPLACING operation can have a delimiter item (BEFORE/AFTER phrase) associated with it.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement Table 5–11 Relationship Among INSPECT Argument, Delimiter, Item Value, and Argument Active Position Argument and Delimiter ‘‘B’’ AFTER ‘‘XX’’ ‘‘X’’ AFTER ‘‘XX’’ ‘‘B’’ AFTER ‘‘XB’’ ‘‘BX’’...
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement When an active argument finds a match, the compiler ignores any remaining arguments in the list and conducts the TALLYING or REPLACING operation on the character. The scanner moves to a new position and the next inspection operation begins with the first argument in the list.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement • An identifier must be an elementary item of DISPLAY usage. It can be any data class. However, if it is not alphanumeric, the compiler performs an implicit redefinition of the item.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement These three tally arguments have the same tally counter, T, and are active over the entire item being inspected. Thus, the preceding statement adds the total number of commas, periods, and semicolons in FIELD1 to the initial value of T.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement 5.3.5.4 Interference in Tally Argument Lists When several tally arguments contain one or more identical characters active at the same time, they may interfere with each other, so that when one of the arguments finds a match, the scanner steps past any other matching characters, preventing those characters from being considered for a match.
Page 174
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement Sometimes you can use the interference characteristics of the INSPECT statement to your advantage. Consider the following sample argument list: MOVE 0 TO T4 T3 T2 T1. INSPECT FIELD1 TALLYING T4 FOR ALL "****"...
Page 175
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement These statements count the number of words in the English statement in FIELD1, assuming that no more than three spaces separate the words in the sentence, that the sentence ends with a period, and that the period immediately follows the last word.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement 5.3.6 Using the REPLACING Phrase When an INSPECT statement contains a REPLACING phrase, that statement selectively replaces characters or groups of characters in the designated item. The REPLACING phrase names a search argument of one or more characters and a condition under which the string can be applied to the item being inspected.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement • LEADING specifies that only adjacent matches of the search argument at the leftmost position of the delimited character-string be replaced. At the first failure to match the search argument, the compiler terminates the replacement operation and causes the argument to become inactive.
Using the STRING, UNSTRING, and INSPECT Statements 5.3 Examining and Replacing Characters Using the INSPECT Statement INSPECT FIELD1 REPLACING ALL "," BY SPACE ALL "." BY SPACE ALL ";" BY SPACE. The previous three replacement arguments all have the same replacement value, SPACE, and are active over the entire item being inspected.
Format 2 INSPECT statement with a series of ALL phrases. (See the INSPECT statement formats in the Compaq COBOL Reference Manual.) An example of the use of the CONVERTING phrase follows: IDENTIFICATION DIVISION.
The Compaq COBOL I/O system offers you a wide range of record management techniques while remaining transparent to you. You can select one of several file organizations and access modes, each of which is suited to a particular application. The file organizations available through Compaq COBOL are sequential, line sequential, relative, and indexed.
File organization is described in Section 6.1.1. Record format is described in Section 6.1.2. 6.1.1 File Organization Compaq COBOL supports the following four types of file organization: • SEQUENTIAL—This organization requires that records be referenced in sequence from the first record to the last. This organization is useful for programs that normally access each record serially.
Table 6–1 (Cont.) Compaq COBOL File Organizations—Advantages and Disadvantages File Organizations Advantages Provides the most flexible record format Allows READ/WRITE sharing Allows data to be stored on many types of media, in a device-independent manner Allows easy file extension Line Sequential Most efficient storage format...
EOF mark and, thus, extend the length of the file. Because the EOF indicates the end of useful data, Compaq COBOL provides no method for reading beyond it, even though the amount of space reserved for the file exceeds the amount actually used.
FILE-CONTROL section and the number of characters in a line (not including the record terminator). When your Compaq COBOL program reads a line from a line sequential file that is shorter than the record area, it reads up to the record terminator, discards the record terminator, and pads the rest of the record with a number of spaces necessary to equal the record’s specified length.
An indexed file uses primary and alternate keys in the record to retrieve the contents of that record. Compaq COBOL allows sequential, random, and dynamic access to records. You access each record by one of its primary or alternate keys.
Page 187
For more information, see the Environment Division clauses RECORD KEY IS and ALTERNATE RECORD KEY IS in the Compaq COBOL Reference Manual. You must define at least one main key, called the primary key, for an indexed file.
For information about specifying file organization in your program, see Section 6.2.2. 6.1.2 Record Format Compaq COBOL provides four record format types: fixed, variable, print-control, and stream. Table 6–2 shows the record format availability. Table 6–2 Record Format Availability Fixed length...
If a file has more than one record description, the different record descriptions automatically share the same record area in memory. The I/O system does not clear this area before it executes the READ statement. Therefore, if the record read by the latest READ statement does not fill the entire record area, the area not overlaid by the incoming record remains unchanged.
Processing Files and Records 6.1 Defining Files and Records Example 6–2 Determining Fixed-Length Record Size FD FIXED-FILE RECORD CONTAINS 100 CHARACTERS. 01 FIXED-REC Fixed-length record size is determined by either the largest record description or the record size specified by the RECORD CONTAINS clause, whichever is larger. Example 6–2 shows how fixed-length record size is determined.
OCCURS 1 TO 10 TIMES DEPENDING ON P-BIN-INDEX. Example 6–6 creates variable-length records by using the OCCURS clause with the DEPENDING ON phrase in the record description. Compaq COBOL determines record length by adding the sum of the variable record’s fixed portion to the size of the table described by the number of table occurrences at execution time.
Print-Control Records On OpenVMS, Compaq COBOL places explicit form-control bytes directly into the file. A Compaq COBOL program trying to read a print-control file can read it successfully as a variable file (since the I/O system strips the VFC header).
Stream Stream files contain records of different length, delimited by a record terminator. The compiler generates a stream record formatted file when you use the ORGANIZATION IS LINE SEQUENTIAL clause in the File-Control Division. This record format is useful for files created by text editors. On OpenVMS, a stream file will also be generated under certain situations if you compiled /NOVFC.
FD DAT-FILE. 01 DAT-RECORD PIC X(100). On OpenVMS Alpha systems, if no file type is supplied, Compaq COBOL supplies the default file extension DAT. On Tru64 UNIX and Windows NT systems, the extensions dat and idx (and lck, on Windows NT systems) are appended, but only in the case of indexed files.
Processing Files and Records 6.2 Identifying Files and Records from Within Your Compaq COBOL Program Example 6–9 Defining a Magnetic Tape File (OpenVMS) ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MYFILE-PRO ASSIGN TO "MTA0:MARCH.311" DATA DIVISION. FILE SECTION. FD MYFILE-PRO. 01 DAT-RECORD PIC X(100).
Page 197
6.2 Identifying Files and Records from Within Your Compaq COBOL Program Example 6–10 (Cont.) Defining a Magnetic Tape File (Tru64 UNIX) A000-BEGIN. OPEN INPUT MYFILE-PRO. READ MYFILE-PRO AT END DISPLAY "end". CLOSE MYFILE-PRO. For each OPEN verb referring to a file assigned to magnetic tape, the user is prompted to assign the file to a magnetic tape device.
Page 198
Processing Files and Records 6.2 Identifying Files and Records from Within Your Compaq COBOL Program On Tru64 UNIX, with this code OPEN would create a file with the name "/usr/filename.dat". Establishing Device and File Independence with Logical Names On OpenVMS, logical names let you write programs that are device and file independent and provide a brief way to refer to frequently used files.
6.2 Identifying Files and Records from Within Your Compaq COBOL Program On Tru64 UNIX, you can also use the literal or alphanumeric item to specify a run-time environment variable set. See Example 6–11 and the commands that follow it illustrate how to use the ASSIGN TO clause in conjunction with an environment variable.
Division ORGANIZATION and ACCESS MODE clauses, if present, specify these two characteristics. In a Compaq COBOL program, each file is given a file name in a separate Environment Division SELECT statement. The compiler determines the file organization from the SELECT statement and its associated clauses.
6.2 Identifying Files and Records from Within Your Compaq COBOL Program Examples 6–13, 6–14, and Example 6–15 illustrate how to specify the file organization and access mode for sequential, relative, and indexed files. Example 6–13 Specifying Sequential File Organization and Sequential Access Mode for a Sequential File IDENTIFICATION DIVISION.
Any program using the identical entries in the SELECT clause as shown in Example 6–15 can reference the DAIRY file sequentially and randomly. Refer to the Compaq COBOL Reference Manual for information relating to the RECORD KEY and ALTERNATE RECORD KEY clauses.
6.2 Identifying Files and Records from Within Your Compaq COBOL Program Record Access Mode The methods for retrieving and storing records in a file are called record access modes. Compaq COBOL supports the following three types of record access modes: •...
files. 6.3.1 Opening and Closing Files A Compaq COBOL program must open a file with an OPEN statement before any other I/O or Report Writer statement can reference it. Files can be opened more than once in the same program as long as they are closed before being reopened.
Example 6–21 OPEN and CLOSE Statements OPEN INPUT MASTER-FILE. OPEN OUTPUT REPORT-FILE. OPEN I-O MASTER-FILE2 TRANS-FILE OUTPUT REPORT-FILE2. CLOSE MASTER-FILE. CLOSE TRANS-FILE, MASTER-FILE2 REPORT-FILE, REPORT-FILE2. The OPEN statement must specify one of the following four open modes: INPUT OUTPUT I-O {Not for LINE SEQUENTIAL} EXTEND Your choice, along with the file’s organization and access mode, determines which I/O statements you can use.
Creating a sequential or line sequential file involves the following: 1. Opening the file for OUTPUT or EXTEND 2. Executing valid I/O statements 3. Closing the file By default, Compaq COBOL assumes sequential organization and sequential access mode. (See Example 6–22.) Example 6–22 Creating a Sequential File IDENTIFICATION DIVISION.
OPEN OUTPUT LINESEQ-FILE. CLOSE LINESEQ-FILE. STOP RUN. By default, Compaq COBOL assumes sequential access mode when the line sequential organization is specified. (See Example 6–23.) Statements for Sequential and Line Sequential File Processing Processing a sequential or line sequential file involves the following: 1.
Processing Files and Records 6.3 Creating and Processing Files • OUTPUT—Output mode can create the following two kinds of files: Storage files—A storage file remains on tape or disk for future reference or processing. Print-control files—The Data Division LINAGE clause, the Environment Division APPLY PRINT-CONTROL clause, the Procedure Division ADVANCING phrase (in the WRITE statement), or Report Writer statements and phrases designates a file as a print-control file.
----------------(1)---------------- WRITE STOCK-RECORD FROM STOCK-WORK. When you omit the FROM phrase, you process the records directly in the record area or buffer (for example, STOCK-RECORD). The following example writes the record PRINT-LINE to the device assigned to that record’s file, then skips three lines. At the end of the page (as specified by the LINAGE clause), it causes program control to transfer to HEADER- ROUTINE.
Processing Files and Records 6.3 Creating and Processing Files Creating a Relative File in Sequential Access Mode When your program creates a relative file in sequential access mode, the I/O system does not use the relative key. Instead, it writes the first record in the file at relative record number 1, the second record at relative record number 2, and so on, until the program closes the file.
Page 211
Example 6–25 (Cont.) Creating a Relative File in Random Access Mode IDENTIFICATION DIVISION. PROGRAM-ID. REL03. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FLAVORS ASSIGN TO "BRAND" ORGANIZATION IS RELATIVE ACCESS MODE IS RANDOM RELATIVE KEY IS KETCHUP-MASTER-KEY. DATA DIVISION. FILE SECTION. FD FLAVORS.
2. Back up the file. 3. Recreate the file either by using the OpenVMS Alpha CONVERT Utility to optimize file space, or by using a Compaq COBOL program. Statements for Indexed File Processing Processing an indexed file involves the following: 1.
Processing Files and Records 6.3 Creating and Processing Files Table 6–6 lists the valid I/O statements and illustrates the following relationships: • File organization determines valid access modes. • File organization and access mode determine valid open modes. • All three (organization, access, and open mode) enable or disable I/O statements.
Then the following line in your program, which specifies the segmented key name and three of its segments: RECORD KEY IS NAME = SURNAME FORENAME INITIAL causes Compaq COBOL to treat name as if it were an explicitly defined group item consisting of the following: 02 SURNAME PIC X(20).
Page 216
Processing Files and Records 6.3 Creating and Processing Files Example 6–27 (Cont.) Using Segmented Keys DATA DIVISION. FILE SECTION. FD FLAVORS. 01 ICE-CREAM-MASTER. 02 ICE-CREAM-DATA. 03 ICE-CREAM-STORE-KIND 03 ICE-CREAM-STORE-MANAGER 03 ICE-CREAM-STORE-SIZE 03 ICE-CREAM-STORE-ADDRESS 03 ICE-CREAM-STORE-CITY 03 ICE-CREAM-STORE-STATE 03 ICE-CREAM-STORE-ZIP WORKING-STORAGE SECTION. 01 PROGRAM-STAT 88 OPERATOR-STOPS-IT PROCEDURE DIVISION.
6.4 Reading Files Reading sequential, line sequential, relative, and indexed files includes the following tasks: 1. Opening the file 2. Executing a READ or START statement Sections 6.4.1, 6.4.2, and 6.4.3 describe the specific tasks involved in reading sequential, line sequential, relative, and indexed files. 6.4.1 Reading a Sequential or Line Sequential File Reading a sequential or line sequential file involves the following: 1.
Processing Files and Records 6.4 Reading Files Reading a Relative File Randomly Reading relative records randomly involves the following: 1. Specifying ORGANIZATION IS RELATIVE in the Environment Division SELECT clause 2. Specifying ACCESS MODE IS RANDOM (or DYNAMIC) in the Environment Division SELECT clause 3.
available to the program. In dynamic mode, the program can switch from random access I/O statements to sequential access I/O statements in any order, without closing and reopening files. However, you must use the READ NEXT statement to sequentially read a relative file open in dynamic mode. Sequential processing need not begin at the first record of a relative file.
Processing Files and Records 6.4 Reading Files 6.4.3 Reading an Indexed File Your program can read an indexed file sequentially, randomly, or dynamically. Reading an Indexed File Sequentially Reading indexed records sequentially involves the following: 1. Specifying ORGANIZATION IS INDEXED in the Environment Division SELECT clause 2.
Example 6–32 (Cont.) Reading an Indexed File Sequentially PROCEDURE DIVISION. A000-BEGIN. OPEN INPUT FLAVORS. A010-SEQUENTIAL-READ. PERFORM A100-READ-INPUT UNTIL END-OF-FILE = "Y". A020-EOJ. DISPLAY "END OF JOB". STOP RUN. A100-READ-INPUT. READ FLAVORS AT END MOVE "Y" TO END-OF-FILE. IF END-OF-FILE NOT = "Y" DISPLAY ICE-CREAM-MASTER STOP "Type CONTINUE to display next master".
Page 224
Processing Files and Records 6.4 Reading Files Example 6–33 (Cont.) Reading an Indexed File Randomly DATA DIVISION. FILE SECTION. FD FLAVORS. 01 ICE-CREAM-MASTER. 02 ICE-CREAM-KEY 02 ICE-CREAM-DATA. 03 ICE-CREAM-STORE-CODE 03 ICE-CREAM-STORE-ADDRESS 03 ICE-CREAM-STORE-CITY 03 ICE-CREAM-STORE-STATE WORKING-STORAGE SECTION. 01 PROGRAM-STAT 88 OPERATOR-STOPS-IT PROCEDURE DIVISION.
Sequential processing need not begin at the first record of an indexed file. The START statement specifies the next record to be read sequentially, selects which key to use to determine the logical sort order, and repositions the file position indicator for subsequent I/O operations anywhere within the file.
Processing Files and Records 6.4 Reading Files A100-GET-RECORDS. READ IND-ALPHA NEXT RECORD AT END MOVE "Y" TO END-OF-FILE. IF END-OF-FILE NOT = "Y" DISPLAY INPUT-RECORD. A100-GET-RECORDS-EXIT. EXIT. READ PRIOR retrieves a record from an Indexed file which logically precedes the one which was made current by the previous file access operation, if such a logically previous record exists.
Example 6–35 (Cont.) Reading an Indexed File Dynamically, with READ PRIOR * READ PREVIOUS after file open for IO, from a middle * record to beginning record on primary key. OPEN I-O F. MOVE "2345678990" TO R. READ F INVALID KEY DISPLAY "?6" GO TO P2 END-READ. IF R NOT = "2345678990"...
Processing Files and Records 6.4 Reading Files Table 6–7 (Cont.) Indexed File—ISAM Mapping COBOL Data Type signed quadword PIC S9(18) COMP unsigned quadword PIC 9(18) COMP packed decimal PIC S9(n) COMP-3 Note that any data type not directly supported by ISAM is translated to a character string, which will sort as a character string in the correct order.
Statements ( 1 ) and ( 2 ) in the following example are logically equivalent: FILE SECTION. FD STOCK-FILE. 01 STOCK-RECORD PIC X(80). WORKING-STORAGE SECTION. 01 STOCK-WORK PIC X(80). ---------------(1)------------------ REWRITE STOCK-RECORD FROM STOCK-WORK. When you omit the FROM phrase, you process the records directly in the record area or buffer (for example, STOCK-RECORD).
IF TRANSACTION-RECORD NOT = "END" WRITE TRANSACTION-RECORD. Without the EXTEND mode, a Compaq COBOL program would have to open the input file, copy it to an output file, and add records to the output file. 6.5.2 Updating a Relative File A program updates a relative file with the WRITE, REWRITE, and DELETE...
4. Using a START statement and then a READ statement to read the target record 5. Updating the record 6. Rewriting the record into its cell Example 6–38 reads a relative record sequentially and displays the record on the terminal. The program then passes the record to an update routine that is not included in the example.
Processing Files and Records 6.5 Updating Files Rewriting Relative Records in Random Access Mode Rewriting relative records in random access mode involves the following: 1. Specifying ORGANIZATION IS RELATIVE in the Environment Division SELECT clause 2. Specifying ACCESS MODE IS RANDOM (or DYNAMIC) in the Environment Division SELECT clause 3.
Example 6–39 (Cont.) Rewriting Relative Records in Random Access Mode A100-UPDATE-RECORD. DISPLAY "TO UPDATE A RECORD ENTER ITS RECORD NUMBER". ACCEPT KETCHUP-MASTER-KEY. READ FLAVORS INVALID KEY DISPLAY "BAD READ" DISPLAY "*********BEFORE UPDATE*********". DISPLAY KETCHUP-MASTER. ******************************************************** Update routine ******************************************************** DISPLAY "*********AFTER UPDATE*********". DISPLAY KETCHUP-MASTER.
Example 6–41 (Cont.) Deleting Relative Records in Random Access Mode DATA DIVISION. FILE SECTION. FD FLAVORS. 01 KETCHUP-MASTER WORKING-STORAGE SECTION. 01 KETCHUP-MASTER-KEY PROCEDURE DIVISION. A000-BEGIN. OPEN I-O FLAVORS. PERFORM A010-DELETE-RECORDS UNTIL KETCHUP-MASTER-KEY = 00. A005-EOJ. DISPLAY "END OF JOB". CLOSE FLAVORS. STOP RUN.
Processing Files and Records 6.5 Updating Files Updating an Indexed File Sequentially Updating indexed records in sequential acess mode involves the following: 1. Specifying ORGANIZATION IS INDEXED in the Environment Division SELECT clause 2. Specifying ACCESS MODE IS SEQUENTIAL in Environment Division SELECT clause 3.
Example 6–42 (Cont.) Updating an Indexed File Sequentially PROCEDURE DIVISION. A000-BEGIN. OPEN I-O FLAVORS. DISPLAY "Which store code do you want to find?". ACCEPT REWRITE-KEY. DISPLAY "What is its new address?". ACCEPT NEW-ADDRESS. DISPLAY "Which state do you want to delete?". ACCEPT DELETE-KEY.
Page 238
Processing Files and Records 6.5 Updating Files Example 6–43 (Cont.) Updating an Indexed File Randomly FILE-CONTROL. SELECT FLAVORS DATA DIVISION. FILE SECTION. FD FLAVORS. 01 ICE-CREAM-MASTER. 02 ICE-CREAM-MASTER-KEY 02 ICE-CREAM-MASTER-DATA. 03 ICE-CREAM-STORE-CODE 03 ICE-CREAM-STORE-ADDRESS 03 ICE-CREAM-STORE-CITY 03 ICE-CREAM-STORE-STATE WORKING-STORAGE SECTION. 01 HOLD-ICE-CREAM-MASTER 01 PROGRAM-STAT 88 OPERATOR-STOPS-IT...
Page 239
Example 6–43 (Cont.) Updating an Indexed File Randomly IF LETS-SEE-NEXT-STORE AND ICE-CREAM-STORE-STATE = "NY" PERFORM A500-DELETE-RANDOM-RECORD. IF LETS-SEE-NEXT-STORE AND ICE-CREAM-STORE-STATE = "NJ" MOVE "Monmouth" TO ICE-CREAM-STORE-CITY PERFORM A400-REWRITE-RANDOM-RECORD. IF LETS-SEE-NEXT-STORE AND ICE-CREAM-STORE-STATE = "CA" MOVE ICE-CREAM-MASTER TO HOLD-ICE-CREAM-MASTER PERFORM A500-DELETE-RANDOM-RECORD MOVE HOLD-ICE-CREAM-MASTER TO ICE-CREAM-MASTER MOVE "AZ"...
Processing Files and Records 6.6 Backing Up Your Files 6.6 Backing Up Your Files Files can become unusable if either of the following situations occur: • Your disk file becomes corrupted by a hardware error. • Your disk file becomes corrupted with bad data. Proper backup procedures are the key to successful recovery.
Handling Input/Output Exception Conditions Many types of exception conditions can occur when a program processes a file; not all of them are errors. The three categories of exception conditions are as follows: • AT END condition—This is a normal condition when you access a file sequentially.
7.1 Planning for the AT END Condition 7.1 Planning for the AT END Condition Compaq COBOL provides you the option of testing for this condition with the AT END phrase of the READ statement (for sequential, relative, and indexed files) and the AT END phrase of the ACCEPT statement.
Your program can check for the specific cause of the failure of a file operation by checking for specific file status values in its exception handling routines. To obtain Compaq COBOL file status values, use the FILE STATUS clause in the file description entry.
01 ANSWER 7.3.1 File Status Values The run-time execution of any Compaq COBOL file processing statement results in a two-digit file status value that reports the success or failure of the COBOL statement. To access this file status value, you must specify the FILE STATUS clause in the file description entry, as shown in Example 7–3.
Compaq COBOL on OpenVMS Alpha checks for RMS completion codes after each file and record operation. If the code indicates anything other than unconditional success, Compaq COBOL maps the RMS completion code to a file status value. However, not all RMS completion codes map to distinct file status values. Many RMS completion codes map to File Status 30, a COBOL code for errors that have no specific file status value.
Page 246
These special registers supplement the file status values already available and allow the Compaq COBOL program to directly access RMS completion codes. For more information on RMS completion codes, refer to the Compaq COBOL Reference Manual and the OpenVMS Record Management Services Reference Manual.
Handling Input/Output Exception Conditions 7.3 Using File Status Values and OpenVMS RMS Completion Codes Example 7–5 (Cont.) Referencing RMS-STS, RMS-STV, RMS-CURRENT-STS, and RMS-CURRENT-STV Codes (OpenVMS) PROCEDURE DIVISION. A000-BEGIN. WRITE RECORD-1 INVALID KEY PERFORM A901-REPORT-FILE1-STATUS. The following PERFORM statement displays the RMS completion codes resulting from the above WRITE statement for FILE-1.
In Compaq COBOL Declarative procedures, the conditions in the USE statements indicate when they execute. There are five conditions. One USE statement can have only one condition;...
USE procedure does not exist for that file. Note that the USE statement itself does not execute; it defines the condition that causes the Declarative procedure to execute. Refer to the Compaq COBOL Reference Manual for more information about specifying Declarative procedures with the USE statement.
Page 251
Handling Input/Output Exception Conditions Example 7–8 (Cont.) Five Types of Declarative USE Procedures ******************************************************** D2-00-FILE-INPUT-PROBLEM SECTION. USE AFTER STANDARD EXCEPTION PROCEDURE ON INPUT. * If an error occurs for any file open * in the INPUT mode except FILE-A, * D2-00-FILE-INPUT-PROBLEM executes. D2-01-FILE-INPUT-PROBLEM.
Page 252
Handling Input/Output Exception Conditions 7.4 Using Declarative USE Procedures Example 7–8 (Cont.) Five Types of Declarative USE Procedures ******************************************************** D5-00-FILE-EXTEND-PROBLEM SECTION. USE AFTER STANDARD EXCEPTION PROCEDURE ON EXTEND. * If an error occurs for any file open * in the EXTEND mode except FILE-A, * D5-00-FILE-EXTEND-PROBLEM executes.
This chapter includes the following information about sharing files and protecting records for sequential, relative, and indexed files: • Controlling access to files and records (Section 8.1) • Choosing X/Open standard or Compaq standard file sharing and record locking (Section 8.2) • Ensuring successful file sharing (Section 8.3) •...
file connector) is concurrently accessing a file, as in Figure 8–1. A Compaq COBOL program, via the I/O system, can define one or more access streams. You create one access stream with each OPEN file-name statement. The access stream remains active until you terminate it with the CLOSE file-name...
file connector. The two are mutually exclusive. The Compaq COBOL compiler determines whether to apply X/Open standard behavior or Compaq standard behavior for any file connector on the basis of the syntax used for that file connector. The following syntax identifies X/Open...
The remainder of this section describes these requirements in more detail. 8.3.1 Providing Disk Residency Only files that reside on a disk can be shared. In Compaq COBOL you can share sequential, relative, and indexed files. 8.3.2 Using File Protection By applying the appropriate file permissions at the operating system level, the...
Page 257
• Group—Users in the same group as the owner • Others—All other users Compaq COBOL determines the access permission for newly created files in the following manner: 1. The default access permissions are granted: • User and Group are granted read and write access.
file. You specify this intention by using the Compaq COBOL open and access modes. The Compaq COBOL open modes are INPUT, OUTPUT, EXTEND, and I-O. The Compaq COBOL access modes are SEQUENTIAL, RANDOM, and DYNAMIC.
Page 259
Sharing Files and Locking Records 8.3 Ensuring Successful File Sharing LOCK MODE IS EXCLUSIVE You can also select X/Open file sharing by just specifying WITH LOCK on the OPEN or READ statements. However, it is recommended that you use the LOCK MODE clause to avoid ambiguity and maintain readability.
* The file defaults to exclusive; others cannot access it: OPEN EXTEND job-codes. 8.3.5 Specifying File Access Using Compaq Standard File Sharing Compaq standard file sharing is summarized in this section and fully described in the Compaq COBOL Reference Manual (Environment Division and Procedure Division chapters).
Page 261
OPEN ALLOWING WRITERS or UPDATERS or ALL—Allows access by other streams. Other access streams can open the file in INPUT, EXTEND, and I-O modes. Compaq COBOL also permits a list of OPEN ALLOWING options, separated by commas. The list results in the following equivalent ALLOWING specifications: •...
Sharing Files and Locking Records 8.3 Ensuring Successful File Sharing a file is shared. Note that some streams can be locked out if their intentions are not compatible with those of the streams that have already been allowed entry to the file.
Second stream is denied access to the file because the first stream intends to write, while the second stream specifies read-only sharing. Second stream is denied access to the file because the second stream intends to write, while the first stream specifies read-only sharing. No sharing;...
USE procedure will be invoked. A ‘‘file-locked’’ condition results in an I-O status code of 91. It is invalid to specify both X/Open and Compaq standard file sharing for the same file connector. Any attempts are flagged by the compiler when detectable in a single compilation unit.
File Status 91 indicates that a previous access stream has denied access to the file. That previous access stream opened the file with locking attributes which conflict with the OPEN statement of the subsequent stream. You can obtain the values that apply to file-sharing exceptions (or to successful file-sharing operations), as shown in Example 8–2.
Sharing Files and Locking Records 8.3 Ensuring Successful File Sharing Example 8–2 (Cont.) Program Segment for File Status Values * handle other possible errors here RETRY-OPEN. OPEN I-O FILE-NAME. add 1 to RETRY-COUNT. On OpenVMS, Table 8–4 describes RMS-STS values used in a file-sharing environment.
You can obtain the values that apply to file-sharing exceptions (or to successful file-sharing operations) by using the VALUE IS EXTERNAL clause, as shown in Example 8–3: Example 8–3 Program Segment for RMS-STS Values (OpenVMS) WORKING-STORAGE SECTION. 01 RMS-SUC PIC S9(9) COMP VALUE IS EXTERNAL RMS$_SUC. 01 RMS-FLK PIC S9(9) COMP VALUE IS EXTERNAL RMS$_FLK.
files. You must use the same method for record locking as for file sharing. For any single file connector, you cannot mix the X/Open standard and the Compaq standard methods. 8–16 Sharing Files and Locking Records FILE A Record 1...
8.4.1 X/Open Standard Record Locking This section describes the X/Open standard method of specifying automatic or manual record locking. Specifying Automatic Record Locking (X/Open Standard) You specify X/Open standard automatic record locking in the Environment Division by using LOCK MODE IS AUTOMATIC [WITH LOCK ON RECORD] on the SELECT statement.
Note that User 2 could have employed AUTOMATIC record locking just as well. In this case, manual and automatic locking work similarly. 8.4.2 Compaq Standard Record Locking Automatic Record Locking (Compaq Standard) You specify automatic record locking by using the ALLOWING phrase of the OPEN statement.
You specify manual record locking by using the APPLY LOCK-HOLDING clause (in the I-O-CONTROL paragraph), the OPEN ALLOWING statement, and the ALLOWING clauses on the Compaq COBOL record operations (except DELETE). Manual record locking allows greater control of locking options by permitting users to lock multiple records in a file and by permitting different types of locking...
Allowing no others DELETE START Allowing Updaters Some exceptions exist on Windows NT and Tru64 UNIX. See Compaq COBOL Reference Manual for details. 8–20 Sharing Files and Locking Records —Locks records for exclusive access. Others —Does not apply any locks to the records. Others Lock Held (for first stream)
Page 273
READ statement (READ...ALLOWING NO OTHERS). When the UNLOCK is executed, the records can be read by another access stream if that stream opens the file allowing writers. Example 8–6 Sample Program Using Manual Record Locking (Compaq Standard) FILE-CONTROL.
Page 274
Sharing Files and Locking Records 8.4 Ensuring Successful Record Locking stream on the file (UNLOCK ALL RECORDS). (On Tru64 UNIX and Windows NT systems for indexed files only, there is no current record lock.) When you access a shared file with ACCESS MODE IS SEQUENTIAL and use manual record locking, the UNLOCK statement can cause you to violate either of the following statements: ( 1 ) the REWRITE statement rule that states that the last input-output statement executed before the REWRITE must be a READ or...
Interpreting Locking Error Conditions Two record-locking conditions (hard and soft record lock) indicate whether a record was transferred to the record buffer. Compaq COBOL provides the success, failure, or informational status of an I/O operation in the file status variable.
Page 276
8.4 Ensuring Successful Record Locking Soft Record Locks Soft record locks can occur only with Compaq standard record locking. A soft record lock condition, which causes the file status variable to be set to 90, indicates that the record operation was successful, the record was transferred to the buffer, and a prior access stream holds a lock on that record.
If the application must continue reading records, the following actions may be taken: • Compaq standard record locking START or READ REGARDLESS may be used to bypass a hard record lock (see Soft Record Locks). •...
Page 278
Sharing Files and Locking Records 8.4 Ensuring Successful Record Locking Example 8–7 (Cont.) Program Segment for Record-Locking Exceptions IF record-locked continue ELSE END-IF. END DECLARATIVES. MAIN-BODY SECTION. BEGIN. DISPLAY "From main-body". GET-RECORD. READ file-name. IF NOT record-ok PERFORM check-read. CHECK-READ. IF record-locked MOVE 1 to retry-count PERFORM retry-read UNTIL record-ok OR...
Using the SORT and MERGE Statements This chapter includes the following information about using the SORT and MERGE statements to sort and merge records for sequential, line sequential, relative, and indexed files: • Sorting data with the SORT statement (Section 9.1) •...
Using the SORT and MERGE Statements 9.1 Sorting Data with the SORT Statement Sorting Concepts Records are sorted based on the data values in the sort keys. Sort keys identify the location of a record or the ordering of data. The following example depicts unsorted employee name and address records used for creating mailing labels: Smith, Jones,...
9.1.2 Specifying Sort Parameters with the ASCENDING and DESCENDING KEY Phrases Use the Data Division ASCENDING and DESCENDING KEY phrases to specify your sort parameters. The order of data names determines the sort hierarchy; that is, the major sort key is the first data name entered, while the minor sort key is the last data name entered.
Using the SORT and MERGE Statements 9.1 Sorting Data with the SORT Statement RETURN statement to transfer records from the sort. For example, you can use the RETURN statement to retrieve the sorted records for printing a report. Example 9–1 shows a sample sort using the INPUT and OUTPUT procedures. Example 9–1 INPUT and OUTPUT PROCEDURE Phrases IDENTIFICATION DIVISION.
Page 283
9.1 Sorting Data with the SORT Statement Example 9–1 (Cont.) INPUT and OUTPUT PROCEDURE Phrases *********************************************************** * You can add, change, or delete records before sorting * using COBOL data manipulation * techniques. *********************************************************** RELEASE SORT-RECORD. GO TO 070-READ-INPUT. 100-DONE-INPUT SECTION. 110-EXIT-INPUT.
Using the SORT and MERGE Statements 9.1 Sorting Data with the SORT Statement Example 9–2 USING Phrase Replaces INPUT PROCEDURE Phrase PROCEDURE DIVISION. 000-SORT SECTION. 010-DO-THE-SORT. SORT SORT-FILE ON ASCENDING KEY SORT-KEY-1 DISPLAY "END OF SORT". STOP RUN. 200-WRITE-OUTPUT SECTION. 210-OPEN-OUTPUT.
In contrast, the WITH DUPLICATES IN ORDER phrase guarantees that records with duplicate sort keys remain in the same sequence as they were in the input file. 9.1.6 Specifying Non-ASCII Collating Sequences with the COLLATING SEQUENCE IS Alphabet-Name Phrase This phrase lets you specify a collating sequence other than the ASCII default. You define collating sequences in the Environment Division SPECIAL-NAMES paragraph.
Using the SORT and MERGE Statements 9.1 Sorting Data with the SORT Statement Example 9–4 (Cont.) Using Two Sort Files 01 SORT-REC-2. 03 FILLER 03 S2-KEY-1 03 FILLER 03 S2-KEY-2 03 FILLER PROCEDURE DIVISION. 000-SORT SECTION. 010-DO-FIRST-SORT. SORT SORT-FILE1 ON ASCENDING KEY 020-DO-SECOND-REPORT.
SORT keys. For the syntax and examples of table sorting, see the SORT statement description in the Procedure Division chapter of the Compaq COBOL Reference Manual. 9.1.11 Sorting at the Operating System Level On OpenVMS an alternative to using the SORT statement within COBOL is to sort at the operating system level, using the bundled SORT utility.
Using the SORT and MERGE Statements 9.1 Sorting Data with the SORT Statement If you select Hypersort at DCL level, it will be in effect for a SORT statement within a COBOL program as well. Hypersort is the sole method available on Tru64 UNIX and Windows NT Alpha. See Appendix A for the record and key size limits with Sort-32 and Hypersort.
9.3 Sample Programs Using the SORT and MERGE Statements Example 9–7 Sorting a File with the USING and GIVING Phrases IDENTIFICATION DIVISION. PROGRAM-ID. SORTA. ************************************************* This program shows how to sort a file with the USING and GIVING phrases of the SORT statement. The fields to be sorted are S-KEY-1 and S-KEY-2;...
Using the SORT and MERGE Statements 9.3 Sample Programs Using the SORT and MERGE Statements Example 9–8 Using the USING and OUTPUT PROCEDURE Phrases IDENTIFICATION DIVISION. PROGRAM-ID. SORTB. ************************************************************** This program shows how to sort a file with the USING and OUTPUT PROCEDURE phrases of the SORT statement.
Page 291
9.3 Sample Programs Using the SORT and MERGE Statements Example 9–8 (Cont.) Using the USING and OUTPUT PROCEDURE Phrases USING INPUT-FILE OUTPUT PROCEDURE IS 300-CREATE-OUTPUT-FILE THRU 600-DONE-CREATE. ************************************************************ At this point, you could transfer control to another * section of the program and continue processing. ************************************************************ DISPLAY "END OF PROGRAM SORTB".
Using the SORT and MERGE Statements 9.3 Sample Programs Using the SORT and MERGE Statements Example 9–9 Using the INPUT PROCEDURE and OUTPUT PROCEDURE Phrases IDENTIFICATION DIVISION. PROGRAM-ID. SORTC. ********************************************************* This program shows how to use the INPUT PROCEDURE and OUTPUT PROCEDURE phrases of the SORT statement.
Page 293
9.3 Sample Programs Using the SORT and MERGE Statements Example 9–9 (Cont.) Using the INPUT PROCEDURE and OUTPUT PROCEDURE Phrases PROCEDURE DIVISION. 000-START SECTION. 005-DO-THE-SORT. SORT SORT-FILE ON ASCENDING KEY S-KEY-1 S-KEY-2 INPUT PROCEDURE IS 010-GET-INPUT THRU 200-DONE-INPUT-GET OUTPUT PROCEDURE IS 300-CREATE-OUTPUT-FILE THRU 600-DONE-CREATE.
Using the SORT and MERGE Statements 9.3 Sample Programs Using the SORT and MERGE Statements Example 9–9 (Cont.) Using the INPUT PROCEDURE and OUTPUT MOVE "N" TO INITIAL-SORT-READ GO TO 400-READ-SORT-FILE. 450-COMPARE-ACCOUNT-NUM. IF S-ACCOUNT-NUM = SR-ACCOUNT-NUM ADD S-AMOUNT TO SR-AMOUNT GO TO 400-READ-SORT-FILE.
9.3 Sample Programs Using the SORT and MERGE Statements Example 9–10 (Cont.) Using the COLLATING SEQUENCE IS Phrase FD INPUT-FILE LABEL RECORDS ARE STANDARD. 01 IN-REC PIC X(30). FD OUTPUT-FILE LABEL RECORDS ARE STANDARD. 01 OUT-REC PIC X(30). PROCEDURE DIVISION. 000-DO-THE-SORT.
Page 296
Using the SORT and MERGE Statements 9.3 Sample Programs Using the SORT and MERGE Statements Example 9–11 (Cont.) Creating a New Sort Key 03 INCOME-FOURTH-QUARTER 03 ORDER-COUNT 03 ORDERS OCCURS 1 TO 7 TIMES DEPENDING ON ORDER-COUNT. 05 ORDER-DATE 05 FILLER SORT-FILE RECORD VARYING FROM 106 TO 496 CHARACTERS DEPENDING ON SORT-LENGTH.
9.3 Sample Programs Using the SORT and MERGE Statements Example 9–11 (Cont.) Creating a New Sort Key 120-WRITE. RETURN SORT-FILE AT END CLOSE OUT-FILE GO TO 130-DONE. MOVE SORT-LENGTH TO OUT-LENGTH. WRITE OUT-REC. GO TO 120-WRITE. 130-DONE. EXIT. Example 9–12 merges three identically sequenced files into one file. Example 9–12 Merging Files IDENTIFICATION DIVISION.
Page 298
Using the SORT and MERGE Statements 9.3 Sample Programs Using the SORT and MERGE Statements Example 9–12 (Cont.) Merging Files FD TOTAL-SALES LABEL RECORDS ARE STANDARD. 01 TOTAL-RECORD WORKING-STORAGE SECTION. 01 INITIAL-READ 01 THE-COUNTERS. 03 PRODUCT-AMT 03 REGION1-AMT 03 REGION2-AMT 03 REGION3-AMT 03 TOTAL-AMT 01 SAVE-MERGE-REC.
Page 299
9.3 Sample Programs Using the SORT and MERGE Statements Example 9–12 (Cont.) Merging Files 050-TALLY-AMOUNTS. ADD M-SALES-AMT TO PRODUCT-AMT TOTAL-AMT. IF M-REGION-CODE = "01" ADD M-SALES-AMT TO REGION1-AMT. IF M-REGION-CODE = "02" ADD M-SALES-AMT TO REGION2-AMT. IF M-REGION-CODE = "03" ADD M-SALES-AMT TO REGION3-AMT.
There are three Compaq COBOL programming capabilities for producing formatted reports: conventional, linage file, and Report Writer. This chapter presents the following topics to help you format and produce reports: • Designing a report (Section 10.1) • Components of a report (Section 10.2) •...
Page 303
Example 10–1 (Cont.) Components of a Report 04-NOVEMBER-96 Year To Date Sales Report Salesman Salary/Bonus Client Name ************************ JANUARY REPORT ************************** SMITH $30,000.00 STREN JOHN $10,000.00 TOTAL JANUARY SALES: $ 2,000,000.00 ****************************************************************** ************************ FEBRUARY REPORT ************************* ********************** COMPANY CONFIDENTIAL ********************** ********************** COMPANY CONFIDENTIAL ********************** ********************** COMPANY CONFIDENTIAL ********************** <<<<<<<<<<<<<<<<<<<<<<<CONTINUED ON NEXT PAGE>>>>>>>>>>>>>>>>>>>>>...
Producing Printed Reports 10.2 Components of a Report Control Heading (CH)—The control heading consists of one or more lines of information identifying the beginning of a new logical area on a page. Detail Lines (DL)—The detail (the lines marked with 4 and all the lines between) consists of one or more lines of the primary data of the report.
Figure 10–2 Subtotals, Crossfoot Totals, and Rolled Forward Totals 04−NOVEMBER−96 Salesman Salary/Bonus −−−−−−−−− −−−−−−−−−−−− ************************* JANUARY REPORT *************************** SMITH $30,000.00 JOHN $10,000.00 LEPRO $25,000.00 RONALD $10,000.00 BALLET $20,000.00 FRANCES $10,000.00 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− JANUARY TOTALS SALARY BONUS TOTAL SALARY EXPENSE TOTAL SALES ************************* FEBRUARY REPORT ************************** SMITH $30,000.00...
10.5.1 Defining the Logical Page in a Conventional Report Your program specifies the format of your report. Using the report layout worksheet you created, you can write a Compaq COBOL program that defines the logical page area for a conventional report. Figure 10–3 shows the logical page area for a conventional report.
To advance to the next logical page and position the printer to the page heading area, you must be able to track the number of lines that your program writes on a page. The Compaq COBOL compiler lets you control the number of lines written on a page with the WRITE statement.
Producing Printed Reports 10.5 Programming a Conventional File Report Example 10–2 Checking for the Page-Overflow Condition PROCEDURE DIVISION. A000-BEGIN. A100-FIRST-REPORT-ROUTINES. * A901-HEADER-ROUTINE executes whenever the number of lines written exceeds * the number of lines on the 66-line default logical page. WRITE A-LINE1 AFTER ADVANCING 2 LINES.
Section 10.7 describes the different modes for printing a report. 10.5.5 A Conventional File Report Example Example 10–3 shows a Compaq COBOL program that produces two reports from the same input file. Example 10–3 Page Advancing and Line Skipping IDENTIFICATION DIVISION.
Page 310
Producing Printed Reports 10.5 Programming a Conventional File Report Example 10–3 (Cont.) Page Advancing and Line Skipping 01 FORM1-LINE-14. 02 FORM1-STREET 01 FORM1-LINE-15. 02 FORM1-CITY 02 FORM1-STATE 02 FORM1-ZIP 01 FORM2-HEADER-1. 02 F2H-PAGE 01 FORM2-HEADER-2. PROCEDURE DIVISION. A000-BEGIN. OPEN INPUT INPUT-FILE OUTPUT FORM1-REPORT FORM2-REPORT.
Example 10–3 (Cont.) Page Advancing and Line Skipping A900-PRINT-HEADERS-ROUTINE. * This routine generates a form feed, writes two lines, * skips two lines, then resets the line counter to 4 to * indicate used lines on the current logical page. * Line 5 on this page is the next print line.
10.6 Programming a Linage-File Compaq COBOL Report A linage-file report has sequential organization and access mode, and consists of one or more logical pages. A Compaq COBOL program that produces a linage-file report uses the LINAGE and LINAGE-COUNTER capabilities in addition to the facilities used for conventional reports.
10.6.1 Defining the Logical Page in a Linage-File Report Your program specifies the format of your report. Using the report layout worksheet you created, you can write a Compaq COBOL program that defines the logical page area and divides the page into logical page sections for a linage- file report.
10.6.2 Controlling the Spacing in a Linage-File Report To control the horizontal spacing on a logical page, define every report item from your report layout worksheet in the Working-Storage Section of your Compaq COBOL program. To control the vertical spacing on a logical page, use the WRITE statement. The WRITE statement controls whether one or more lines is skipped before or after your program writes a line of the report.
Producing Printed Reports 10.6 Programming a Linage-File Compaq COBOL Report ADVANCING PAGE clause or the AFTER ADVANCING PAGE clause. For an example of the WRITE statement, see Section 10.6.7. Section 10.6.5 describes how to handle a page-overflow condition. 10.6.5 Programming for the End-of-Page and Page-Overflow Condition A page-overflow condition occurs when your program writes more lines than the...
Producing Printed Reports 10.6 Programming a Linage-File Compaq COBOL Report Figure 10–7 A 28-Line Logical Page Column 12345678901234567890123456789012345678901234567890123456789012 Line XYZ Clothing Store STATEMENT OF ACCOUNT Name: XXXXXXXXXXX X XXXXXXXXXXXXXX Address: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Date: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Legend: T = Top margin P = Page body...
Page 317
10.6 Programming a Linage-File Compaq COBOL Report Example 10–4 (Cont.) Checking for End-of-Page on a 28-Line Logical Page DATA DIVISION. FILE SECTION. FD INPUT-FILE. 01 INPUT-RECORD. 02 I-NAME. 03 I-FIRST PIC X(10). 03 I-MID PIC X. 03 I-LAST PIC X(15).
Page 318
Producing Printed Reports 10.6 Programming a Linage-File Compaq COBOL Report Example 10–4 (Cont.) Checking for End-of-Page on a 28-Line Logical Page 01 HEAD-5. 02 H5-LC 02 FILLER 02 FILLER 02 FILLER 02 FILLER 02 FILLER 01 HEAD-6 01 DETAIL-LINE. 02 DET-LC 02 DL-DATE PIC X(9).
DCL PRINT command as follows: $ PRINT report-file-specification/NOFEED On OpenVMS Alpha systems, the LINAGE clause causes a Compaq COBOL report file to be in print-file format. (See Chapter 6 for more information.) When a WRITE statement positions the file to the top of the next logical page, the device is positioned by line spacing rather than by page ejection or form feed.
Producing Printed Reports 10.6 Programming a Linage-File Compaq COBOL Report 10.6.7 A Linage-File Report Example Example 10–5 shows a Compaq COBOL program that produces a linage-file report. The LINAGE clause in the following File Description entry defines the logical page areas shown in Figure 10–8:...
Page 321
Producing Printed Reports 10.6 Programming a Linage-File Compaq COBOL Report to exceed 15. The pointer is then positioned on the first print line of the next logical page. LINAGE is the sum of N (where N represents the number of lines of text) plus X (where X represents the number of lines at the top) plus Y (where Y represents the number of lines at the bottom).
10.7.1 Directly Allocating a Printer To directly allocate a printer, your Compaq COBOL program must include the printer’s device name in the file specification for the report file. On OpenVMS, for example: SELECT REPORT-FILE ASSIGN TO "LP:".
To spool your report to a mass storage device (such as a disk or magnetic tape) for later printing, your Compaq COBOL program must include a file specification. For example, to spool JAN28P.DAT you would include the following code in your program: SELECT REPORT-FILE ASSIGN TO "USER1$:JAN28P".
Detailed examples using Report Writer are documented in Section 10.9. 10.8.1 Using the REPORT Clause in the File Section To create a report with Report Writer, you must write a report to a specific file. That file is described by a File Description (FD) entry; however, unlike a conventional or linage-file report, your FD entry for a Report Writer file must contain the REPORT clause, and you must assign a name for each report in the REPORT clause.
Producing Printed Reports 10.8 Programming a Report Writer Report The RD entry example in Section 10.8.2 contains the following PAGE clause information: RD Entry Line PAGE LIMIT IS HEADING FIRST DETAIL LAST DETAIL FOOTING The PAGE LIMIT clause line numbers are in ascending order and must not exceed the number specified in the PAGE LIMIT clause (in this example, 66 lines).
10.8 Programming a Report Writer Report Figure 10–9 Presentation Order for a Logical Page REPORT HEADING PAGE HEADING CONTROL HEADING FINAL CONTROL HEADING 1 CONTROL HEADING 2 DETAIL CONTROL FOOTING 2 CONTROL FOOTING 1 CONTROL FOOTING FINAL PAGE FOOTING REPORT FOOTING Figure 10–10 shows a report that uses all seven of the report groups listed in the preceding table.
REPORT-HEADER TYPE IS REPORT HEADING. PAGE-HEADER TYPE IS PAGE HEADING. CONTROL-HEADER TYPE IS CONTROL HEADING CONTROL-NAME-1. DETAIL-LINE TYPE IS DETAIL. CONTROL-FOOTER TYPE IS CONTROL FOOTING CONTROL-NAME-2. PAGE-FOOTER TYPE IS PAGE FOOTING. REPORT-FOOTER TYPE IS REPORT FOOTING. 10.8.5 Vertical Spacing for the Logical Page You use the LINE clause for positioning vertical lines within a report group or for indicating vertical line space between two report groups.
Producing Printed Reports 10.8 Programming a Report Writer Report You can also specify absolute line spacing with the NEXT GROUP clause. An absolute line example—NEXT GROUP IS 10—places the next report group on line 10 of the page. In addition you can use NEXT GROUP NEXT PAGE, which causes a page-eject to occur before the NEXT GROUP report group prints.
In the next example, the COLUMN NUMBER clauses are subordinate to a LINE NUMBER clause: 02 LINE 5 ON NEXT PAGE. COLUMN 1 PIC X(12) COLUMN 14 PIC 9999 COLUMN 18 PIC X COLUMN 20 PIC X(15) COLUMN 36 PIC $$$$,$$$.99 SUM TOT-PURCHS. The previous example produces the following output: column 1234567890123456789012345678901234567890123456 (Cust-Number 1234) TOTAL PURCHASES...
Producing Printed Reports 10.8 Programming a Report Writer Report You can also code a SOURCE clause with PAGE-COUNTER or LINE-COUNTER as its operand, as the following example shows. PAGE-COUNTER references a special register created by the compiler for each Report Description entry in the Report Section.
Page 333
10.8 Programming a Report Writer Report When the value of a control name changes, a control break occurs. The Report Writer acknowledges this break only when you execute a GENERATE or TERMINATE statement for the report, which causes the information related to that CONTROL report group to be printed.
Producing Printed Reports 10.8 Programming a Report Writer Report This example produces the following output: column 1234567890123456789012345678901234567890123456789012345 TOTAL SALES FOR YEAR-TO-DATE WAS 10.8.11 Defining and Incrementing Totals In addition to using either the VALUE or SOURCE clause to assign a value to a report item, you can use the SUM clause to accumulate values of report items.
10.8.11.2 Crossfooting In crossfooting, the SUM clause adds all the sum counters in the same CONTROL FOOTING report group and automatically creates another sum counter. In the following example, the CONTROL FOOTING group shows both subtotaling (SALES-1) and crossfooting (SALES-2): 01 TYPE DETAIL LINE PLUS 1.
Producing Printed Reports 10.8 Programming a Report Writer Report 10.8.11.4 RESET Option When a CONTROL FOOTING group is printed, the SUM counter in that group is automatically reset to zero. If you want to specify when a SUM counter is reset to zero, use the RESET phrase.
In the preceding example, the value of ADD-COUNTER is added to the CONTROL FOOTING FINAL counter every time the FIRST-DETAIL-LINE report group is generated. 10.8.12 Restricting Print Items In a Report Writer program, the GROUP INDICATE clause eliminates repeated information from report detail lines by allowing an elementary item in a DETAIL report group to be printed only the first time after a control or page break.
Producing Printed Reports 10.8 Programming a Report Writer Report With the GROUP INDICATE clause, the program produces the following output: 10.8.13 Processing a Report Writer Report In a Report Writer program, you usually use the following five statements: • INITIATE •...
10.8.13.2 Generating a Report Writer Report The GENERATE statement prints the report. You can produce either detail or summary reports depending on the GENERATE identifier. If you code the name of a DETAIL report group with GENERATE, you create a detail report; if you code a report name with GENERATE, you create a summary report.
Producing Printed Reports 10.8 Programming a Report Writer Report • CONTROL FOOTING and CONTROL HEADING report groups print after the specified control breaks occur. • In a detail report, the TYPE DETAIL report groups print. • SUM operands are incremented. •...
If no GENERATE statement has been executed for the report, the TERMINATE statement does not produce any report groups. A second TERMINATE statement for the report must not be executed before a second INITIATE statement for the report has been executed. The TERMINATE statement does not close the report file;...
Producing Printed Reports 10.8 Programming a Report Writer Report The following example indicates that the phrase BEGINNING-OF-REPORT is to be displayed just before the REPORT HEADING group named REPORT- HEADER; the phrase END-OF-REPORT is to be displayed just before the REPORT FOOTING group called REPORT-FOOTER.
10.8.14.2 Summary Reporting In summary reporting, the GENERATE statement performs all of the automatic operations of the Report Writer facility, but does not produce any TYPE DETAIL report groups. A report name references the name of an RD entry. If MASTER-LIST is an RD entry, then GENERATE MASTER-LIST produces HEADING and FOOTING report groups (in the order defined), but omits DETAIL report group lines.
Producing Printed Reports 10.9 Report Writer Examples Figure 10–14 Sample MASTER.DAT File Abbott John Adam Harold Albert Robert Alexander Greg Abbott John Allan David Amos James Amico Abbott John Ames Alice Alwin Alexander Greg Berger Abbott John Ames Alice Carter Winston Alexander Greg...
Example 10–6 Sample Program EX1006 IDENTIFICATION DIVISION. PROGRAM-ID. EX1006. ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUSTOMER-FILE ASSIGN TO "MASTER.DAT". SELECT SORT-FILE ASSIGN TO "EX1006-SORTIN.TMP". SELECT SORTED-FILE ASSIGN TO "EX1006-SORTOUT.TMP". SELECT PRINTER-FILE ASSIGN TO "EX1006.LIS". DATA DIVISION. FILE SECTION. SORT-FILE.
Page 346
Producing Printed Reports 10.9 Report Writer Examples Example 10–6 (Cont.) Sample Program EX1006 REPORT SECTION. MASTER-LIST PAGE LIMIT IS 66 HEADING FIRST DETAIL 13 LAST DETAIL 55 CONTROL IS FINAL. TYPE IS PAGE HEADING. LINE 5. COLUMN 1 PIC X(27) VALUE "CUSTOMER MASTER FILE REPORT". COLUMN 105 PIC X(4) VALUE "PAGE".
Page 347
Example 10–6 (Cont.) Sample Program EX1006 PIC X(4) VALUE "CITY". COLUMN 71 PIC X VALUE "|". COLUMN 72 PIC X(2) VALUE "ST". COLUMN 74 PIC X VALUE "|". COLUMN 81 PIC X VALUE "|". COLUMN 83 PIC X(4) VALUE "DATE". COLUMN 90 PIC X VALUE "|".
Producing Printed Reports 10.9 Report Writer Examples Example 10–6 (Cont.) Sample Program EX1006 000-DO-SORT. DISPLAY "*** EX1006 ***". SORT SORT-FILE ON ASCENDING KEY SORT-NAME WITH DUPLICATES IN ORDER USING CUSTOMER-FILE GIVING SORTED-FILE. DISPLAY "*** Created EX1006.LIS ***". 050-START. OPEN INPUT SORTED-FILE. OPEN OUTPUT PRINTER-FILE.
10.9.3 EX1007—Detail Report Program Example 10–7 (EX1007) is a Report Writer program that uses the REPORT HEADING, PAGE HEADING, DETAIL, CONTROL FOOTING, and REPORT FOOTING report groups and produces a detail report—EX1007.LIS (shown in Figure 10–16). The output includes both subtotals and rolling-forward totals. Example 10–7 Sample Program EX1007 IDENTIFICATION DIVISION.
Page 350
Producing Printed Reports 10.9 Report Writer Examples Example 10–7 (Cont.) Sample Program EX1007 MASTER-LIST PAGE LIMIT IS 66 HEADING FIRST DETAIL 13 LAST DETAIL CONTROLS ARE FINAL NAME. REPORT-HEADER TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE. LINE 24. COLUMN 45 PIC X(31) VALUE ALL "*".
Page 351
Example 10–7 (Cont.) Sample Program EX1007 COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 33. COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 34. COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*".
Page 352
Producing Printed Reports 10.9 Report Writer Examples Example 10–7 (Cont.) Sample Program EX1007 COLUMN 1 PIC X VALUE "|". COLUMN 2 PIC X(110) VALUE ALL "-". COLUMN 112 PIC X VALUE "|". LINE 10. COLUMN 1 PIC X(6) VALUE "| LAST". COLUMN 16 PIC X(7) VALUE "| FIRST".
Page 353
Example 10–7 (Cont.) Sample Program EX1007 TYPE DETAIL LINE PLUS 2. 02 COLUMN 1 PIC X(15) SOURCE LAST-NAME. 02 COLUMN 17 PIC X(10) SOURCE FIRST-NAME. 02 COLUMN 28 PIC XX 02 COLUMN 30 PIC X(20) SOURCE ADDRESS. 02 COLUMN 51 PIC X(20) SOURCE CITY.
Page 354
Producing Printed Reports 10.9 Report Writer Examples Example 10–7 (Cont.) Sample Program EX1007 COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 28. COLUMN 45 PIC X VALUE "*". COLUMN 55 PIC Z9 SOURCE UE-DAY. COLUMN 57 PIC X COLUMN 58 PIC 99...
Page 355
Example 10–7 (Cont.) Sample Program EX1007 DISPLAY "*** EX1007 ***". DISPLAY "Enter Current Date (YYYYMMDD) :". ACCEPT UNEDITED-DATE. OPEN INPUT SORTED-FILE. OPEN OUTPUT PRINTER-FILE. INITIATE MASTER-LIST. PERFORM 200-READ-MASTER UNTIL NAME = HIGH-VALUES. 100-END-OF-FILE. TERMINATE MASTER-LIST. CLOSE SORTED-FILE, PRINTER-FILE. STOP RUN. 200-READ-MASTER.
Producing Printed Reports 10.9 Report Writer Examples Figure 10–16 EX1007.LIS Listing ******************************* ******************************* CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ Abbott John B 12 Pleasant Street Abbott John B 12 Pleasant Street Abbott John B 12 Pleasant Street...
Figure 10–16 (Cont.) EX1007.LIS Listing CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ Amos James A 71 State Rd TOTAL RECORDS: Berger H 700 McDonald Lane TOTAL RECORDS: Carroll Alice L 192 Lewis Road TOTAL RECORDS: Carter Winston...
Producing Printed Reports 10.9 Report Writer Examples Example 10–8 Sample Program EX1008 IDENTIFICATION DIVISION. PROGRAM-ID. EX1008. ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUSTOMER-FILE ASSIGN TO "MASTER.DAT". SELECT SORT-FILE ASSIGN TO "EX1008-SORTIN.TMP". SELECT SORTED-FILE ASSIGN TO "EX1008-SORTOUT.TMP". SELECT PRINTER-FILE ASSIGN TO "EX1008.LIS". DATA DIVISION.
Page 359
Example 10–8 (Cont.) Sample Program EX1008 03 INVOICE-NUMBER 03 INVOICE-SALES 03 INVOICE-DATE. 04 INV-DAY 04 INV-MO 04 INV-YR REPORT SECTION. MASTER-LIST PAGE LIMIT IS 66 HEADING FIRST DETAIL 13 LAST DETAIL CONTROLS ARE FINAL. REPORT-HEADER TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE. LINE 24.
Page 360
Producing Printed Reports 10.9 Report Writer Examples Example 10–8 (Cont.) Sample Program EX1008 LINE 29. COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 30. COLUMN 45 PIC X(31) VALUE "* LINE 31. COLUMN 45 PIC X(31) VALUE "* LINE 32.
Page 361
Example 10–8 (Cont.) Sample Program EX1008 COLUMN 1 PIC X VALUE "|". COLUMN 2 PIC X(110) VALUE ALL "-". COLUMN 112 PIC X VALUE "|". LINE 10. COLUMN 1 PIC X(6) VALUE "| LAST". COLUMN 16 PIC X(7) VALUE "| FIRST". COLUMN 26 PIC X(4) VALUE "|MI|".
Page 362
Producing Printed Reports 10.9 Report Writer Examples Example 10–8 (Cont.) Sample Program EX1008 LINE 11. COLUMN 1 PIC X VALUE "+". COLUMN 2 PIC X(110) VALUE ALL "-". COLUMN 112 PIC X VALUE "+". DETAIL-LINE TYPE DETAIL LINE IS PLUS 1. 02 COLUMN 1 PIC X(15) SOURCE LAST-NAME.
Page 363
Example 10–8 (Cont.) Sample Program EX1008 COLUMN 45 PIC X VALUE "*". COLUMN 55 PIC Z9 SOURCE UE-DAY. COLUMN 57 PIC X COLUMN 58 PIC 99 SOURCE UE-MONTH. COLUMN 60 PIC X COLUMN 61 PIC 9999 SOURCE UE-YEAR. COLUMN 75 PIC X VALUE "*".
Page 364
Producing Printed Reports 10.9 Report Writer Examples Example 10–8 (Cont.) Sample Program EX1008 MAIN SECTION. 000-DO-SORT. SORT SORT-FILE ON ASCENDING KEY SORT-NAME WITH DUPLICATES IN ORDER USING CUSTOMER-FILE GIVING SORTED-FILE. 000-START. DISPLAY "*** EX1008 ***". DISPLAY "Enter Current Date (YYYYMMDD) :". ACCEPT UNEDITED-DATE.
Figure 10–17 EX1008.LIS Listing ******************************* ******************************* CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ Abbott John B 12 Pleasant Street Adam Harold B 980 Main Street Albert Robert S 100 Meadow Lane Alexander Greg T 317 Narrows Road Allan...
Page 366
Producing Printed Reports 10.9 Report Writer Examples Example 10–9 (Cont.) Sample Program EX1009 DATA DIVISION. FILE SECTION. SORT-FILE. SORTED-CUSTOMER-MASTER-FILE. 02 SORT-NAME CUSTOMER-FILE. CUSTOMER-MASTER-FILE SORTED-FILE. CUSTOMER-MASTER-FILE. 02 NAME. 03 LAST-NAME 03 FIRST-NAME 03 MIDDLE-INIT 02 ADDRESS 02 CITY 02 STATE 02 ZIP 02 SALESMAN-NUMBER 03 INVOICE-NUMBER 03 INVOICE-SALES...
Page 367
Example 10–9 (Cont.) Sample Program EX1009 LINE 24. COLUMN 45 PIC X(31) VALUE ALL "*". LINE 25. COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 26. COLUMN 45 PIC X(31) VALUE "* LINE 27. COLUMN 45 PIC X VALUE "*".
Page 368
Producing Printed Reports 10.9 Report Writer Examples Example 10–9 (Cont.) Sample Program EX1009 COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 34. COLUMN 45 PIC X(31) VALUE ALL "*". TYPE IS PAGE HEADING. LINE 5. COLUMN 1 PIC X(27) VALUE "CUSTOMER MASTER FILE REPORT".
Page 369
Example 10–9 (Cont.) Sample Program EX1009 PIC X(6) VALUE "STREET". COLUMN 48 PIC X VALUE "|". COLUMN 52 PIC X(4) VALUE "CITY". COLUMN 71 PIC X VALUE "|". COLUMN 72 PIC X(2) VALUE "ST". COLUMN 74 PIC X VALUE "|". COLUMN 76 PIC X(3) VALUE "ZIP".
Page 370
Producing Printed Reports 10.9 Report Writer Examples Example 10–9 (Cont.) Sample Program EX1009 LINE 59. COLUMN 45 PIC X(16) VALUE "C O M P A N Y ". COLUMN 62 PIC X(25) VALUE "C O N F I D E N T I A L ". LINE 60.
Page 371
Example 10–9 (Cont.) Sample Program EX1009 COLUMN 45 PIC X VALUE "*". COLUMN 55 PIC Z9 SOURCE UE-DAY. COLUMN 57 PIC X COLUMN 58 PIC 99 SOURCE UE-MONTH. COLUMN 60 PIC X COLUMN 61 PIC 9999 SOURCE UE-YEAR. COLUMN 75 PIC X VALUE "*".
Page 372
Producing Printed Reports 10.9 Report Writer Examples Example 10–9 (Cont.) Sample Program EX1009 100-END-OF-FILE. TERMINATE MASTER-LIST. CLOSE SORTED-FILE, PRINTER-FILE. STOP RUN. 200-READ-MASTER. READ SORTED-FILE AT END MOVE HIGH-VALUES TO NAME. IF NAME NOT = HIGH-VALUES GENERATE DETAIL-LINE. 10–72 Producing Printed Reports...
Figure 10–18 EX1009.LIS Listing ******************************* ******************************* CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ Abbott John B 12 Pleasant Street 12 Pleasant Street 12 Pleasant Street 12 Pleasant Street 12 Pleasant Street 12 Pleasant Street 12 Pleasant Street TOTAL RECORDS: Adam...
Producing Printed Reports 10.9 Report Writer Examples Figure 10–18 (Cont.) EX1009.LIS Listing CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ Carter Winston R 123 Timpany Street TOTAL RECORDS: Cooper Frank J 300 Mohican Avenue TOTAL RECORDS: Dickens Arnold...
Example 10–10 Sample Program EX1010 IDENTIFICATION DIVISION. PROGRAM-ID. EX1010. ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUSTOMER-FILE ASSIGN TO "MASTER.DAT". SELECT SORT-FILE ASSIGN TO "EX1010-SORTIN.TMP". SELECT SORTED-FILE ASSIGN TO "EX1010-SORTOUT.TMP". SELECT PRINTER-FILE ASSIGN TO "EX1010.LIS". DATA DIVISION. FILE SECTION. SORT-FILE.
Page 376
Producing Printed Reports 10.9 Report Writer Examples Example 10–10 (Cont.) Sample Program EX1010 REPORT SECTION. MASTER-LIST PAGE LIMIT IS 66 HEADING FIRST DETAIL 13 LAST DETAIL FOOTING CONTROLS ARE FINAL NAME. REPORT-HEADER TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE. LINE 24.
Page 377
Example 10–10 (Cont.) Sample Program EX1010 COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 33. COLUMN 45 PIC X VALUE "*". COLUMN 75 PIC X VALUE "*". LINE 34. COLUMN 45 PIC X(31) VALUE ALL "*". LINE 5.
Page 378
Producing Printed Reports 10.9 Report Writer Examples Example 10–10 (Cont.) Sample Program EX1010 PIC X VALUE "|". COLUMN 72 PIC X(2) VALUE "ST". COLUMN 74 PIC X VALUE "|". COLUMN 76 PIC X(3) VALUE "ZIP". COLUMN 81 PIC X VALUE "|". COLUMN 83 PIC X(4) VALUE "DATE".
Page 379
Example 10–10 (Cont.) Sample Program EX1010 FINAL-FOOTING TYPE IS CONTROL FOOTING FINAL NEXT GROUP NEXT PAGE. LINE IS PLUS 2. COLUMN 70 PIC X(42) VALUE ALL "*". LINE IS PLUS 1. COLUMN 14 PIC X(21) VALUE "GRAND TOTAL RECORDS: ". 03 FDC COLUMN 40 PIC ZZZ,ZZZ,ZZ9 SUM IDC.
Page 380
Producing Printed Reports 10.9 Report Writer Examples Example 10–10 (Cont.) Sample Program EX1010 LINE 59. COLUMN 45 PIC X(16) VALUE "C O M P A N Y ". COLUMN 62 PIC X(25) VALUE "C O N F I D E N T I A L ". LINE 60.
Figure 10–19 EX1010.LIS Listing ******************************* ******************************* CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: C O M P A N Y C O M P A N Y CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+...
Producing Printed Reports 10.9 Report Writer Examples Figure 10–19 (Cont.) EX1010.LIS Listing CUSTOMER MASTER FILE REPORT +--------------------------------------------------------------------------------------------------------------+ NAME ADDRESS |--------------------------------------------------------------------------------------------------------------| | LAST | FIRST |MI| STREET +--------------------------------------------------------------------------------------------------------------+ TOTAL RECORDS: TOTAL RECORDS: TOTAL RECORDS: GRAND TOTAL RECORDS: C O M P A N Y C O M P A N Y ******************************* *******************************...
Example 10–12 (Cont.) Printing Labels Four-Up in Sort Order A100-READ-INPUT. READ INPUT-FILE AT END MOVE "Y" TO END-OF-FILE. IF END-OF-FILE = "Y" NEXT SENTENCE ELSE PERFORM A200-GENERATE-LABELS. A200-GENERATE-LABELS. MOVE INPUT-NAME MOVE INPUT-ADDRESS TO LABEL-ADDRESS(ROW-INDEX, ADDRESS-INDEX) MOVE INPUT-CITY MOVE INPUT-STATE MOVE INPUT-ZIP IF ROW-INDEX = 6 AND NAME-INDEX = 4 PERFORM A300-PRINT-PAGE-OF-LABELS VARYING ROW-INDEX FROM 1 BY 1 UNTIL ROW-INDEX IS GREATER THAN 6...
Producing Printed Reports 10.10 Solving Report Problems Table 10–2 (Cont.) Results of Group Indicating Without Group Indicating STATE CITY Massachusetts Maynard Massachusetts Maynard Massachusetts Maynard Massachusetts Maynard Massachusetts Tewksbury Massachusetts Tewksbury New Hampshire Manchester New Hampshire Manchester New Hampshire Merrimack New Hampshire Merrimack New Hampshire...
10.10.5 Underlining Items in Your Reports The examples in this section apply only to printers that support overprinting. Sometimes you must underline a column of numbers to denote a total and also underline the total to highlight it: 1234 1122 ---- 2356 ====...
Page 390
Producing Printed Reports 10.10 Solving Report Problems For example: WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES. * Move spaces over the items in the source print line (TOTAL-LINE) * that are not to be bolded MOVE SPACES TO ... WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
I/O. • Section 11.2 explains how you can design an online video form similar to a printed form by using the Compaq extensions to the ACCEPT and DISPLAY statements . • Section 11.3 describes the X/Open Screen Section features. You can use it to design video forms easily and efficiently in a single section of your COBOL...
Page 392
For more information on the logical names or environment variables and the mnemonic names, see the SPECIAL-NAMES section in the Environment Division chapter in the Compaq COBOL Reference Manual. ACCEPT Statement On OpenVMS, the ACCEPT statement transfers data from the input device to a data item.
• Improve the appearance of an application’s terminal dialog. Figure 11–1 is a sample form created by a Compaq COBOL program. It is for entry of employee information into a master file. This program prompts the user to type in data. Then the program writes it to the master file and displays a new form.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Figure 11–1 Adding Information to a Master File with a Video Form 12345678901234567890123456789012345678901234567890123456789012345678901234567890 *******PERSONNEL MASTER FILE DATA INPUT FORM**** Employee Number:____________ Employee Name:___________________________________ Employee Address:________________________________ Employee Phone No.:______________________________...
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions • ERASE LINE—Erase the entire specified line before accepting or displaying data at the specified or implied cursor position. • ERASE TO END OF SCREEN—Erase from the specified or implied cursor position to the end of the screen before accepting or displaying data at the specified cursor position.
STOP RUN. The default initial cursor position is in the upper left corner of the screen. Compaq COBOL moves the cursor to this initial position just prior to the execution of the first ACCEPT or DISPLAY statement. This is true regardless of the format of the statement, unless you specify the cursor position.
If you do not use either phrase, data is accepted or displayed at the position specified by the rules for Format 1 ACCEPT and DISPLAY in the Compaq COBOL Reference Manual. The presence of either or both the LINE and COLUMN phrases implies NO ADVANCING.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions In Example 11–3, the PLUS phrase is used twice to show relative positioning, once with an integer, and once without. Figure 11–4 shows the results. Example 11–3 Using PLUS for Cursor Positioning IDENTIFICATION DIVISION.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Table 11–1 Available Character Attributes by Terminal Type Character Attribute BELL Sounds the terminal bell UNDERLINED Underlines the text BOLD Intensifies the text BLINKING...
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Figure 11–5 Screen Display with Character Attributes 12345678901234567890123456789012345678901234567890123456789012345678901234567890 Employee No.: Employee wage class: NAME SALARY: $ Example 11–5 Using the CONVERSION Phrase IDENTIFICATION DIVISION.
Page 401
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–5 (Cont.) Using the CONVERSION Phrase DISPLAY "X(10) Test" LINE 8 ERASE LINE. ACCEPT DATA1A WITH CONVERSION PROTECTED REVERSED LINE 8 COLUMN 50.
11.2.5.1 Using CONVERSION with ACCEPT Data When you use the CONVERSION phrase with an ACCEPT numeric operand (other than floating point), Compaq COBOL converts the data entered on the form to a trailing-signed decimal field. Editing is performed when specified by destination.
11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions When you use the CONVERSION phrase with an ACCEPT numeric floating- point operand, Compaq COBOL converts input data to floating-point (COMP-1 or COMP-2 as appropriate). The converted result is then moved to the destination as if moving a numeric literal equivalent to the input data with the MOVE statement.
This phrase prevents overwriting or deleting parts of the screen. For more information about using the PROTECTED phrase, refer to the ACCEPT statement in the Compaq COBOL Reference Manual. If you use this phrase, and you try to type past the rightmost position of the input field or delete past the left edge of the input field, the terminal bell sounds...
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions When you use the FILLER phrase with the NO BLANK phrase, the input field is filled with the filler character only after you have entered the first character. The PROTECTED SIZE phrase sets the size of the input field on the screen and allows you to change the size of the input field from the size indicated by the PICTURE phrase of the destination item.
.123456789 12345.6789 When you do not use the PROTECTED phrase, the amount of data transferred is determined according to the ACCEPT statement rules. (See the Compaq COBOL Reference Manual.) 11.2.5.4 Using NO ECHO with ACCEPT Data By default, the characters you type at the terminal are displayed on the screen.
Page 407
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions • There is a high probability that the default value is identical in most of the records, as where a constant (such as a state’s abbreviation) is used in a mailing list.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–9 Using the DEFAULT Phrase IDENTIFICATION DIVISION. PROGRAM-ID. TRYDEF. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 DATA1A PIC 9(12). 01 NAME1A PIC XXXXX.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–9 (Cont.) Using the DEFAULT Phrase A05-GET-DATA. ACCEPT NAME1A PROTECTED DEFAULT NAME-DEFAULT LINE PLUS COLUMN 15 ERASE TO END OF LINE. ACCEPT DATA1A PROTECTED DEFAULT "***[TBS]****"...
Table 11–2 is for VT100 and later series terminals. Depending on your terminal type, certain keys listed in this table are not applicable to your terminal keyboard. Table 11–2 Compaq COBOL Characters Returned for Cursor Positioning, Program Function, Function, Keypad, and Keyboard Keys...
Page 411
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Table 11–2 (Cont.) Compaq COBOL Characters Returned for Cursor Keypad or Keyboard Key Name Name Keypad Keypad Keypad Keypad Keypad...
Page 412
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Table 11–2 (Cont.) Compaq COBOL Characters Returned for Cursor Key Name Function key Function key Function key Function key Function key...
Page 413
01 CSIX 01 CSI REDEFINES CSIX Figure 11–10 and Figure 11–11 show the Compaq COBOL control keys for various terminals. The shaded keys correspond to the keypad names in Table 11–2, which lists the characters returned to the application program.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–10 Using the CONTROL KEY IN Phrase IDENTIFICATION DIVISION. PROGRAM-ID. SPECIAL. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. SYMBOLIC CHARACTERS CR-VAL CSI-VAL Ctrl-Z-VAL SS3-VAL TAB-VAL ESC ARE 14 DATA DIVISION.
Page 416
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–10 (Cont.) Using the CONTROL KEY IN Phrase IF CR DISPLAY "RETURN" LINE 10 COLUMN 5 ERASE LINE GO TO P1. IF TAB DISPLAY "\TAB"...
Page 417
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–10 (Cont.) Using the CONTROL KEY IN Phrase DISPLAY "Not an allowable control key -" "press the Return key to continue" LINE 10 COLUMN 5 WITH BELL ERASE LINE.
Specifying the EDITING phrase of the ACCEPT statement enables field editing. Table 11–3 briefly describes the keys that the EDITING phrase enables. See the ACCEPT section of Compaq COBOL Reference Manual for a complete list of field editing keys. Table 11–3 Key Functions for the EDITING Phrase...
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–11 EDITING Phrase Sample Code PROCEDURE DIVISION. A1000-BEGIN. OPEN I-O EMP-FILE. B1000-MODIFY. DISPLAY "MODIFY EMPLOYEE INFORMATION FORM" ERASE SCREEN DISPLAY "Enter Employee Number : "...
Page 420
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions Example 11–11 (Cont.) EDITING Phrase Sample Code ACCEPT DAY-NUM FROM LINE 6 COLUMN 27 PROTECTED WITH EDITING REVERSED DEFAULT IS CURRENT AT END STOP RUN.
DISPLAY extensions for designing video forms. Screen Section, which is based on the X/Open CAE Specification for COBOL, is also a Compaq extension to the ANSI Standard. It enables you to design video forms in a single section of your Compaq COBOL program.
(They are completely described in the Data Division chapter of the Compaq COBOL Reference Manual.) Table 11–4 Character Attribute Clauses for Screen Description Formats...
Page 423
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY Table 11–4 (Cont.) Character Attribute Clauses for Screen Description Formats Clause Formats BLANK SCREEN 1, 2, 3 BLANK WHEN ZERO[ES] BLINK 2, 3 COLUMN...
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY Table 11–5 Color Table Color Black Blue Green Cyan 11.3.1.1 Comparison of Screen Section Extensions with Other Extensions of ACCEPT and DISPLAY This section points out some of the major differences and similarities between the Screen Section and non-Screen Section extensions to help you determine which to...
Page 425
PICTURE or VALUE clause. • Conversion is always performed during an ACCEPT; as the operator leaves each field, Compaq COBOL performs field validation and conversion and displays the resulting value. • The screen does not scroll during a Screen Section ACCEPT or DISPLAY. Any fields that are positioned beyond the edge of the screen are truncated.
All control sequences are captured and processed by Compaq COBOL and not returned to the application. Refer to Section 11.2, and also the Compaq COBOL Reference Manual Data Division chapter’s section on Screen Description and clauses, for details on these features.
Page 427
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY Example 11–12 (Cont.) Designing a Video Form for a Daily Calendar Normal termination of the ACCEPT statement will result in a value of ’0’...
Page 428
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY Example 11–12 (Cont.) Designing a Video Form for a Daily Calendar 01 SCHEDULE-SCREEN BLANK SCREEN. 02 TITLE-BAR FOREGROUND-COLOR 7 BACKGROUND-COLOR 4. 03 LINE 1 PIC X(80) FROM EMPTY-LINE.
Page 429
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY Example 11–12 (Cont.) Designing a Video Form for a Daily Calendar For brevity, the sample program includes complete code for the "Schedule Appointment" screen only. A complete program for a calendar would also include code for displaying, canceling, and printing the day’s appointments.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY Figure 11–14 MENU-SCREEN Output +------------------------------------------------------------------------------+ Show appointments for a day Schedule an appointment Cancel an appointment Print your appointments Use the arrow keys to move the cursor among menu items. Press <Return>...
COBOL programs can communicate with each other, as well as with non-COBOL programs. Program-to-program communication is conducted by using one (or combinations) of the following: • The CALL statement • External data • cobcall routine • routine cobcancel • routine cobfunc 12.1 Multiple COBOL Program Run Units A multiple COBOL program run unit consists of either of the following:...
Interprogram Communication 12.1 Multiple COBOL Program Run Units Example 12–1 Run Unit with Three Separately Compiled Programs IDENTIFICATION DIVISION. PROGRAM-ID. MAIN-PROGRAM. CALL SUB1. STOP RUN. END PROGRAM MAIN-PROGRAM A separately compiled program has a nesting level number of 1. If this program contains other source programs, it is the outermost containing program.
( int argc, char **argv, char **envp A Compaq COBOL program called MAIN will only interfere with main if it was compiled with the 12.2 COBOL Program Attributes Any Compaq COBOL program can have the INITIAL clause in the PROGRAM-ID paragraph.
Interprogram Communication 12.2 COBOL Program Attributes Example 12–3 Run Unit with Three Separately Compiled Programs, One with Two Contained Programs IDENTIFICATION DIVISION. PROGRAM-ID. MAIN-PROGRAM. CALL SUB1. CALL SUB2. STOP RUN. IDENTIFICATION DIVISION. PROGRAM-ID. SUB1. CALL SUB3. EXIT PROGRAM. END PROGRAM SUB1. IDENTIFICATION DIVISION.
A CALL statement transfers the run unit’s flow of control from the calling program to the beginning of the called subprogram’s Procedure Division. See the Compaq COBOL Reference Manual for the CALL statement format. The first time the called subprogram gains the flow of control, it is in its initial state.
Interprogram Communication 12.3 Transferring Flow of Control A program cannot cancel itself nor can any program cancel the program that called it. In COBOL programs, to call a routine named SPECIALROUTINE from an overlying COBOL program you might use: MOVE "SPECIALROUTINE" TO ROUTINE-NAME. CALL ROUTINE-NAME.
Page 437
Example 12–4 (Cont.) Execution Sequence of Nested CALL Statements BEGIN. DISPLAY " 1. MAINPROG has control first. DISPLAY " 2. MAINPROG transfers control to SUB1 DISPLAY " upon executing the following CALL. CALL "SUB1" DISPLAY "11. MAINPROG has control last. DISPLAY "12.
Interprogram Communication 12.3 Transferring Flow of Control Example 12–5 Sequence of Messages Displayed When Example 12–4 Is Run 1. MAINPROG has control first. 2. MAINPROG transfers control to SUB1 upon executing the following CALL. This is the entry point to SUB1. 4.
Figure 12–2 Transfer of Control Flow from a Main Program to Multiple Subprograms from a Main Program to Multiple Subprograms IDENTIFICATION DIVISION. IDENTIFICATION DIVISION. PROGRAM−ID. MAINPROG. PROGRAM−ID. SUB. ENVIRONMENT DIVISION. ENVIRONMENT DIVISION. DATA DIVISION. DATA DIVISION. PROCEDURE DIVISION. PROCEDURE DIVISION. BEGIN.
Interprogram Communication 12.4 Accessing Another Program’s Data Division Figure 12–3 Accessing Another Program’s Data Division IDENTIFICATION DIVISION. PROGRAM−ID. MAINPROG. ENVIRONMENT DIVISION. DATA DIVISION. WORKING−STORAGE SECTION. 01 A PICTURE X. 01 B PICTURE 9. 01 C PICTURE XX. 01 D PICTURE 99. PROCEDURE DIVISION.
• On OpenVMS, DESCRIPTOR—The address of (pointer to) the data item’s descriptor is passed to the called program. (Note that BY DESCRIPTOR is not supported by Tru64 UNIX. See Compaq COBOL Reference Manual, the CALL statement.) • OMITTED—A value equivalent to BY VALUE 0 is passed to the called program.
Interprogram Communication 12.4 Accessing Another Program’s Data Division Values can also be returned through the BY REFERENCE parameter in the USING phrase. However, the GIVING phrase uses the return value by immediate value mechanism. Use of this mechanism requires that the GIVING result (ITEMC) be an elementary integer numeric data item with COMP, COMP-1, or COMP-2 usage and no scaling positions.
For more information on Scope of Names rules, refer to the Compaq COBOL Reference Manual. The common attribute is attained by specifying the COMMON clause in a program’s Identification Division.
Some names are always global, other names are always local, and some names are either local or global depending on specifications in the program that declares the names. For more information on Scope of Names rules, see the Compaq COBOL Reference Manual.
Interprogram Communication 12.5 Communicating with Contained COBOL Programs IDENTIFICATION DIVISION. PROGRAM-ID. MAINPROG. DATA DIVISION. FILE SECTION. CUSTOMER-FILE GLOBAL Any special registers associated with a GLOBAL file are also global. 12.5.2.3 Sharing USE Procedures The USE statement specifies declarative procedures to handle input/output errors.
12.5 Communicating with Contained COBOL Programs At run time, two special precedence rules apply for the selection of a declarative when programs are contained in other programs. In applying these two rules, only the first qualifying declarative is selected for execution. The order of precedence for the selection of a declarative follows: Rule 1 —The declarative that executes first is the declarative within the program containing the statement that caused the qualifying condition.
Interprogram Communication 12.5 Communicating with Contained COBOL Programs Figure 12–7 Executing Declaratives Within Contained Programs (Rule 2) IDENTIFICATION DIVISION. PROGRAM−ID. MAIN−PROGRAM. PROCEDURE DIVISION. DECLARATIVES. FILEA−OUTPUT−PROBLEM SECTION. USE GLOBAL AFTER STANDARD ERROR PROCEDURE ON OUTPUT. FILEB−PROBLEM SECTION. USE GLOBAL AFTER STANDARD ERROR PROCEDURE ON FILEB. IDENTIFICATION DIVISION.
Configuration Section or any program contained in that program. 12.6 Calling Compaq COBOL Programs from Other Languages The CALL and CANCEL verbs allow you to call and cancel Compaq COBOL programs (including routines and separately compiled program units) from within a Compaq COBOL program. The allow you to call and cancel those programs from programs written in other languages.
254. For Tru64 UNIX programs, if the main routine is written in C, it must call cob_init. (See Section 12.1.2, Calling Procedures.) The Compaq COBOL program must expect its arguments by reference. 12–20 Interprogram Communication...
12.6 Calling Compaq COBOL Programs from Other Languages Example 12–9 COBOL Called Program "CALLEDFROMC" IDENTIFICATION DIVISION. PROGRAM-ID. CALLEDFROMC. DATA DIVISION. WORKING-STORAGE SECTION. 01 TEST-RESET PIC X(10) VALUE "OFF". 01 RETVAL PIC 9(5) COMP VALUE 357. LINKAGE SECTION. 01 ARG1 PIC X(10).
Interprogram Communication 12.6 Calling Compaq COBOL Programs from Other Languages Example 12–10 C Program Using cobcall, cobfunc, and cobcancel /* File: progc.c */ #include "stdlib.h" #include "stdio.h" #include "string.h" void cobcancel(char *name); cobcall (char *name, int argc, char **argv); cobfunc (char *name, int argc, char **argv);...
Page 453
12.6 Calling Compaq COBOL Programs from Other Languages Example 12–11 (Cont.) COBOL Called Program "PROGCOB" data division. working-storage section. 01 retVal pic 9(9) comp value 987654321. 01 myVal pic 9(9) comp value 0. 01 arg1 pic 9(9) comp value 0.
Page 454
Interprogram Communication 12.6 Calling Compaq COBOL Programs from Other Languages [Windows NT] c:\> cobol -c progmain.cob progcob.cob The order of listing at (*) is fundamental. Here is a sample run: [0] All the initialized values ============================== retval = 0 arg1...
= 987654321 arg1 12.7 Calling Non-COBOL Programs from Compaq COBOL Because the Compaq COBOL compiler is part of a common language environment, a Compaq COBOL program can call a procedure written in another language available in this environment. This communication among...
Interprogram Communication 12.7 Calling Non-COBOL Programs from Compaq COBOL Example 12–12 (Cont.) Calling a Fortran Program from a COBOL Program DATA DIVISION. WORKING-STORAGE SECTION. 01 INPUT-NUMBER. 03 INTEGER 03 DEC-POINT 03 DECIMAL 01 WORK-NUMBER. 03 INTEGER 03 DECIMAL 01 WORK-NUMBER-A REDEFINES WORK-NUMBER PIC 9(5)V9(8).
The rich, yet easily accessed features of BASIC make that language a natural environment for development of short routines to be called from COBOL. Example 12–14 shows one example of a Compaq COBOL program that calls a BASIC program. Example 12–14 Calling a BASIC Program from a COBOL Program IDENTIFICATION DIVISION.
Interprogram Communication 12.7 Calling Non-COBOL Programs from Compaq COBOL Example 12–14 (Cont.) Calling a BASIC Program from a COBOL Program DISPLAY "Enter 3 digit mortgage/rent". ACCEPT MORTGAGE-RENT. MOVE MORTGAGE-RENT TO C-MORTGAGE-RENT. DISPLAY "Enter 2 digit years employed by current employer".
= %s\n", i, argv[i]); Example 12–17 is a representation of how you can call a C program from your Compaq COBOL application. In this case, the C routine crtn (in Example 12–16) is called. Example 12–17 Calling a C Program from a COBOL Program IDENTIFICATION DIVISION.
CALL statement can be either a literal or a data-name. The same is true for the CANCEL verb. For more information on shareable images refer to Compaq COBOL online help file and the OpenVMS Linker Utility Manual. 12.8.3 Calling Tru64 UNIX Shareable Objects (Tru64 UNIX) When you call a subprogram contained in a shared object, the program name specified in the CALL statement must be a literal.
These language features are meaningful only when both the calling program and the called program are Compaq COBOL programs. 12.8.4.2 Calling C Programs from Compaq COBOL on Tru64 UNIX and Windows NT Because lowercase is the names option default, the names upper option is only required to call C functions whose names contain uppercase letters, as described in Table 12–2.
The man pages for information on system service routines in Tru64 UNIX. • Reading an Indexed File from Other Languages on Tru64 UNIX section in Chapter 6 of this manual • Compaq COBOL Reference Manual, CALL and CANCEL sections 12–32 Interprogram Communication flag and /names= -names...
• Tru64 UNIX library routines On Tru64 UNIX, your Compaq COBOL programs can also call routines written in other languages, including system services routines on Tru64 UNIX. These calls must conform to the Tru64 UNIX Calling Standard for Alpha Systems.
Table 13–1 OpenVMS Alpha Register Usage (OpenVMS) Register R2-R15 R16-R21 R22-R24 13–2 Using Compaq COBOL in the Alpha Common Language Environment Function value return register (see also F0, F1) Conventional scratch register Conventional saved registers Argument registers, one register per argument, additional arguments...
System routines are OpenVMS Alpha routines that perform common tasks, such as finding the square root of a number or allocating virtual memory. You can call any system routine from your program, provided that Compaq COBOL supports the data structures required to call the routine.
13–4 Using Compaq COBOL in the Alpha Common Language Environment Types of Tasks Performed Library routines that handle floating-point data conversion DECtalk routines that are used to control a Compaq DECtalk device Library routines that: Obtain records from devices Manipulate strings...
For example, on OpenVMS Alpha, LIB$GET_INPUT returns a return status. Using Compaq COBOL in the Alpha Common Language Environment 13–5 13.3 OpenVMS Alpha System Routines (OpenVMS) Types of Tasks Performed Designates condition handlers for special purposes Clears, sets, reads, and waits for event flags, and associates with...
The handle-address argument appears in square brackets ( [ ] ), indicating that it is an optional argument. Hence, when you call the system routine LIB$STAT_ TIMER, only the first two arguments are required. 13–6 Using Compaq COBOL in the Alpha Common Language Environment...
COBOL. To determine the syntax of the CALL statement for a function call or a procedure call, see the Compaq COBOL Reference Manual, and refer to the examples in this chapter.
While COBOL does not interpret the data type, it may be used to pass objects from one language to another. 13–8 Using Compaq COBOL in the Alpha Common Language Environment (continued on next page)
Page 471
Although unsigned computational data structures are not directly supported in COBOL, you may substitute the signed equivalent provided you do not exceed the range of the signed data structure. Using Compaq COBOL in the Alpha Common Language Environment 13–9 04 COMP-LENGTH PIC S9(4) COMP.
Page 472
Although unsigned computational data structures are not directly supported in COBOL, you may substitute the signed equivalent provided you do not exceed the range of the signed data structure. 13–10 Using Compaq COBOL in the Alpha Common Language Environment 04 BUF-LEN PIC S9(4) COMP.
Page 473
Using Compaq COBOL in the Alpha Common Language Environment 13.4 Calling Routines Table 13–4 (Cont.) COBOL Implementation of the OpenVMS Alpha Data Types (OpenVMS)
Page 474
If the argument is described as ‘‘address of descriptor,’’ use BY DESCRIPTOR. If a routine requires a passing mechanism that is not supported by COBOL, calling that routine from COBOL is not possible. 13–12 Using Compaq COBOL in the Alpha Common Language Environment Note...
VALUE IS EXTERNAL become link-time constants; that is, the evaluation of the symbolic name is deferred until link time because it is known only at link time. Using Compaq COBOL in the Alpha Common Language Environment 13–13 13.4 Calling Routines...
Page 476
WHEN LIB$_INPSTRTRU DISPLAY "User name too long" WHEN COND-VALUE IS FAILURE DISPLAY "More serious error". 13–14 Using Compaq COBOL in the Alpha Common Language Environment PIC X(30). PIC X(16) VALUE IS "Type Your Name". PIC S9(4) USAGE IS COMP. PIC S9(9) USAGE IS COMP.
To establish a user condition handler, call the LIB$ESTABLISH routine. The form of the call is as follows: CALL LIB$ESTABLISH USING BY VALUE new-handler GIVING old-handler Using Compaq COBOL in the Alpha Common Language Environment 13–15 Meaning Insufficient virtual memory No such device Floating overflow in Math Library procedure...
Page 478
Compaq COBOL condition handler. When an exception occurs, the user condition handler, if one exists, is executed first, followed by the Compaq COBOL condition handler, if the user condition handler could not handle the exception.
SS$_RESIGNAL. If the routine does remedy the exception condition, then it should return with a value of SS$_CONTINUE. DATA DIVISION. Using Compaq COBOL in the Alpha Common Language Environment 13–17 0 0 0 0 0 0 0 0. (continued on next page)
Page 480
MOVE SS$_CONTINUE TO SS_HAND END-IF. EXIT PROGRAM. END PROGRAM SSHAND. 13–18 Using Compaq COBOL in the Alpha Common Language Environment PIC S9(9) COMP. PIC S9(9) COMP VALUE EXTERNAL SS$_SSFAIL. PIC S9(9) COMP VALUE EXTERNAL SS$_RESIGNAL. PIC S9(4) COMP.
END-PERFORM. Example 13–3 shows a program fragment that calls the SYS$SETDDIR system service. Example 13–4 calls the System Service routine $ASCTIM. Using Compaq COBOL in the Alpha Common Language Environment 13–19 Routine Name Line Number rel PC 0 8005FA40 SSCOND...
DISPLAY "LENGTH OF RETURNED = " D-TIMLEN ELSE DISPLAY "ERROR". STOP RUN. Example 13–5 shows output from a sample run of the CALLTIME program. 13–20 Using Compaq COBOL in the Alpha Common Language Environment OMITTED OMITTED GIVING STAT. PIC 9999 COMP VALUE 0.
The following example uses LIB$SET_SYMBOL to set a value for a DCL symbol and shows the use of LIB$K_* symbols for arguments and LIB$_* symbols for return status values. Using Compaq COBOL in the Alpha Common Language Environment 13–21 13.6 Examples (OpenVMS)
$ link setsym,libdef $ run setsym Ambiguous $ show symbol xset* XSETS == "Test1C" XSET*SYM = "Test1A" 13–22 Using Compaq COBOL in the Alpha Common Language Environment value external SS$_NORMAL. value external LIB$_AMBSYMDEF. COND-VAL. display "OK" display "Not OK". COND-VAL.
Conventional ANSI format produces source programs compatible with the reference format as defined in the ANSI-85 COBOL Standard. The Compaq COBOL Reference Manual describes both formats in detail. On OpenVMS, REFORMAT is installed by the Compaq COBOL installation procedure (if you answered "yes" to the query during installation), and is placed in the following location: SYS$SYSTEM:REFORMAT.EXE...
Using the REFORMAT Utility 14.1 Running the REFORMAT Utility REFORMAT - REFORMAT - Enter Y for ANSI-to-terminal conversion, or REFORMAT - Enter N (default) for terminal-to-ANSI conversion. REFORMAT - Enter ^Z to exit. REFORMAT - ANSI-to-terminal format conversion mode [ Y / [N] ]? n REFORMAT - Terminal-to-ANSI format selected REFORMAT - Terminal-format input file spec : myprog.cob REFORMAT -...
A is to be placed in the indicator area. Clearly both characters cannot be placed in the indicator area. Compaq COBOL continues the conditional compilation line by placing the A in the indicator area. This means the program remains valid if conditionals are not used in the compilation because the lines become comment lines.
Using the REFORMAT Utility 14.3 Terminal-to-ANSI Format Conversion is a text processor and does not perform the level of checking required by lines such as these. You detect this error during a compile operation. 14.4 REFORMAT Error Messages If any of your responses to the prompts are incorrect, REFORMAT displays error messages.
Page 489
Using the REFORMAT Utility 14.4 REFORMAT Error Messages To process another file, type a new input file specification and continue the prompting message sequence. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems). Using the REFORMAT Utility 14–5...
Optimizing Your Compaq COBOL Program You can specify optimization and data alignment on the COBOL compiler comnp15l.19BOL improv9BOL You can als3BOLdecreas9BOL tim9BOL32(and)-334(sav9BOL32(storage)-334(spac9BOL32(by)-334(writing)-33-3programs)-334(...
Running programs compiled with the EV56 keyword may incur emulation overhead on EV4 and EV5 processors, but will still run correctly on OpenVMS Version 7.1 (or later) systems. 15–2 Optimizing Your Compaq COBOL Program or /TUNE=keyword) specifies the -tune keyword...
Page 493
Alpha instructions (no extensions). Programs compiled with the EV5 option run without instruction emulation overhead on all Alpha processors. qualifier (or option on Tru64 UNIX) -arch Optimizing Your Compaq COBOL Program 15–3...
Page 494
7.1 (or later) systems. If a program contains declarations of non-EXTERNAL variables that are not referenced in the program, the Compaq COBOL compiler does not allocate those variables. These variables are not affected by /OPTIMIZE; they simply are not allocated. This feature improves both resource usage and run-time performance, and allows the use of site ‘‘copybooks’’...
Page 495
Optimizing Your Compaq COBOL Program 15.1 Specifying Optimization on the Compiler Command Line On OpenVMS Alpha systems, in general, specify /NOOPTIMIZE if you specify /DEBUG when you compile a program. If you specify /DEBUG but omit any form of the /OPTIMIZE qualifier on the command line, the compiler issues the...
file record structures. Tools That Can Help You Decide Whether to Convert a Program Compaq does not recommend a massive conversion of all source programs to use COMP operands. Most existing COBOL programs perform very well, and conversions of old programs can be expensive.
Optimizing Your Compaq COBOL Program 15.3 Using COMP Data Items for Speed ) that require large amounts pixie Optimizing Your Compaq COBOL Program 15–7...
While these operations are actually transparent to you, there is a cost in both performance and accuracy, as some data can be lost in the two conversions. Wherever you have the luxury of choice, Compaq suggests you use G-FLOAT data types in your programs.
SEARCH ALL, you must pre-sort the table. If the table is not sorted, SEARCH ALL often gives incorrect results. The SORT statement (Format 2, which is a Compaq extension) can be used to sort an entire table. This is particularly useful in connection with SEARCH ALL.
Record buffer If you need to reference LINKAGE SECTION items in a USE procedure, try to limit the size of the program unit containing that USE procedure. Compaq COBOL will be able to perform more aggressive optimizations on all the other program units that do not contain the LINKAGE SECTION references in any USE procedures.
file. 15.6.1.3 Using the DEFERRED-WRITE Phrase of the APPLY Clause The format of APPLY DEFERRED-WRITE is as follows: APPLY DEFERRED-WRITE ON { file-name } ... Optimizing Your Compaq COBOL Program Optimizing Your Compaq COBOL Program 15–11 15.6 I/O Operations...
The format of APPLY FILL-SIZE is as follows: APPLY FILL-SIZE ON { file-name } ... Use the APPLY FILL-SIZE clause to populate (load) the file and force the Compaq COBOL compiler to write records into the bucket area not reserved by the fill number.
The records do not exist separately. Therefore, if the program changes a record defined for the output file, the input file record is no longer available. Optimizing Your Compaq COBOL Program 15–13...
WRITE OUT−REC ... Process Without Shared Areas READ (move) INP−REC MOVE OUT−REC WRITE (move) 15–14 Optimizing Your Compaq COBOL Program Program with Shared Record Area I−O−CONTROL. SAME RECORD AREA FOR INP−FILE OUT−FILE. PROCEDURE DIVISION. READ INP−FILE ... WRITE OUT−REC ...
In the following example, the BLOCK CONTAINS clause specifies five records. RMS calculates the block size as eight records, or 512 bytes. Optimizing Your Compaq COBOL Program Optimizing Your Compaq COBOL Program 15–15 15.6 I/O Operations...
File size—The number of blocks used to preallocate the file. 15.7.2.1 Maximum Record Number (MRN) If you create a relative file with a Compaq COBOL program, the system sets the maximum record number (MRN) to 0, allowing the file to expand to any size.
Page 507
DATA DIVISION. FILE SECTION. FD A-FILE RECORD CONTAINS 60 CHARACTERS BLOCK CONTAINS 1 RECORD. Optimizing Your Compaq COBOL Program 15.7 Optimizing File Design (OpenVMS) = 1500 bytes 25 bytes 11 bytes TOTAL = 1536 bytes Optimizing Your Compaq COBOL Program 15–17...
first forces formatting of the entire file only once. However, this technique can waste disk space if the file is only partially loaded and not preallocated. 15–18 Optimizing Your Compaq COBOL Program = 480 bytes 8 bytes = 24 bytes...
The data record’s location is then determined so that a record can be retrieved or a new record written. Optimizing Your Compaq COBOL Program 15.7 Optimizing File Design (OpenVMS) ROOT BUCKET Optimizing Your Compaq COBOL Program 15–19 LEVEL 2 LEVEL 1 LEVEL 0 ZK−1540−GE...
I/O system splits it in similar fashion, on up to the top level (root level). In an indexed file, the I/O system also maintains chains of forward pointers through the buckets. 15–20 Optimizing Your Compaq COBOL Program PIC X(10). PIC X(70).
Page 511
Thus, a bucket size of 1 specifies a 512-byte bucket, while a bucket size of 2 specifies a 1024-byte bucket, and so on. The Compaq COBOL compiler passes bucket size values to the I/O system based on what you specify in the BLOCK CONTAINS clause. In this case, you express bucket size in terms of records or characters.
Page 512
0 buckets of alternate indexes. Use these calculations to determine data and index record size: • Data records: 15–22 Optimizing Your Compaq COBOL Program = 535 bytes (Record size is 100 bytes, record overhead is 7 bytes for each of 5...
Page 513
Primary key index level calculations: In the following calculations, some results are to be rounded up, and some truncated. Level 0 (data level buckets): Level 1 (index buckets): 15.7 Optimizing File Design (OpenVMS) Note Optimizing Your Compaq COBOL Program 15–23...
The following example uses an average efficiency of .55. In each of the following calculations, the results are either rounded up or truncated. Level 0 (data level buckets—no duplicate alternate keys): Level 1 (index buckets): Level 2 (index buckets): 15–24 Optimizing Your Compaq COBOL Program...
DCL SET RMS commands and RESERVE AREA clause provide the same functionality. For information about DCL commands, see the OpenVMS DCL Dictionary. 15.8 Image Activation Optimization (Tru64 UNIX) Shared objects are checksumm(checksu1vour)o(are)-35nU[(DC57tedtiveCOUbuffe52(examplts)-35 Optimizing Your Compaq COBOL Program 15.7 Optimizing File Design (OpenVMS)
(For example, longword is the natural boundary for four-byte integers.) Two forms of alignment are available in Compaq COBOL. The basic form of alignment allows you to align only elementary data items without padding the record structures and substructures within which they reside.
On the Tru64 UNIX system, it is allocated as a 64-bit quadword integer, with 8 bytes of storage. On the OpenVMS Alpha system, Compaq COBOL allocates 4 bytes for POINTER data to maintain Compaq COBOL for OpenVMS VAX compatibility. On the Tru64 UNIX system, it allocates 8 bytes for POINTER data (a 64-bit quadword integer).
• Ease of use and conversion—You might need to make a minimal number of changes to existing source files before compiling them with the Compaq COBOL compiler. In some cases, all you need to do is specify the or the /ALIGNMENT qualifier with or without the padding option when you compile.
When you use an alignment directive or qualifier to align data in records, you should consider whether the data will be written to a file to be accessed by applications written in Compaq COBOL for OpenVMS VAX. These directives are not allowed in the PROCEDURE DIVISION of a program source.
— The alignment specified by the command-line option if no previous alignment directive exists • The beginning of the next file specified in a comma list (on the Compaq COBOL command line). This event closes all of the preceding alignment directives. The alignment specified with the command-line option becomes the current alignment.
The alignment examples that follow illustrate the following important points: • Compaq COBOL for OpenVMS VAX and Compaq COBOL align 01 (and 77) data items along different boundaries, as follows: Compaq COBOL for OpenVMS VAX aligns 01 data records and items along longword boundaries.
filler byte. The fields are indicated by the callouts in the right column of Example 16–2. Compaq COBOL for OpenVMS VAX would align the data as follows: | 1223 | 3444 | 4555 | 5555 | 5 Compaq COBOL without the the /NOALIGNMENT qualifier would align the data as follows:...
UNIX environments. The program fragment in Example 16–3 was extracted from a COBOL program that was compiled three times on Compaq COBOL, using the following qualifiers for each compilation: 1. /LIST/MAP=D—No alignment and no padding, as in Compaq COBOL for OpenVMS VAX (see Example 16–4)
Record length is 26 bytes. The asterisk (*) designates FLD3-1. Also, no padding or filler will result, just as with Compaq COBOL for OpenVMS VAX on OpenVMS VAX. Example 16–5 Data Map for /ALIGNMENT, -align Data Names in Declared Order...
Managing Memory and Data Access 16.4 Using Alignment Directives, Qualifiers, and Flags Byte Layout for Example 16–5: |REC1 |FLD1 |FLD1-1 |FLD1-2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Begin byte number (starting with 0) Record length is 29 bytes. The asterisk (*) designates FLD3-1. The letter f designates internal filler bytes produced because the field FLD3-2 has to start on the boundary that is the next higher multiple of 4 because it is longword-aligned.
Page 529
16.4 Using Alignment Directives, Qualifiers, and Flags 3. These three pad bytes bring FLD3 up to: 16 = 4*4 bytes 4. The total number of bytes in the record is now: 36 = 12 + 8 + 16 bytes 5. *, p, f apply in the same way as for /ALIGN without PADDING. Managing Memory and Data Access Managing Memory and Data Access 16–13...
Compiler Implementation Specifications The following list summarizes the specifications and restrictions for the Compaq COBOL compiler. The compiler issues diagnostic messages whenever you exceed its design parameters. • Run-time storage (generated object code and data) for COBOL programs cannot exceed 2,147,483,647 bytes.
Page 532
The maximum static nesting depth of contained programs is 256. • The maximum number of characters in a user-word in Compaq COBOL is 31. The maximum number of characters allowed in a user-word as defined by the ANSI COBOL standard is 30. The compiler issues an informational diagnostic if you use 31-character user-words.
Page 533
• The Sort-32 (available on OpenVMS) record size limit is 65,535 bytes. • The Sort-32 key size limit is 65,529 bytes. • The Hypersort key size limit is 65,535 bytes. • If a file is assigned to magnetic tape media and you use the BLOCK CONTAINS clause in the associated file description, the number of characters in a physical block determined from the BLOCK CONTAINS clause must be an even multiple of 8.
Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration Compaq COBOL is based on and is highly compatible with Compaq COBOL for OpenVMS VAX, which runs on the OpenVMS VAX system. However, there are differences, which are summarized in this appendix. This information can help...
Page 536
Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B.1 Compatibility Matrix Table B–1 (Cont.) Cross-Platform Compatibility of COBOL Features Print control files with VFC OpenVMS OpenVMS Tru64 Windows NT Alpha UNIX Alpha N N N...
• A flag or qualifier (/DISPLAY_FORMATTED or causes the proper display of numeric values without the use of WITH CONVERSION on the DISPLAY statement. Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B–3 OpenVMS OpenVMS Alpha -arch...
Forms Unit utilities and Vertical Forms Printing). Compaq COBOL includes the following: • Support for the relevant subset of the features in the Compaq COBOL for OpenVMS VAX /STANDARD=V3 qualifier. See Section B.3.3. • Support for file status values that are compatible with Compaq COBOL for OpenVMS VAX Version 5.1 or higher.
The flags are generally equivalent in features to the qualifiers, except that flags do not have a negative form. There are some differences in behavior and features between Compaq COBOL and Compaq COBOL for OpenVMS VAX. See the specific documentation for details.
Table B–3 lists the command-line qualifiers and flags for features specific to Compaq COBOL. These qualifiers and flags are not available in Compaq COBOL for OpenVMS VAX. Table B–3 Compaq COBOL Options Not Available in Compaq COBOL for OpenVMS VAX OpenVMS Alpha Qualifier, Windows NT Option...
Page 541
OpenVMS Alpha form; see /TUNE for Windows NT equivalent. The action of Compaq COBOL on OpenVMS Alpha with this qualifier is designed to closely match the default action with Compaq COBOL for OpenVMS VAX. This qualifier is not available on Windows NT.
Windows NT form; see /OPTIMIZE=TUNE for OpenVMS Alpha equivalent. The action of Compaq COBOL on OpenVMS Alpha with this qualifier is designed to closely match the default action with Compaq COBOL for OpenVMS VAX. This qualifier is not available on Windows NT.
Page 543
Table B–4 (Cont.) Compaq COBOL for OpenVMS VAX Specific Qualifiers Qualifier /WARNINGS=STANDARD /STANDARD=V3, -std v3 Compaq COBOL does not support a number of features supported by the Compaq COBOL for OpenVMS VAX implementation of the /STANDARD=V3 qualifier and -std v3 •...
In some cases, the Compaq COBOL compiler (whether on the OpenVMS Alpha, Windows NT, or the Tru64 UNIX system) generates more complete messages about unreachable code or other logic errors than does the Compaq COBOL for OpenVMS VAX compiler. The following example illustrates a sample program and the messages issued by the Compaq COBOL compiler: Source file...
With Compaq COBOL for OpenVMS VAX, /NOOBJECT suppresses just the creation of the .OBJ. Compaq COBOL for OpenVMS VAX still does all the work to generate the object code so it can be placed in the listing.
The following two compiler listing files illustrate the difference in the position of the listing annotations, represented by the letter ‘‘L,’’ for multiple COPY statements on a single line in a COBOL program using Compaq COBOL and Compaq COBOL for OpenVMS VAX.
Compaq COBOL for OpenVMS VAX Listing File for Multiple COPY Statements B.4.2.5 COPY Insert Statement The compiler listing files for a Compaq COBOL program and a Compaq COBOL for OpenVMS VAX program differ when a COPY statement inserts text in the middle of a line.
COMPILED result in compiler listing files that contain multiple instances of the source line. For a REPLACE statement in a Compaq COBOL program, if the Compaq COBOL compiler issues a message on the replacement text, the message corresponds to the original text in the program, as shown in the following compiler listing file.
• PROGRAM_3 source listing • PROGRAM_3 machine code listing Note that this is consistent with listings produced by Compaq COBOL for OpenVMS VAX. Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B–15 P0. REPLACE ==xyzpdqnothere== BY ==nothere==.
ACCEPT statements are also used by the ANSI ACCEPT statements. (See Table 11–3 for a complete list of editing keys.) B–16 Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration...
This difference is clearly shown when the first ACCEPT or DISPLAY statement does not contain the LINE and COLUMN clauses. In this case Compaq COBOL moves the cursor to the top of the screen to perform the ACCEPT or DISPLAY, whereas Compaq COBOL for OpenVMS VAX does not move the cursor.
Unsigned computational fields can hold larger values than signed computational fields. In accordance with the ANSI COBOL Standard, the values for unsigned items should always be treated as positive. Compaq COBOL for OpenVMS VAX, however, treats unsigned items as signed, while Compaq COBOL treats them as positive.
floating-point and binary data. Routines that return floating-point values return them in register F0; routines that return binary values return them in register R0. Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B–19 PIC X(14) VALUE ’A_LOGICAL_NAME’. PIC X(4).
To produce behavior identical to Compaq COBOL for OpenVMS VAX, correct the problem causing the diagnostic. • If one of the operands in a comparison is illegal, both VAX and Compaq COBOL emit an error message. Compaq COBOL for OpenVMS VAX continues analyzing the statement containing the conditional, but Compaq COBOL skips to the next statement (thus not finding any additional errors in...
• There is a difference between Compaq COBOL for OpenVMS VAX and Compaq COBOL in the enforcement of the general rule that name conflicts should be avoided, including names used for COPY libraries. The Compaq COBOL for OpenVMS VAX compiler does not enforce this rule in some cases, including COPY and PROGRAM-ID.
There is one other instance when the RMS special registers can contain different values for Compaq COBOL and Compaq COBOL for OpenVMS VAX applications. Upon the successful completion of an RMS operation on a Compaq COBOL file, the RMS special registers always contain RMS completion codes. Upon the successful completion of an RMS operation on a Compaq COBOL for OpenVMS VAX file, the RMS special registers usually contain RMS completion codes, but...
Compaq COBOL for OpenVMS VAX often returns the low order digits of the true result in such cases; Compaq COBOL does not. When standard arithmetic is used, the results are unaltered.
You should refer to the Release Notes to get the most recent information about these differences. The next few sections describe distinct differences in feature implementation and behavior. B–24 Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration...
file was created, but not when reopened by the current program, the behavior will be as if DUPLICATES were not allowed. Compaq COBOL on Windows NT and on Tru64 UNIX issues a severe run-time error if there is a mismatch, unless relax key checking (the in which case the behavior is inconsistent.
DUPLICATES may give unexpected results. B.5.5 Indexed Files Compaq COBOL on Tru64 UNIX and Windows NT treats indexed files differently from the way they are treated by both Compaq COBOL on OpenVMS Alpha and Compaq COBOL for OpenVMS VAX on OpenVMS Alpha. Specifically: •...
file with the incompatible key. B.5.6 RMS Special Register References in Your Code Compaq COBOL on Windows NT and Tru64 UNIX does not support RMS Special Registers. If you include them, you may receive the following general diagnostic message when you attempt to compile the program: cobol: Severe: .
COBOL and the initialize routine is written in Compaq C, the initialize routine will not be called. If you are using Compaq COBOL for OpenVMS VAX on OpenVMS VAX Version 7.1, however, the routine will be called; also, it will be called if your main program is in C or in BASIC rather than COBOL, so this can be a practical workaround.
This difference from Compaq COBOL for OpenVMS VAX can help you debug a program. Because these messages are informational, the compiler produces an object file, which you can link and execute. However, the messages may point out otherwise undetected logic errors, as the structure of the program is probably not what you intended.
Severe: . . . Undefined name B.11.2 Multistream DBMS DML With Compaq COBOL, when you use multistream Oracle DBMS DML, you must access different schemas or streams from separate source files. B–30 Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration...
Compaq FUSE is the Compaq integrated software development environment for UNIX workstations. Compaq FUSE is available in two variations: the Compaq FUSE base system, and FUSElite, a subset of Compaq FUSE (used for C program development), which is upgradable to the full base system.
Technical Note With certain COBOL programs in the Compaq FUSE environment a problem will manifest itself by displaying the wrong file in the Compaq FUSE Editor tool for certain COBOL items which are clicked on from the Cross-Referencer tool. This can only happen for COBOL programs with successive COPY statements where there are no intervening data item references or declarations.
Page 567
C.2 Debugging Tools for Compaq COBOL Programs • Perform other functions, such as executing shell commands, examining files, examining the call stack, or displaying registers. The debugging examples in Section C.3 and Section C.4 focus on a sample program, shown in Example C–1. One common program has been used, to emphasize the portability of Compaq COBOL.
53: END PROGRAM TESTB. 54: END PROGRAM TESTA. C.3 Ladebug Debugger (Tru64 UNIX) The Ladebug Debugger is used to debug Compaq COBOL programs on the Tru64 UNIX operating system. This section provides a representative debugging session that is designed to demonstrate the use of debugger features.
Page 569
flags ( at the beginning of the example in this section. 1. To begin this example you compile a Compaq COBOL program consisting of the single compilation unit named TESTA.
Page 570
Programming Productivity Tools C.3 Ladebug Debugger (Tru64 UNIX) 8. Use the list (ladebug) list 43,50 PERFORM LOOK-BACK VARYING SUB-1 FROM 20 BY -1 MOVE SUB-1 TO CHARCT. PERFORM MOVE-IT MOVE HOLD-WORD TO TEMP-WORD. 48 MOVE-IT. MOVE TEMP-CHAR (SUB-1) TO HOLD-CHAR (SUB-2). SUBTRACT 1 FROM SUB-1.
Page 571
(ladebug) print temp-char of temp-word(2) "b" 19. You can qualify data names in debug commands as you can in Compaq COBOL. For example, if you examine IN-WORD while you debug your program, you can use the following Ladebug Debugger command: (ladebug) print in-word of testa-data "abc...
C.4.2 Notes on Debugging Optimized Programs The Compaq COBOL compiler is a highly optimizing compiler. Several of the optimizations it performs, such as instruction scheduling and label deletion, can cause unexpected behavior in the OpenVMS Debugger.
Page 573
The following OpenVMS Alpha debugging session does not show the location of program errors; it is designed to show only the use of debugger features. 1. The following example shows how to compile and link a Compaq COBOL program consisting of a single compilation unit named TESTA.
Page 574
Programming Productivity Tools C.4 OpenVMS Debugger (OpenVMS) $ RUN TESTA %DEBUG-I-INITIAL, Language: COBOL, Module: TESTA %DEBUG-I-NOTATMAIN, type GO to get reach MAIN program DBG> 3. Use the GO command to get to the start of the main program. DBG> GO break at routine TESTA DISPLAY "ENTER WORD"...
Page 575
11. Set a watchpoint on the data item DISP-COUNT. When an instruction tries to change the contents of DISP-COUNT, the debugger returns control to you. DBG> SET WATCH DISP-COUNT DEBUG-I-WPTTRACE, non-static watchpoint, tracing every instruction 12. Execution resumes with the GO command. Before line 50 in TESTB executes, the debugger executes the contents of the DO command entered at step 7.
Page 576
Programming Productivity Tools C.4 OpenVMS Debugger (OpenVMS) 21. You can examine any character of a subscripted data item by specifying the character position. The following EXAMINE command accesses the second character on TEMP-CHAR. DBG> EXAMINE TEMP-CHAR(2) TEMP-CHAR of TESTA\TESTB\TEMP-WORD(2): "b" 22.
C.4.2.1 Separately Compiled Programs When you debug a Compaq COBOL program, the default module (which will be brought into the debugger) is the main module name. If your program consists of multiple separately compiled programs (SCPs), and was compiled with the /SEPARATE_COMPILATION qualifier (see Section 1.3.2.4 and Section B.4.2.8),...
On CMS–See the Guide to Code Management System for VMS Systems. C.5.2 Preparing an SCA Library SCA stores data generated by the Compaq COBOL compiler in an SCA library. The data in an SCA library contains information about all symbols, modules, and files encountered during a specific compilation of the source.
C.5 Language-Sensitive Editor (LSE) and the Source Code Analyzer (SCA) (OpenVMS) This command line compiles the input files PG1.COB, PG2.COB and PG3.COB, and generates corresponding output files for each input file, with the file types OBJ and ANA. The COBOL compiler puts these files in your current default directory.
When you compile a COBOL program, Oracle CDD/Repository data definitions can be accessed by means of the COPY FROM DICTIONARY statement. If the attributes of the data definitions are consistent with Compaq COBOL requirements, the data definitions are included in the COBOL program. Oracle CDD/Repository data definitions, in the form of COBOL source code, can appear...
Oracle CDD/Repository can also store information about the structure of a program, such as the compiled modules that go into making an object module, or the record and field definitions that are used by COBOL programs. If, for example, a record definition needs to change, you can analyze the impact that change will have on the various programs that use it.
PIC X(5). For more information on the COPY FROM DICTIONARY statement, refer to the Compaq COBOL Reference Manual. For more information on the /LIST and /COPY_LIST command qualifiers, invoke the online HELP facility for COBOL at the operating system prompt.
C.6.3 Recording Dependencies When you compile a program with the /DEPENDENCY_DATA qualifier, the compiler creates the following repository objects to represent the compiled modules, the resulting object module, and the relationships between them: • A compiled module object is created for each separately compiled program. The name of the object is the PROGRAM-ID name with hyphens translated to underscores.
Table C–1 shows how Oracle CDD/Repository data types are translated into COBOL data types. It also states the level of support Compaq COBOL provides for Oracle CDD/Repository data types.
C.6 Using Oracle CDD/Repository (OpenVMS) Table C–1 Oracle CDD/Repository Data Types Data Type UNSPECIFIED SIGNED BYTE UNSIGNED BYTE SIGNED WORD UNSIGNED WORD SIGNED LONGWORD UNSIGNED LONGWORD SIGNED QUADWORD UNSIGNED QUADWORD SIGNED OCTAWORD UNSIGNED OCTAWORD F_FLOATING F_FLOATING COMPLEX D_FLOATING D_FLOATING COMPLEX G_FLOATING G_FLOATING COMPLEX H_FLOATING...
Programming Productivity Tools C.6 Using Oracle CDD/Repository (OpenVMS) C.6.5 For More Information For more information about Oracle CDD/Repository, refer to the following manuals: Document Oracle CDD/Repository Architecture Manual Using Oracle CDD/Repository on OpenVMS Systems Oracle CDD/Repository CDO Reference Manual Oracle CDD/Repository Callable Interface Manual Oracle CDD/Repository Information Model Volume I,...
(or, in a few cases, implemented as new features of Compaq COBOL). The default is for full porting assistance to be turned off, but you can enable it at compile time by adding the foreign extensions option to the COBOL command.
-rsv foreign_extensions Without full porting assistance enabled, if you compile program source code that was written for a compiler other than Compaq COBOL, extensions that are not directly supported by Compaq COBOL are flagged with terse messages and the compile fails. Porting assistance will provide you with better diagnostics and more information that can assist you in recoding the indicated operations with Compaq COBOL syntax.
D.3 Implemented Extensions The following foreign extensions are implemented in Compaq COBOL to make it easier to port programs: • ZEROES and ZEROS can be used in a BLANK WHEN ZERO clause.
Page 591
READ NEXT statement, 6–44 Access stream definition, 8–2 ACMSxp, 1–15 ADVANCING phrase, 6–8 -align flag Compaq COBOL support for, B–3 syntax of, 16–5 Alignment along byte boundaries, 16–5 and SYNCHRONIZED clause, 16–4 changing with directives, 16–6, 16–7 *DC END-SET ALIGNMENT, 16–6 *DC SET ALIGNMENT, 16–6...
Page 592
Calling sequence examples, 13–19 to 13–21 Calling COBOL Programs from C on Tru64 UNIX, 12–31 Calling C Programs from Compaq COBOL on Tru64 UNIX and Windows NT, 12–31 Calling OpenVMS Alpha shareable images, 12–30 Calling procedure, 12–2 Calling routines, 13–5...
Page 593
Calling Tru64 UNIX Shareable Objects, 12–30 CALL statement nesting, 12–6 transferring execution control, 12–5 use of, 12–5 -call_shared flag, 1–12, 1–21 Case sensitivity issues on Tru64 UNIX, 12–30 on Windows NT, 12–30 cc command using cobol command instead of, 1–18 See Oracle CDD/Repository data types supported, C–20 source representation, C–17...
Page 595
Compaq COBOL errors, 1–35 Command-line argument accessing, 1–23 Command-line arguments accessing at run time, 1–48 Command-line qualifiers, B–4 to B–10 Compaq COBOL for OpenVMS VAX only (tab.), B–8 Compaq COBOL only (tab.), B–6 shared, B–5 shared (tab.), B–5 Comment symbol, 14–3 terminal format, 1–6...
Page 596
Compatibility (cont’d) fixed-length records, B–27 ORGANIZATION INDEXED file, reading, B–27 print-controlled files, B–27 reading COBOL indexed files, 6–47 variable-length records, B–27 VFC files, B–27 COMP data item advantages of, 15–5 to 15–7 Compilation performance, 1–2 and physical memory, 1–4 and separate compilation, 1–6 and virtual memory, 1–3 Compiled module entry, C–19 Compiler...
Page 597
10–7 CONVERSION phrase, 11–9, 11–12 /CONVERT, 1–32, 2–2 LEADING_BLANKS option Compaq COBOL support for, B–3 -convert flag, 2–2 Converting Compaq COBOL for OpenVMS VAX programs, B–1 Converting Compaq COBOL for OpenVMS VAX programs (cont’d) using the /STANDARD=OPENVMS_AXP qualifier option, B–9 reference format using REFORMAT, 1–7...
Page 598
C–20 to C–21 scaling and mixing, 15–7 selection for performance, 15–8 DATE-COMPILED statement differences, B–15 Compaq COBOL for OpenVMS VAX (ex.), B–15 Compaq COBOL on OpenVMS Alpha (ex.), B–15 listing multiple instances of source line, B–14 *DC, 16–1, 16–6 DCL commands ASSIGN, 1–60...
Page 599
Elementary data items nonnumeric, 3–2 Elementary moves nonnumeric, 3–7 numeric-edited, 2–7 END-DISPLAY, B–17 END-DISPLAY phrase, 11–14 END PROGRAM statement and Compaq FUSE, 1–15 END-SET ALIGNMENT directive syntax of, 16–6 END-SET PADALIGN, 16–6 END-SET VOLATILE directive syntax of, 16–3 Entry point main, 1–23...
Page 600
External report file number of characters compiler implementation specifications, A–2 FD record length compiler implementation specifications, A–1 -feedback file flag, 1–12 File See also Access mode See also Record ACCEPT and DISPLAY statements, 11–1 ACCEPT statement, 11–2 backing up, 6–60 recommended intervals, 6–60 changing output file names (cobol), 1–17 closing...
Page 601
I/O system builds a COBOL, 6–25 keeping as a variable, 6–18 overriding at run-time, 6–18 variable, 6–18 File status values, 8–12 Compaq COBOL support for, B–4 differences, B–21 for Compaq COBOL, 7–4 for RMS, 7–5 RMS-STS values, 8–14 using, 7–3...
Page 602
-warn [no]information, 1–14 -warn [no]other, 1–14 -xref, 1–14 -xref_stdout, 1–14 Flags -align, B–3 -align padding, B–8 with no Compaq COBOL for OpenVMS VAX equivalent qualifiers, B–6 /FLOAT, 1–33 /FLOAT qualifier Compaq COBOL support for, B–3 Footing area, 10–13 Foreign extensions, detecting, D–1 Foreign syntax recognized extensions, D–2...
Page 603
Image activation optimization, 15–25 /INCLUDE, 1–33 -include flag, 1–12 Index data item, 4–16 declaration, 4–16 modifying with SET, 4–16 where defined, 4–3 Indexed file See also Optimization access modes, 6–34 alternate key, 6–7 and ISAM mapping, 6–47 AT END condition, 7–2 capabilities, 6–6 creating, 6–32 creating and populating, 6–33...
Page 604
Language-Sensitive Editor Labels printing four-up (ex.), 10–82 printing four-up (fig.), 10–82 printing four-up in sort order (ex.), 10–84 printing four-up in sort order (fig.), 10–84 Language-Sensitive Editor, C–13 Language Sensitive Editor (LSE) Program Design Facility (PDF) unsupported by Compaq COBOL, B–4...
Page 605
1–41 using shareable images, 1–43 using system-supplied object module libraries, 1–42 using user-created object module libraries, 1–41 with non Compaq COBOL modules, 1–40 LINK qualifiers /INCLUDE, object module library, 1–41 list of, 1–40 /SHARE, 1–43, 1–46 shareable images, 1–43 /LIST, 1–33, C–18...
Page 606
Multiple source files, compiling on OpenVMS Alpha, 1–6, 1–30, 1–31 Multiple source files, compiling on Tru64 UNIX, 1–16 NAMCLASS error difference in Compaq COBOL for OpenVMS VAX and Compaq COBOL behavior, B–21 /NAMES, 1–34 Names, conflicting, B–21 -names as_is flag, 1–13 -names lower or -names lowercase flag, 1–13...
Nested IF statements static nesting depth compiler implementation limitations, A–3 Nested program See Contained program Nesting CALL statements, 12–6 nm command, 1–26 use in locating undefined symbols, 1–19 /NOALIGNMENT syntax of, 16–5 /NOALIGNMENT qualifier default, 16–5 NO ECHO phrase, 11–16 -nolocking flag, 1–13 Non-COBOL programs including in run unit, 12–25...
Page 609
1–27 driver, 12–1 running, 1–16 Program conversion using the /STANDARD=OPENVMS_AXP qualifier option, B–9 Program development, 1–25 PROGRAM-ID statement and Compaq FUSE, 1–15 Program listing files, 1–38 separate compilation, B–15 Program listings See Compiler listing files Program run errors data errors, 1–52 logic errors, 1–53...
Page 610
Program run messages, 1–52 Program structure differences, B–10 Compaq COBOL (ex.), B–10 Compaq COBOL for OpenVMS VAX, B–10 debugging a Compaq COBOL program, B–29 using the /OPTIMIZE qualifier, B–11 Program switches See Switches PROTECTED phrase, 11–14 Protecting records automatic record locking, 8–17, 8–18 bypassing a record lock, 8–22...
Page 611
5–32 to inspect data, 5–31 Replacement value, 5–31 REPLACE statement differences, B–14 Compaq COBOL for OpenVMS VAX, B–14 Compaq COBOL for OpenVMS VAX (ex.), B–14 Compaq COBOL on OpenVMS Alpha, B–14 Compaq COBOL on OpenVMS Alpha (ex.), B–14...
Declarative procedures, 10–41, 10–42 VALUE clause, 10–31 RESERVE AREAS clause value of integers compiler implementation specifications, A–2 Reserved words, D–2 compatibility with Compaq COBOL for OpenVMS VAX, B–28 /RESERVED_WORDS, 1–34 /RESERVED_WORDS qualifier, D–1 Compaq COBOL support for, B–4 Restrictions on interprogram communication, 12–30 RETURN-CODE, 12–12...
Page 613
-rsv [no]foreign_extensions, 1–13 -rsv [no]xopen flag, 1–13 RUN command, 1–48 on OpenVMS Alpha, 1–48 syntax, on OpenVMS Alpha, 1–50 Running Compaq COBOL programs on OpenVMS Alpha, 1–48 on Tru64 UNIX, 1–23 Run time accessing environment variables, 1–24 accessing environment variables (ex.), 1–24 accessing logicals, 1–49...
Page 614
Sequential file organization (fig.), 6–3 Sequential search, 4–16 to 4–18 See also SEARCH statement function of AT END statement, 4–17 requirements for, 4–17 SET ALIGNMENT directive syntax of, 16–6 setenv command, 1–60 SET NOALIGNMENT directive syntax of, 16–6 SET NOPADALIGN directive, 16–6 SET NOVOLATILE directive syntax of, 16–3 SET PADALIGN directive, 16–6...
Page 615
3–5 Special registers and GLOBAL, 12–16, 12–18 LINE-COUNTER, 12–18 PAGE-COUNTER, 12–18 RETURN-CODE, 12–12 Stack usage, 13–2 /STANDARD, 1–35 Compaq COBOL support for, B–4 /STANDARD=OPENVMS_AXP qualifier option, B–9 default, B–10 STANDARD option, 1–32 Status library return, 13–15 -std 85 flag, 1–13 -std flag, 1–13...
Page 616
SWITCH clause value of switch numbers compiler implementation specifications, A–1 Switches checking, 1–60, 1–61 controlling, 1–61 controlling externally, 1–61 controlling internally, 1–60 definition, 1–59 order of evaluation, 1–61 program, 1–59 to 1–62 SET statement, 1–60 setting externally, 1–60 setting for a process, 1–60 setting internally, 1–60 using, 1–59 Symbol...
Testing nonnumeric data items, 3–3 numeric items, 2–3 relational tests, 2–3 /TIE, 1–35 /TIE qualifier Compaq COBOL support for, B–4 Time, fractional seconds, B–27 TMPDIR environment variable use during compliation, 1–17 -T num flag, 1–14 Tools, C–1 Top margin, 10–13 -tps flag, 1–14, 1–15...
Page 618
A–2 replaces INPUT PROCEDURE phrase example, 9–5 usage of, 12–9 Using the /STANDARD=OPENVMS_AXP qualifier option with Compaq COBOL for OpenVMS VAX programs, B–10 Using the DEFINE command default object module libraries, 1–42 Index–28 Using the MERGE statement example, 9–10...
Page 619
WRITE AFTER ADVANCING, 6–12 WRITE statement with LINAGE statement, B–17 Writing files line sequential, 6–28 Writing programs compatibility and portability with Compaq COBOL for OpenVMS VAX, B–1 X/Open standard file sharing, 8–3 X/Open standard record locking, 8–3 XOPEN option, 1–34 200X option, 1–34 -xref flag, 1–14...
Need help?
Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?
Questions and answers