Running the Code [ Micro Focus COBOL Compatibility Guide ] MPE/iX 5.0 Documentation
Micro Focus COBOL Compatibility Guide
Running the Code
Once you have successfully submitted your RM/COBOL source program to this
COBOL system and produced executable code, you may encounter difficulties
when you try 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 areas of difficulty you may encounter, and offer hints on
how you can avoid 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 operationson 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.
You also need to ensure that the Trun-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 can differ under the two systems. So can 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. 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 successfully 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 try to display them as literals but the
results are undefined.
Solution.
Remove the control sequences from your source program and replace with
the equivalent Micro Focus COBOL syntax. In the above example, use the
syntax WITH UNDERLINE. See your Language Reference for a full description
of all Micro Focus 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 and Dialect Summary
Part 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
the chapter RM/COBOL Source Compatibility 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:
01 birthdate-1 pic 9(6) comp-6.
01 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:
01 birthdate-1 pic 9(6) comp-6.
01 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.
01 birthdate-1a pic 9(6).
01 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.
Solution.
Try to ensure that the capacity of any data items in your source programs
is 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.
Solution.
Specify the ON SIZE ERROR clause.
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:
01 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 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 filesdo not detect or acquire locks if they are opened for
output. This is regardless of whether you specify the WITH LOCK
phrase
* relativeand 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.
If this feature causes 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.
03 item-1 pic x.
03 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 try 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, the position of that item on the screen under this COBOL
system will differ from its position under the RM/COBOL system.
Solution.
Ensure that column numbers do not exceed 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, 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 try to READ a sequential file in either
COBOL system because you have reached the end of the file, status key 1
in the FILE STATUSis set to 1 and status key 2 is set to 0. This
indicates that there is no next logical record. If you try to READthe
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 try to READ the same file again under the RM/COBOL system, status key
1 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 tests 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 OFFand ECHOclauses 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 Nonexistent 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.
Several solutions are available:
* Add the keyword OPTIONALto 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