VMS / OpenVMS COBOL to ANSI COBOL (Fujitsu and MicroFocus) on x86 Intel Linux


VX/COBOL allows your VMS / OpenVMS COBOL application to run without manual changes on x86 Intel Linux

VX/COBOL is a full-featured VMS / OpenVMS COBOL to ANSI COBOL Compiler/Transpiler®. VX/COBOL allows VMS / OpenVMS COBOL source code to be compiled on Linux and multiple host machines. The application can be maintained in the original COBOL language or can be switched over to Linux ANSI COBOL Development Environments. VX/COBOL will convert 100% of supported VMS / OpenVMS COBOL syntax and Semantics to working COBOL (Fujitsu or Micro Focus).

 

Many of our Cobol clients have indicated that they wanted to see "Less Words" more "Examples" so, we've tried to strike a balance between Examples and keeping this site "Google Mobile [Responsive] Friendly"

 

Learn More

INTRODUCTION

VX/COBOL is an advanced utility that reads VMS / OpenVMS COBOL sources and rewrites these seamlessly as ANSI COBOL.

This processing can happen as part of the build process: continue developing and maintaining the original VMS / OpenVMS COBOL sources, leverage expertise of current developers, without disrupting the current development environment.

Current sources, directory layout, and logical controls for development, testing, and production are retained. Provide production Linux deployment of native executables and applications built from current VMS / OpenVMS sources.

VX/COBOL has proven its capabilities hundres of times, effortlessly converting code based of 8 Million to 12 Million lines of coBOL.

VX/COBOL is part of the Continuous Integration initiative and has been certified by Sector7 as "CI Capable".

VX/COBOL is so complete that entire IT departments continue to develop on VMS / OpenVMS COBOL and get release after release into production, at the same time, when each release is "pushed" the CI VX/COBOL : Translated all the COBOL from scratch, compiles all the cobol, links all the cobol, then run autoamted test sutes. The migration to Linux is simplh "part of the VMS / OpenVMS Development Cycle".

VX/COBOL is a mature product that detects and fixes problems that you'll never even know existed until you have prodution code issues.

VX/COBOL produces code that does not depend on any COBOL helper libraries beyond an external file handler specific to the chosen compiler; the generated code is pure COBOL

ITEMLISTS

IItemlists can be problematic when written on 32bit VMS / OpenVMS COBOL but used on 64bit ANSI COBOL. For a 32-bit itemlist, the pointer elements may be defined as 32-bit numeric types. These need to be changed to pointer types in order to work with the VXRT runtime.

The VXRT runtime routines will recognize 32 and 64 bit itemlist formats, however 64-bit pointer space must be provided by the COBOL compiler. Changing the type to pointer will compile the space properly.

VMS / OpenVMS COBOL

01 ITEM_LIST.
05 FILLER PIC S9(04) COMP VALUE 9.
05 FILLER PIC S9(04) COMP VALUE
EXTERNAL SJC$_QUEUE.
05 POINTER VALUE REFERENCE BQUE_NAME.
05 FILLER PIC S9(05) COMP VALUE 0.

 

ANSI COBOL

01 ITEM_LIST.
05 FILLER PIC S9(04) COMP VALUE 9.
05 FILLER PIC S9(04) COMP VALUE 134.
05 ANON_POINTER_003 POINTER VALUE NULL.
05 FILLER POINTER VALUE NULL.


This code is added to the initialization paragraph:

 

/s7/INIT.
MOVE FUNCTION ADDR(BQUE_NAME)
TO ANON_POINTER_003.

COPYBOOKS


Copy statements for using CDD Dictionary and copybooks with logical names are modified to conform to ANSI COBOL.

COPY "DEF0:CUST_FD.DEF"
COPY 'CDD$COPYBOOKS.CUST_REC' FROM DICTIONARY


By default, VX/COBOL will expand all COPY files into a single source file. Source changes are made by VX/COBOL acting as a preprocessor for all inputs.

Used this way, VX/COBOL can always take as input the latest sources from VMS / OpenVMS and these can be maintained as VMS / OpenVMS COBOL using current development staff with no retraining. This default behavior allows the VMS / OpenVMS COBOL to be maintained on VMS / OpenVMS or on Linux indefinitely.

