PreviousCompatibility with RM/COBOL Converting RM/COBOL Data TypesNext

Chapter 5: RM/COBOL Conversion Issues

The syntax of most of the RM/COBOL source programs which you supply to this system will be accepted, and will run successfully. Sometimes, however, this COBOL system might reject some of the syntax in your original RM/COBOL source program, or might cause your program to behave unexpectedly at run time.

This COBOL system has been designed in such a way that there will probably be few or none of these problems. If, however, you do encounter any syntax discrepancies, this section details the known features which may cause errors, or which may not behave as you are expecting, at run time. Hints are also given on how you can either rectify the cause of such errors, or emulate the RM/COBOL type of behavior under this system.

5.1 Producing Executable Code

The following sections detail the known areas of difficulty you may encounter when you submit RM/COBOL source programs to this COBOL system to produce executable code. Hints on how you can avoid these areas are also given.

5.1.1 Length of Nonnumeric Literals

The RM/COBOL system allows you to write source programs containing nonnumeric literals in the Procedure Division that are up to 2047 characters long. However, this COBOL system will accept only nonnumeric literals in the Procedure Division that are up to 160 characters long, as specified in the ANSI X3.23-1985 COBOL standard.

Solution:

Amend your source program by creating a new data item in the Working-Storage Section, and assigning the literal to the VALUE clause. If you then use the data item in the Procedure Division in the place of the original long literal, this COBOL system will accept your source program.

Example:

The RM/COBOL system accepts the following line of code but this COBOL system does not:

 move "abc...aa" to screen-buffer.

where abc...aa represents a literal of 1500 characters.

Change the code to:

 move long-literal-1 to screen-buffer.

Define a new item in the Working-Storage section of your source program:

 01 long-literal-1  pic x(1500) value "abc...aa". 

You can now submit your amended RM/COBOL source program to this COBOL system and it will be accepted successfully.

5.1.2 Source Code in Columns 73 to 80

This COBOL system ignores any of the code in your source programs which lies within columns 73-80 inclusive.

Solution:

The illegal COBOL code has probably resulted from expanding TAB characters in your source program to standard TAB stops. If your source program contains TAB stops, convert them to spaces before submitting the program to this COBOL system.

5.1.3 Linkage Section in Main Program

Under RM/COBOL, if the main program has a Linkage Section, it is initialized by the parameter passed on the command line. Under this COBOL system, it is illegal to reference Linkage Section items in the main program.

Solution:

Use the following root program to pass the command line and its length to your main program:

 identification division.
 program-id.     root.
 environment division.
 configuration section.
 source-computer. cobol2.
 working-storage section.
 01  main-linkage.
     03  cmd-length                  pic 9(4) binary value 0.
     03  cmd-line                    pic x(100).
 procedure division.
 accept cmd-line from command-line.
 if cmd-line not = spaces
     inspect cmd-line tallying cmd-length for
     characters before initial space
 end-if
 call "main" using main-linkage.
 exit program.

5.1.4 Extended I-O Status Codes

Under RM/COBOL, your program must call an RM/COBOL internal subprogram named C$RERR in order to get an extended file status code. Under this COBOL system, extended file status codes are reported in the second byte of the file status.

Solution:

C$RERR can be emulated by the following program.

 identification division.
 program-id.     crerr.
 environment division.
 configuration section.
 source-computer. cobol2.
 working-storage section.
 01  mfc2-file-status.
     03  mfc2-status-1               pic x.
     03  mfc2-status-2               pic x.
     03  mfc2-status-binary redefines mfc2-status-2
                                             pic 99 comp-x.
 linkage section.
 01  rm-extended-status.
     03  rm-extended-status-1        pic 9.
     03  rm-extended-status-2        pic 999.
 procedure division using rm-extended-status.
     move rm-extended-status to mfc2-file-status.
     if mfc2-status-1 = "9"
         move mfc2-status-binary to rm-extended-status-2
     else
         move "00" to rm-extended-status ( 3 : 2 )
     end-if
     exit program.

For the above example to work correctly, the first two bytes of LINKAGE item RM-EXTENDED-STATUS must contain the COBOL file status as in the following example:

 file-control.
     select optional seq-file
         assign to random "myfile"
         organization line sequential
         status is io-file-status.
 working-storage section.
 01  io-file-status
     03  rm-extended-status  pic x(4).

5.1.5 Reserved Words

System directives, such as MF or ANS85, activate various features and their associated reserved words in this COBOL language. As a result, you may receive errors when you submit source programs to this COBOL system with such directives set, because data items in them might have the same names as words which are defined as reserved words.

Solution:

