HP 3000 Manuals

Problems When Running the Code [ COBOL/HP-UX Compatibility Guide for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Compatibility Guide for the Series 700 and 800

Problems When Running the Code 

Once you have successfully submitted your RM/COBOL source program to this
COBOL system and produced executable code, you may receive problems when
you attempt to run this code under this system.  Alternatively, the code
may run but you may find that its behavior under this COBOL system is not
exactly the same as under the RM/COBOL system.  The following sections
detail known problems you may experience, and offer hints on how you can
solve them.

Trailing Blanks in Line Sequential Files 

This COBOL system always removes trailing blanks from line sequential
records before writing the record.  The RM/COBOL system removes trailing
blanks from such records only if the FD entry contains 01 level records
of different sizes.  This will not cause you any problems when you run
your converted RM/COBOL programs under this COBOL system.  However, 
you may receive errors at run-time if any REWRITE operations on line
sequential files change the length of the records.

Solution 

Change the file organization to sequential, or move an alternative
padding character (for example, LOW-VALUES) to the end of the record
before it is written.  This ensures that full-length records are written.

Also, ensure that the T run-time switch is not set, as this may also
change the size of the record.  See your COBOL System Reference for
details of this switch.

Undefined Results of MOVE and Arithmetic Operations 

The results of MOVE statements involving numeric and alphanumeric data
items may differ under the two systems.  So may the results of 
arithmetic operations or comparisons on numeric items which contain
nonnumeric data, or when a numeric data item containing nonnumeric data
is moved to an alphanumeric data item in generated code.

Solution 

You can overcome most of these incompatibilities by redefining the data
items involved, or by recoding the comparisons.  Note that if you submit
a program to this COBOL system containing an alphanumeric to numeric data
item MOVE statement, a warning message will be displayed indicating this.

Example 

If you submit a source program containing the following data items and
procedural statements the specified test will fail at run-time:

     01 NUMERIC-FIELD        PIC 9(5).
     PROCEDURE DIVISION.
         MOVE "ABC" TO NUMERIC-FIELD.
         IF NUMERIC-FIELD = "00ABC"
             ....

When the RM directive is set, this COBOL system partially emulates the
behavior of the RM/COBOL system for alphanumeric to numeric MOVEs by
treating the numeric item as an alphanumeric item which is right
justified.  However, the above example will still fail because the
RM/COBOL system treats the literal ABC as numeric, and places 00ABC in
the numeric item.  To make the statement run succesfully under this COBOL
system, amend the test in the source program to:

     IF NUMERIC-FIELD = " ABC"

and resubmit the source program to the system.

Embedded Control Sequences in DISPLAY Statements 

In your RM/COBOL source program you may have embedded control sequences
within data items which you want to be displayed.  One of the most
commonly used sequences is that for selecting underline:

     <-]4m

This COBOL system ignores such control characters at run-time as they are
hardware dependent.  It will attempt to display them as literals but the
results are undefined.

Solution 

Remove the control sequences from your source program and replace with
the equivalent VS COBOL syntax.  In the above example, use the syntax
WITH UNDERLINE. See your Language Reference for a full description of all
VS COBOL syntax available to you.  Resubmit your amended source program
to this COBOL system.  If any of the syntax which you have added to your
source program needs to have additional directives set before the system
will accept it, you must set these directives.  In the above example you
would need to set the 3 parameter with the MF directive.  See your COBOL 
System Reference for a full description of all the available directives,
and your Language Reference for a list of which reserved words are
enabled by each directive.

Printer Output is Written to Disk 

By default, this COBOL system writes all output intended for a printer to
disk.

Solution 

The way in which you can write directly to the printer is specific to
your implementation and is given in your COBOL System Reference.

Redefinition of COMPUTATIONAL or COMPUTATIONAL-6 Data Items 

This COBOL system fully supports the size and capacity of RM/COBOL type
COMPUTATIONAL and COMPUTATIONAL-6 data items, provided the source
programs containing such items are submitted to this COBOL system with
the RM directive set.  However, the internal representation of such data
items in this COBOL system and the RM/COBOL system is not the same.  See
Chapter 6  for details.  This may cause you problems if you want to
redefine these data items to take advantage of their internal format.

Solution 

MOVE the data items concerned to other data items which are not defined
as COMPUTATIONAL or COMPUTATIONAL-6.  Moving these data items converts
the data automatically, overcoming any problems you may have had.

Example 

The following source code is coded to take advantage of the internal
representation of COMPUTATIONAL-6 data items under the RM/COBOL system,
and to analyze a date field:

     O1 BIRTHDATE-1          PIC 9(6) COMP-6.
     O1 BIRTHDATE-2 REDEFINES BIRTHDATE-1.
         03 MONTH-2         PIC 99 COMP-6.
         03 DAY-2           PIC 99 COMP-6.
         03 YEAR-2          PIC 99 COMP-6.
         ....

     PROCEDURE DIVISION.
     START-UP SECTION.
     PARA-1.
         ....

         MOVE 082462 TO BIRTHDATE-1.
         ....

         IF YEAR-2 = 62
             DISPLAY "RECORDS NOT AVAILABLE FOR 1962."

