Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP OpenVMS Systems Documentation

Content starts here

Compaq COBOL
User Manual


Previous Contents Index

B.5.3 VFC File Format

If a VFC file is created on OpenVMS Alpha and then read on Tru64 UNIX, the data record will be returned with the 2-byte control string in the data record when it is read.

The workaround is to convert the file to a non-VFC format on OpenVMS Alpha by specifying /NOVFC. Alternatively, you can skip over the VFC bytes when you read the file on Tru64 UNIX.

The following files are by default created in VFC format on OpenVMS Alpha:

LINAGE
REPORT WRITER
SEQUENTIAL EXTERNAL/GLOBAL
Output with WRITE ADVANCING

B.5.4 File Attribute Checking (Tru64 UNIX)

Compaq COBOL on Tru64 UNIX provides limited file attribute checking. No file attribute checking is performed for sequential and relative files. For indexed files, Compaq COBOL verifies that the following file attributes match what is specified in the application:

  • Number of keys
  • Size and position (within the record structure) of each key
  • Whether or not duplicates are allowed for each key

If these attributes do not match, the file will not be opened and a fatal run-time error will occur (or Declaratives will be invoked, if applicable).

However, with the relax key checking option selected, Compaq COBOL for Tru64 UNIX will allow you to open a file that specifies fewer keys than were 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 that specifies DUPLICATES for a key in a way differently from the specification given when the file was created.

There is an additional check in creating an indexed file: unless relax key checking is specified, you cannot have two keys that are identical except for whether DUPLICATES are allowed. If this restriction is violated, there will be an explicit run-time error message and those operations that are affected by DUPLICATES might give unexpected results.

B.5.5 Indexed Files

Compaq COBOL for Tru64 UNIX treats indexed files differently from the way they are treated by both Compaq COBOL for OpenVMS Alpha and Compaq COBOL for OpenVMS VAX. Specifically, on Tru64 UNIX:

  • For an indexed file, the run-time system creates two files on the disk: one file with the dat extension, and the other file with the idx extension.
  • If you try to open an indexed file as a sequential file, the key part of any record other than a character key will be different. The reason is that the keys in a record are translated to a file format on disk.
  • When you open an existing indexed file, the RTL checks its key structure and returns a severe error if there is a serious mismatch.
    On Tru64 UNIX, this RTL check does not detect some differences that would be detected on an OpenVMS Alpha system, because all but signed 16- and 32-bit integers are mapped onto character strings. For example, if you write an indexed file using a key described as an unsigned 32-bit integer, the character string you will read is the integer with its bytes reversed.
    On an OpenVMS Alpha system, by contrast, you receive a severe error when you try to open a file with the incompatible key.

B.5.6 RMS Special Register References in Your Code

Compaq COBOL for Tru64 UNIX does not support RMS Special Registers. If you include them, you may receive the following general diagnostic message when you attempt to compile the program:



cobol: Severe: ...Undefined name   

B.6 File Compatibility Across Languages and Platforms

Files created by different 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 be aware of the following:

  • Print-controlled files that are created on the Tru64 UNIX operating system cannot be used as VFC files on the OpenVMS Alpha operating system.
  • VFC files cannot be used on the Tru64 UNIX operating system.
  • On Tru64 UNIX, to read a file with variable-length records, you must describe the file as such in the program (use RECORD IS VARYING). On OpenVMS Alpha, you can read a file with variable-length records by using a file description for fixed-length records.
  • On OpenVMS Alpha, a file with fixed-length records can be described in a COBOL program with an FD specifying a length shorter than the file record length. On input, the extra data in each record is ignored on OpenVMS Alpha. On Tru64 UNIX, the length specified for the FD must match the actual length of the records in the file; you must not use RECORD IS VARYING to read a file with fixed-length records.
  • On Alpha, to read a file sequentially, use ORGANIZATION INDEXED, ACCESS SEQUENTIAL (or DYNAMIC), and READ NEXT.

Data Type Differences

Data types vary by programming language and by utilities. For example, Compaq Fortran does not support the PACKED-DECIMAL data type and, therefore, cannot easily use PACKED-DECIMAL data in COBOL files.

You can use the following techniques to overcome data type incompatibilities:

  • Use the NATIVE character set, which uses ASCII representation, for all data in files intended for use across languages.
  • If your requirements include processing non-ASCII data, you can specify a character set in the SPECIAL-NAMES paragraph of the Environment Division, along with the CODE-SET clause in the SELECT statement. Except for NATIVE, you must specify all character sets in the SPECIAL-NAMES paragraph.
  • Use common numeric data types (numeric data types that remain constant across the application).

