background image

Optimizing Your Compaq COBOL Program
15.7 Optimizing File Design (OpenVMS)

Total record space is (100 + 7) * 5

= 535 bytes

(Record size is 100 bytes, record
overhead is 7 bytes for each of 5
records)

TOTAL

= 550 bytes

Because blocks are 512 bytes long, and buckets are always an integral number of
blocks, the smallest bucket size possible (the system default) in this case is two
blocks. The system, however, puts in as many records as fit into each bucket.
Thus, the bucket actually contains nine records, not five.

The CHARACTERS option of the BLOCK CONTAINS clause lets you specify
bucket size more directly. For example:

BLOCK CONTAINS 2048 CHARACTERS

This specifies a bucket size of four 512-byte blocks. The number of characters in
a bucket is always a multiple of 512. If not, the I/O system rounds it to the next
higher multiple of 512.

Index Depth

The length of data records, key fields, and buckets in the file determines
the depth of the index. Index depth, in turn, determines the number of disk
accesses needed to retrieve a record. The smaller the index depth, the better the
performance. In general, an index depth of 3 or 4 gives satisfactory performance.
If your calculated index depth is greater than 4, you should consider redesigning
the file.

You can optimize your file’s index depth after you have determined file, record,
and key size. Calculating index depth is an iterative process, with bucket size as
the variable. Keep in mind that the highest level (root level) can contain only one
bucket.

If much data is added over time to an indexed file, you should reorganize the file
periodically to restore its indexes to their optimal levels.

Following is detailed information on calculating file size, and an example of index
depth calculation:

File Size

When you calculate file size:

Every bucket in an indexed file contains 15 bytes of overhead.

Every bucket in an indexed file contains records. Only record type and size
differ.

Data records are only in level 0 buckets of the primary index.

Index records are in level 1 and higher-numbered buckets.

If you use alternate keys, secondary index data records (SIDRs) are only in
level 0 buckets of alternate indexes.

Use these calculations to determine data and index record size:

Data records:

F ixed 0 length record size = actual record size + 7

V ariable 0 length record size = actual record size + 9

15–22 Optimizing Your Compaq COBOL Program

Содержание COBOL AAQ2G1FTK

Страница 1: ...ms for the OpenVMS Alpha and Compaq Tru64 UNIX platforms Revision Update Information This manual supersedes the DIGITAL COBOL User Manual Version 2 5 Operating System and Version OpenVMS Alpha Version...

Страница 2: ...paq shall not be liable for technical or editorial errors or omissions contained herein The information in this document is subject to change without notice THE INFORMATION IN THIS PUBLICATION IS PROV...

Страница 3: ...d Flags 1 11 1 2 2 3 External File Handler Support 1 15 1 2 2 4 Specifying Multiple Files and Flags 1 15 1 2 2 5 Compiling Multiple Files 1 15 1 2 2 6 Debugging a Program 1 16 1 2 2 7 Output Files Obj...

Страница 4: ...1 3 4 1 Accessing Command Line Arguments at Run Time 1 48 1 3 4 2 Accessing System Logicals at Run Time 1 49 1 3 4 3 Accessing Input and Output Devices at Run Time 1 50 1 3 4 4 Debugging Environment 1...

Страница 5: ...onnumeric Items 3 5 3 5 Data Movement 3 6 3 6 Using the MOVE Statement 3 7 3 6 1 Group Moves 3 7 3 6 2 Elementary Moves 3 7 3 6 2 1 Edited Moves 3 9 3 6 2 2 Justified Moves 3 9 3 6 3 Multiple Receivin...

Страница 6: ...ING Scanning Using the POINTER Phrase 5 14 5 2 6 Counting UNSTRING Receiving Items Using the TALLYING Phrase 5 15 5 2 7 Exiting an UNSTRING Statement Using the OVERFLOW Phrase 5 16 5 2 8 Common UNSTRI...

Страница 7: ...Relative File 6 53 6 5 3 Updating an Indexed File 6 55 6 6 Backing Up Your Files 6 60 7 Handling Input Output Exception Conditions 7 1 Planning for the AT END Condition 7 2 7 2 Planning for the Invali...

Страница 8: ...5 2 Controlling the Spacing in a Conventional Report 10 7 10 5 3 Advancing to the Next Logical Page in a Conventional Report 10 7 10 5 3 1 Programming for the Page Overflow Condition in a Conventiona...

Страница 9: ...10 9 5 EX1009 Detail Report Program 10 65 10 9 6 EX1010 Summary Report Program 10 74 10 10 Solving Report Problems 10 82 10 10 1 Printing More Than One Logical Line on a Single Physical Line 10 82 10...

Страница 10: ...12 5 2 4 Sharing Other Resources 12 18 12 6 Calling Compaq COBOL Programs from Other Languages 12 19 12 6 1 Calling COBOL Programs from C 12 19 12 7 Calling Non COBOL Programs from Compaq COBOL 12 25...

Страница 11: ...of Data for Optimum Performance 15 5 15 3 Using COMP Data Items for Speed 15 5 15 4 Other Ways to Improve the Performance of Operations on Numeric Data 15 7 15 4 1 Mixing Scale Factors and Data Types...

Страница 12: ...rectives 16 7 16 4 3 Comparing Alignment Directive Effects 16 8 A Compiler Implementation Specifications B Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B 1 Compatibility M...

Страница 13: ...n C and COBOL B 28 B 8 Reserved Words B 28 B 9 Debugger Support Differences B 29 B 10 DECset LSE Support Differences B 29 B 11 DBMS Support B 29 B 11 1 Compiling on Tru64 UNIX and Windows NT B 29 B 11...

Страница 14: ...a Three Dimensional Table 4 5 4 6 Defining a Variable Length Table 4 6 4 7 Sample Record Description Defining a Table 4 7 4 8 Record Description Containing a COMP SYNC Item 4 8 4 9 Adding an Item With...

Страница 15: ...an Indexed File 6 21 6 16 Specifying Line Sequential File Organization with Sequential Access Mode 6 22 6 17 SELECT Statements for Sequential Files with Sequential Access Mode 6 23 6 18 SELECT Statem...

Страница 16: ...ng 8 18 8 5 Automatic Record Locking Compaq Standard 8 19 8 6 Sample Program Using Manual Record Locking Compaq Standard 8 21 8 7 Program Segment for Record Locking Exceptions 8 25 9 1 INPUT and OUTPU...

Страница 17: ...ause 12 14 12 7 Calling a COBOL Program from C 12 20 12 8 C Include File cobfunc h 12 20 12 9 COBOL Called Program CALLEDFROMC 12 21 12 10 C Program Using cobcall cobfunc and cobcancel 12 22 12 11 COB...

Страница 18: ...9 5 3 Sample INSPECT Statement 5 21 5 4 Typical REPLACING Phrase 5 22 5 5 The Replacement Argument 5 31 6 1 Sequential File Organization 6 3 6 2 A Multiple Volume Sequential File 6 4 6 3 Line Sequenti...

Страница 19: ...Typical VT200 or Later Keypad and Keyboard 11 24 11 12 Screen Display of Program SPECIAL 11 28 11 13 Form with ACCEPT WITH EDITING Phrase 11 31 11 14 MENU SCREEN Output 11 40 11 15 SCHEDULE SCREEN Ou...

Страница 20: ...ges 6 2 6 2 Record Format Availability 6 8 6 3 Valid I O Statements for Sequential Files 6 27 6 4 Valid I O Statements for Line Sequential Files 6 28 6 5 Valid I O Statements for Relative Files 6 32 6...

Страница 21: ...1 Cross Platform Compatibility of COBOL Features B 1 B 2 Qualifiers Shared by Compaq COBOL and Compaq COBOL for OpenVMS VAX and Equivalent Flags and Options B 5 B 3 Compaq COBOL Options Not Available...

Страница 22: ......

Страница 23: ...ng of the COBOL language Some familiarity with your operating system is also recommended This is not a tutorial manual If you are a new COBOL user you may need to read introductory COBOL textbooks or...

Страница 24: ...esources while also maximizing run time performance Appendix A contains a list of Compaq COBOL specificatons and limits on the Tru64 UNIX and OpenVMS Alpha systems Appendix B describes compatibility a...

Страница 25: ...example 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 in...

Страница 26: ...tch name g A vertical ellipsis indicates that not all of the statements are shown Format Program examples are shown in terminal format rather than in ANSI standard format special character words The f...

Страница 27: ...aq COBOL and Compaq COBOL for OpenVMS VAX Return A boxed symbol indicates that you must press a key on the terminal for example Return indicates that you press the Return key Tab This symbol indicates...

Страница 28: ...1958 1959 by Unisys Corporation IBM Commercial Translator Form No F28 8013 copyrighted 1959 by IBM FACT DSI 27A5260 2760 copyrighted 1960 by Minneapolis Honeywell They have specifically authorized the...

Страница 29: ...s of a two digit year 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 For more information see...

Страница 30: ......

Страница 31: ...h Compaq COBOL will be a familiar process You set up your development environment create your source compile link and run A few of the specific tasks are Choosing a reference format terminal or ANSI C...

Страница 32: ...o use all of the functional units of the processor and it must determine how to make the best use of registers and on chip data cache because reads and writes to main memory are generally slow compare...

Страница 33: ...rticularly the sections on Managing System Parameters and Managing System Page Swap and Dump Files Note that many tuning exercises are more beneficial if you work with a relatively quiet system submit...

Страница 34: ...exceeds the Charged CPU time value as the system waits for disk I Os to resolve page faults In this situation tuning attempts may be of limited benefit If the physical memory on the system is adequate...

Страница 35: ...AX to no more than approximately 40 of physical memory or 52000 pagelets 1 MB 2048 pagelets With 128 MB or more of physical memory a setting of 50 of physical memory can be attempted The effects of ph...

Страница 36: ...into the reference format of the source program 1 1 3 1 Terminal Reference Format Compaq recommends using terminal format a Compaq optional format when you create source files from interactive termina...

Страница 37: ...3 3 Converting Between Reference Formats 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 COB...

Страница 38: ...OBOL program cobol prog1 o The link command assumes file type no a out Type the output file name to run the image ACTION prog1 cob a out INPUT OUTPUT FILES Compile the source program Link the object m...

Страница 39: ...do not specify a name cobol prog1 cob The cobol command automatically passes a standard default list of Tru64 UNIX and Compaq COBOL libraries to the ld linker If all external routines used by a progr...

Страница 40: ...q COBOL Program on Tru64 UNIX Compilation does the following for you Detects errors in your program syntax Displays compiler messages on your terminal screen Generates machine language instructions fr...

Страница 41: ...fips warn information zeroes cob To work around this you may truncate compiler flag options arguments to their shortest unambiguous form as follows cobol rsv for flagger high warn info zeroes cob 1 2...

Страница 42: ...k nodecimal check no perform check noperform check none on conditionals selector off convert no leading_blanks convert noleading_blanks copy off copy_list off cord off cross_reference off cross_refere...

Страница 43: ...es lowercase nationality japan nationality us nationality us nolocking off noobject off non_shared call_shared nowarn off O0 off O1 off O2 off O3 off O4 or O on o output a out p0 on p1 or p off relax_...

Страница 44: ...additional information see The COBOL Command Driver description earlier in this chapter Section 1 2 2 12 and the c description under man cobol 2 The tps flag causes the Compaq COBOL compiler to use a...

Страница 45: ...vendor Integration Architecture MIA COBOL is one of the languages approved by MIA for transaction processing TP client programs customer written presentation procedures and processing procedures For d...

Страница 46: ...ebug a program using the Ladebug Debugger compile the source files with the g flag to request additional symbol table information for source line debugging in the object and executable program files T...

Страница 47: ...e of prog1 out for the source file test1 cob cobol o prog1 out test1 cob Besides specifying the name of the executable image file you can use the o output flag to rename the object file if you specifi...

Страница 48: ...err output file and any listing file If you enter the cobol command interactively the messages are displayed on your terminal Compiler messages have the following format cobol severity filename line n...

Страница 49: ...hen you enter a cobol command the ld linker is invoked automatically unless a compilation error occurs or you specify the c flag on the command line 1 2 3 1 Specifying Object Libraries for Linking You...

Страница 50: ...that ld uses to locate all specified library files The standard ld directories are searched before directories specified by the Ldir flag The following example specifies the additional object library...

Страница 51: ...nces found in an archive library result in that routine being included in the resulting executable program file at link time External references found in a shared object library result in a special li...

Страница 52: ...ng system documentation Specifying Shared Object Libraries When you link your program with a shared library all symbols must be referenced before ld searches the shared library so you should always sp...

Страница 53: ...lstring flag Ldir flag or specify the object library or object modules on the command line 1 2 4 Running a Compaq COBOL Program on Tru64 UNIX The simplest form of the run command to execute a program...

Страница 54: ...by putting the directory in the value of the environment variable COBOLPATH and the file name in a command line argument Example 1 1 Accessing Environment Variables and Command Line Arguments identifi...

Страница 55: ...the following command lines cobol o myprog myprog cob myprog 1028 powers dat The following will result howmany records will contain 1028 env dir will contain usr files file name will contain powers da...

Страница 56: ...re information on Ladebug Debugger see the Ladebug Debugger Manual Install program Use setld and related commands such as tar For more information see the Tru64 UNIX documentation on programming suppo...

Страница 57: ...e and link your program The COBOL command invokes the Compaq COBOL compiler driver that is the actual user interface to the Compaq COBOL compiler The compiler driver can accept command options and mul...

Страница 58: ...he text editor of your preference to create and revise your source files For example the following command line invokes the DECTPU editor and creates the source file PROG_1 COB EDIT PROG_1 COB The fil...

Страница 59: ...odule that provides the following information The name of the entry point It takes this name from the program name in the first PROGRAM ID paragraph in the program A list of variables that are declare...

Страница 60: ...compiler concatenates each of the specified source files and creates one object file and one listing file In the following example only one object file PROG_1 OBJ and one listing file PROG_1 LIS are c...

Страница 61: ...extract just the procedures that are specifically needed 1 3 2 5 COBOL Qualifiers COBOL options also known as qualifiers or flags control the way in which the compiler processes a file You can process...

Страница 62: ...ITECTURE GENERIC ARITHMETIC n STANDARD NATIVE o ARITHMETIC NATIVE CHECK 2 6 6 6 4 NO PERFORM NO BOUNDS NO DECIMAL NO DUPLICATES ALL1 NONE 3 7 7 7 5 or NOCHECK NOCHECK or CHECK NONE CONDITIONALS charac...

Страница 63: ...D NODISPLAY_FORMATTED FIPS 74 or NOFIPS NOFIPS FLAGGER 2 6 6 6 6 6 6 6 4 HIGH_FIPS1 INTERMEDIATE_FIPS MINIMUM_FIPS OBSOLETE OPTIONAL_FIPS REPORT_WRITER SEGMENTATION SEGMENTATION_1 3 7 7 7 7 7 7 7 5 or...

Страница 64: ...AT NAMES 8 AS_IS LOWER LOWERCASE UPPER UPPERCASE 9 NAMES LOWERCASE NATIONALITY h JAPAN US i NATIONALITY US OBJECT filename ext or NOOBJECT Temporary names used OPTIMIZE 8 LEVEL 8 02 1 2 3 41 9 TUNE 8...

Страница 65: ...NOTIE NOTIE TRUNCATE or NOTRUNCATE NOTRUNCATE VFC or NOVFC VFC WARNINGS 2 4 NO INFORMATION NO OTHER ALL1 NONE 3 5 or NOWARNINGS WARNINGS OTHER 1This is the default keyword when using the named option...

Страница 66: ...r source file when you compile your program the Compaq COBOL compiler flags these errors and displays helpful messages You can reference the message locate the error and if necessary correct the error...

Страница 67: ...e message The severity code of the message The message identification a mnemonic of the message text The text of the message Although most compiler messages are self explanatory some require additiona...

Страница 68: ...specify the NOLIST qualifier to suppress creation of the listing file if that suits your purposes In either case however the listing file is not automatically printed By default the name of the listin...

Страница 69: ...about the LINK qualifiers invoke the online HELP facility for the LINK command at the system prompt For a complete discussion of linker capabilities and for detailed descriptions of LINK qualifiers an...

Страница 70: ...input file is a library file LIBRARY Not applicable Indicate that an input file is a linker options file OPTIONS Not applicable Request output file define a file specification and specify whether the...

Страница 71: ...UDE qualifier with the LINK command2 and specify the modules you want to link The following example links the subprogram modules EGGPLANT TOMATO BROCCOLI and ONION contained in the VEGETABLES library...

Страница 72: ...cess group and system logical name tables in that order are searched for the name LNK LIBRARY_1 If the logical name exists in any of these tables and if it contains the desired reference the search is...

Страница 73: ...Shareable Images You can create Compaq COBOL programs as shareable images by using the LINK qualifier SHARE A shareable image is a single copy of a program that can be shared by many users or applica...

Страница 74: ...bout shareable images The following sample programs and command procedure provide an example of how to create link and install a subprogram as a shareable image as described in the preceding steps Exa...