Amend your source program to use the DISPLAY format instead of redefining
COMPUTATIONAL-6 data items, before submitting it to this COBOL system:

     O1 BIRTHDATE-1          PIC 9(6) COMP-6.
     O1 BIRTHDATE-2 REDEFINES BIRTHDATE-1.
         03 MONTH-2         PIC 99 COMP-6.
         03 DAY-2           PIC 99 COMP-6.
         03 YEAR-2          PIC 99 COMP-6.

     O1 BIRTHDATE-1A         PIC 9(6).
     O1 BIRTHDATE-2A REDEFINES BIRTHDATE-1A.
         03 MONTH-2A        PIC 99.
         03 DAY-2A          PIC 99.
         03 YEAR-2A         PIC 99.
         ....

     PROCEDURE DIVISION.
     START-UP SECTION.
     PARA-1.
         ....

         MOVE 082462 TO BIRTHDATE-1.
         MOVE BIRTHDATE-1 TO BIRTHDATE-1A.
         ....

         IF YEAR-2A = 62
             DISPLAY "RECORDS NOT AVAILABLE FOR 1962."

ON SIZE ERROR Clause 

Each COBOL system treats the ON SIZE ERROR condition differently.  The ON
SIZE ERROR condition exists under the RM/COBOL system when the value
resulting from an arithmetic operation exceeds the capacity for the
associated data item.  However, the ON SIZE ERROR condition exists under
this COBOL system when the value resulting from an arithmetic operation
exceeds the capacity of the specified picture string.  You may thus have
problems if your source programs contain data items whose capacity is not
specified by a picture string, for example COMPUTATIONAL-1 data items.

Field Wrap-Around 

If, when using binary data items (that is, RM/COBOL COMPUTATIONAL-1
format items) an arithmetic operation gives a value which exceeds the
capacity of the data item, and there is no ON SIZE ERROR clause, this
COBOL system wraps-around the value of the item.  However, under the same
conditions the RM/COBOL system sets the data item to the limit of its
capacity.

Example 

Under the RM/COBOL system the following lines of code result in the value
+32767 being stored in the data item, CALC-ITEM. However, under this
COBOL system the value -32768 is stored in CALC-ITEM:

     O1 CALC-ITEM         PIC S9(4)  COMP-1.

      PROCEDURE DIVISION.
           ....
          MOVE 32767 TO CALC-ITEM.
          ADD 1 TO CALC-ITEM.

COMPUTATIONAL-1 Data Items with a PICTURE other than S9(4) 

The RM/COBOL system takes note of the PICTURE string for the
COMPUTATIONAL-1 MOVE 
data item when it is used as the source of a MOVE statement to an
alphanumeric item.  However, this COBOL system always assumes a
COMPUTATIONAL-1 data item has a PICTURE string of S9(4).

Solution 

To produce the result you require, you must alter the definition of the
target of the MOVE statement.

Example 

The following source code causes TEST-RECORD to hold "9900" under the
RM/COBOL system, but "0099" under this COBOL system.

     01 TEST-RECORD                PIC X(4).
     01 COMP-1-ITEM                PIC 99 COMP-1.
     PROCEDURE DIVISION.
         ...

         MOVE 99 TO COMP-1-ITEM.
         MOVE COMP-1-ITEM TO TEST-RECORD.

To overcome this problem, alter the definition of TEST-RECORD as shown
below:

     01 TEST-RECORD.
         03 TEST-NUMERIC-FIELD     PIC 99.
         03 FILLER      PIC XX.
     01 COMP-1-ITEM                PIC 99 COMP-1.
     PROCEDURE DIVISION.
         ...
        MOVE 99 TO COMP-1-ITEM.
        MOVE COMP-1-ITEM TO TEST-NUMERIC-FIELD.

This avoids moving the COMPUTATIONAL-1 data item directly to an
alphanumeric field.

File and Record Locking 

Certain versions of the RM/COBOL system contain some software errors in
the way in which locks for files and records are handled.  These errors
are not emulated in this COBOL system.  For example:

   *   Indexed files do not detect or acquire locks if they are opened
       for output.  This is regardless of whether you specify the WITH
       LOCK phrase.

   *   Relative and sequential files cannot be locked exclusively.

   *   Files which are opened for input can detect record locks, although
       the RM/COBOL documentation states that they cannot.  When the RM
       directive is set under this COBOL system, record locks can still
       be detected by files opened for input.

   *   The first record in sequential files opened for input-output is
       locked whenever any other record in that file is.

Initialization of Working-Storage 

