Producing Executable Code [ Micro Focus COBOL Compatibility Guide ] MPE/iX 5.0 Documentation
Micro Focus COBOL Compatibility Guide
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.
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.
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, run the tabx program before submitting your
source program to this COBOL system. This expands TAB characters into a
form which is acceptable to this COBOL system. See the chapter
Converting an RM/COBOL Application for details on the tabx program.
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.
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).
Reserved Words
When you set system directives, such as MF or ANS85, this activates
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 system directive to remove a specified reserved word from the
reserved word list. See your COBOL System Reference for details of the
REMOVE directive, and your 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.
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 your
Language Reference - Additional Topics.
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 your Language Reference.
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.
MPE/iX 5.0 Documentation