Страница 75: ...Calling SUBSHR2 CALL SUBSHR2 ON EXCEPTION DISPLAY Second call failed Control returned to CALLER END CALL END PROGRAM SUBSHR1 SUBSHR2 COB IDENTIFICATION DIVISION PROGRAM ID SUBSHR2 This program is lin...

Страница 76: ...LE EOD Link the main program with the shareable image subprograms through the options file LINK CALLER OPTIONS2 OPT Now you can run the main program Using Symbol Vectors with Shareable Images To make...

Страница 77: ...d your input file with the appropriate file type the linker signals an error message and does not produce an image file Trying to link a nonexistent module The linker signals an error message if you m...

Страница 78: ...logicals Command line arguments enable you to provide information to a program at run time Your program provides the logic to parse the command line identify command line options and act upon them For...

Страница 79: ...N CONFIGURATION SECTION SPECIAL NAMES SYSERR IS STANDARD ERROR ENVIRONMENT NAME IS NAME OF LOGICAL ENVIRONMENT VALUE IS LOGICAL VALUE ARGUMENT NUMBER IS POS OF COMMAND LINE ARGUMENT ARGUMENT VALUE IS...

Страница 80: ...G is as follows RUN NO DEBUG file spec In the preceding syntax format file spec is the name of the executable image to be run A typical example would be RUN DEBUG MYPROG In this example MYPROG is the...

Страница 81: ...iler and the OpenVMS Alpha Run Time Library include facilities for detecting and reporting errors You can use the OpenVMS Debugger and the traceback facility to help you locate errors that occur durin...

Страница 82: ...d 77 COUNTER PIC S9 PROCEDURE DIVISION LOOP ADD 1 TO COUNTER IF COUNTER 10 GO TO LOOP The IF clause will produce an infinite loop because of the one digit size limit of COUNTER which is PIC S9 If COUN...

Страница 83: ...ompilation lines see Section 1 3 2 7 in your program can also help you to debug it 1 4 2 Program Logic Errors When checking your program for logic errors first examine your program for some of the mor...

Страница 84: ...O TO 200 PRINT REPORT The following statement does not contain the logic error IF TEST FIELD NOT A AND NOT B GO TO 200 PRINT REPORT 1 4 3 Run Time Input Output Errors An input output error is a condit...

Страница 85: ...e associated imperative statement and no other file processing for the current statement The Declarative USE procedure if any is not performed The INVALID KEY phrase processes I O errors due to invali...

Страница 86: ...GN TO SYS OUTPUT DATA DIVISION FILE SECTION FD EMP FILE VALUE OF ID IS VAL OF ID 01 EMP RECORD 02 EMP ID PIC 9 7 02 EMP NAME PIC X 15 02 EMP ADDRESS PIC X 30 FD REPORT FILE REPORT IS RPT WORKING STORA...

Страница 87: ...L REGISTERS SET OP FAILED TO TRUE EVALUATE RMS STS OF EMP FILE TRUE WHEN END OF FILE OP READ SET VALID OP TO TRUE SET E O F TO TRUE WHEN BADNAME OP OPEN WHEN FILE NOT FOUND OP OPEN WHEN DIR NOT FOUND...

Страница 88: ...TO TRUE SET OP READ TO TRUE READ EMP FILE 200 CLEANUP TERMINATE RPT SET OP CLOSE TO TRUE CLOSE EMP FILE REPORT FILE END PROGRAM RMS SPEC REGISTERS Example 1 6 Using RMS CURRENT Special Registers to D...

Страница 89: ...CURRENT STV WITH CONVERSION DISPLAY END DECLARATIVES MAIN PROG SECTION MAIN PARA OPEN INPUT FILE 1 OPEN INPUT FILE 2 OPEN INPUT FILE 3 CLOSE FILE 1 CLOSE FILE 2 CLOSE FILE 3 STOP RUN END PROGRAM RMS C...

Страница 90: ...out setting internal switches 1 5 2 Setting and Controlling Switches Externally On Tru64 UNIX systems to set switches from outside the image use the SETENV command to change the status of program swit...

Страница 91: ...CL DEASSIGN command to remove the switch setting logical name from your process and reactivate the group or system logical name if any DEASSIGN COB SWITCHES To change the status of external switches d...

Страница 92: ...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 log...

Страница 93: ...decisions that are based on years External displays of year information can continue to use two digit formats when that is appropriate You should check program logic in code that uses ACCEPT to verify...

Страница 94: ......

Страница 95: ...hen the data file is large The storage considerations applicable to tables are described in Chapter 4 For each numeric data item Compaq COBOL stores the numeric value and a sign if an S appears in the...

Страница 96: ...4 The absence of signs for the numeric items A and B results in two different answers after parallel arithmetic operations have been done This occurs because internal temporaries required by the COMPU...

Страница 97: ...ailure conditions The following sections explain these conditional expressions in detail 2 5 1 Numeric Relation Test A numeric relation test compares two numeric quantities and determines if the speci...

Страница 98: ...ELD1 POSITIVE IF FIELD1 0 IF FIELD1 NOT POSITIVE IF FIELD1 NOT 0 IF FIELD1 NEGATIVE IF FIELD1 0 IF FIELD1 NOT NEGATIVE IF FIELD1 NOT 0 IF FIELD1 ZERO IF FIELD1 0 IF FIELD1 NOT ZERO IF FIELD1 NOT 0 Sig...

Страница 99: ...CCESS FAILURE The SET statement is typically in the called program but the calling program may also SET the status of status code id The SUCCESS class condition is true if status code id has been set...

Страница 100: ...numeric edited de editing is applied to establish the unedited numeric value which may be signed then the unedited numeric value is moved to the receiving field If necessary the numeric move operatio...

Страница 101: ...nding item is placed in it If the sending item is unsigned and the receiving item is signed a positive sign is placed in the receiving item If the sending item is signed and the receiving item is unsi...

Страница 102: ...gn at either end of the item Insert zeros spaces slashes and or the symbols CR or DB Insert commas and a decimal point or decimal points and a comma if DECIMAL POINT IS COMMA Table 2 3 illustrates sev...

Страница 103: ...ertion characters past the decimal point to force zero values to appear as 00 instead of spaces use 99 or 99 Forgetting that the currency sign plus sign minus sign CR or DB insertion characters requir...

Страница 104: ...exactly This data type affects the truncation of the intermediate result and the consequent precision It also affects compatibility of arithmetic results with previous versions of COBOL and other impl...

Страница 105: ...18 digits CIT4 776154942704344166077667096295 32 digits Other Consequences of Intermediate Range Differences Because each intermediate data type has a different maximum magnitude an arithmetic stateme...

Страница 106: ...tation ARITHMETIC STANDARD forces MATH_INTERMEDIATE CIT4 described in Section 2 7 2 1 The default is ARITHMETIC NATIVE arithmetic native Using the OPTIONS Paragraph An alternative way to specify nativ...

Страница 107: ...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 resulta...

Страница 108: ...r perform sections of code only when no size error occurs 2 7 6 Using the GIVING Phrase The GIVING phrase moves the intermediate result of an arithmetic operation to a receiving item The phrase acts e...

Страница 109: ...that was described as an unsigned quantity and then testing for a value less than zero Forgetting that the MULTIPLY statement without the GIVING phrase stores the result back into the second operand m...

Страница 110: ......

Страница 111: ...rcase or lowercase and space characters Alphanumeric Can contain the following types of values All alphabetic All numeric A mixture of alphabetic and numeric Any character from the ASCII character set...

Страница 112: ...items or other group items all of which have higher valued level numbers than the group to which they are subordinate The size of a group item is the sum of the sizes of its subordinate elementary ite...

Страница 113: ...n nonnumeric literals since the compiler uses them to delimit the source text You can place special characters into items of the object program by defining symbolic characters in the SPECIAL NAMES par...

Страница 114: ...manner in which the compiler handles numeric operands depends on the nonnumeric operand as follows If the nonnumeric operand is an elementary item or a literal the compiler treats the numeric operand...

Страница 115: ...alue in a nonnumeric data item USAGE DISPLAY only to determine whether it contains numeric alphabetic or user defined data and uses the result to alter the flow of control in the program For example I...

Страница 116: ...For example it cannot by itself concatenate a series of sending items into a single receiving item or disperse a single sending item into several receiving items Two MOVE statements will however bring...

Страница 117: ...n one end or the other It also truncates or space fills the other end The movement of group items and nonnumeric elementary items is discussed in Section 3 6 1 and Section 3 6 2 respectively The MOVE...

Страница 118: ...s the characters starting at the leftmost position in the item and proceeding character by character to the rightmost position If the sending item is shorter than the receiving item the compiler fills...

Страница 119: ...eiving item PICTURE character string When the sending item is exhausted the compiler supplies space characters to fill any remaining character positions not insertion positions in the receiving item I...

Страница 120: ...et many items equal to the same value such as during initialization code at the beginning of a section of processing For example MOVE SPACES TO LIST LINE EXCEPTION LINE NAME FLD MOVE ZEROS TO EOL FLAG...

Страница 121: ...of a group move 3 6 6 Using the MOVE CORRESPONDING Statement for Nonnumeric Items The MOVE CORRESPONDING statement allows you to move multiple items from one group item to another group item using a...

Страница 122: ...ence modification is valid anywhere an alphanumeric identifier is allowed unless specific rules for a general format prohibit it The following is an example of reference modification WORKING STORAGE S...

Страница 123: ...use subscripted or indexed procedural instructions In either case you can directly access a known table element occurrence or search for an occurrence based on some known condition You can define eit...

Страница 124: ...B Longword number Byte number Level 01 Level 05 Legend A TABLE A ZK 6039 GE B ITEM B Example 4 1 specifies only a single data item However you can specify as many data items as you need in the table...

Страница 125: ...n 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 Re...

Страница 126: ...ant 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 t...

Страница 127: ...S Figure 4 5 Organization of a Three Dimensional Table Level 05 Longword number Byte number Level 01 ZK 6043 GE 1 2 3 A B 0 0 0 0 0 0 0 0 0 1 1 1 1 2 3 4 5 6 7 8 9 0 1 2 Level 10 1 1 1 1 1 1 1 2 2 2 2...

Страница 128: ...ELEM Example 4 6 Defining a Variable Length Table 01 NUM ELEM PIC 9 01 VAR LEN TABLE 05 TAB ELEM OCCURS 2 TO 4 TIMES DEPENDING ON NUM ELEM 10 A PIC X 10 B PIC X 4 1 4 Storage Allocation for Tables Th...

Страница 129: ...for a total of 25 bytes Each table element after the first is allowed to start in any byte of a word with no regard for word boundaries 4 1 4 1 Using the SYNCHRONIZED Clause By default the Compaq COBO...

Страница 130: ...longword boundary This requires the addition of 3 fill bytes after ITEM1 and each GROUP G occupies 8 bytes In Example 4 8 A TABLE requires 32 bytes to store four elements of 8 bytes each If in the pre...

Страница 131: ...all occurrences of the table element are mapped in an identical manner Now each element requires 12 bytes and the complete table occupies 48 bytes This is illustrated by Example 4 10 and Figure 4 9 E...

Страница 132: ...C 03 MONTH GROUP PIC XXX USAGE DISPLAY OCCURS 12 TIMES Figure 4 10 Memory Map for Example 4 11 Level 03 Longword number Byte number Level 01 ZK 6047 GE 1 2 3 A TABLE M M M M M M 0 0 0 0 0 0 0 0 0 1 1...

Страница 133: ...and ITEM2 in Example 4 13 is initialized to X Figure 4 11 shows how this is mapped into memory Example 4 13 Initializing Mixed Usage Items 01 A RECORD ALT 05 FILLER PIC XX VALUE AX 05 FILLER PIC S99...

Страница 134: ...ze tables at run time To initialize tables at run time use the INITIALIZE statement This statement allows you to initialize all occurrences of a table element to the same value For more information ab...

Страница 135: ...lusive level and is represented by A GROUP in Example 4 16 The second subscript applies to the next most inclusive level and is represented by ITEM3 in the example Finally the third subscript applies...

Страница 136: ...of Subscripts Required to Refer to the Name Item Size of Item in Bytes Each Occurrence A TABLE NONE 1105 A GROUP ONE 221 ITEM1 ONE 1 ITEM2 TWO 2 ITEM3 TWO 9 ITEM4 TWO 1 ITEM5 THREE 2 4 3 3 Subscripti...

Страница 137: ...ard COBOL should not rely on this feature 4 3 5 Relative Indexing To perform relative indexing when referring to a table element you follow the index name with a plus or minus sign and an integer lite...

Страница 138: ...You can also set an index name to an integer data item For example SET INDEX A TO COUNT 1 More than one index can be set with a single SET statement For example SET TAB1 IND TAB2 IND TO 15 Table index...

Страница 139: ...e search terminates either successfully or unsuccessfully the index remains at its current setting At this point you can reference the data in the table element pointed to by the index unless the AT E...

Страница 140: ...equential search a binary search allows multiple equality checks The following search sequence lists the capabilities of a binary search At program execution time the system 1 Examines the range of pe...

Страница 141: ...ION WORKING STORAGE SECTION 01 TEMP IND USAGE IS INDEX 01 FED TAX TABLES 02 ALLOWANCE DATA 03 FILLER PIC X 70 VALUE 0101440 0202880 0304320 0405760 0507200 0608640 0710080 0811520 0912960 1014400 02 A...

Страница 142: ...mple 4 19 shows how to perform a serial search Example 4 19 A Serial Search 01 TAXABLE INCOME PIC 9 6 VALUE 50000 01 FED TAX DEDUCTION PIC 9 6 PROCEDURE DIVISION BEGIN PERFORM SINGLE DISPLAY FED TAX D...

Страница 143: ...ABLE INCOME M TAX IND 3 M PERCENT IND 3 Example 4 21 Using SEARCH and Varying an Index Data Item 01 TAXABLE INCOME PIC 9 6 VALUE 50000 01 FED TAX DEDUCTION PIC 9 6 PROCEDURE DIVISION BEGIN PERFORM SIN...

Страница 144: ...FROM TAXABLE INCOME MULTIPLY TAXABLE INCOME BY S PERCENT IND 2 ROUNDED ADD TAXABLE INCOME TO FED TAX DEDUCTION Example 4 23 shows how to perform a serial search without using the VARYING phrase Exampl...

Страница 145: ...VALUE SMITH HARRY C 573 3306 10 FILLER PIC X 30 VALUE SMITH HARRY J 295 3485 10 FILLER PIC X 30 VALUE SMITH LARRY X 976 5504 10 FILLER PIC X 30 VALUE SMITHWOOD ALBERT J 349 9927 05 PHONE DIRECTORY TA...

Страница 146: ......

Страница 147: ...e sending item of the string is shorter than the receiving item the compiler does not replace unused positions in the receiving item with spaces Thus the STRING statement can leave some portion of the...

Страница 148: ...ING Statement and Literals 01 ADDRESS GROUP 03 CITY PIC X 20 03 STATE PIC XX 03 ZIP PIC X 5 01 ADDRESS LINE PIC X 31 PROCEDURE DIVISION BEGIN STRING CITY SPACE STATE SPACE ZIP DELIMITED BY SIZE INTO A...

Страница 149: ...statement in the following example has the same effect as the two STRING statements in the preceding example Placing the operands on separate source lines has no effect on the operation of the statem...

Страница 150: ...mplete P points to one character position beyond the last character replaced in the receiving item If FIELD1A and FIELD1B are both four characters long P contains a value of 13 5 4 4 when the operatio...

Страница 151: ...1 QUOTE DELIMITED BY SIZE INTO FIELD2 ON OVERFLOW DISPLAY overflow at 1 2 STRING FIELD1 FIELD1 DELIMITED BY SIZE INTO FIELD2 ON OVERFLOW DISPLAY overflow at 2 3 STRING FIELD1 FIELD1 DELIMITED BY C INT...

Страница 152: ...item FIELD1 can be either 1 a group item or 2 an alphanumeric or alphanumeric edited elementary item The receiving item FIELD2 can be alphabetic alphanumeric or numeric but it cannot specify any type...

Страница 153: ...Values Moved into the Receiving Items Based on the Sending Item Value FIELD1 PIC X 15 VALUE IS FIELD2A PIC X 5 FIELD2B PIC S9 5 LEADING SEPARATE FIELD2C PIC S999V99 ABCDE1234512345 ABCDE 12345 3450 X...

Страница 154: ...NG delimiters can be literals figurative constants including ALL literal or identifiers identifiers can even be subscripted data names This section describes the use of these three types of delimiters...

Страница 155: ...NSTRING FIELD1 DELIMITED BY SPACE INTO FIELD2A FIELD2B The compiler generates code that scans FIELD1 searching for a character that matches the delimiter If it finds a match it moves the scanned chara...

Страница 156: ...lowing UNSTRING operation using a 2 character delimiter UNSTRING FIELD1 DELIMITED BY INTO FIELD2A FIELD2B Table 5 6 Results of Delimiting with Two Asterisks Values After UNSTRING Operation FIELD1 PIC...

Страница 157: ...lowing UNSTRING operation that combines ALL with a 2 character delimiter UNSTRING FIELD1 DELIMITED BY ALL INTO FIELD2A FIELD2B Table 5 8 Results of Delimiting with ALL Double Asterisks Values After UN...