Alternatively, the -Xc option will have VX/COBOL rewrite the source files out as their ANSI COBOL counterparts. This option allows the resulting ANSI COBOL to be maintained on the target Linux system thereafter.

-Xc   Do NOT expand COPY modules into the generated source file.

Normally, all COPY modules are expanded into the generated source, such that the new file is one large source file with no COPY modules.

This switch disables the expansion, leaving the COPY statement, with the specified Net COBOL conversions. Each COPY module file is translated into a new file with the same base name of the module file and the extension NEW. These new modules are placed into the folder specified by the environment variable XPP_MODULE_DIR. If this variable is not defined, a warning is given and no new module files are created.


DIVISION AND SECTION HANDLING


Each division, sections and declarations modified to confirm to ANSI COBOL include:

  • IDENTIFICATION DIVISION.
  • ENTRY
  • ENVIRONMENT DIVISION.
  • INPUT-OUTPUT SECTION
  • I-O-CONTROL
  • SELECT
  • DATA DIVISION.
  • FILE SECTION.
  • FD
  • SD
  • WORKING-STORAGE SECTION.
  • LINKAGE SECTION.
  • PROCEDURE DIVISION

POINTERS


VMS / OpenVMS COBOL allows initialization of pointer as reference to another variable. ANSI COBOL does not allow reference to be used in pointer initialization.
Pointers cannot be initialized with a reference to another variable. The initialization is changed to be NULL and a MOVE statement is issued in a /s7/INIT paragraph that is appended at the end of the program. A perform of this /s7/INIT paragraph is added at the beginning of the program. Nameless pointers are assigned a new name of ANON_POINTER_nnn with nnn incrementing from 001.

VMS / OpenVMS

05 POI COBOLNTER VALUE REFERENCE QUE_NAME2.
05 POINTER VALUE REFERENCE FILE_NAME.

 

ANSI COBOL

05 ANON_POINTER_001 POINTER VALUE NULL. 05 ANON_POINTER_002 POINTER VALUE NULL.

 

The following code is inserted in the PROCEDURE DIVISION:
PERFORM /s7/INIT THRU /s7/INIT_END.
...
TO ANON_POINTER_001.
MOVE FUNCTION ADDR(FILE_NAME) TO
ANON_POINTER_002.
/s7/INIT_END.
EXIT.

INTEGRATED RMS

VX/RMS (VMS / OpenVMS RMS Compatibility For ANSI Cobol) is integrated into the External File System for both Fujitsu and Micro Focus COBOL. When the VMS / OpenVMS application calls OPEN/CLOSE/ACCEPT/DISPLAY/READ/WRITE the VMS / OpenVMS options are diverted to VX/RMS which provides 100% RMS file handling and locking on Linux and Windows.

Some Examples of VMS / OpenVMS COBOL to ANSI COBOL

VERBS Changed by VX/COBOL to ANSI Functional Equivalents

ACCEPT ADD ALTER CALL
CANCEL CLOSE COMPUTE CONTINUE
DELETE DISPLAY DIVIDE EVALUATE
EXEC EXIT GENERATE GO
IF INITIALIZE INITIATE INSPECT
MOVE MULTIPLY OPEN PERFORM
READ RELEASE REPLACE RETURN
REWRITE SEARCH SET SORT
START STOP RUN STRING SUBTRACT
SUPPRESS TERMINATE UNLOCK UNSTRING
USE WRITE

COMPUTE

The text "+ /s7/PREC" is appended to any COMPUTE statement that has a divide "/" operation because of NetCOBOL computational differences.

VMS / OpenVMS COBOL

COMPUTE PCT_CNT ROUNDED = (SUB_CNT / TOT_CNT) * 100

ANSI COBOL

COMPUTE PCT_CNT ROUNDED = (SUB_CNT / TOT_CNT) * 100 + /s7/PREC

The CONSTANTS.COB file contains this definition.

77 /s7/PREC PIC 9V9(5) VALUE 0.


HP VMS / OpenVMS uses an intermediate data area for arithmetic operations. In The Rounding Phrase the intermediate data item always contains 31 digits of precision, with the rounding performed on the final move to the resultant variable.

 

01 SUB_CNT PIC 9(05) VALUE 7.
01 TOT_CNT PIC 9(05) VALUE 59.
01 PCT_CNT PIC 9(03)V99.
COMPUTE PCT_CNT ROUNDED = (SUB_CNT / TOT_CNT)
    * 100 ( 7 / 59 = 0.118644 ) * 100 = 11.86

