Chapter 4: Compatibility with RM/COBOL

This COBOL system supports certain extensions that enable you to submit source programs written in the RM/COBOL language.

To convert an RM/COBOL application and make it suitable for input to this COBOL system:

  1. Submit your RM/COBOL source programs to this COBOL system.
  2. Compile the programs with RM directive set

RM/COBOL Source Programs

To submit RM/COBOL source programs to this COBOL system which contain syntax not supported in the standard COBOL language, you must set the RM Compiler directive. See the topic RM for full details of of this Compiler directive.

When you set the RM directive the additional syntax required is enabled. See the section Ryan McFarland COBOL V2.0 Syntax Support in your Language Reference for details of syntax support for Ryan McFarland COBOL V2.0.

You will need to alter your source programs only if they contain RM/COBOL features which are not supported by this COBOL system. You might also want to change your source programs if they contain features which behave differently under both COBOL systems, in order to force this system to emulate the behavior of the RM/COBOL system.

You must change any tab characters to spaces before submitting any source programs to this COBOL system.

The RM Directive

By default, the standard COBOL language supported by this system, as documented in the Language Reference , already supports much of the RM/COBOL syntax and behavior. You can, however, enable some additional RM/COBOL syntax, using the RM Compiler directive. Setting the RM directive when you submit your RM/COBOL source programs to this COBOL system, ensures that most of the programs are accepted the first time they are submitted. The additional syntax enabled by the RM directive is documented in the section Ryan McFarland COBOL V2.0 Syntax Support in your Language Reference.

If you normally set the ANSI switch when you submit your RM/COBOL source programs to the RM/COBOL system, you must specify the ANSI parameter with the RM directive when you submit these programs to this COBOL system.

Setting the RM directive automatically sets additional Compiler directives, namely NOTRUNC, OLDINDEX, NOOPTIONAL-FILE, RETRYLOCK, ALIGN"2" and SEQUENTIAL"LINE". See the topic Compiler directives for full details of these Compiler directives.

The system will also behave as if you had specified the following syntax:

sign trailing separate

for signed numeric data items, and:

lock mode is automatic

for each file in the program which has no explicit locking syntax declared. When you set the RM directive with the ANSI parameter, the same Compiler directives are set as for the RM directive, except that the SEQUENTIAL directive is set as SEQUENTIAL"RECORD". Also, the system behaves as if you had specified the syntax:

sign trailing included

for signed numeric data items, and:

lock mode is automatic

for each file in the program which has no explicit locking syntax declared.

We also recommend that you set the NOMF directive when you submit your RM/COBOL source programs to this COBOL system. This ensures that only those words which are treated as reserved words under the ANSI '74 COBOL standard are regarded as reserved words by this COBOL system.

Setting the NORM directive disables the syntax enabled when the RM directive was set, and automatically resets the additional Compiler directives to NOSPZERO, TRUNC"ANSI", NOOLDINDEX, OPTIONAL-FILE, NORETRYLOCK, ALIGN"8" and SEQUENTIAL"RECORD". Additionally, the system behaves as if you had specified the syntax:

sign trailing included

for signed numeric data items, and:

lock mode is exclusive

for each file in the program which has no explicit locking syntax declared. The final states of the additional directives set when you use the NORM directive are not necessarily the same as their initial default states.

RM/COBOL File Status Codes

RM/COBOL file status codes are either ANSI'74 file status codes or can be mapped onto extended file status codes, as shown below.

Status Key 1 Status Key 2 Extended File Status Code Description
9 0 9/143 REWRITE/DELETE not after successful READ
9/147 Wrong open or access mode for READ/ START.
9/148 Wrong open or access mode for WRITE.
9/149 Wrong open or access mode for REWRITE/ DELETE.
1 9/142 File not open - cannot be closed.
2 9/141 File already open - cannot be opened.
3 9/138 File is closed with lock - cannot open.
9/210 File is closed with lock.
4 9/013 File not found.
9/035 Incorrect access permission.
9/037 File access denied.
9/139 Record length or key inconsistent.
9 4 9/188 Filename too large.
6 9/146 No current record defined for sequential read.
8 9/071 Bad indexed file format.
9 9/065 File locked.
9/068 Record is locked.

Perform Statements

PERFORM statements are not treated in the same way by both COBOL systems. This COBOL system uses a stack-based perform handling system, while the RM/COBOL system associates a return address with a specific procedure name. As a result, under the RM/COBOL system, all end-points to PERFORM statements are always active until they are used. However, under this system, only the end-point of the last PERFORM statement is active at any one time.