Страница 158: ...aracters Table 5 9 Results of Multiple Delimiters FIELD1 PIC X 12 FIELD2A PIC XXX FIELD2B PIC 9999 FIELD2C PIC XXX A 0 C Return A 0000 C A Tab 456 E A 0456 E A 3 9 A 0003 9 A Tab Tab B Return A 0000 B...

Страница 159: ...ual character or characters that delimited the sending item to be stored in a user supplied data area This phrase is most useful when The UNSTRING statement contains a delimiter list Any one of the de...

Страница 160: ...r that delimited that string Thus the program needs to move the first sending item hold its scanning position in the sending item and examine the results of the operation to determine how to handle th...

Страница 161: ...program must decrement PNTR by 1 to work because the second UNSTRING statement increments the pointer by 1 The program must initialize the POINTER phrase data item before the UNSTRING statement uses i...

Страница 162: ...exists when The UNSTRING statement is about to execute and its pointer data item contains a value less than one or greater than the size of the sending item The compiler generates code that executes...

Страница 163: ...ertain characters in the item and the REPLACING operation which replaces certain characters in the item can be applied either to the characters in the delimited area of the item being inspected or to...

Страница 164: ...iter character finds a match in the item being inspected The underlined characters indicate the portion of the item the statement inspects as a result of the delimiters of the BEFORE and AFTER phrases...

Страница 165: ...BCDEFGHI INSPECT FIELD1 BEFORE I ABCDEFGHI INSPECT FIELD1 AFTER I ZK 1426A GE The compiler alters the digit position containing the sign before beginning the INSPECT operation and restores it to its f...

Страница 166: ...2 62 B 102 C 103 3 63 C 103 D 104 4 64 D 104 E 105 5 65 E 105 F 106 6 66 F 106 G 107 7 67 G 107 H 110 8 70 H 110 I 111 9 71 I 111 175 0 60 175 J 112 1 61 J 112 K 113 2 62 K 113 L 114 3 63 L 114 M 115...

Страница 167: ...one or more identifiers or literals B These identifiers or literals comprise the arguments More than one argument makes up the argument list Figure 5 3 Sample INSPECT Statement ZK 6052 GE B FOR ALL BE...

Страница 168: ...atus at any given setting of the scanner For example an argument that has an AFTER phrase associated with it starts the INSPECT operation in an inactive state The delimiter of the AFTER phrase must fi...

Страница 169: ...ase the argument cannot possibly find a match in the item so it becomes inactive Because the BEFORE AFTER delimiters are found on a separate scan of the item the compiler generates code that recognize...

Страница 170: ...ers it can be COMP or DISPLAY usage and it can be signed separate or overpunched Each time the tally argument matches the delimited string being inspected the compiler adds 1 to the tally counter You...

Страница 171: ...of the delimited character string be counted At the first failure to match the tally argument the compiler terminates counting and causes the argument to become inactive The sample statement INSPECT T...

Страница 172: ...R ALL Each tally argument in the preceding statement has its own tally counter the first two arguments have delimiter phrases and the last one is active over the entire item being inspected Thus the f...

Страница 173: ...of all the commas in FIELD1 and T2 is always unchanged The following INSPECT statement arguments only partially interfere with each other INSPECT FIELD1 TALLYING T2 FOR ALL AFTER A T1 FOR ALL The firs...

Страница 174: ...re identical characters and one of the arguments has a LEADING condition the argument with the LEADING condition should appear first Consider the following sample statement MOVE 0 TO T1 T2 INSPECT FIE...

Страница 175: ...haracters instead of spaces a second LEADING argument can count the tab characters For example INSPECT FIELD1 TALLYING T1 FOR LEADING SPACES T1 FOR LEADING TAB T2 FOR ALL When an argument list contain...

Страница 176: ...rch argument specify a particular character string which can be represented by a literal or an identifier The search argument character string can be any length However each character of the argument...

Страница 177: ...meric literal or a figurative constant other than ALL literal A figurative constant represents as many characters as the length of the search argument requires If the replacement value is an identifie...

Страница 178: ...placement arguments with no chance of interference The statement also exchanges zeros and 1s Here however the first space in FIELD1 causes both arguments to become inactive INSPECT FIELD1 REPLACING AL...

Страница 179: ...l characters 5 3 7 Using the CONVERTING Option When an INSPECT statement contains a CONVERTING phrase that statement selectively replaces characters or groups of characters in the designated item it e...

Страница 180: ......

Страница 181: ...ing controlling and spooling your I O needs or requests Compaq COBOL through the I O system provides you with extensive capabilities for data storage retrieval and modification On the OpenVMS Alpha op...

Страница 182: ...anization lets you access records randomly or sequentially by record number values While this organization is more flexible than sequential organization it is less flexible than indexed organization b...

Страница 183: ...al random and dynamic access Allows data to be stored on disk only Allows random record deletion and insertion on the basis of a user supplied key Requires more disk space Allows READ WRITE sharing Us...

Страница 184: ...tiple Volume Sequential File ZK 6056 GE Volume 1 REC REC REC REC REC REC EOV Volume 2 REC REC REC REC REC REC EOV Volume 3 REC REC REC REC REC REC EOF When you select the medium for your sequential fi...

Страница 185: ...tor and pads the rest of the record with a number of spaces necessary to equal the record s specified length When your program reads a line from a line sequential file that is longer than the record a...

Страница 186: ...e file record number 21 occupies the twenty first cell and so forth Figure 6 4 illustrates relative file organization Figure 6 4 Relative File Organization Beginning of file Cell no 1 2 3 EMPTY RECORD...

Страница 187: ...the file description entry FD When duplicate key values are present you can retrieve the first record written in the logical sort order of the records with the same key value and any subsequent record...

Страница 188: ...ndexed Disk Tape Fixed length yes yes no yes yes Variable length yes yes no yes yes Print control yes no no no no Stream no no yes no no The compiler determines the record format from the information...

Страница 189: ...rete pieces of information referred to as elementary items 02 level items You give each elementary item a specific location in the record give it a name and define its size and type The part number is...

Страница 190: ...ore the record size is 90 characters Example 6 3 Determining Fixed Length Record Size for Files with Multiple Record Descriptions FD REC FILE RECORD CONTAINS 80 CHARACTERS 01 FIXED REC1 PIC X 75 01 FI...

Страница 191: ...NG 118 TO 163 CHARACTERS 01 PARTS REC 03 P PART NUM PIC X 10 03 P PART INFO PIC X 100 03 P BIN INDEX PIC 999 03 P BIN NUMBER PIC X 5 OCCURS 1 TO 10 TIMES DEPENDING ON P BIN INDEX Example 6 6 creates v...

Страница 192: ...PARTS REC 1 PARTS REC 2 PARTS REC 3 or PARTS REC 4 produces records equal in length to the longest record PARTS REC 4 Note that this is not variable length I O Print Control Records On OpenVMS Compaq...

Страница 193: ...records can be accessed sequentially randomly or dynamically Storage Medium You can access sequential relative and indexed files on disk Be careful to use a disk pack that is large enough to meet your...

Страница 194: ...Processing Files and Records 6 1 Defi...

Страница 195: ...he record name DAT RECORD The I O system uses the ASSIGN clause to interpret DAT FILE as REPORT DAT on OpenVMS Alpha systems and REPORT on Tru64 UNIX and Windows NT systems The default directory will...

Страница 196: ...CLOSE MYFILE PRO Example 6 10 achieves the same result as Example 6 9 but on Tru64 UNIX The I O statements in Example 6 10 refer to MYFILE PRO which the ASSIGN clause identifies to the operating syste...

Страница 197: ...ironment variable needed in Example 6 10 to assign the MARCH 311 file to tape device dev rmt0a is setenv COBOL_TAPE_MARCH dev rmt0a Establishing File Names with ASSIGN and VALUE OF ID If the file spec...

Страница 198: ...translation It continues in this way until it cannot translate the equivalence name Assume that your program updates monthly sales files for example JAN DAT FEB DAT MAR DAT and so forth Your SELECT st...

Страница 199: ...AT RECORD PIC X 100 PROCEDURE DIVISION P0 OPEN OUTPUT F DISK CLOSE F DISK PE STOP RUN END PROGRAM ENVVAR EXAMPLE cobol o envtest envvar example cob setenv MYENV hello dat envtest ls dat hello dat unse...

Страница 200: ...iler determines the file organization from the SELECT statement and its associated clauses For relative and indexed files you must specify the ORGANIZATION IS RELATIVE or the ORGANIZATION IS INDEXED p...

Страница 201: ...C 99 02 MASTER TABLE OCCURS 0 to 50 TIMES DEPENDING ON MASTER SIZE 03 MASTER YEAR PIC 99 03 MASTER COUNT PIC S9 5 V99 FD TRANS FILE 01 TRANSACTION RECORD PIC X 25 FD REPRT FILE 01 REPORT LINE PIC X 13...

Страница 202: ...mic access mode indexed file with one primary key and two alternate record keys Note that one alternate record key allows duplicates Any program using the identical entries in the SELECT clause as sho...

Страница 203: ...nd forth between sequential access mode and random access mode while reading a file by using the the NEXT phrase on the READ statement For more information about dynamic access mode see READ and REWRI...

Страница 204: ...Example 6 20 SELECT Statements for Line Sequential Files with Sequential Access Modes 1 2 FILE CONTROL FILE CONTROL SELECT MAMMALS SELECT VACATION SPOTS ASSIGN TO DOLPHINS ASSIGN TO BAHAMAS ORGANIZATI...

Страница 205: ...translated 2 The I O system checks the file s current status If the file is unavailable or if it was closed WITH LOCK the OPEN statement fails See Chapter 8 for information on file sharing 3 If the f...

Страница 206: ...for Sequential and Line Sequential Files 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 fi...

Страница 207: ...h valid I O statements 3 Closing the file Table 6 3 lists the valid I O statements for sequential files and Table 6 4 lists the valid I O statements for line sequential files Both tables illustrate th...

Страница 208: ...r Line Sequential Files Open Mode File Organization Access Mode Statement INPUT OUTPUT EXTEND LINE SEQUENTIAL SEQUENTIAL READ Yes No No WRITE No Yes Yes UNLOCK Yes Yes Yes Writing a Line Sequential Fi...

Страница 209: ...destination area is padded on the right with spaces if longer the destination area is truncated on the right This follows the rules for a group move 6 3 3 File Handling for Relative Files Creating a...

Страница 210: ...ELATIVE ACCESS MODE IS SEQUENTIAL DATA DIVISION FILE SECTION FD FLAVORS 01 KETCHUP MASTER 02 FILLER PIC X 14 02 REC NUM PIC 9 05 02 FILLER PIC X 31 02 FILLER PIC X 31 WORKING STORAGE SECTION 01 REC CO...

Страница 211: ...MASTER KEY PERFORM A010 CREATE RELATIVE FILE 10 TIMES DISPLAY END OF JOB CLOSE FLAVORS STOP RUN A010 CREATE RELATIVE FILE ADD 2 TO KETCHUP MASTER KEY MOVE Record number TO KETCHUP MASTER ADD 2 TO REC...

Страница 212: ...that already contains valid data use the REWRITE statement 6 3 4 File Handling for Indexed Files Creating an indexed file involves the following tasks 1 Specifying ORGANIZATION IS INDEXED in the Envir...

Страница 213: ...RE CITY PIC X 20 03 ICE CREAM STORE STATE PIC XX WORKING STORAGE SECTION 01 END OF FILE PIC X PROCEDURE DIVISION A000 BEGIN OPEN INPUT INPUT FILE OPEN OUTPUT FLAVORS A010 POPULATE PERFORM A100 READ IN...

Страница 214: ...e You specify sequential access mode in the Environment Division SELECT clause when you want to write records in ascending or descending order by primary key depending on the sort order Specify random...

Страница 215: ...A segment can be an alphanumeric or alphabetic item a group item or an unsigned numeric display item A segment can be qualified but it cannot be a group item containing a variable occurrence item See...

Страница 216: ...TE A005 TERMINATE DISPLAY END OF JOB STOP RUN A020 INITIAL PROMPT DISPLAY Do you want to see the manager of a store PERFORM A040 GET ANS UNTIL PROGRAM STAT Y OR y OR N OR n IF PROGRAM STAT N OR n THEN...

Страница 217: ...N FD STOCK FILE 01 STOCK RECORD PIC X 80 WORKING STORAGE SECTION 01 STOCK WORK PIC X 80 1 2 READ STOCK FILE INTO STOCK WORK READ STOCK FILE MOVE STOCK RECORD TO STOCK WORK When you omit the INTO phras...

Страница 218: ...S RELATIVE in the Environment Division SELECT clause 2 Specifying ACCESS MODE IS SEQUENTIAL or DYNAMIC in the Environment Division SELECT clause and using the READ NEXT phrase 3 Opening the file for I...

Страница 219: ...NTIAL RELATIVE KEY IS KETCHUP MASTER KEY DATA DIVISION FILE SECTION FD FLAVORS 01 KETCHUP MASTER PIC X 50 WORKING STORAGE SECTION 01 KETCHUP MASTER KEY PIC 99 01 END OF FILE PIC X PROCEDURE DIVISION A...

Страница 220: ...fying ORGANIZATION IS RELATIVE in the Environment Division SELECT clause 2 Specifying ACCESS MODE IS RANDOM or DYNAMIC in the Environment Division SELECT clause 3 Opening the file for INPUT or I O 4 M...

Страница 221: ...have been run each record has a unique even number from 2 to 20 as its key The program positions the record pointer using the START statement to the cell corresponding to the value in INPUT RECORD KE...

Страница 222: ...condition occurs execution of the READ statement is unsuccessful see Chapter 7 Example 6 32 reads an entire indexed file sequentially beginning with the first record in the file displaying every recor...

Страница 223: ...ng the KEY IS clause To read the file randomly the program must initialize either the primary key data name or the alternate key data name before reading the target record and specify that data name i...

Страница 224: ...you want to see another store PERFORM A040 GET ANSWER UNTIL PROGRAM STAT Y OR y OR N OR n IF PROGRAM STAT Y OR y PERFORM A030 RANDOM READ ELSE MOVE 1 TO PROGRAM STAT A030 RANDOM READ DISPLAY Enter ke...

Страница 225: ...mary key The program positions the file to the first record whose INPUT RECORD KEY is equal to the specified letter of the alphabet The program s READ NEXT statement sequentially retrieves the remaini...

Страница 226: ...M ID READ_PRIOR ENVIRONMENT DIVISION INPUT OUTPUT SECTION FILE CONTROL SELECT F ASSIGN TO READPR ORGANIZATION IS INDEXED ACCESS IS DYNAMIC RECORD KEY IS K0 ALTERNATE RECORD IS K2 DUPLICATES DATA DIVIS...

Страница 227: ...D DISPLAY 17 GO TO P5 END READ IF R NOT 1234567890 THEN DISPLAY 18 R READ F PREVIOUS AT END DISPLAY 19 GO TO P5 END READ IF R NOT 0123456789 THEN DISPLAY 20 R READ F PREVIOUS AT END GO TO P5 DISPLAY 2...

Страница 228: ...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 6 5 Updating Files Updating sequential line sequential...

Страница 229: ...UTPUT SECTION FILE CONTROL SELECT TRANS FILE ASSIGN TO TRANS DATA DIVISION FILE SECTION FD TRANS FILE 01 TRANSACTION RECORD PIC X 25 WORKING STORAGE SECTION 01 ANSWER PIC X PROCEDURE DIVISION A000 BEG...

Страница 230: ...lative File A program updates a relative file with the WRITE REWRITE and DELETE statements The WRITE statement adds a record to the file Only the REWRITE and DELETE statements change the contents of r...

Страница 231: ...CONTROL SELECT FLAVORS ASSIGN TO BRAND ORGANIZATION IS RELATIVE ACCESS MODE IS SEQUENTIAL RELATIVE KEY IS KETCHUP MASTER KEY DATA DIVISION FILE SECTION FD FLAVORS 01 KETCHUP MASTER PIC X 50 WORKING ST...

Страница 232: ...cessfully read record back into its cell in the file If the cell does not contain a valid record or if the REWRITE operation is unsuccessful the invalid key condition occurs and the REWRITE operation...

Страница 233: ...eting relative records Sequential access mode deletion Random access mode deletion Deleting A Relative Record in Sequential Access Mode Deleting a relative record in sequential access mode involves th...

Страница 234: ...Y DISPLAY INVALID START STOP RUN READ FLAVORS AT END DISPLAY FILE AT END GO TO A005 EOJ Deleting Relative Records in Random Access Mode Deleting a relative record in random access mode involves the fo...

Страница 235: ...dating an Indexed File Updating a record in an indexed file in sequential access mode involves the following 1 Reading the target record 2 Verifying that the record is the one you want to change 3 Cha...

Страница 236: ...WRITE statement replaces the record just read while the DELETE statement logically removes the record just read from the file Example 6 42 updates an indexed file sequentially Example 6 42 Updating an...