In the following example, the input file is written in EBCDIC. This creates a file that would be difficult to handle in most languages other than COBOL on OpenVMS Alpha.



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 FOREIGN-CODE. 

            . 

            . 

            . 

B.7 LIB$INITIALIZE Interaction Between C and COBOL

If you use LIB$INITIALIZE when the main program is written in Compaq COBOL on Alpha, or on an OpenVMS VAX version prior to Version 7.1, and the initialize routine is written in Compaq C, the initialize routine will not be called. If you are using OpenVMS VAX Version 7.1 or higher, however, the routine will be called; also, it will be called if your main program is in C or in BASIC rather than COBOL, so this can be a practical workaround.

The problem is due to the quadword alignment with which C creates the LIB$INITIALIZE psect. The LIB$INITIALIZE psect requires longword alignment. The programmer can explicitly specify longword alignment on the extern_model pragma to avoid the problem.

B.8 Reserved Words

Depending on the use of the /RESERVED_WORDS qualifier or equivalent flag, there are a number of additional reserved words in Compaq COBOL on Alpha that are not reserved in Compaq COBOL on VAX. Refer to the appendix on reserved words in the Compaq COBOL Reference Manual for complete information.

B.9 Debugger Support Differences

Compaq COBOL debugger support on Alpha differs in several ways from VAX, as follows:

  • Compaq COBOL on Alpha issues the following informational message when the /DEBUG qualifier is used on the COBOL command line with the default optimization in effect:


    
    %COBOL-I-DEBUGOPT, /NOOPTIMIZE is recommended with /DEBUG 
    
    

    You receive this message if you specify nothing about optimization when you specify /DEBUG. (/OPTIMIZE is the default for the compiler.) Unlike other informational messages, which are turned off by default, this message is always allowed through by the Compaq COBOL on Alpha compiler, even if /WARN=NOINFO is in effect. To turn the message off, use any form of the qualifier /[NO]OPTIMIZE on the COBOL command line (for example, /NOOPTIMIZE or /OPTIMIZE or /OPTIMIZE=LEVEL=x).
  • Compaq COBOL for OpenVMS VAX does not have the /OPTIMIZE qualifier.
  • With Compaq COBOL on Alpha, unlike Compaq COBOL for OpenVMS VAX, the debugger sometimes changes underscores to hyphens and hyphens to underscores in variable names. This difference from Compaq COBOL for OpenVMS VAX can help you debug a program.

B.10 DECset/LSE Support Differences

Compaq COBOL on Alpha does not support the DECset/LSE Program Design Facility, the /DESIGN qualifier, design comments, or pseudocode placeholders.

B.11 DBMS Support

On OpenVMS, Compaq COBOL support for Oracle CODASYL DBMS has some differences depending on whether you are developing programs with Compaq COBOL on OpenVMS Alpha or with Compaq COBOL for OpenVMS VAX.

B.11.1 Compiling on Tru64 UNIX

In Compaq COBOL for Tru64 UNIX, Oracle CODASYL DBMS sub-schema access (DML for Oracle CODASYL DBMS) is not supported. Attempting to compile a program containing any Oracle CODASYL DBMS syntax results in the following diagnostic message:



cobol: Severe: ...DBMS Data Manipulation Language is not supported 

Oracle CODASYL DBMS syntax includes the following language elements: COMMIT, CONNECT, DB, DB-EXCEPTION, EMPTY, ERASE, FETCH, FIND, FREE, GET, KEEP, LD, MEMBER, MODIFY, OWNER, READY, RECONNECT, RETAINING, ROLLBACK, STORE, SUB-SCHEMA, TENANT, and WHERE.

You might also receive the following general diagnostic message when you attempt to compile a program (on Tru64 UNIX) that contains variables defined in your Oracle CODASYL DBMS sub-schema:



cobol: Severe: ...Undefined name   

B.11.2 Multistream DBMS DML

With Compaq COBOL for OpenVMS Alpha, when you use multistream Oracle CODASYL DBMS DML, you must access different schemas or streams from separate source files.

<>


Appendix C
Programming Productivity Tools

Various programming productivity tools can help you increase your productivity as a Compaq COBOL programmer. These include the following:

  • On Tru64 UNIX, Compaq FUSE, an integrated development environment <>
  • Debugging tools for Compaq COBOL programs
    • Ladebug Debugger for the Tru64 UNIX operating system ( Section C.3)
    • OpenVMS Debugger for the OpenVMS Alpha operating system ( Section C.4)
  • Language-Sensitive Editor (LSE) and Source Code Analyzer (SCA) ( Section C.5), available on the OpenVMS Alpha operating system
  • Oracle CDD/Repository ( Section C.6), available on the OpenVMS Alpha operating system <>