You must set the PERFORM-TYPE directive with the RM parameter if this COBOL system is to emulate the behavior of RM/COBOL PERFORM statements.

Table Bound Checking

If you try to run a program under this COBOL system which contains a subscript value greater than the size of the table to which it refers, the run-time system will produce an error indicating this. Under the RM/COBOL system, however, no such table bound checking is done. Therefore, if you wish to disable table bound checking in this COBOL system, you must use the NOBOUND directive.

If you use the NOBOUND directive when running intermediate code, you will be able to access data beyond a table's bounds by using a subscript value greater than the table size. Use of the NOBOUND directive when you are producing intermediate code will also disable bound checking when running generated code. However, if you wish to access data beyond a table's bounds when running generated code, you must also use the directive NOBOUNDOPT.

Note: When you use the NOBOUNDOPT directive, performance will be impaired.

Types of Data

This COBOL system always allocates the same number of bytes to a data item as in the original program, but might redefine its contents when it is converted. Therefore, you must be aware that if these items are redefined, and the program logic expects to find a certain binary value in the redefinition, you might not receive the behavior you are expecting at run time. At run time, this COBOL system might treat the ON SIZE ERROR clause differently from the RM/COBOL system. See the chapter RM/COBOL Conversion Issues for further details.

The following sections define how this COBOL system treats COMPUTATIONAL, COMPUTATIONAL-1 and COMPUTATIONAL-6 types of data.

COMPUTATIONAL (COMP) Data Types

This COBOL system treats any COMP data items in your RM/COBOL source program as the standard Micro Focus COBOL DISPLAY format. The difference in the internal representation of such data in the two systems is that this COBOL system always sets the most significant four bits of each byte to the value 3, while the RM/COBOL system always sets such bits to the value 0.

For example, under the RM/COBOL system:

PIC 999 COMP VALUE 123

is held in three bytes as hexadecimal value 01 02 03

while under this COBOL system:

PIC 999 VALUE 123

is held in three bytes as hexadecimal value 31 32 33.

COMPUTATIONAL-1 (COMP-1) Data Types

For each data item declared as USAGE COMP-1 in your RM/COBOL source program, regardless of its picture-string, this COBOL system allocates a 2-byte signed binary data item. This data item is capable of holding a hexadecimal value in the range -32768 to +32767. That is, this COBOL system treats each RM/COBOL USAGE COMP-1 data item as though it had a standard Micro Focus COBOL picture-string of S9(4) COMP. See your Language Reference for details on the standard Micro Focus COBOL language.

COMPUTATIONAL-6 (COMP-6) Data Types

This COBOL system treats any COMP-6 data items in your RM/COBOL source program as the standard Micro Focus COBOL COMP format. If, as a result of this, less data space is allocated to each item than would be under the RM/COBOL system, this COBOL system pads the space with a byte containing a zero, as shown in the following table:

RM COMP-6 PICTURE clause Bytes allocated when converting to Micro Focus COBOL COMP PICTURE clause Number of bytes containing leading zeros required to precede COMP PICTURE clause
9(1) 1 NONE
9(2) 1 NONE
9(3) 2 NONE
9(4) 2 NONE
9(5) 3 NONE
9(6) 3 NONE
9(7) 4 NONE
9(8) 4 NONE
9(9) 5 NONE
9(10) 5 NONE
9(11) 5 1
9(12) 5 1
9(13) 6 1
9(14) 6 1
9(15) 7 1
9(16) 7 1
9(17) 8 1
9(18) 8 1
Table 4-1: COMP-6 to COMP Conversion

The padding byte precedes the converted field, and is therefore included in any redefinition of group fields which contain the converted field. However, the padding byte would not be included if you redefined only the converted field. If you wish to ensure that the padding byte is included in the redefinition of the converted field, you must add a field at a higher level immediately before the converted field, and redefine this new field instead.

The DECIMAL POINT IS COMMA Clause

This COBOL system cannot process the DECIMAL-POINT IS COMMA clause in the Special-Names paragraph. To overcome this limitation remove the DECIMAL-POINT IS COMMA clause.

PICTURE Character-strings

The maximum length of a PICTURE character-string in a record description is 20 characters. However, you can overcome this limitation by splitting any PICTURE character-string which exceeds this limit into two, and defining a FILLER item with a PICTURE character-string which corresponds to the size of the second half of the original string.


Copyright © 2006 Micro Focus (IP) Ltd. All rights reserved.