Страница 237: ...D KEY DISPLAY Bad rewrite ABORTED STOP RUN A300 DELETE MASTER DELETE FLAVORS Updating an Indexed File Randomly Updating indexed records in random access mode involves the following 1 Specifying ORGANI...

Страница 238: ...RANDOM READ UNTIL OPERATOR STOPS IT A020 EOJ DISPLAY END OF JOB STOP RUN A030 RANDOM READ DISPLAY Enter key ACCEPT ICE CREAM MASTER KEY PERFORM A100 READ INPUT BY PRIMARY KEY THROUGH A100 READ INPUT...

Страница 239: ...n Indexed File Dynamically Updating indexed records in dynamic access mode involves the following 1 Specifying ORGANIZATION IS INDEXED in the Environment Division SELECT clause 2 Specifying ACCESS MOD...

Страница 240: ...corrupted with bad data Proper backup procedures are the key to successful recovery You should back up your disk file at some reasonable point daily weekly or monthly depending on file activity and va...

Страница 241: ...normal conditions if you plan for them with Declarative USE procedures or abnormal conditions that cause your program to terminate Planning for exception conditions effectively increases program and p...

Страница 242: ...nning for the Invalid Key Condition The INVALID KEY clause is available for the Compaq COBOL DELETE READ REWRITE START and WRITE statements It does not apply to the READ NEXT statement An invalid key...

Страница 243: ...E DUPLICATES N END READ A510 READ NEXT DUPLICATES READ INDEXED FILE NEXT RECORD AT END MOVE N TO ANY MORE DUPLICATES NOT AT END PERFORM A520 VALIDATE END READ IF ANY MORE DUPLICATES Y PERFORM A700 PRI...

Страница 244: ...ample 7 4 in paragraph A900 EXCEPTION HANDLING ROUTINE the file status that was defined in Example 7 3 is used However not all statements allow you to access the file status value as part of the state...

Страница 245: ...d locks and Declarative USE procedures Each file processing statement described in the Procedure Division section of the Compaq COBOL Reference Manual contains a specific list of file status values in...

Страница 246: ...URRENT STV contains other relevant information see the OpenVMS System Messages and Recovery Procedures Reference Manual an archived manual that is available on the OpenVMS Documentation CD ROM When yo...

Страница 247: ...tatement for FILE 2 PERFORM A903 REPORT RMS CURRENT STATUS The following PERFORM statement moves the RMS completion codes resulting from the above WRITE statement for FILE 2 to data fields that are ex...

Страница 248: ...ative USE procedure executes whenever an I O statement results in an exception condition a file status value that does not begin with a zero 0 and the I O statement does not contain an AT END or INVAL...

Страница 249: ...limited scope you can use them only in programs where they are originally introduced Global Declarative USE procedures have a wider scope you can use them in programs that introduce them as well as in...

Страница 250: ...r that file EXTEND You can define only one EXTEND Declarative USE procedure for each program This procedure executes for any unsuccessful exception condition if 1 the file is open for EXTEND and 2 a f...

Страница 251: ...ILE STATUS D3 00 FILE OUTPUT PROBLEM SECTION USE AFTER STANDARD EXCEPTION PROCEDURE ON OUTPUT If an error occurs for any file open in the OUTPUT mode except FILE A D3 00 FILE OUTPUT PROBLEM executes D...

Страница 252: ...XTEND 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 D5 01 FILE EXTEND PROBLE...

Страница 253: ...Section 8 4 8 1 Controlling Access to Files and Records In a data manipulation environment where many users and programs access the same data file control must be applied to protect files from nonpriv...

Страница 254: ...ure 8 2 illustrates the relationship of record locking to file sharing Figure 8 2 Relationship of Record Locking to File Sharing Manual Record Locking FILE SHARING Automatic Record Locking ZK 6105 GE...

Страница 255: ...ehavior for any file connector on the basis of the syntax used for that file connector The following syntax identifies X Open standard LOCK MODE SELECT statement WITH LOCK OPEN statement WITH NO LOCK...

Страница 256: ...owed by other streams using X Open standard or Compaq standard syntax to specify file sharing The remainder of this section describes these requirements in more detail 8 3 1 Providing Disk Residency O...

Страница 257: ...dified protection For more information on file protection refer to the OpenVMS User s Manual Note The following Tru64 UNIX operating system file access types are not a part of Compaq COBOL syntax On T...

Страница 258: ...RT REWRITE DELETE RANDOM DYNAMIC READ START REWRITE DELETE WRITE EXTEND SEQUENTIAL WRITE Note If the file protection does not permit the intended operations file access is not granted even if open and...

Страница 259: ...ecommended that you use the LOCK MODE clause to avoid ambiguity and maintain readability If this is not done and any I O verbs rely on default behavior that might result in ambiguity you should compil...

Страница 260: ...file for exclusive access Attempts by other access streams to access the file cause a file lock condition OPEN ALLOWING READERS Locks the file against operations that indicate intended write access O...

Страница 261: ...opens the file ALLOWING NO OTHERS would fail Also if the first access stream opens the file ALLOWING READERS the following access stream that opens the file ALLOWING ALL and WITH I O mode would fail b...

Страница 262: ...NPUT NONE OUTPUT ALL READERS NONE UPDATE ALL G 3 2 G 3 2 5 UPDATE READERS 4 3 4 2 G 3 2 5 UPDATE NONE 1 1 3 1 2 1 1 3 1 2 5 INPUT ALL G G 2 G G 2 5 INPUT READERS 4 4 2 G G 2 5 INPUT NONE 1 1 1 2 1 1 1...

Страница 263: ...6 3 4 2 G 5 2 UPDATE NONE 1 1 3 1 2 1 1 3 1 2 INPUT ALL G G 2 G G 2 INPUT READERS 7 7 2 G G 2 INPUT NONE 1 1 1 2 1 1 1 2 Legend UPDATE OPEN EXTEND or OPEN I O INPUT OPEN INPUT OUTPUT OPEN OUTPUT ALL A...

Страница 264: ...any file contention error results in an unsuccessful statement for which a 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 Ope...

Страница 265: ...FILE STAT WORKING STORAGE SECTION 01 FILE STAT PIC XX 88 FILE OPENED VALUES 00 05 07 88 FILE LOCKED VALUE 91 01 RETRY COUNT PIC 9 2 01 MAX RETRY PIC 9 2 VALUE 10 PROCEDURE DIVISION DECLARATIVES FILE U...

Страница 266: ...NF File not found RMS _FUL Device full insufficient space RMS _KEY Invalid record number key or key value RMS _KRF Invalid key of reference for GET FIND RMS _KSZ Invalid key size for GET FIND RMS _OK_...

Страница 267: ...eams open the file in EXTEND mode and both streams issue a write to the end of the file EOF the additional data will come from both streams and the data will be inserted into the file in the order in...

Страница 268: ...nd prepared for duplicate key errors by using INVALID KEY and USE procedures especially on the first write to the file by the second access stream Subsequent writes should also allow for duplicate key...

Страница 269: ...an use the WITH NO LOCK phrase of the READ statement to prevent the acquiring of an automatic record lock For files opened in INPUT mode READ and READ WITH LOCK statements do not acquire a record lock...

Страница 270: ...RE DIVISION BEGIN OPEN I O FILE 1 READ FILE 1 WITH LOCK REWRITE FILE 1 REC UNLOCK FILE 1 CLOSE FILE 1 STOP RUN Note that User 2 could have employed AUTOMATIC record locking just as well In this case m...

Страница 271: ...the first stream Record locks can also occur to the first stream when the second stream reads a record and the first stream tries to read the same record Example 8 5 Automatic Record Locking Compaq S...

Страница 272: ...is clause constitutes a no record lock condition 2 However if the file s OPEN mode is INPUT using the ALLOWING clause on the record operation does not lock the record On Tru64 UNIX and Windows NT syst...

Страница 273: ...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 SELECT FILE 1 ORGANIZATI...

Страница 274: ...n is RELATIVE the access stream receives the record locked status If the file organization is INDEXED the access stream succeeds receives the success status In relative files the lock is on the relati...

Страница 275: ...r 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 Hard Record Locks A hard record lock c...

Страница 276: ...ond stream sucessfully reads the record and receives a soft record lock The second stream cannot update the record For example a soft record lock results from a situation such as the following which u...

Страница 277: ...en standard record locking For indexed and relative files a START statement with the appropriate KEY clause may be used to skip the record that is locked Because X Open START statements do not detect...

Страница 278: ...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 retry count max retry IF record locked AND retry count max re...

Страница 279: ...D entry to define the sort file s characteristics 3 Use a Procedure Division SORT statement The following program segments demonstrate SORT program coding SELECT Statement Environment Division SELECT...

Страница 280: ...t key and employee name second minor sort key For example if you sort the file in ascending order by state and last name the employee names and addresses appear in the order shown in the following exa...

Страница 281: ...em to the sort 3 Sorts the records in ascending sequence using the data in SORT KEY 1 4 Opens the output file and writes the sorted records to OUTPUT FILE 5 Closes all files used in the SORT statement...

Страница 282: ...SIGN TO sort dat DATA DIVISION FILE SECTION FD INPUT FILE 01 INPUT RECORD PIC X 100 FD OUTPUT FILE 01 OUTPUT RECORD PIC X 100 SD SORT FILE 01 SORT RECORD PIC X 100 01 SORT KEY 1 PIC XXX 01 SORT KEY 2...

Страница 283: ...RT FILE AT END CLOSE OUTPUT FILE GO TO 230 DONE OUTPUT MOVE SORT RECORD TO OUTPUT RECORD You can add change or delete sorted records using COBOL data manipulation techniques WRITE OUTPUT RECORD GO TO...

Страница 284: ...rds with duplicate sort keys may not be written to the output file in the same sequence as they were read into it The WITH DUPLICATES IN ORDER phrase ensures that any records with duplicate sort keys...

Страница 285: ...ding the EBCDIC CODE collating sequence Example 9 3 Overriding the COLLATING SEQUENCE IS Phrase ENVIRONMENT DIVISION OBJECT COMPUTER FOO PROGRAM COLLATING SEQUENCE IS EBCDIC CODE SPECIAL NAMES ALPHABE...

Страница 286: ...1 ON DESCENDING KEY S2 KEY 2 USING INPUT FILE OUTPUT PROCEDURE IS 400 CREATE REPORT 2 THRU 700 DONE REPORT 2 030 END JOB DISPLAY PROGRAM ENDED STOP RUN 050 CREATE REPORT 1 SECTION Use the RETURN state...

Страница 287: ...ILE DISPLAY END OF SORT STOP RUN Note The USE PROCEDURE phrase does not apply to Sort Description SD files 9 1 10 Sorting Tables The SORT statement can be used to order the elements in a table This is...

Страница 288: ...ORDER INPUT PROCEDURE are not allowed with MERGE In Example 9 6 district sales data is merged into one regional sales file Example 9 6 Using the MERGE Statement DATA DIVISION FILE SECTION SD MERGE FIL...

Страница 289: ...PFIL SELECT OUTPUT FILE ASSIGN TO OUTFIL ORGANIZATION IS RELATIVE SELECT SORT FILE ASSIGN TO SRTFIL DATA DIVISION FILE SECTION SD SORT FILE 01 SORT REC 03 S KEY 1 05 S ACCOUNT NUM PIC X 8 03 FILLER PI...

Страница 290: ...ONMENT DIVISION CONFIGURATION SECTION INPUT OUTPUT SECTION FILE CONTROL SELECT INPUT FILE ASSIGN TO INPFIL SELECT OUTPUT FILE ASSIGN TO OUTFIL ORGANIZATION IS INDEXED SELECT SORT FILE ASSIGN TO SRTFIL...

Страница 291: ...AT END PERFORM 500 WRITE THE OUTPUT CLOSE OUTPUT FILE GO TO 600 DONE CREATE IF INITIAL SORT READ Y MOVE SORT REC TO SAVE SORT REC MOVE N TO INITIAL SORT READ GO TO 400 READ SORT FILE 450 COMPARE ACCOU...

Страница 292: ...PROCEDURE phrases of the SORT statement Input to the sort is two files containing the same type of data Records with a D status code are not released to the sort The program eliminates duplicate reco...

Страница 293: ...and continue processing DISPLAY END OF PROGRAM SORTC STOP RUN 010 GET INPUT SECTION 050 OPEN FILES OPEN INPUT FIRST FILE 100 READ FIRST FILE READ FIRST FILE AT END CLOSE FIRST FILE OPEN INPUT SECOND F...

Страница 294: ...Example 9 10 Using the COLLATING SEQUENCE IS Phrase IDENTIFICATION DIVISION PROGRAM ID SORTD This program sorts a file into a non ASCII collating sequence The collating sequence is defined by the alph...

Страница 295: ...D STOP RUN Example 9 11 is an example of creating a new sort key Example 9 11 Creating a New Sort Key IDENTIFICATION DIVISION PROGRAM ID SORTE This program increases the size of the variable input rec...

Страница 296: ...ENGTH PIC 9 3 COMP 01 OUT LENGTH PIC 9 3 COMP PROCEDURE DIVISION 000 START SECTION 005 SORT HERE SORT SORT FILE ON DESCENDING SORT ANNUAL INCOME INPUT PROCEDURE 010 GET INPUT THRU 070 DONE INPUT OUTPU...

Страница 297: ...writes one record for each product code ENVIRONMENT DIVISION CONFIGURATION SECTION INPUT OUTPUT SECTION FILE CONTROL SELECT REGION1 SALES ASSIGN TO REG1SLS SELECT REGION2 SALES ASSIGN TO REG2SLS SELE...

Страница 298: ...0 BUILD TOTAL SALES THRU 100 DONE TOTAL SALES DISPLAY TOTAL SALES FOR REGION 1 REGION1 AMT DISPLAY TOTAL SALES FOR REGION 2 REGION2 AMT DISPLAY TOTAL SALES FOR REGION 3 REGION3 AMT DISPLAY TOTAL ALL S...

Страница 299: ...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...

Страница 300: ......

Страница 301: ...ection 10 10 10 1 Designing a Report The design of a report is dictated by the data you must include in the report If you have a general idea of what the report is to contain you can produce a rough o...

Страница 302: ...8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5 ZK 6077 GE 0 1 2 10 11 12 Example 10 1 Components of a Report 1 COMPANY CONFIDENTIAL COMPANY CONFIDENTIAL COMPANY CONFIDENT...

Страница 303: ...CONFIDENTIAL COMPANY CONFIDENTIAL 7 COMPANY CONFIDENTIAL The numbers in the following list correspond to the circled numbers in Example 10 1 1 Report Heading RH The report heading the lines marked wi...

Страница 304: ...report so that you can tell at a glance that you have all the pages The consecutive page numbers tell if a page is missing but they do not indicate which page is the last 10 3 Accumulating and Report...

Страница 305: ...EAR TO DATE TOTALS SALARY 150 000 00 BONUS 60 000 00 TOTAL SALARY EXPENSE 210 000 00 TOTAL SALES 870 000 00 COMPANY CONFIDENTIAL COMPANY CONFIDENTIAL COMPANY CONFIDENTIAL Crossfoot total salary bonus...

Страница 306: ...does not use linage or Report Writer facilities To program a conventional report you should understand how to do the following Define the logical page Advance to the next logical page Program for the...

Страница 307: ...tain either the AFTER ADVANCING PAGE or BEFORE ADVANCING PAGE clause Example 10 3 demonstrates the use of the WRITE statement with the AFTER ADVANCING PAGE clause The next two sections discuss how to...

Страница 308: ...E COUNT A902 HEADER ROUTINE WRITE A LINE2 FROM REPORT2 HEADER LINE 1 AFTER ADVANCING PAGE MOVE 0 TO REPORT2 LINE COUNT ADD 1 TO REPORT2 LINE COUNT Although the WRITE statement allows you to check for...

Страница 309: ...ENTIFICATION DIVISION PROGRAM ID REP01 ENVIRONMENT DIVISION INPUT OUTPUT SECTION FILE CONTROL SELECT INPUT FILE ASSIGN TO REPIN DAT SELECT FORM1 REPORT ASSIGN TO FORM1 DAT SELECT FORM2 REPORT ASSIGN T...

Страница 310: ...HEADERS ROUTINE PERFORM A100 PRINT REPORTS UNTIL END OF FILE Y CLOSE INPUT FILE FORM1 REPORT FORM2 REPORT DISPLAY END OF JOB STOP RUN A100 PRINT REPORTS READ INPUT FILE AT END MOVE Y TO END OF FILE IF...

Страница 311: ...elope This report has a logical page length of 20 lines and a width of 80 characters Note that this report uses only the first 15 lines on the page Because this is a preprinted form the program suppli...

Страница 312: ...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 C...

Страница 313: ...gical page area and divides the page into logical page sections for a linage file report Figure 10 6 shows the logical page area and the four divisions of a linage file report Figure 10 6 Logical Page...

Страница 314: ...before or after your program writes a line of the report For example to print a line before advancing five lines use the following WRITE BEFORE ADVANCING 5 LINES To print a line after advancing two li...

Страница 315: ...ll you should include routines in your program that limit the number of lines on each logical page Example 10 4 demonstrates how to include these routines in your program using the logical page shown...