The RM/COBOL system initializes all Working-Storage items to SPACES,
unless you have placed numeric data items between data items with VALUE
clauses.  This COBOL system initializes all Working-Storage items without
VALUE clauses to SPACES without exception.

Solution 

In the unlikely event of this feature causing you any problems, add a
VALUE clause with the appropriate value to your source program and
resubmit it to this COBOL system.  This will resolve any problems which
may occur if your program relies on the initial value given to the
system.

Example 

The RM/COBOL system initializes the following group item to SPACES:

     01 GROUP-ITEM.
          O3 ITEM-1     PIC X.
          O3 ITEM-2     PIC 99.
          03 ITEM-3     PIC X.

However, if ITEM-1 and ITEM-3 have value clauses associated with them,
the RM/COBOL system initializes the second byte of ITEM-2 to hexadecimal
value 0 when ITEM-2 is defined as USAGE COMP (signed or unsigned) or
USAGE DISPLAY (unsigned only).

Screen Column Number Specification 

This COBOL system allows you to specify screen column numbers up to and
including 999, but the RM/COBOL system allows you to specify column
numbers greater than 999.  If you attempt to run an RM/COBOL source
program containing a column number greater than 999 under this COBOL
system, the column number is truncated so that only the last three digits
are used.  If truncation of the column number occurs for an item to be
displayed on the screen, then the position of that item on the screen
under this COBOL system will differ from its position under the RM/COBOL
system.

Solution 

Recode your source programs so that you make column numbers greater than
999, less than or equal to 999.  If you want an item on the screen that
has a column number greater than 999 to remain in the same position under
this COBOL system as under the RM/COBOL system, then you will need to
recode your program.  See your Language Reference for details of the use
of column numbers in this COBOL system.

End of File Notification 

The first time you unsuccessfully attempt to READ a sequential file in
either COBOL system because you have reached the end of the file, 
status key 1 in the FILE STATUS is set to 1 and status key 2 is set to 0.
This indicates that there is no next logical record. 
If you attempt to READ the same file again, without it either having been
previously closed and reopened, or it having been successfully started,
this COBOL system continues to indicate that there is no next logical
record.  However, if you attempt to READ the same file again under the
RM/COBOL system, status key 1 in the FILE STATUS is set to 9 and status
key 2 is set to 6.

Solution 

A solution to the different FILE STATUSes returned for the circumstances
given above will depend on the way in which your source program is coded.
We suggest that you include a test for the values 1 and 0 in status key 1
and 2 of the FILE STATUS, respectively, at the same time as you test for
the values 9 and 6 in these status keys.

ACCEPT Fields at the Edge of the Screen 

If your program contains an ACCEPT statement for a numeric data item at a
position on the screen where the definition of the numeric data item
would cause the ACCEPT field to go beyond the right-hand edge of the
screen, both COBOL systems will truncate the input value.  Under the
RM/COBOL system, the input value will be aligned into the ACCEPT field as
an alphanumeric field, whereas under this COBOL system the input value is
aligned as a numeric field.

Solution 

Change the definition of the relevant PICTURE clause from numeric to
alphanumeric.  Alternatively, change the PICTURE clause so that the field
does not go beyond the edge of the screen.

Example 

If your program contains the following statement:

     ACCEPT data-item AT COLUMN NUMBER 75.

where data-item is a numeric data item defined as PIC 9(10), a value of
123456 entered into the ACCEPT field will be held under this COBOL system
as "0000123456".  Under the RM/COBOL system, however, the value in the
ACCEPT field would be held as "1234560000".  To allow this COBOL system
to emulate the behavior of this value when it is held in the ACCEPT field
under the RM/COBOL system, alter the definition of the data item in your
program to PIC X(10) or PIC 9(6).

Display of Input Data in Concealed ACCEPT Fields 

If you have specified OFF and ECHO clauses for the same ACCEPT statement
in your program, the RM/COBOL system will conceal any data entered during
input for that statement but on completion of input will display the
data.  This COBOL system, however, will not display the data for this
ACCEPT statement once input has been completed.

Solution 

If you wish to display the data input for an ACCEPT statement with the
OFF and ECHO clauses specified, you must add a DISPLAY statement after
the ACCEPT statement.

Open EXTEND of Non-Existent File 

Because setting the RM directive sets the NOOPTIONALFILE directive, if
you try to open a non-existent file for I-O or EXTEND the Run-Time System
will give an error message.  For I-O, RM COBOL does the same.  However,
for EXTEND, RM/COBOL creates the file and opens it as if you had
specified OUTPUT.

Solution 

There are several solutions:

   *   Add the keyword OPTIONAL to the SELECT statement.  This makes this
       COBOL system create the file and open it for OUTPUT.

   *   Create the file, empty, before running your program.

   *   Specify the OPTIONALFILE directive.  This makes this COBOL system
       create the file and open it for OUTPUT. However, the behavior with
       files opened for I-O will now differ from RM/COBOL.



MPE/iX 5.0 Documentation