PIC 9(05). 7 has no decimals
PIC 9(05). 59 has no decimals (intermediate .118644nnn has 31 decimals)
PIC 999 100 has no decimals
(intermediate 11.8644nnn has 31 decimals )
PIC 999.99 11.86 result

 

The NetCobol manual also talks about arithmetic operations and an intermediate result which contains the results of operations. NetCOBOL V10.4 Language Reference Page 258 section 6.3.6 Arithmetic Statements Page 259 section 6.3.8 ROUNDED Phrase Page 675 Appendix D Intermediate Results with focus on D.2.1 Fixed Point The intermediate data item contains the maximum digits seen from all operands in the statement.

 

SUB_CNT PIC 9(05). 7 has no decimals
TOT_CNT PIC 9(05). 59 has no decimals
PIC 999 100 has no decimals
PCT_CNT PIC 999.99 has 2 decimals.
( ROUNDED makes it 3 )
intermediate .118 has 3 decimals
intermediate 11.800 has 3 decimals
result PIC 999.99 11.80 result

 

By adding a zero with 5 decimal precision provides sufficient decimal places for most computations to be correct. Note that COBPP does not compute the decimal usage of data elements. Therefore a COBOL source could have data elements defined with large decimal places. SourceFile nnn: JMN3024I-W The intermediate result cannot contain more than 30 digits. The intermediate result is assumed to have 30 digits. SourceFile nnn: JMN3024I-W The intermediate result cannot contain more than 30 digits. The intermediate result is assumed to have 30 digits.

STATISTICS:
HIGHEST SEVERITY CODE=W,
PROGRAM UNIT=1

COMPUTE WS_AVG_CPH = ((((WS_AVG_MPT *
    (COST_AVG_HBM * COST_AVG_HC))
    + (WS_AVG_NH * COST_AH)) / WS_AVG_NH)
    / (WS_COST_TF / COST_AVG_HC)) + /s7/PREC

01 WS_AVG_CPH PIC 9(08)V9999.
01 WS_AM PIC 9(08)V9999.
01 WS_COST_TF PIC 9(04)V9999.
01 WS_AVG_NH PIC 9(08)V9999.
  05 COST_AVG_HBM PIC 9(04)V9999.
  05 COST_AVG_HC PIC 9(04)V9999.
  05 COST_AH PIC 9(04)V99.

I-O-CONTROL (A subset of examples)

VMS / OpenVMS uses the APPLY LOCK HOLDING statement to set file locking characteristics. ANSI COBOL uses LOCK MODE on the SELECT statement.


For each file listed in the APPLY LOCK HOLDING statement, the clause LOCK MODE IS AUTOMATIC is added in the FILE-CONTROL paragraph on the SELECT statement for that file.
The APPLY LOCK HOLDING statement is made into a comment.

VMS / OpenVMS COBOL

INPUT-OUTPUT SECTION.
FILE-CONTROL
  SELECT OPTIONAL CUST_FILE ASSIGN TO CUST
    ORGANIZATION IS INDEXED
    FILE STATUS IS FILE_STATUS_BYTE
    ACCESS IS DYNAMIC
    RECORD KEY IS CUST_KEY
    ALTERNATE RECORD KEY IS CUST_ALPHA_CODE.

I-O-CONTROL.
APPLY LOCK HOLDING ON CUST_FILE.

ANSI COBOL


INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OPTIONAL CUST_FILE ASSIGN TO "CUST,EXFH"
    ORGANIZATION IS INDEXED
    FILE STATUS IS FILE_STATUS_BYTE
    ACCESS IS DYNAMIC
    RECORD KEY IS CUST_KEY
    ALTERNATE RECORD KEY IS CUST_ALPHA_CODE
ALOCK MODE IS AUTOMATIC.


CALL

The word GIVING is replaced with RETURNING. Parameters that are missing or given as OMITTED are replaced with BY VALUE 0.The procedure name is shifted to lower-case to match program-ids that are also shifted (see rule S.1.1).

VMS / OpenVMS COBOL

CALL "LIB$GETJPI" USING BY REFERENCE
GETJPI_ITEM_CODE
    OMITTED
    OMITTED
    BY REFERENCE GETJPI_GROUP_NO
    OMITTED
    OMITTED