Страница 316: ...ng area B Bottom margin lines 01 26 lines 25 26 lines 27 28 none P P P 16 17 18 19 20 12 13 14 15 B B 24 25 26 27 28 21 22 23 P P P P P P P Name XXXXXXXXXXX X XXXXXXXXXXXXXX Address XXXXXXXXXXXXXXXXXX...

Страница 317: ...EAD 1 02 H1 LC PIC 99 02 FILLER PIC X 20 VALUE XYZ Clothing Store 02 FILLER PIC X 25 VALUE SPACES 02 FILLER PIC X 6 VALUE Page 02 H1 PAGE PIC Z 9 01 HEAD 2 02 H2 LC PIC 99 02 FILLER PIC X 20 VALUE STA...

Страница 318: ...N 01 THESE MANY PIC 99 VALUE IS 1 PROCEDURE DIVISION A000 BEGIN OPEN INPUT INPUT FILE OUTPUT REPORT FILE DISPLAY Enter date DD MMM YY ACCEPT H2 DATE PERFORM A100 READ INPUT UNTIL END OF FILE Y A050 W...

Страница 319: ...E PRINT LINE FROM HEAD 6 A600 SET UP HEADERS MOVE I FIRST TO H3 FNAME MOVE I MID TO H3 MNAME MOVE I LAST TO H3 LNAME MOVE I ACCOUNT NUMBER TO H3 NUM MOVE I STREET TO H4 STRT MOVE I CITY TO H4 CITY MOV...

Страница 320: ...XXXXXXX XX 99999 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Dear Mr XXXXXXXXXXXXXXX X X X X X X X X X X Preprint message is here Column Line P P P P P P T T P P P B B B B B P P P P 6...

Страница 321: ...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 li...

Страница 322: ...AGE SECTION 01 END OF FILE PIC X VALUE SPACE 01 LINE UP OK PIC X VALUE SPACE 01 MINIF1 LINE 3 02 FILLER PIC X 9 VALUE SPACES 02 MINIF1 LAST PIC X 15 02 FILLER PIC X 23 VALUE SPACES 02 FILLER PIC X 6 V...

Страница 323: ...mediately produce the report or it can spool the report to a mass storage device for printing later Section 10 7 1 and Section 10 7 2 describe these two modes of printing Note that spooling the report...

Страница 324: ...d on production and shop requirements and print the file according to your priority needs You optimize use of the printer Spooling results in printing the maximum number of lines per minute You have a...

Страница 325: ...on 10 8 2 Defining the Report Section and the Report File The Report Section in the Data Division provides specific information about the reports that are specified with the REPORT clause Each report...

Страница 326: ...page There are seven types of report groups which consist of one or more report lines printed as a complete unit for example a page heading Each report line can be subdivided into data items or fields...

Страница 327: ...G 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 RH PH CH DE CF PF RF ZK 6087 GE Fi...

Страница 328: ...re 10 10 Sample Report Using All Seven Report Groups SALES REPORT MONTH WK SALES CONTINUED MONTH WK SALES CONTINUED END OF REPORT JAN REPORT JAN 4 10 000 JAN 11 15 000 JAN TOTALS 25 000 FEB REPORT FEB...

Страница 329: ...t DETAIL LINE prints two lines after the last line of the previous report group If you used a CONTROL HEADING report group that ended on line 20 before DETAIL LINE then DETAIL LINE would print beginni...

Страница 330: ...e vertical positioning of a report 10 8 6 Horizontal Spacing for the Logical Page The COLUMN NUMBER clause defines the horizontal location of items within a report line You use the COLUMN NUMBER claus...

Страница 331: ...5 03 COLUMN 1 PIC X 27 VALUE CUSTOMER MASTER FILE REPORT 03 COLUMN 40 PIC X 5 VALUE SALES The previous example results in the following output 1 2 3 4 5 column 1234567890123456789012345678901234567890...

Страница 332: ...Report Section To identify the lines of two or more reports in one file you use the CODE clause as shown in the following example FILE SECTION FD REPORT FILE REPORTS ARE REPORT1 REPORT2 REPORT3 REPOR...

Страница 333: ...s example if the value in WEEK CONTRL changes a break occurs and Report Writer processes the CONTROL FOOTING WEEK CONTRL report group If the value in MONTH CONTRL changes a break occurs and Report Wri...

Страница 334: ...See Section 10 3 for further discussion 10 8 11 1 Subtotaling In subtotaling the SUM clause references elementary numeric data items that appear in the File or Working Storage Sections and then gener...

Страница 335: ...ling totals forward the SUM clause adds a sum counter from a lower level CONTROL FOOTING report group to a sum counter in a higher level footing group The control logic and necessary control hierarchy...

Страница 336: ...EACH MONTH EACH WEEK 01 TYPE CONTROL FOOTING EACH MONTH 02 COLUMN 10 PIC ZZ9 99 SUM SALES RESET ON YEAR 10 8 11 5 UPON Option Another SUM option is the UPON phrase This phrase allows selective subtota...

Страница 337: ...0 SOURCE BRANCH prints each time These statements produce the following lines SALES BRANCH A BRANCH B BRANCH C The next two examples are nearly identical programs the only difference is the use of the...

Страница 338: ...port Writer statement is executed the report file must be open 10 8 13 1 Initiating the Report The INITIATE statement begins the report processing and is executed before any GENERATE or TERMINATE stat...

Страница 339: ...specified TYPE DETAIL report group A USE BEFORE REPORTING declarative can also execute just before the associated report group is produced to produce a cover page for the report for example Note Figu...

Страница 340: ...ROL FOOTINGS from minor to this control break level control break set control to new values write CH from this control break level to minor DETAIL Report Write DETAIL line add all SUM operands Reset S...

Страница 341: ...GE produce PF group produce RF group TERMINATE 10 8 13 5 Applying the USE BEFORE REPORTING Statement In a COBOL program you specify a Declarative section to define procedures that supplement the stan...

Страница 342: ...SUPPRESS statement applies only to that particular instance of the report group that group will be printed the next time unless the SUPPRESS statement is executed again The SUPPRESS statement has no e...

Страница 343: ...rts 2 through 5 have been compressed into fewer pages than you would normally find For example a report title page is typically found on a separate page Whether you are producing a report for yourself...

Страница 344: ...Street Westminster MA0147312341000013876900002072000 Cooper Frank J300 Mohican Avenue Mohawk MA0148034167000014341678002072000 Alexander Greg T317 Narrows Road East Westminster MA01473341600000041000...

Страница 345: ...FILE 02 SORT NAME PIC X 26 02 PIC X 73 01 CUSTOMER MASTER FILE PIC X 99 FD SORTED FILE 01 CUSTOMER MASTER FILE 02 NAME 03 LAST NAME PIC X 15 03 FIRST NAME PIC X 10 03 MIDDLE INIT PIC X 02 ADDRESS PIC...

Страница 346: ...X VALUE 03 COLUMN 2 PIC X 110 VALUE ALL 03 COLUMN 112 PIC X VALUE 02 LINE 8 03 COLUMN 1 PIC X VALUE 03 COLUMN 10 PIC X 4 VALUE NAME 03 COLUMN 29 PIC X VALUE 03 COLUMN 43 PIC X 7 VALUE ADDRESS 03 COLU...

Страница 347: ...N 28 PIC XX SOURCE MIDDLE INIT 02 COLUMN 30 PIC X 20 SOURCE ADDRESS 02 COLUMN 51 PIC X 20 SOURCE CITY 02 COLUMN 72 PIC XX SOURCE STATE 02 COLUMN 75 PIC 99999 SOURCE ZIP 02 COLUMN 81 PIC Z9 SOURCE INV...

Страница 348: ...2 06 2000 000004 10 000 71 Alexander Greg T 317 Narrows Road Westminster MA 01473 2 06 2000 000004 10 000 71 Alexander Greg T 317 Narrows Road East Westminster MA 01473 2 06 2000 000004 10 000 71 Ale...

Страница 349: ...ELECT SORTED FILE ASSIGN TO EX1007 SORTOUT TMP SELECT PRINTER FILE ASSIGN TO EX1007 LIS DATA DIVISION FILE SECTION SD SORT FILE 01 SORTED CUSTOMER MASTER FILE 02 SORT NAME PIC X 26 02 PIC X 73 01 CUST...

Страница 350: ...C X VALUE 03 COLUMN 45 PIC X 31 VALUE Customer Master File 02 LINE 27 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 28 03 COLUMN 45 PIC X VALUE 03 COLUMN 55 PIC Z9 SOURCE UE DAY 03 COLUMN...

Страница 351: ...VALUE ALL 02 LINE 5 03 COLUMN 1 PIC X 27 VALUE CUSTOMER MASTER FILE REPORT 03 COLUMN 105 PIC X 4 VALUE PAGE 03 COLUMN 109 PIC ZZZ9 SOURCE PAGE COUNTER 02 LINE 7 03 COLUMN 1 PIC X VALUE 03 COLUMN 2 PIC...

Страница 352: ...ALUE STREET 03 COLUMN 48 PIC X VALUE PIC X 4 VALUE CITY 03 COLUMN 71 PIC X VALUE 03 COLUMN 72 PIC X 2 VALUE ST 03 COLUMN 74 PIC X VALUE 03 COLUMN 76 PIC X 3 VALUE ZIP 03 COLUMN 81 PIC X VALUE 03 COLUM...

Страница 353: ...NVOICE SALES NEXT GROUP IS PLUS 2 02 LINE IS PLUS 2 03 COLUMN 72 PIC X 41 VALUE ALL 02 LINE IS PLUS 1 03 COLUMN 20 PIC X 17 VALUE TOTAL RECORDS 03 IDC COLUMN 40 PIC ZZZ ZZZ ZZ9 SUM ONE COUNT 03 IIA CO...

Страница 354: ...E 29 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 30 03 COLUMN 45 PIC X 31 VALUE End of EX1007 LIS 02 LINE 31 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 32 COLUMN 45 PIC X...

Страница 355: ...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...

Страница 356: ...g T 317 Narrows Road Westminster MA 01473 2 06 2000 000004 10 000 71 Alexander Greg T 317 Narrows Road Westminster MA 01473 2 06 2000 000004 10 000 71 Alexander Greg T 317 Narrows Road Westminster MA...

Страница 357: ...CITY ST ZIP DATE NUMBER AMOUNT TOTAL RECORDS 1 12 341 67 Dickinson Rose E 21 Depot Road Amherst MA 01423 2 07 2000 000019 66 688 90 TOTAL RECORDS 1 66 688 90 Frost Alfred R 123 Amherst Street Merrima...

Страница 358: ...02 SORTED NAME PIC X 26 02 S ADDRESS PIC X 20 02 S CITY PIC X 20 02 S STATE PIC XX 02 S ZIP PIC 99999 02 S SALESMAN NUMBER PIC 99999 03 S INVOICE NUMBER PIC 999999 03 S INVOICE SALES PIC S9 5 V99 03 S...

Страница 359: ...REPORT HEADER TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE 02 LINE 24 03 COLUMN 45 PIC X 31 VALUE ALL 02 LINE 25 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 03 COLUMN 45 PIC X 31 VALUE Customer...

Страница 360: ...UE 02 LINE 34 03 COLUMN 45 PIC X 31 VALUE ALL 01 TYPE IS PAGE HEADING 02 LINE 5 03 COLUMN 1 PIC X 27 VALUE CUSTOMER MASTER FILE REPORT 03 COLUMN 105 PIC X 4 VALUE PAGE 03 COLUMN 109 PIC ZZZ9 SOURCE PA...

Страница 361: ...UMN 26 PIC X 4 VALUE MI 03 COLUMN 35 PIC X 6 VALUE STREET 03 COLUMN 48 PIC X VALUE PIC X 4 VALUE CITY 03 COLUMN 71 PIC X VALUE 03 COLUMN 72 PIC X 2 VALUE ST 03 COLUMN 74 PIC X VALUE 03 COLUMN 76 PIC X...

Страница 362: ...IC 99 SOURCE INV MO 02 COLUMN 86 PIC X VALUE 02 COLUMN 87 PIC 9999 SOURCE INV YR 02 COLUMN 92 PIC 9 6 SOURCE INVOICE NUMBER 02 COLUMN 99 PIC 99 SOURCE SAVE INVOICE SALES NEXT GROUP NEXT PAGE 02 LINE I...

Страница 363: ...45 PIC X 31 VALUE End of Report EX1008 02 LINE 31 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 32 COLUMN 45 PIC X 31 VALUE ALL PROCEDURE DIVISION DECLARATIVES BOR SECTION USE BEFORE REPO...

Страница 364: ...CCEPT UNEDITED DATE OPEN INPUT SORTED FILE OPEN OUTPUT PRINTER FILE MOVE SPACES TO NAME INITIATE MASTER LIST PERFORM 200 READ MASTER UNTIL EOF Y 100 END OF FILE TERMINATE MASTER LIST CLOSE SORTED FILE...

Страница 365: ...3 416 76 Cooper Frank J 300 Mohican Avenue Mohawk MA 01480 2 07 2000 000014 34 167 80 Dickens Arnold C 100 Bleak Street Gardner MA 01440 2 07 2000 000011 12 341 67 Dickinson Rose E 21 Depot Road Amher...

Страница 366: ...IC X 20 02 CITY PIC X 20 02 STATE PIC XX 02 ZIP PIC 99999 02 SALESMAN NUMBER PIC 99999 03 INVOICE NUMBER PIC 999999 03 INVOICE SALES PIC S9 5 V99 03 INVOICE DATE 04 INV DAY PIC 99 04 INV MO PIC 99 04...

Страница 367: ...75 PIC X VALUE 03 COLUMN 45 PIC X VALUE 03 COLUMN 55 PIC Z9 SOURCE UE DAY 03 COLUMN 57 PIC X VALUE 03 COLUMN 58 PIC 99 SOURCE UE MONTH 03 COLUMN 60 PIC X VALUE 03 COLUMN 61 PIC 9999 SOURCE UE YEAR 03...

Страница 368: ...E COUNTER 03 COLUMN 1 PIC X VALUE 03 COLUMN 2 PIC X 110 VALUE ALL 03 COLUMN 112 PIC X VALUE 02 LINE 8 03 COLUMN 1 PIC X VALUE 03 COLUMN 10 PIC X 4 VALUE NAME 03 COLUMN 29 PIC X VALUE 03 COLUMN 43 PIC...

Страница 369: ...L 03 COLUMN 112 PIC X VALUE TYPE DETAIL LINE PLUS 1 02 COLUMN 1 PIC X 15 SOURCE LAST NAME GROUP INDICATE 02 COLUMN 17 PIC X 10 SOURCE FIRST NAME GROUP INDICATE 02 COLUMN 28 PIC XX SOURCE MIDDLE INIT G...

Страница 370: ...COLUMN 96 PIC 99 SUM INVOICE SALES 03 COLUMN 111 PIC X VALUE 02 LINE IS PLUS 1 03 COLUMN 73 PIC X 39 VALUE ALL NEXT GROUP NEXT PAGE 02 LINE IS PLUS 2 03 COLUMN 70 PIC X 42 VALUE ALL 02 LINE IS PLUS 1...

Страница 371: ...C X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 32 COLUMN 45 PIC X 31 VALUE ALL PROCEDURE DIVISION DECLARATIVES BOR SECTION USE BEFORE REPORTING REPORT HEADER EOR SECTION USE BEFORE REPORTING REPORT FOOTER...

Страница 372: ...mple 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 VAL...

Страница 373: ...4 10 000 71 317 Narrows Road Westminster MA 01473 2 06 2000 000004 10 000 71 317 Narrows Road East Westminster MA 01473 2 06 2000 000004 10 000 71 TOTAL RECORDS 6 INVOICE SUB TOTAL 60 004 26 Allan Dav...

Страница 374: ...013 87 690 00 TOTAL RECORDS 1 INVOICE SUB TOTAL 87 690 00 Thoreaux Ralph H 800 Emerson Street Walden MA 01416 2 07 2000 000016 6 00 C O M P A N Y C O N F I D E N T I A L C O M P A N Y C O N F I D E N...

Страница 375: ...SORT NAME PIC X 26 02 PIC X 73 FD CUSTOMER FILE 01 CUSTOMER MASTER FILE PIC X 99 FD SORTED FILE 01 CUSTOMER MASTER FILE 02 NAME 03 LAST NAME PIC X 15 03 FIRST NAME PIC X 10 03 MIDDLE INIT PIC X 02 AD...

Страница 376: ...COLUMN 75 PIC X VALUE 03 COLUMN 45 PIC X 31 VALUE Customer Master File 02 LINE 27 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 28 03 COLUMN 45 PIC X VALUE 03 COLUMN 55 PIC Z9 SOURCE UE D...

Страница 377: ...N 1 PIC X VALUE 03 COLUMN 2 PIC X 110 VALUE ALL 03 COLUMN 112 PIC X VALUE 03 COLUMN 1 PIC X VALUE 03 COLUMN 10 PIC X 4 VALUE NAME 03 COLUMN 29 PIC X VALUE 03 COLUMN 43 PIC X 7 VALUE ADDRESS 03 COLUMN...