C.1 Compaq FUSE---an Integrated Development Environment (Tru64 UNIX)

Compaq FUSE is the Compaq integrated software development environment for UNIX workstations. Compaq FUSE supports basic software development activities 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 integrated debugger is Ladebug Debugger. These Compaq FUSE tools provide easy-to-use Motif graphic interfaces, plus benefits achieved through integration with other Compaq FUSE tools and through extensions to the capabilities of the base tools.

Compaq FUSE also provides an integrated text editor with a Motif user interface as well as integrated emacs and vi . Other Compaq FUSE tools provide integrated static analysis and browsing capabilities, including program source cross-referencing and call-graph browsing.

Additional tools (such as the Code Manager, Profiler, and Compare---all based on standard UNIX utilities---and the Cross-Referencer and Call Graph Browser) are available with the Compaq FUSE base system.

The Compaq FUSE integration framework allows tools to invoke one another and trigger operations. Programming tasks are automated and streamlined, reducing some operations to a single mouse button click.

With Compaq FUSE you can:

  • Distribute a build and run compilations in parallel.
  • Create and use nested (recursive) makefiles.
  • Use default configurations to automatically set up tools for a new session.
  • Customize your best tools configuration.
  • Create custom language templates for use with the Compaq FUSE editor.
  • Specify pre- and postprocessing scripts for code management operations.
  • Tailor your work environment, selecting your editor and debugger, as well as personal favorite (and meaningful) colors and fonts, for example.
  • Save your work context, and reestablish that work context from session to session.
  • Automatically start and configure your chosen development productivity tools.

Refer to the Compaq FUSE documentation for additional, detailed information.

Technical Note

With certain COBOL programs in the Compaq FUSE environment a problem will manifest itself by displaying the wrong file in the Compaq FUSE Editor tool for certain COBOL items which are clicked on from the Cross-Referencer tool. This can only happen for COBOL programs with successive COPY statements where there are no intervening data item references or declarations. 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-2". 

You should also insert an extra reference to a data item between successive COPY statements in the PROCEDURE DIVISION as follows:



 DISPLAY "TEST 7". 

 COPY "LIBRARY-1". 

 move 1 to extra-item. 

 COPY "LIBRARY-2". 

<>

C.2 Debugging Tools for Compaq COBOL Programs

This appendix includes representative debugging sessions that demonstrate debugger features for both the OpenVMS Debugger and the Tru64 UNIX Ladebug Debugger. These tools are source-level, symbolic debuggers that support Compaq COBOL data types and use.

Both the OpenVMS Debugger and the Tru64 UNIX Ladebug Debugger let you:

  • Control the execution of individual source lines in a program.
  • Set stops (breakpoints) at specific source lines or under various conditions.
  • Change the value of variables within the debugging environment.
  • Refer to program locations by their symbolic names, using the debugger's knowledge of the Compaq COBOL language to determine the proper scoping rules and how the values should be evaluated and displayed.
  • Print the values of variables and set a trace (tracepoint) to notify you when the value of a variable changes.
  • Perform other functions, such as executing shell commands, examining core files, examining the call stack, or displaying registers.

The debugging examples in Section C.3 and Section C.4 focus on a sample program, shown in Example C-1. One common program has been used, to emphasize the portability of Compaq COBOL.

As you read the debugging sections that follow, refer to the code in Example C-1 to identify source lines.

The program, TESTA, accepts a character string from the terminal and passes it to contained program TESTB. TESTB reverses the character string and returns it (and its length) to TESTA.

Example C-1 Source Code Used in the Sample Debug Sessions