GIVING RETURN_CODE

 

ANSI COBOL

CALL "lib$getjpi" USING BY REFERENCE
GETJPI_ITEM_CODE
    BY VALUE 0
    BY VALUE 0
    BY REFERENCE GETJPI_GROUP_NO
    BY VALUE 0
    BY VALUE 0
RETURNING RETURN_CODE

 

Net COBOL does not support parameters passed by descriptor. Therefore a temporary 64-bit descriptor is created and passed by reference. Because this involves multiple MOVE and COMPUTE statements, besides the CALL, all these statements are placed inside a PERFORM block.

ANSI COBOL

CALL "LIB$STOP" USING BY VALUE RETURN_CODE,
  2,
  BY DESCRIPTOR "ACTION_RECOG"
WS_PROGRAM_ID
PERFORM
  MOVE "ACTION_RECOG" TO /s7/LITERAL(1)
  COMPUTE DSC_LEN OF /s7/DESCRIPTOR(1) =
    FUNCTION
    STORED-CHAR-LENGTH(/s7/LITERAL(1))
    MOVE FUNCTION ADDR(/s7/LITERAL(1)) TO
    DSC_PTR OF /s7/DESCRIPTOR(1)
    COMPUTE DSC_LEN OF /s7/DESCRIPTOR(2) =
    FUNCTION LENGTH(WS_PROGRAM_ID)
    MOVE FUNCTION ADDR(WS_PROGRAM_ID) TO
    DSC_PTR OF /s7/DESCRIPTOR(2)
CALL "lib$stop" USING BY VALUE RETURN_CODE,
    2,
    BY REFERENCE /s7/DESCRIPTOR(1)
    /s7/DESCRIPTOR(2)
END-PERFORM

LITERALS AND OPERATORS

Literals


VMS / OpenVMS COBOL allows literals to be empty. ANSI COBOL requires literals to have a value.
Quoted strings must:

  • Contain at least 1 character,
  • No more than 160 characters,
  • And be followed by a space, comma, or period.
  • Empty strings as in "" are replaced with the word SPACES.


VMS / OpenVMS COBOL

MOVE "" TO MYVAR CALL"routine"using by value 0

 

ANSI (Net COBOL)

MOVE SPACES TO MYVAR CALL "routine" USING BY VALUE 0

 

Net COBOL will give compile errors on strings that are greater than 160 characters, and compile warnings for strings that contain a tab character.

file.cob 14: JMN1023I-S The literal has exceeded the maximum length.
    The first x characters is assumed to be the literal.

file.cob 1004: JMN1486I-I A tab is included in a literal.
    The tab is accepted as code.

Operators
VMS / OpenVMS COBOL does not require a space between operators or around literals. ANSI COBOL does require a space between operators, words, or literals.

VMS / OpenVMS COBOL Operators
   Addition
 -  Subtraction
 *  Multiplication
 /  Division
 =  Equal or Assignment
 **  Exponentiation
 >  Greater Than
 ≥  Greater Than Or Equal To
 <  Less Than Or Equal To
 ≤  Less Than Or Equal To
 ,  Comma


VMS / OpenVMS COBOL

MOVE "-" TO V1,V2,V3, STRING "PRO_NUMBER",",","EXCEPTION_REASON"

IF TEST_FLAG="Y"
  PERFORM UNTIL (WS_DONE = "Y" OR WS_COUNT =1)
    MOVE TABLE(IDX,1) TO SMALL_TABLE(IDX,1)
    IF (TABLE(IDX) NOT= 0)
      COMPUTE TTL = A_SHIP+ B_SHIP
      COMPUTE TTL = (C_RECS(IDX,3) /
      T_RECS(IDX,4))* 100

 

ANSI COBOL

MOVE "-" TO V1, V2, V3
STRING "PRO_NUMBER", ",", "EXCEPTION_REASON"
IF TEST_FLAG = "Y"
  PERFORM UNTIL (WS_DONE = "Y" OR WS_COUNT = 1)
    MOVE TABLE(IDX, 1) TO SMALL_TABLE(IDX, 1)
    IF (TABLE(IDX) NOT = 0)
      COMPUTE TTL = A_SHIP + B_SHIP
      COMPUTE TTL = (C_RECS(IDX, 3) /
      T_RECS(IDX, 4)) * 100