Страница 378: ...20 SOURCE ADDRESS 02 COLUMN 51 PIC X 20 SOURCE CITY 02 COLUMN 72 PIC XX SOURCE STATE 02 COLUMN 75 PIC 99999 SOURCE ZIP 02 COLUMN 81 PIC Z9 SOURCE INV DAY 02 COLUMN 83 PIC X VALUE 02 COLUMN 84 PIC 99...

Страница 379: ...OTING 02 LINE 24 ON NEXT PAGE COLUMN 45 PIC X 31 VALUE ALL 02 LINE 25 03 COLUMN 45 PIC X VALUE 03 COLUMN 75 PIC X VALUE 02 LINE 26 03 COLUMN 45 PIC X 31 VALUE Customer Master File 02 LINE 27 03 COLUMN...

Страница 380: ...G REPORT FOOTER EOR A DISPLAY Created EX1010 LIS END DECLARATIVES MAIN SECTION 000 DO SORT SORT SORT FILE ON ASCENDING KEY SORT NAME WITH DUPLICATES IN ORDER USING CUSTOMER FILE GIVING SORTED FILE 000...

Страница 381: ...SUB TOTAL 30 000 00 TOTAL RECORDS 1 INVOICE SUB TOTAL 12 340 70 C O M P A N Y C O N F I D E N T I A L C O M P A N Y C O N F I D E N T I A L CUSTOMER MASTER FILE REPORT PAGE 3 NAME ADDRESS INVOICE LAST...

Страница 382: ...hysical line If you were to print names and addresses on four up self sticking multilabel forms you would print the form left to right and top to bottom as shown in Figure 10 20 and Example 10 11 To p...

Страница 383: ...SECTION FD INPUT FILE 01 INPUT RECORD 02 INPUT NAME PIC X 20 02 INPUT ADDRESS PIC X 15 02 INPUT CITY PIC X 10 02 INPUT STATE PIC XX 02 INPUT ZIP PIC 99999 FD REPORT FILE 01 REPORT RECORD PIC X 132 WOR...

Страница 384: ...PORT FILE DISPLAY END OF JOB STOP RUN 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 TABLE A200 GENERATE TABLE MOVE INPUT NAME T...

Страница 385: ...7 8 9 10 13 15 16 19 20 21 22 11 12 14 17 18 23 24 Example 10 12 Printing Labels Four Up in Sort Order IDENTIFICATION DIVISION PROGRAM ID REP03 ENVIRONMENT DIVISION INPUT OUTPUT SECTION FILE CONTROL S...

Страница 386: ...MES INDEXED BY ADDRESS INDEX 07 LABEL ADDRESS PIC X 15 07 FILLER PIC X 15 04 CSZ LINE 05 LINE 3 OCCURS 4 TIMES INDEXED BY CSZ INDEX 07 LABEL CITY PIC X 10 07 FILLER PIC XXXX 07 LABEL STATE PIC XX 07 F...

Страница 387: ...BY 1 ELSE SET ROW INDEX UP BY 1 A300 PRINT PAGE OF LABELS WRITE REPORT RECORD FROM NAME LINE ROW INDEX AFTER ADVANCING 3 WRITE REPORT RECORD FROM ADDRESS LINE ROW INDEX AFTER ADVANCING 1 WRITE REPORT...

Страница 388: ...many unused spaces as possible between columns Columns should not be run together however you can use one blank space instead of several Eliminate nonessential information Print two or more lines with...

Страница 389: ...hree times is sufficient This darkens the line but does not advance to the next line 2 Write the line one last time without the BEFORE ADVANCING phrase This overprints the line again and advances to t...

Страница 390: ...RE 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 WRITE PRINT LINE...

Страница 391: ...transfer data between your program and the standard input and output devices If you do not use the FROM or UPON phrases or an environment variable the default device for ACCEPT is the keyboard and th...

Страница 392: ...and Windows NT the ACCEPT statement transfers data from the input device to a data item If you do not use the FROM phrase the system uses the environment variable COBOL_INPUT if it is defined or stdi...

Страница 393: ...ign video forms to Make data entry applications menu selections and special control keys easier to use Clarify the input expected from an operator Improve the appearance of an application s terminal d...

Страница 394: ...ACCEPT and DISPLAY Options When you design a video form you can use the ACCEPT and DISPLAY options to do the following Erase specific parts or the entire screen Use relative and absolute cursor positi...

Страница 395: ...notifications of new mail from interrupting the screen displays In Example 11 1 an introductory message is first displayed on the screen along with a prompt to the user Then the ERASE SCREEN option c...

Страница 396: ...DIVISION DATA DIVISION WORKING STORAGE SECTION 01 COL NUM PIC 99 VALUE 4 PROCEDURE DIVISION A00 OUT PARA DISPLAY Employee name LINE 19 COLUMN COL NUM ERASE SCREEN DISPLAY LINE 24 COLUMN 1 STOP RUN No...

Страница 397: ...he position specified by the rules for Format 1 ACCEPT and DISPLAY in the Compaq COBOL Reference Manual Note The presence of either or both the LINE and COLUMN phrases implies NO ADVANCING You can use...

Страница 398: ...he LINE PLUS phrase so relative positioning goes beyond the bottom of the screen your form scrolls with each such display Figure 11 4 Cursor Positioning Using the PLUS Option 1234567890123456789012345...

Страница 399: ...ISION A00 BEGIN DISPLAY Employee No UNDERLINED LINE 5 COLUMN 5 ERASE SCREEN DISPLAY Employee wage class BOLD LINE 5 COLUMN 25 DISPLAY NAME BLINKING LINE PLUS 6 COLUMN 6 DISPLAY SALARY REVERSED LINE PL...

Страница 400: ...11 5 Using the CONVERSION Phrase IDENTIFICATION DIVISION PROGRAM ID CONVERT ENVIRONMENT DIVISION DATA DIVISION WORKING STORAGE SECTION 01 DATA1A PIC X 10 01 DATA1B PIC X 10 JUST 01 DATA2 PIC 9999 99...

Страница 401: ...LUMN 65 P4 DISPLAY Num COMP Test S9 3 V9 3 LINE 16 ERASE LINE ACCEPT DATA4 PROTECTED REVERSED WITH CONVERSION LINE 16 COLUMN 50 DISPLAY DATA4 REVERSED WITH CONVERSION LINE 16 COLUMN 65 P5 DISPLAY Num...

Страница 402: ...AME RMS CURRENT STS RMS CURRENT STV RMS CURRENT FILENAME LINAGE COUNTER register RETURN CODE special register RWCS registers PAGE COUNTER LINE COUNTER VALUE EXTERNAL data items POINTER VALUE REFERENCE...

Страница 403: ...if not protected of the ACCEPT data with an overflow to either the left or right of the decimal point the imperative statement associated with ON EXCEPTION executes and the destination field does not...

Страница 404: ...of the input field or delete past the left edge of the input field the terminal bell sounds and the screen cursor does not move You can accept the data on the screen by pressing a legal terminator ke...

Страница 405: ...a 10 digit number exceeding the storage capacity of the data item NUM DATA on the left side of the assumed decimal point Note The SIZE phrase controls only the number of characters you can enter it do...

Страница 406: ...aq 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 Example 11 8 shows how you can use the NO ECHO phrase t...

Страница 407: ...eturn However the value is not automatically displayed on the screen You can also use the CURRENT VALUE phrase with the DEFAULT phrase to specify that the default input value is the initial value of t...

Страница 408: ...AY PLEASE ENTER THE FOLLOWING INFORMATION LINE 5 COLUMN 15 REVERSED BLINKING ERASE SCREEN DISPLAY LINE 7 COLUMN 15 DISPLAY Part Part Part STORED AS LINE 9 COLUMN 15 DISPLAY Name Number Price Name Numb...

Страница 409: ...with the DEFAULT Phrase 12345678901234567890123456789012345678901234567890123456789012345678901234567890 4 1 2 3 5 6 7 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ZK 6097 GE Part...

Страница 410: ...ified in the CONTROL KEY IN phrase 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 Tab...

Страница 411: ...SCREEN CSI 5 Keypad NEXT SCREEN CSI 6 Tab Tab 9 Return Return 13 Function key HOLD SCREEN Not Available Function key PRINT SCREEN Not Available Function key SET UP Not Available Function key DATA TALK...

Страница 412: ...on key F15 HELP CSI 28 Function key F16 DO CSI 29 Function key F17 CSI 31 Function key F18 CSI 32 Function key F19 CSI 33 Function key F20 CSI 34 Ctrl A 1 Ctrl B 2 Ctrl C Not Available Ctrl D 4 on Ope...

Страница 413: ...need no qualification The definition and value of the CSI and SS3 characters used in Table 11 2 follow 01 SS3X PIC 9999 COMP VALUE 143 01 SS3 REDEFINES SS3X PIC X 01 CSIX PIC 9999 COMP VALUE 155 01 CS...

Страница 414: ...L Control Keys on the Standard VT100 Keypad and Keyboard ZK 6099 GE Tab Ctrl Z LINE LOCAL TOGGLE 1 0 RESET CLEAR ALL TABS SET CLEAR TAB SET UP A B TRANSMIT SPEED RECEIVE SPEED 80 132 COLUMNS ONLINE LO...

Страница 415: ...ALUE TAB VAL 02 REMAINING CHAR CONTROL KEY PIC XXXX 88 UP ARROW VALUE A 88 DOWN ARROW VALUE B 88 RIGHT ARROW VALUE C 88 LEFT ARROW VALUE D 88 PF1 VALUE P 88 PF2 VALUE Q 88 PF3 VALUE R 88 PF4 VALUE S 8...

Страница 416: ...E LINE GO TO P1 IF AUX1 DISPLAY AUXILIARY KEYPAD 1 LINE 10 COLUMN 5 ERASE LINE GO TO P1 IF AUX2 DISPLAY AUXILIARY KEYPAD 2 LINE 10 COLUMN 5 ERASE LINE GO TO P1 IF AUX3 DISPLAY AUXILIARY KEYPAD 3 LINE...

Страница 417: ...IF NOT CR GO TO P0 ELSE DISPLAY END OF JOB LINE 13 COLUMN 35 BOLD BLINKING REVERSED BELL ERASE SCREEN P3 DISPLAY ESC WITH NO puts you out of alternate keypad mode DISPLAY ESC WITH NO STOP RUN Figure 1...

Страница 418: ...ns for the EDITING Phrase Key Function Description Left arrow Move left Moves the cursor one space to the left If the cursor is at the first character position of the field the terminal bell rings Rig...

Страница 419: ...MN 29 DISPLAY YR IN AT COLUMN 30 DISPLAY Current Value AT COLUMN 38 DISPLAY MON NUM AT COLUMN 54 DISPLAY AT COLUMN 56 DISPLAY DAY NUM AT COLUMN 57 DISPLAY AT COLUMN 59 DISPLAY YR NUM AT COLUMN 60 DISP...

Страница 420: ...8 COLUMN 21 PROTECTED WITH EDITING REVERSED DEFAULT IS CURRENT AT END STOP RUN DISPLAY DEPT NUM AT LINE 8 COLUMN 54 ACCEPT F NAME FROM LINE 10 COLUMN 21 PROTECTED WITH EDITING REVERSED DEFAULT IS CURR...

Страница 421: ...n 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 Then in...

Страница 422: ...ur program Three formats are available for a screen description entry and are completely defined in the Data Division chapter of the Compaq COBOL Reference Manual Format 1 A group screen item Format 2...

Страница 423: ...tensity are available LOWLIGHT is the same as normal REQUIRED 1 3 Specifies that at least one character must be entered in the input or update field REVERSE VIDEO 2 3 Specifies that the foreground and...

Страница 424: ...ify a line and column position If the line and column are not specified for a screen item then the screen item begins immediately following the previous screen item Regardless of whether you display o...

Страница 425: ...e edge of the screen are truncated In addition to the line and column position for each screen item you can also specify a line and column position for the ACCEPT and DISPLAY statements By default thi...

Страница 426: ...ed 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...

Страница 427: ...dar with a menu screen from which the user selects an option to show appointments schedule an appointment cancel an appointment and print the appointments SCREEN SECTION 01 MENU SCREEN BLANK SCREEN FO...

Страница 428: ...MN 42 PIC XX USING APPT MERIDIEM 02 HELP TEXT FOREGROUND COLOR 6 BACKGROUND COLOR 0 03 LINE 16 COLUMN 18 VALUE Use Cursor Keys to move within the fields 03 LINE 17 COLUMN 18 VALUE Press Tab to enter n...

Страница 429: ...URSOR LINE 9 MOVE 01 TO APPT DAY MOVE 01 TO APPT MONTH MOVE 94 TO APPT YEAR MOVE 12 TO APPT HOUR MOVE 00 TO APPT MINUTE MOVE AM TO APPT MERIDIEM DISPLAY SCHEDULE SCREEN The user types the description...

Страница 430: ...the arrow keys to move the cursor among menu items Press Return when the cursor is at the desired item Press F10 to exit Figure 11 15 SCHEDULE SCREEN Output Schedule Appointment Description of Appoin...

Страница 431: ...either of the following One main driver program and one or more separately compiled programs each program may or may not have contained programs One main program with one or more contained nested prog...

Страница 432: ...5 is a directly contained program of MAIN PROGRAM SUB2 6 is an indirectly contained program of MAIN PROGRAM Example 12 3 shows a run unit with three separately compiled programs 7 1 0 and 1 1 One of t...

Страница 433: ...e Library RTL initialization routine also called main This RTL routine is needed to make a CALL data name statement or cobfunc cobcall cobcancel work correctly Your program main must supply the necess...

Страница 434: ...N PROGRAM ID SUB4 1 1 EXIT PROGRAM 12 2 1 The INITIAL Clause A COBOL program with an INITIAL clause is returned to its initial state whenever that program exits This ensures that it will be in its ini...

Страница 435: ...Section entry the data items in RECORD 1 are available to any program in the image that also describes RECORD 1 and its data items as EXTERNAL 01 RECORD 1 EXTERNAL 03 ITEMA PIC X 03 ITEMB PIC X 20 03...

Страница 436: ...re 12 1 shows a nested image that executes a series of three CALL statements from three separate programs Figure 12 1 Nesting CALL Statements MAINPROG ZK 1475 GE SUB SUBA SUBB 1 6 2 5 3 4 MAINPROG cal...

Страница 437: ...BEGIN DISPLAY 3 This is the entry point to SUB1 DISPLAY 4 SUB1 now has control DISPLAY 5 SUB1 transfers control to SUB2 CALL SUB2 DISPLAY 9 SUB1 regains control DISPLAY 10 after executing the followin...

Страница 438: ...ent of the sequence For example IF A B DISPLAY A equals B EXIT PROGRAM READ INPUT FILE AT END DISPLAY End of input file PERFORM END OF FILE ROUTINE EXIT PROGRAM If you do not include an EXIT PROGRAM s...

Страница 439: ...IT PROGRAM IDENTIFICATION DIVISION PROGRAM ID SUBA ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION BEGIN CALL SUBB EXIT PROGRAM IDENTIFICATION DIVISION PROGRAM ID SUBB ENVIRONMENT DIVISION DATA...

Страница 440: ...rring to the data names in its Procedure Division USING phrase For example the data names correspond as follows Data Name in MAINPROG Calling Program Corresponding Data Name in SUB Called Subprogram A...

Страница 441: ...sm ensures that the contents of the parameter in the calling program are always identical to the contents of the parameter in the called program If the BY CONTENT phrase is either specified or implied...

Страница 442: ...IVISION USING PART AMOUNT COLOR COST Of those data items you define in the Linkage Section only those named in the calling program s Procedure Division header s USING phrase are accessible to the call...

Страница 443: ...e a containing program A COBOL containing contained program provides you with program and data attributes that noncontained COBOL programs do not have These attributes described in the next several se...

Страница 444: ...luded in that containing program and by any programs directly or indirectly contained in that containing program except the program possessing the common attribute and any programs contained within it...

Страница 445: ...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 12 5 2 1 Sha...

Страница 446: ...gram can apply to an input output operation when there is one procedure for file name and another for the applicable open mode In this case only the procedure for file name executes Figure 12 5 shows...

Страница 447: ...ERROR PROCEDURE ON FILEA OPEN INPUT FILEA END PROGRAM USE PROGRAM END PROGRAM SUB1 END PROGRAM MAIN PROGRAM 3 2 1 ZK 1428A GE Rule 2 If a declarative is not found using Rule 1 the Run Time System sear...

Страница 448: ...1427A GE 12 5 2 4 Sharing Other Resources Condition names record names and report names can also have the global attribute Any program directly or indirectly contained within the program declaring th...

Страница 449: ...in other languages When you use cobcall cobcancel and cobfunc the same considerations and results will be in effect as if you had used the CALL and CANCEL statements see Section 12 1 2 and Section 12...

Страница 450: ...routine char name READ name of the program int argc READ how many arguments char argv READ array of pointers to the arguments int cobfunc Call a COBOL program from a C routine then CANCEL it char nam...