module TESTA 

     1: IDENTIFICATION DIVISION. 

     2: PROGRAM-ID.  TESTA. 

     3: DATA DIVISION. 

     4: WORKING-STORAGE SECTION. 

     5:    01  TESTA-DATA        GLOBAL. 

     6:        02   LET-CNT      PIC 9(2)V9(2). 

     7:        02   IN-WORD      PIC X(20). 

     8:        02   DISP-COUNT   PIC 9(2). 

     9: PROCEDURE DIVISION. 

    10: BEGINIT. 

    11:     DISPLAY "ENTER WORD:". 

    12:     MOVE SPACES TO IN-WORD. 

    13:     ACCEPT IN-WORD. 

    14:     CALL "TESTB" USING IN-WORD LET-CNT. 

    15:     PERFORM SHOW-IT. 

    16:     STOP RUN. 

    17: SHOW-IT. 

    18:     DISPLAY IN-WORD. 

    19:     MOVE LET-CNT TO DISP-COUNT. 

    20:     DISPLAY DISP-COUNT " CHARACTERS". 

    21: IDENTIFICATION DIVISION. 

    22: PROGRAM-ID.  TESTB    INITIAL. 

    23: DATA DIVISION. 

    24: WORKING-STORAGE SECTION. 

    25:    01  SUB-1  PIC 9(2) COMP. 

    26:    01  SUB-2  PIC S9(2)  COMP-3. 

    27:    01  HOLD-WORD. 

    28:        03      HOLD-CHAR PIC X OCCURS 20 TIMES. 

    29:    01  HOLD-CHARS-REHOLD-WORD. 

    30:        03  CHARS PIC X(20). 

    31: LINKAGE SECTION. 

    32:    01  TEMP-WORD. 

    33:        03  TEMP-CHAR  PIC X OCCURS 20 TIMES. 

    34:    01  TEMP-CHARS REDEFINES TEMP-WORD. 

    35:        03  CHARS PIC X(20). 

    36:    01  CHARCT  PIC 99V99. 

    37: PROCEDURE DIVISION USING TEMP-WORD, CHARCT. 

    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 = SPACE. 

    45:     MOVE SUB-1 TO CHARCT. 

    46:     PERFORM MOVE-IT    VARYING SUB-2 FROM 1 BY 1   UNTIL SUB-1 = 0. 

    47:     MOVE HOLD-WORD TO TEMP-WORD. 

    48: MOVE-IT. 

    49:     MOVE TEMP-CHAR (SUB-1) TO HOLD-CHAR (SUB-2). 

    50:     SUBTRACT 1 FROM SUB-1. 

    51: LOOK-BACK. 

    52:     EXIT. 

    53: END PROGRAM TESTB. 

    54: END PROGRAM TESTA. 

C.3 Ladebug Debugger (Tru64 UNIX)

The Ladebug Debugger is used to debug Compaq COBOL programs on the Tru64 UNIX operating system.