Edit your source programs to rename the offending data item(s), or use the REMOVE Compiler directive to remove a specified reserved word from the reserved word list.

NetExpress:
See the Compiler Directives help for full details of the REMOVE directive.

Server Express:
See the chapter Directives for Compiler in your Server Express User's Guide for full details of the REMOVE Compiler directive.

See the Language Reference for details of reserved words.

Example:

Your RM/COBOL source program may contain the following lines of code:

     .... 
     03 sort   pic 99. 
     .... 
     move 1 to sort

If you submit this to this COBOL system you will receive an error as this system supports the SORT verb, while the RM/COBOL system does not. However, if you specify the REMOVE"SORT" directive when you submit this source program to this COBOL system, you will receive no errors.

5.1.6 Numbering of Segments

The RM/COBOL system allows you to specify segment numbers greater than 99. However, this COBOL system conforms to segment number limit specified in the ANS X3.23-1985 COBOL standard, and allows you to specify segment numbers only in the range 0 to 99 inclusive.

Solution:

Recode your source programs so that segment numbers greater than 99 are less than or equal to 99. Make sure that any new segment numbers you allocate do not clash with an already existing segment number. Segment numbers between 0 and 49, inclusive, are used by this COBOL system to indicate fixed portions of your object program, while segment numbers 50 to 99, inclusive, indicate independent segments. For details on the use of segmentation and segment numbers in your source programs, see the Language Reference.

5.1.7 Program Identification and Data-names

The RM/COBOL system allows the name given in the PROGRAM-ID phrase and a data item in that program to be the same. However, this COBOL system does not allow the use of the same name for the PROGRAM-ID and a data item in the program, and requires instead that each should be unique.

Solution:

Change either the program-name in the PROGRAM-ID paragraph, or the name of the data item, so that you follow the conventions of this COBOL language as given in the Language Reference.

5.1.8 Duplicate Paragraph-names

If your program contains duplicate paragraph-names, both COBOL systems will resolve references to the duplicate paragraph-names in the same way, provided the duplicate paragraph-names are only referenced from within the sections in which they are declared. If, however, you reference a duplicate paragraph-name from a different section from the one it is declared in, the RM/COBOL system will assume that the reference is to the next declaration of the duplicate paragraph-name, whereas this COBOL system will give an error when you are producing intermediate code.

Solution:

To ensure that references to duplicate paragraph-names are correctly resolved, you must qualify a reference to a duplicate paragraph-name by adding the section-name in which it is declared.

Example:

If your source code contains the following:

      .... 
      perform para-2. 
      .... 
 sect-1 section. 
      para-1. 
      .... 
      para-2. 
      .... 
 sect-2 section. 
      para-2. 
      ....

the RM/COBOL system will resolve the reference to para-2 in the PERFORM statement by using the declaration of para-2 in the sect-1 SECTION. Under this COBOL system, however, you must qualify the reference to the duplicate paragraph-name in your source code by using the PERFORM para-2 OF sect-1 statement.

5.2 Running the Code

Once you have successfully submitted your RM/COBOL source program to this COBOL system and produced executable code, you might encounter difficulties when you try to run this code under this system. Alternatively, the code might run but you might 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 might encounter, and offer hints on how you can avoid them.

5.2.1 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.

You also need to ensure that the T run-time switch is not set, as this might also change the size of the record.

NetExpress:
See the Run-time Configuration help topic for details of this switch.

Server Express:
See the chapter Descriptions of Run-time Switches in your Server Express User's Guide for full details of the REMOVE Compiler directive.

5.2.2 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.

5.2.3 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:

<left-arrow>]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 the Language Reference help 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.

NetExpress:
See the Compiler Directives help for full details of the available directives.

Server Express:
See the chapter Directives for Compiler in your Server Express User's Guide for full details of the available directives.

See the Language Reference help for a list of which reserved words are enabled by each directive.

5.2.4 Printer Output is Written to Disk

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

Solution:

NetExpress:
Rewrite your programs to use the PC_PRINT_ library routines. See the Library Routines help for details.

5.2.5 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 Compatibility with RM/COBOL for details. This might 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 might 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."

5.2.6 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.

5.2.7 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.

5.2.8 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.

5.2.9 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:

5.2.10 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).

5.2.11 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 the Language Reference help for details of the use of column numbers in this COBOL system.

5.2.12 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 STATUS is set to 1 and status key 2 is set to 0. This indicates that there is no next logical record. If you try 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 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.

5.2.13 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).

5.2.14 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.

5.2.15 Open EXTEND of Nonexistent File

Because setting the RM directive sets the NOOPTIONALFILE Compiler 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:


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousCompatibility with RM/COBOL Converting RM/COBOL Data TypesNext