Страница 451: ...O TEST RESET DISPLAY arg1 ARG1 DISPLAY arg1 ARG1 arg2 ARG2 arg3 ARG3 WITH CONVERSION END PROGRAM CALLEDFROMC Values Returned by cobcall and cobfunc The RTL calls cobcall and cobfunc can return a signe...

Страница 452: ...NUMARGS a_list display 3 After calling cobcall again retval arg1 display 4 After calling cobcancel retval arg1 retval cobcall progcob NUMARGS a_list display 5 After calling cobcall again retval arg1...

Страница 453: ...isplay retVal retVal with conversion display Note that the C program progc c does not have a function called main The function name main has to be renamed because the COBOL RTL already contains a symb...

Страница 454: ...ter add arg1 arg2 arg3 arg4 giving arg1 myVal myVal 10 arg1 10 arg2 2 arg3 3 arg4 4 retVal 987654321 1 After calling cobcall retval 987654321 arg1 10 From COBOL myVal 10 arg1 10 arg2 2 arg3 3 arg4 4 r...

Страница 455: ...ing Standard or the Compaq Tru64 UNIX Calling Standard for Alpha Systems as applicable when generating a call to a procedure Section 13 2 briefly describes the OpenVMS Alpha calling standard On OpenVM...

Страница 456: ...INVALID ARGUMENT FOR SQUARE ROOT ELSE DISPLAY The square root is INPUT NUMBER INSPECT INPUT NUMBER REPLACING ALL BY 0 MOVE CORRESPONDING INPUT NUMBER TO WORK NUMBER WORK NUMBER A TO DISPLAY NUMBER DIS...

Страница 457: ...m from a COBOL Program IDENTIFICATION DIVISION PROGRAM ID APPL This COBOL program accepts credit application information and passes this information to a BASIC program that performs a credit analysis...

Страница 458: ...from the program s execution Example 12 15 BASIC Program APP and Output Data 10 SUB APP A B C D E 40 IF A 999 THEN 999 50 IF B 26000 THEN 800 60 IF B 18000 THEN 600 70 IF B 15000 THEN 500 80 IF B 1000...

Страница 459: ...use of argc and argv in c routines called from Compaq COBOL include cobfunc h include stdio h extern int _ _Argc extern char _ _Argv define argc _ _Argc define argv _ _Argv void crtn int i i 0 for i 0...

Страница 460: ...n 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...

Страница 461: ...utine Called by Statement CALL Job1 FLAG option Routine Called names lowercase names lower job1 names uppercase names upper JOB1 names as_is names as_is Job1 For example a Compaq COBOL program must be...

Страница 462: ...OpenVMS documentation set Material on calling system routines in the OpenVMS Programming Concepts manual OpenVMS RTL Library LIB Manual OpenVMS System Services Reference Manual The following OpenVMS...

Страница 463: ...to the following curses 3 Library that controls cursor movement and windowing curses_intro 3 Introduction to the curses routines which optimizes terminal screen handling and updating restartterm 3 Re...

Страница 464: ...unwinding These attributes are discussed in detail in the OpenVMS Programming Concepts manual 13 2 1 Register and Stack Usage The OpenVMS Alpha architecture provides 32 general purpose integer regist...

Страница 465: ...eturn value that is assigned to the function s identifier during execution According to the OpenVMS Calling Standard a function value may be returned as either an actual value or a condition value tha...

Страница 466: ...hmetic algebraic and trigonometric calculations OTS General purpose routines that perform tasks such as data type conversions as part of a compiler s generated code PPL Parallel processing routines th...

Страница 467: ...utines The basic steps for calling routines are the same whether you are calling a routine subprogram written in COBOL a routine written in some other language a system service or a Run Time Library r...

Страница 468: ...tine as a procedure call RETURNS None 13 4 2 Defining the Argument OpenVMS Most system routines have one or more arguments These arguments are used to pass information to the system routine and to obt...

Страница 469: ...The statistic returned by LIB STAT_TIMER The value argument argument contains the address of a longword or quadword that is this statistic All statistics are longword integers except elapsed time whic...

Страница 470: ...S Alpha usage floating_point represents any OpenVMS Alpha floating point data type Table 13 4 lists the OpenVMS Alpha usages and the COBOL statements you need to implement them Table 13 4 COBOL Implem...

Страница 471: ...O completely within COBOL and let the COBOL compiler generate the FAB structure or do the I O in another language file_protection 01 FILE PROT PIC 9 4 COMP 2 function_code 01 FUNCTION CODE 02 MAJOR F...

Страница 472: ...9 18 COMP 2 mask_word 01 MW PIC 9 4 COMP 2 null_arg CALL USING OMITTED or PIC S9 9 COMP VALUE 0 passed USING BY VALUE octaword_signed NA octaword_unsigned NA page_protection 01 PAGE PROT PIC 9 9 COMP...

Страница 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...

Страница 474: ...G RET STATUS In general Run Time Library routines use the optional argument format while system services use the optional argument format In passing arguments to the procedure you must define the pass...

Страница 475: ...cates success or failure this value can be either returned or signaled In general system routines return a condition value with the following exceptions The system routine returns a function value The...

Страница 476: ...hen the success code SS _WASSET is returned you can check for this condition value as follows and branch accordingly IF RET STATUS EQUAL SS _WASSET or EVALUATE RET STATUS WHEN SS _WASSET If the condit...

Страница 477: ...virtual memory FOR _NO_SUCDEV No such device MTH _FLOOVEMAT Floating overflow in Math Library procedure BAS _SUBOUTRAN Subscript out of range 13 4 6 Locating the Result OpenVMS Once you have defined t...

Страница 478: ...s call removes the condition handler established in the current program unit Note that the LIB ESTABLISH and LIB REVERT routines only affect user condition handlers not the default Compaq COBOL condit...

Страница 479: ...lt COBOL condition handler is invoked If the default COBOL condition handler does not handle the exception then the exception is handled by the operating system Example 13 1 User Written Condition Han...

Страница 480: ...03 MECH_ARGS OCCURS 5 TIMES 05 MECH PIC 9 9 COMP PROCEDURE DIVISION USING SIGNAL_ARRAY MECHANISM_ARRAY GIVING SS_HAND BEGIN Initialize the return result MOVE SS _RESIGNAL TO SS_HAND IF SIGNAL_VALUE 1...

Страница 481: ...ate how to call system routines from COBOL programs Example 13 2 shows a procedure call and gives a sample run of the program RUNTIME It calls MTH RANDOM a random number generator from the Run Time Li...

Страница 482: ...time to an ASCII string representation DATA DIVISION WORKING STORAGE SECTION 01 TIMLEN PIC 9999 COMP VALUE 0 01 D TIMLEN PIC 9999 VALUE 0 01 TIMBUF PIC X 24 VALUE SPACES 01 RETURN VALUE PIC S9 9 COMP...

Страница 483: ...ING OLD SET The following example shows how to call the procedure that finds the first clear bit in a given bit field LIB FFC This procedure returns a COMP longword condition value represented in the...

Страница 484: ...COND AMBSYMDEF display Ambiguous else if COND NORMAL display OK else display Not OK 2 call LIB SET_SYMBOL using by descriptor XSETS by descriptor Test1B by reference LOCAL SYM giving COND VAL if COND...

Страница 485: ...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...

Страница 486: ...spec 3 The user typed myprog2 cob in response to the prompt for an output file spec 4 The program next prompted for an identification entry in columns 73 to 80 and the user simply pressed Return 5 End...

Страница 487: ...ying these lines at character position 72 Placing either identification characters if supplied at program initialization or spaces into character positions 73 to 80 Right justifying at position 72 the...

Страница 488: ...this error The default device is SYS DISK on OpenVMS systems it is on Tru64 UNIX systems To continue examine the output file specification and type a corrected version To end execution type Ctrl Z on...

Страница 489: ...RMAT 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 syst...

Страница 490: ......

Страница 491: ...aq 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 wr...

Страница 492: ...s are turned on Level 4 Is identical to level 3 for COBOL This is the default if you specify optimize with no value or if you compile without specifying any form of the optimize option on the command...

Страница 493: ...tion scheduling purposes while the ARCHITECTURE qualifier determines the type of code instructions generated for the program unit being compiled OpenVMS Version 7 1 and subsequent releases provide an...

Страница 494: ...implementation that uses the byte and word manipulation instruction extensions and multimedia instruction extensions of the Alpha architecture Programs compiled with the PCA56 option may incur emulati...

Страница 495: ...issued even if WARNINGS NOINFORMATION is in effect You can turn it off by specifying any form of the OPTIMIZE qualifier If you need to debug optimized code see the OpenVMS Debugger Manual Other Effec...

Страница 496: ...OMP 3 PACKED DECIMAL and DISPLAY operands are the same each can be scaled except for COMP 5 and COMP X and signed and can hold up to 18 decimal digits Therefore converting existing programs from COMP...

Страница 497: ...ing different scale factors and data types in arithmetic operations In general type conversions can be minimized by using operands of the same usage Scaling operations can be minimized by using compat...

Страница 498: ...s 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 FLOA...

Страница 499: ...while SEARCH imposes no restrictions on table organization Also with SEARCH ALL there should be unique key values in the table Before using SEARCH ALL you must pre sort the table If the table is not s...

Страница 500: ...ent The Compaq COBOL language elements that can specify alternatives to the I O system defaults are as follows The APPLY clause in the I O CONTROL paragraph The RESERVE n AREAS clause in the FILE CONT...

Страница 501: ...one extent It needs one map pointer only and window turning does not take place after you open the file The following statements create a file after OPEN WRITE and preallocate 150 contiguous blocks E...

Страница 502: ...of APPLY WINDOW is as follows APPLY WINDOW ON file name Window size is the number of file mapping pointers stored in memory A large window improves I O because the system spends less time remapping t...

Страница 503: ...ME RECORD AREA clause in the I O CONTROL paragraph of the Environment Division Records need not be the same size nor must the maximum size of each current record area be the same Figure 15 1 shows the...

Страница 504: ...FILE OUT FILE I O CONTROL ZK 1539 GE PROCEDURE DIVISION Program with Shared Record Area Process Without Shared Areas Process with Shared Areas PROCEDURE DIVISION READ INP FILE READ INP FILE WRITE OUT...

Страница 505: ...access a buffer area larger than the default Because the system transfers disk data in 512 byte blocks a blocking factor with a multiple of 512 bytes improves I O access time In the following example...

Страница 506: ...um record number MRN to 0 allowing the file to expand to any size If you create a relative file with the CREATE FDL Utility select a realistic MRN since an attempt to insert a record with a number hig...

Страница 507: ...in bytes per bucket Consider the following example FILE CONTROL SELECT A FILE ORGANIZATION IS RELATIVE DATA DIVISION FILE SECTION FD A FILE RECORD CONTAINS 60 CHARACTERS BLOCK CONTAINS 1536 CHARACTERS...

Страница 508: ...f records in the f ile number of cells per bucket Assume that you want to create a relative file able to hold 3 000 records The records are 255 bytes long plus 1 byte per record for overhead with 4 ce...

Страница 509: ...he number of levels above level zero is called the index depth Figure 15 2 shows a 2 level primary index Figure 15 2 Two Level Primary Index LEVEL 2 LEVEL 1 LEVEL 0 ZK 1540 GE ROOT BUCKET An index is...

Страница 510: ...e that all records be equal in length For example assume that you are designing an employee master file A variable length record file lets you write a long record for a senior employee with a large am...

Страница 511: ...each WRITE REWRITE and DELETE operation takes The throughput of READ operations is not affected by multiple keys If your application requires alternate keys you can minimize I O processing time if yo...

Страница 512: ...ral an index depth of 3 or 4 gives satisfactory performance If your calculated index depth is greater than 4 you should consider redesigning the file You can optimize your file s index depth after you...

Страница 513: ...each Primary key 20 characters Alternate key 8 characters no duplicates allowed Bucket size 3 an arbitrary value No fill number Primary key index level calculations In the following calculations some...

Страница 514: ...ement Services Reference Manual Because alternate index records are usually inserted in random order the bucket packing efficiency ranges from about 5 to about 65 The following example uses an average...

Страница 515: ...aching index roots Allocate one buffer for each key that your program uses to access file records in addition to the two required buffers For example if the file contains a primary key and two alterna...

Страница 516: ......

Страница 517: ......

Страница 518: ...cific the warnings at lines 16 17 and 18 must be heeded If this application is run on a CPU that supports byte word granularity the warning at line 16 PIC X indicates that the move will not produce by...

Страница 519: ...ipulation of binary data that is COMP COMP 1 COMP 2 INDEX and POINTER data items is significantly faster if alignment is on natural boundaries A natural boundary is the smallest boundary at which data...

Страница 520: ...ates 8 bytes for POINTER data a 64 bit quadword integer 16 3 2 Data Field Padding In Compaq COBOL all 01 and 77 level data items are always aligned on quadword boundaries With Alpha natural alignment...

Страница 521: ...ads data structures that contain them in conformity with the Compaq Alpha Calling Standards The format of the ALIGNMENT qualifier is as follows ALIGNMENT NO PADDING or NOALIGNMENT On Tru64 UNIX system...

Страница 522: ...lpha alignment of elementary data items The DC SET PADALIGN specifies Alpha natural alignment and padding The DC SET NOALIGNMENT directive specifies OpenVMS VAX compatible alignment The optional DC EN...

Страница 523: ...precedence or until the beginning of the next file specified in a comma list You can nest alignment directives within a program to specify different alignments for selected sets of data Alignment dir...

Страница 524: ...ND SET ALIGNMENT directive terminates the alignment specified with the previous SET directive 3 SET NOALIGNMENT Alignment is once again along the natural boundaries as specified by 2 the SET ALIGNMENT...

Страница 525: ...comp synchronized 7 02 cg c3 synch pic 9 3 comp synchronized 8 02 cg c7 synch pic 9 7 comp synchronized 9 02 cg c12 synch pic 9 12 comp synchronized 1 0 The data is aligned as shown in the following e...

Страница 526: ...in Declared Order from the listing maps show the differences in vertical format in the Location and Byte columns Note the horizontal byte layouts to make it easier to read in that orientation Example...

Страница 527: ...ple 16 4 REC1 FLD1 FLD2 FLD3 FLD1 1 FLD1 2 FLD3 2 FLD3 3 1 5 12 17 22 18 Begin byte number starting with 0 Record length is 26 bytes Note The asterisk designates FLD3 1 Also no padding or filler will...

Страница 528: ...EC1 2 00000000 36 36 DISPLAY Group 8 02 FLD1 2 00000000 12 12 DISPLAY Group 9 03 FLD1 1 2 00000000 9 4 COMP N 10 03 FLD1 2 2 00000004 7 7 DISPLAY N 11 02 FLD2 2 0000000C 5 5 DISPLAY AN 12 02 FLD3 2 00...

Страница 529: ...nt 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 with...

Страница 530: ......

Страница 531: ...for an indexed file s RECORD KEY or ALTERNATE RECORD KEY data item must not be greater than 255 bytes on OpenVMS Alpha systems 120 bytes on Tru64 UNIX systems 128 bytes on Windows NT systems The numb...

Страница 532: ...er 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 diagnosti...

Страница 533: ...OCCURS n TIMES clause of a Data Description entry the maximum allowable value for n is 2 147 483 647 On OpenVMS the maximum static scoping depth of database USE procedures is 84 The maximum number of...

Страница 534: ......

Страница 535: ...al state of compatibility for numerous features in Compaq COBOL Version 2 7 on its three platforms and Compaq COBOL for OpenVMS VAX Version 5 7 Always check the Release Notes for the latest developmen...

Страница 536: ...nd Compaq COBOL Compatibility and Migration B 1 Compatibility Matrix Table B 1 Cont Cross Platform Compatibility of COBOL Features OpenVMS VAX OpenVMS Alpha Tru64 UNIX Windows NT Alpha VFU p N N N Pri...

Страница 537: ...B 2 Differences in Extensions and Other Features Compaq COBOL contains the following language extensions and other features that are not in Compaq COBOL for OpenVMS VAX A choice of alignment with the...

Страница 538: ...as synonyms for COMP READ PRIOR and START LESS X Open ASSIGN TO LINE SEQUENTIAL RETURN CODE SCREEN SECTION FILE SHARING and RECORD LOCKING Compaq COBOL does not contain the following Compaq COBOL for...

Страница 539: ...als COPY_LIST copy_list CROSS_REFERENCE cross_reference DEBUG g DEPENDENCY_DATA3 None DIAGNOSTICS3 None FIPS2 fips 74 FLAGGER flagger LIST list MACHINE_CODE machine_code MAP map NATIONALITY JAPAN US n...

Страница 540: ...mpaq specific Japanese features out of MIA Extension Elements related to Japanese To receive the diagnostics the warn all flag WARNINGS ALL qualifier warn information flag or WARNING INFORMATION quali...

Страница 541: ..._shared OPTIMIZE LEVEL n3 On OPTIMIZE n4 On OPTIMIZE TUNE keyword5 tune keyword No equivalent qualifier p n RELAX_KEY_CHECKING1 relax_key_checking RESERVED_WORDS NO 200X rsv no 200x RESERVED_WORDS NO...