This section provides a representative debugging session that is designed to demonstrate the use of debugger features. For complete reference information on the Ladebug Debugger, you should refer to the Ladebug Debugger Manual in the Tru64 UNIX operating system documentation set. Online help is immediately available to you during a debugging session when you type help command at the debugger prompt (ladebug) . Additional information about the flags shown in this section is available in the man page. For example, you can type man cobol , and page to the appropriate topic to read information about the flags ( -g , -o ) used at the beginning of the example in this section.

  1. To begin this example you compile a Compaq COBOL program consisting of the single compilation unit named TESTA.


    
    % cobol -g -o testa testa.cob
    
    cobol: Warning: file not optimized; use -g3 for debug with optimize
    
    %
    
    

    The -g switch on the compiler command causes the compiler to write the debugger symbol table associated with the program into the executable program.
    Normally, the compiler turns off optimization when you specify -g and gives a warning to that effect. To debug your program with full optimization turned on, use the -g3 switch.
  2. The ladebug command starts the session. You provide your program name as a parameter (argument) to the command. After the debugger reads in your program's symbol table, it returns control with its 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 line 43 of your program.


    
    (ladebug) stop at 43
    
    [#2: stop at "testa.cob":43 ]
    
    
  4. Begin execution with the run command. The debugger starts program TESTA, prompts for a keyboard entry, and waits for a response.


    
    (ladebug) run
    
     ENTER WORD
    
     
    
    
  5. Enter the word to be reversed. Execution continues until the image reaches the breakpoint at line 43 of the contained program.


    
    abc
    
    [2] stopped at [TESTB:43 0x120001aa4]
    
         43     PERFORM LOOK-BACK  VARYING SUB-1 FROM 20 BY -1
    
    
  6. Set two breakpoints. You can give the debugger a list of commands to execute at breakpoints; the commands are entered in braces ({}).


    
    (ladebug) stop at 47 
    
    [#2: stop at "testa.cob":47 ]
    
    (ladebug) when at 50 { print chars of hold-chars; print SUB-1; cont; } 
    
    [#3: when at "testa.cob":50 { print CHARS of HOLD-CHARS; print SUB-1; ; cont ; } ]
    
    
  7. Display the active breakpoints.


    
    (ladebug) status 
    
    #1 PC==0x120001e14 in testa "testa.cob":2 { break }   
    
    #2 PC==0x120001ba4 in TESTB "testa.cob":47 { break } 
    
    #3 PC==0x120001c1c in TESTB "testa.cob":50          
    
       { ; print CHARS of HOLD-CHARS; print SUB-1; ; cont ; ; } 
    
    
  8. Use the list command to display the source lines where you set breakpoints.


    
    (ladebug) list 43,50
    
         43     PERFORM LOOK-BACK  VARYING SUB-1 FROM 20 BY -1
    
         44         UNTIL TEMP-CHAR (SUB-1) NOT = SPACE.
    
         45     MOVE SUB-1 TO CHARCT.
    
         46     PERFORM MOVE-IT    VARYING SUB-2 FROM 1 BY 1   UNTIL SUB-1 = 0.
    
         47     MOVE HOLD-WORD TO TEMP-WORD.
    
         48 MOVE-IT.
    
         49     MOVE TEMP-CHAR (SUB-1) TO HOLD-CHAR (SUB-2).
    
         50     SUBTRACT 1 FROM SUB-1.
    
    
  9. Set a tracepoint at line 15 of TESTA.


    
    (ladebug) trace at 15
    
    [#3: trace at "testa.cob":15 ]
    
    
  10. Set a watchpoint on the data item DISP-COUNT. When an instruction tries to change the contents of DISP-COUNT, the debugger returns control to you.


    
    (ladebug) stop disp-count of testa-data
    
    [#4: stop if DISP-COUNT of TESTA-DATA 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 SUB-1, then resumes execution. Finally, the debugger returns control to the user when the breakpoint at line 47 is reached.


    
    (ladebug) cont 
    
    [3] when [TESTB:50 0x120001c1c] 
    
    "c                   "
    
    3
    
    [3] when [TESTB:50 0x120001c1c] 
    
    "cb                  "
    
    2
    
    [3] when [TESTB:50 0x120001c1c] 
    
    "cba                 "
    
    1
    
    [2] stopped at [TESTB:47 0x120001ba4] 
    
         47     MOVE HOLD-WORD TO TEMP-WORD.
    
    
  12. Examine the contents of SUB-1.


    
    (ladebug) whatis sub-1
    
     unsigned short SUB-1
    
    (ladebug) print sub-1
    
    0
    
    
  13. Deposit the value --42 into data item SUB-2.


    
    (ladebug) whatis sub-2
    
     pic s99 usage comp-3 SUB-2
    
    (ladebug) assign sub-2=-42
    
    
  14. Examine the contents of SUB-2.


    
    (ladebug) print sub-2
    
    -42
    
    
  15. Examine the contents of CHARCT, whose picture is 99V99.


    
    (ladebug) whatis charct
    
     pic 99v99 usage display charct
    
    (ladebug) print charct
    
      3.00
    
    
  16. Deposit a new value into CHARCT.


    
    (ladebug) assign charct=15.95
    
    
  17. CHARCT now contains the new value.


    
    (ladebug) print charct
    
     15.95
    
    
  18. You can examine any character of a subscripted data item by specifying the character position. The following EXAMINE command accesses the second character in TEMP-CHAR.


    
    (ladebug) print temp-char of temp-word(2)
    
     "b"
    
    
  19. You can qualify data names in debug commands as you can in Compaq COBOL. For example, if you examine IN-WORD while you debug your program, you can use the following Ladebug Debugger command:


    
    (ladebug) print in-word of testa-data
    
     "abc                 "
    
    
  20. Restore CHARCT to its original value.


    
    (ladebug) assign charct=3.00
    
    
  21. Resume execution with the cont command. 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-COUNT, the debugger 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, 
    
        before entering cob_acc_display
    
            Old value =   0
    
            New value =   3
    
    [4] stopped at [cob_acc_display:349 0x3ff81808744] 
    
    (Cannot find source file cob_accdis.c) 
    
    

    Note that the Ladebug Debugger "watch" command shown here ( stop disp-count of testa-data ) does not stop immediately at the point when the value of the watched variable changes. In this example, the debugger takes control at the first procedure call or return after the value of the watched variable changes. For more information on the behavior of Ladebug Debugger watch , refer to the Ladebug Debugger Manual.
  22. To see the executable's current location, use the where command. Then, set the debugger file scope back to the main COBOL program, and stop at a specified line number in that file.


    Previous Next Contents Index

     

Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2012 Hewlett-Packard Development Company, L.P.