Страница 542: ...ms will be aligned on their natural boundaries and those group items will be padded out to multiples of their alignments See the Compaq COBOL Reference Manual for detailed information about elementary...

Страница 543: ...FTER statements Format 4 How PIC P digits are interpreted in some moves When the size of variable length tables OCCURS DEPENDING ON is determined in the MOVE statement The WARNINGS ALL qualifier and w...

Страница 544: ...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 Open...

Страница 545: ...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 If you want the machine code to be included...

Страница 546: ...he comment in the middle 9 LCOP1A 11L INPUT OUTPUT SECTION 12L FILE CONTROL 13L SELECT FILE 1 14L ASSIGN TO FILE1 TMP 16 FILE SECTION 17 FD FILE 1 18 01 FILE1 REC PIC X 19 WORKING STORAGE SECTION 20 P...

Страница 547: ...7 DATA DIVISION 8 PROCEDURE DIVISION 9 THE 10 COPY LCOP1J 11L DISPLAY POIUYTREWQ 12C COPY LCOP1J 13L DISPLAY POIUYTREWQ 14C COPY LCOP1J 15L DISPLAY POIUYTREWQ 16 STOP RUN B 4 2 5 COPY Insert Statement...

Страница 548: ...for REPLACE Statement 1 REPLACE A VERY LONG STATEMENT by EXIT PROGRAM 2 EXIT PROGRAM 6 DISPLAY To REPLACE or not to REPLACE Compaq COBOL for OpenVMS VAX Listing File for REPLACE Statement 1 REPLACE A...

Страница 549: ...Listing File for DATE COMPILED Statement 33 34 date compiled 16 Jul 1992 1 COBOL E ERROR 65 1 Missing period is assumed 35 security none B 4 2 8 Compiler Listings and Separate Compilations OpenVMS Th...

Страница 550: ...example COBOL A NOVFC B VFC C NOVFC D In this example source files B and D will produce reports in VFC format Behavior is different when the source file list items are separated by plus signs See Sec...

Страница 551: ...or output redirected to a file the operation differs between Compaq COBOL for OpenVMS VAX and Compaq COBOL In general the Compaq COBOL RTL attempts to use ANSI ACCEPT DISPLAY to handle all ACCEPT and...

Страница 552: ...RKING STORAGE SECTION 01 A2 PIC 99 COMP 01 B1 PIC S9 5 COMP 01 B2 PIC 9 5 COMP PROCEDURE DIVISION TEST 1 MOVE 65535 TO A2 MOVE A2 TO B1 DISPLAY B1 WITH CONVERSION MOVE A2 TO B2 DISPLAY B2 WITH CONVERS...

Страница 553: ...MY RETURN CODE GREATER 0 THEN MOVE MY RETURN CODE TO CMR RETURN CODE GO TO P0 EXIT MOVE CYCLE PARM TO EDIT PARM IF EDIT YR NOT NUMERIC THEN MOVE 4 TO CMR RETURN CODE MY RETURN CODE IF EDIT MO NOT NUM...

Страница 554: ...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...

Страница 555: ...systems against output generated by OpenVMS VAX systems when outputting COMP 2 data to a file Only IEEE floating point is available on Windows NT and on the Tru64 UNIX operating system For information...

Страница 556: ...mpaq COBOL for OpenVMS VAX does RMS_STS RMS_STV RMS_CURRENT_STS RMS_CURRENT_STV B 4 10 Calling Shareable Images On OpenVMS Compaq COBOL and Compaq COBOL for OpenVMS VAX exhibit different behavior when...

Страница 557: ...n for an intermediate result you should use a temporary variable with the desired precision For example COMPUTE D A B C could be written as COMPUTE TMP1 A B COMPUTE D TMP1 C The precision to be used f...

Страница 558: ...mpaq COBOL for OpenVMS VAX are highly likely to get different undefined results in such cases STANDARD dependency The Compaq COBOL for OpenVMS VAX STANDARD qualifier has an effect on when arithmetic e...

Страница 559: ...s on all systems remains essentially the same One notable exception is REGARDLESS which is not supported on Windows NT systems File sharing for indexed files has the following limitation The OPEN stat...

Страница 560: ...specified when the file was originally created This option will provide correct results only in those cases where the unspecified keys are USAGE DISPLAY PIC X Also rkc allows you to open a file which...

Страница 561: ...erent programming languages may require special processing because of language and character set incompatibilities The most common incompatibilities are data types and data record formats You should b...

Страница 562: ...penVMS Alpha operating system ENVIRONMENT DIVISION CONFIGURATION SECTION SPECIAL NAMES ALPHABET FOREIGN CODE IS EBCDIC INPUT OUTPUT SECTION FILE CONTROL SELECT INPUT FILE ASSIGN TO INPFIL CODE SET IS...

Страница 563: ...q 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 oth...

Страница 564: ...mpt to compile a program on Tru64 UNIX that contains variables defined in your Oracle DBMS sub schema cobol Severe Undefined name B 11 2 Multistream DBMS DML With Compaq COBOL when you use multistream...

Страница 565: ...including coding building debugging performance analysis and code management Some of the Compaq FUSE tools are layered on commonly used UNIX tools including make prof rcs and sccs The default integrat...

Страница 566: ...m references or declarations To work around this problem insert an extra declaration between successive COPY statements in the DATA DIVISION as follows COPY LIBRARY 1 01 EXTRA ITEM PIC X COPY LIBRARY...

Страница 567: ...on 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 As you read the debugging sections that follow refer to the code in...

Страница 568: ...0 36 01 CHARCT PIC 99V99 38 STARTUP 39 IF TEMP WORD SPACES 40 MOVE 0 TO CHARCT 41 EXIT PROGRAM 42 MOVE SPACES TO HOLD WORD 43 PERFORM LOOK BACK VARYING SUB 1 FROM 20 BY 1 44 UNTIL TEMP CHAR SUB 1 NOT...

Страница 569: ...ts prompt ladebug ladebug testa Welcome to the Ladebug Debugger Version 2 0 8 eft object file name testa Reading symbolic information done ladebug 3 Set a breakpoint In this case you wish to break at...

Страница 570: ...TA changes 11 Execution resumes with the cont command Each time line 50 in TESTB executes the debugger executes the command list associated with this line it displays the contents of HOLD CHARS and SU...

Страница 571: ...ger displays the old and new values then returns control to you ladebug cont 3 calling testa from main cob_main c 253 0x3ff8181f054 cba 4 The value of DISP COUNT of TESTA DATA was changed in testa bef...

Страница 572: ...debugger shows source text included in a program with the COBOL COPY file statement or the COPY module of library statement However the debugger does not show text which was created with the COPY REPL...

Страница 573: ...ly 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 COBOL DEBUG NOOPTIMIZE TESTA LINK DEBUG...

Страница 574: ...ARYING SUB 1 FROM 20 BY 1 7 Set two breakpoints When the debugger reaches line 50 of TESTB it executes the commands in parentheses displays the two data items and resumes execution DBG SET BREAK LINE...

Страница 575: ...TA TESTB SUB 1 2 break at TESTA TESTB LINE 50 50 SUBTRACT 1 FROM SUB 1 TESTA TESTB HOLD CHARS CHARS cba TESTA TESTB SUB 1 1 break at TESTA TESTB LINE 47 47 MOVE HOLD WORD TO TEMP WORD DBG 13 Examine t...

Страница 576: ...d The program TESTA displays the reversed word When the image reaches line 19 in TESTA the debugger detects that an instruction changed the contents of DISP COUNT Because you set a watchpoint on DISP...

Страница 577: ...CHMODU module INVALIDMODULENAME is not in module chain C 5 Language Sensitive Editor LSE and the Source Code Analyzer SCA OpenVMS The Language Sensitive Editor LSE is a powerful and flexible text edit...

Страница 578: ...anguage specific information on the combined use of LSE and SCA For More Information On LSE See the Guide to Language Sensitive Editor On SCA See the Guide to Source Code Analyzer for VMS Systems On C...

Страница 579: ...ations to your file issue the EXIT command If you do not wish to save the file or any modification to the file issue the QUIT command To invoke SCA from LSE type the SCA command that you wish to execu...

Страница 580: ...el data might have separate directories for each employee type Often it is the job of a repository or data administrator to create repositories define directory structures and insert record and field...

Страница 581: ...tory or a compatibility dictionary in which to store the dependency information C 6 1 Creating Record and Field Definitions The following example shows how you can use CDO to create a number of fields...

Страница 582: ...PY_LIST qualifiers the source listing includes the data definition translated into a COBOL declaration as shown in the following example 1 IDENTIFICATION DIVISION 2 PROGRAM ID MASTER FILE 3 DATA DIVIS...

Страница 583: ...contains a COPY FROM DICTIONARY statement the compiler creates a CDD COMPILED_DEPENDS_ON relationship between the compiled module object and the record or field definition that is being copied It als...

Страница 584: ...this program is compiled with the DEPENDENCY_DATA qualifier the compiler creates the following objects and relationships A compiled module object called MASTER_FILE A temporary file object representin...

Страница 585: ...ATING S D_FLOATING COMPLEX W G_FLOATING S G_FLOATING COMPLEX W H_FLOATING W H_FLOATING COMPLEX W UNSIGNED NUMERIC S LEFT OVERPUNCHED NUMERIC S LEFT SEPARATE NUMERIC S RIGHT OVERPUNCHED NUMERIC S RIGHT...

Страница 586: ...Using Oracle CDD Repository on OpenVMS Systems Provides tutorial information for Oracle CDD Repository users Oracle CDD Repository CDO Reference Manual Provides reference information for the Common D...

Страница 587: ...ou port programs from other COBOL implementations to Compaq COBOL It does so by recognizing and reporting occurrences of known extensions from other COBOL implementations that are not implemented in C...

Страница 588: ...l as follows Foreign extensions EXAMINE statement not implemented Invalid statement syntax The previous message clearly identifies the foreign statement in this case EXAMINE so that you can replace it...

Страница 589: ...a second target LENGTH OF in CALL USING statement The last two features in this list are always detected All others in the list are under control of the foreign extensions option because they require...

Страница 590: ......

Страница 591: ...directives 16 1 16 6 syntax of 16 6 for OpenVMS VAX compatibility 16 4 Alignment cont d for optimal performance 16 4 natural 16 3 natural tab 16 3 OpenVMS VAX compatible 16 3 qualifiers 16 4 specifyi...

Страница 592: ...g logical names 6 18 ASSIGN TO clause 6 18 ASSIGN TO PRINTER clause 6 8 6 12 ASSIGN TO REEL clause block size A 3 number of files A 3 number of magnetic tapes A 3 record size A 3 AT END condition plan...

Страница 593: ...obfunc 12 21 cobfunc routine 12 19 COBOL run time errors See Run time messages COBOL and debugging 1 30 cobol command and ld 1 19 and other software components 1 10 compiling multiple files 1 17 creat...

Страница 594: ...how xref 1 13 std 1 13 std 85 1 13 std v3 1 13 std no mia 1 13 std no syntax 1 13 std no xopen 1 13 cobol flags cont d taso 1 14 T num 1 14 tps 1 14 1 15 trunc 1 14 v 1 14 V 1 14 w 1 14 warn 1 14 warn...

Страница 595: ...ocking B 25 file status values B 21 flags B 6 B 9 indexed files B 26 LINAGE statement B 17 Compaq COBOL compatibility cont d machine code listing B 11 module names B 11 MOVE statement B 18 Multistream...

Страница 596: ...mber of key data items A 1 index name subscript value A 3 Compiler implementation specifications cont d intrinsic functions digits A 2 ISAM keys digits A 2 MERGE number of USING files A 2 multiblock c...

Страница 597: ...5 page advancing 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...

Страница 598: ...es 1 38 Debugging OpenVMS Alpha C 8 to C 12 sample session C 9 to C 12 program structure in relation to B 29 sample Ladebug Debugger session C 4 sample source code C 4 tools C 2 Debugging cont d Tru64...

Страница 599: ...riable 6 18 accessing at run time 1 24 COBOL_INPUT 11 2 COBOL_OUTPUT 11 2 compiler Environment variable compiler cont d specifying directory for temporary files 1 17 stdin 11 2 stdout 11 2 TMPDIR 1 17...

Страница 600: ...9 handling 6 1 to 6 60 identifying 6 14 input to cobol 1 15 to 1 16 logical names 11 1 low volume I O 11 1 logical names 11 1 magnetic tape defining a 6 15 6 16 magnetic tape defining a on Tru64 UNIX...

Страница 601: ...e 1 11 to 1 15 conditionals selector 1 12 convert no leading_blanks 1 12 copy 1 12 copy_list 1 12 cord 1 12 cross_reference 1 12 cross_reference alphabetical 1 12 cross_reference declared 1 12 display...

Страница 602: ...mple 2 14 GLOBAL clause and special registers 12 18 definition of 12 15 sharing data with 12 15 sharing files with 12 15 sharing other resources record name 12 18 sharing other resources report name 1...

Страница 603: ...ynamically 6 59 randomly 6 57 Indexed file updating records randomly cont d example 6 59 sequentially 6 56 example 6 57 valid I O statements tab 6 34 writing 6 34 Indexes 4 1 initializing 4 15 Indexin...

Страница 604: ...n 13 1 contained programs 12 13 COMMON clause 12 14 GLOBAL clause 12 15 sharing data 12 15 sharing files 12 15 sharing other resources 12 18 USE procedures 12 16 examples 13 19 function value 13 3 mul...

Страница 605: ...erflow condition 10 15 printing a 10 19 top margin 10 13 LINE COUNTER option 10 30 Line sequential file creating 6 26 6 27 extending 6 49 organization of 6 5 advantages 6 3 disadvantages 6 3 organizat...

Страница 606: ...ging files example 9 19 Messages issued by compiler general description 1 18 linking 1 22 REFORMAT Utility error 14 4 Migration of programs D 1 Millennium date change xxix 1 62 Module names B 11 Modul...

Страница 607: ...ls compiler implementation specifications A 2 non_shared flag 1 13 1 21 noobject flag 1 13 NOOPTIMIZE 1 2 NOVFC 6 8 nowarn flag 1 13 no_archive flag ld and creating shared libraries 1 21 Numeric class...

Страница 608: ...Calling Standard 13 2 Run Time Library routines 13 4 System Services routines 13 4 Usages 13 8 COBOL equivalents 13 8 OpenVMS Alpha tuning 1 3 Optimization 15 1 to 15 25 confusing behavior in debuggi...

Страница 609: ...e 1 4 Physical page definition 10 5 PICTURE character strings alphanumeric or alphabetic compiler implementation specifications A 2 alphanumeric or numeric edited compiler implementation specification...

Страница 610: ...ction See Protecting records space needs on a physical device 6 9 Record cont d variable length 6 10 variable with fixed control 6 12 Record access mode definition 6 23 RECORD CONTAINS clause 6 8 Reco...

Страница 611: ...L on OpenVMS Alpha B 14 Compaq COBOL on OpenVMS Alpha ex B 14 REPLACE statement differences cont d line numbers Compaq COBOL for OpenVMS VAX ex B 14 Compaq COBOL on OpenVMS Alpha ex B 14 line numbers...

Страница 612: ...0 30 vertical spacing 10 29 Report Writer cont d PAGE clause 10 25 printing GROUP INDICATE clause 10 37 processing a Report Writer report 10 38 detail reporting 10 42 GENERATE statement 10 39 initiati...

Страница 613: ...er implementation specifications A 1 SEARCH ALL statement advantages 15 9 requirements 15 9 Search argument usage in REPLACING phrase 5 30 Searching tables 4 16 Search order definition for object modu...

Страница 614: ...ng COBOL 1 19 Sharing source text 1 28 USE procedures 12 16 show code flag 1 13 show copy flag 1 13 show xref flag 1 13 Sign conventions 2 2 tests description of 2 4 unsigned item and absolute value 2...

Страница 615: ...flag 1 13 std no syntax flag 1 13 std no xopen flag 1 13 Storage allocation byte boundaries 4 7 effect of fill bytes 4 7 table data 4 6 tables containing COMP or COMP SYNC items 4 7 Storage difference...

Страница 616: ...9 System supplied object module libraries definition 1 42 T Table elements initializing 4 10 Tables See also Storage allocation See also Subscript accessing literal subscripts ex 4 13 with indexes 4 1...

Страница 617: ...Tally argument to inspect data 5 24 Tally counter to inspect data 5 24 taso flag 1 14 Temporary files created by cobol 1 17 directory used by cobol 1 17 Temporary files cont d TMPDIR environment vari...

Страница 618: ...aq COBOL for OpenVMS VAX programs B 10 Using the DEFINE command default object module libraries 1 42 Using the MERGE statement example 9 10 Using the USING and OUTPUT PROCEDURE phrases example 9 11 Us...

Страница 619: ...11 12 example 11 9 defining keys 11 20 designing 11 4 displaying data 11 9 DISPLAY statement 11 4 editing 11 28 ERASE phrase 11 4 options 11 4 input object of 11 1 LINE NUMBER phrase 11 5 PLUS option...

Страница 620: ......

Отзывы: