🛠️ P3/COBOL 25.1.0-SNAPSHOT is available for preview.
User Guide
Language Summary

Language Summary

P3/COBOL implements a combination of extensive COBOL language elements needed to accept existing COBOL program logic with little or no reprogramming or conversion effort and additional language elements and features that increase the reliability and reach of new COBOL code needed in the modern Java environment.

The P3/COBOL language base is the 1985 ANSI/ISO standard (with amendments). Unless specifically mentioned otherwise, it can be assumed that all of the 1985 syntax, features and behavior are fully supported by P3/COBOL.

Additional COBOL language extensions commonly used in mainframe (e.g., IBM and Fujitsu/Siemens COBOL dialects) applications and in applications using Micro Focus COBOL variants are also included in P3/COBOL, as are many selected features of less common COBOL dialects and standards (e.g., X/Open). Whenever possible, these and other extensions that P3/COBOL supports comply with the current COBOL standard (ISO 1989:2014), especially when they apply to a capability that is important to P3/COBOL’s application modernization goal.

Finally, P3/COBOL includes unique extensions crucial to its goal of being the most progressive of the COBOL alternatives available.

As a whole the P3/COBOL language is well-equipped as the ideal language for serious, platform-independent, Java-centric business logic remodeling.

1985 Standard COBOL Language Modules and Features

P3/COBOL fully complies with the highest levels of the 1985 standard, with the exception of some archaic and/or obsolete modules. Specifically, P3/COBOL is tested against and passes at the highest level 100% of the approximately 9,000 CCVS tests for the following modules:

  • Nucleus (NC)
  • Intrinsic Functions (IF)
  • Source Management (SM)
  • Inter-program communication (IC)
  • Sequential Files (SQ)
  • Relative Files (RL)
  • Indexed Files (IX)
  • Sort/Merge (ST)
  • Obsolete Elements (OB, as applicable)
  • Report Writer (RW)1

P3/COBOL does not implement the obsolete Communication (CM) and Debug (DB) modules, deprecated and removed by recent standards.

2014 Standard Features and Extensions

In addition to the preceding, many important additions to the COBOL language in the INCITS/ISO/IEC 1989:2014 [2014] standard are included in P3/COBOL. These include (but are not limited to):

  • 31 digit numeric variables (configurable from 1 to 63 digits as extension)
  • Enhanced file sharing and locking syntax
  • Multi-part key support
  • Full TYPEDEF and SAME AS support
  • Enhanced INITIALIZE statement (superset of RM/COBOL enhancements)
  • Extended abbreviated relational expressions
  • Extended EVALUATE WHERE conditions
  • NATIONAL and NATIONAL-EDITED elementary and group usage, national literals and hexadecimal values, national alphabets, and national symbolic characters. See All About Alphabets and Such.
  • Object-oriented syntax1

Legacy Mainframe and Micro Focus Features and Extensions

Many of the language extensions permitted by the various mainframe dialects and by the Micro Focus products are either difficult to find and change, or are useful in a modern COBOL environment. Those features are included in P3/COBOL as well, and are being identified and added as needed. They currently include (but are not limited to):

  • Multiple entry-point (ENTRY) programs (including recursive programs)
  • Various dialect-specific PERFORM behavior alternatives, in addition to standard stack-based PERFORM behavior
  • Relaxed syntax rules for divisions, sections and paragraphs
  • COMP-5 (native binary)
  • COMP-X (byte-oriented binary)
  • Multiple VALUE table initial values
  • Expanded intrinsic FUNCTION usage
  • "Noise" words in conditionals and elsewhere
  • Duplicate paragraph names allowed
  • Leading statements preceding initial section/paragraph
  • Expanded file SELECT ... ASSIGN TO variants

RM/COBOL Language Extensions

In addition to the 2014 COBOL standard extensions, P3/COBOL is a fully-compatible superset of the RM/COBOL language dialect including (but not limited to) the following features:

  • Relaxed syntax in many areas
  • RM ACCEPT/DISPLAY extensions (including pop-up windows)
  • Extensive special registers provided
  • Auto-defining status variables
  • LIKE (regular expression support) and START ... WHILE LIKE ...
  • Unlimited length variable names
  • Zero-length group definitions
  • Nested OCCURS … DEPENDING ON (no ODO slide)
  • Unpacked decimal (COMP)
  • Strictly bounded pointers
  • Binary allocation override (BINARY(n), POINTER(n), COMP-5(n))
  • Unsigned packed decimal (COMP-6)

P3/COBOL Extensions and Features

Most importantly, P3/COBOL includes key features many of which are not found in any other COBOL. All of these directly address the mission to make COBOL the best language for expressing business logic in a modern Java environment.

Java Augmented Syntax

✨ Many of the significant problems with any COBOL program result from the basic language philosophy rooted in the best practices of mid-1960’s. This include both the high-level expression of program structure and the low-level scoping of control using asymmetric delimiting. Most problematic and error-prone of all is the significance of the period separator (. ) in determining nested statement and control flow scope or extent. In order to allow much more robust and maintainable COBOL programs, P3/COBOL permits an alternative form for many of the COBOL language constructs. These alternatives are completely optional and are represent exactly the same semantics as the traditional COBOL expression. Furthermore, they may be freely intermixed with traditional syntax, so that a programmer may employ them incrementally to improve the readability and maintainability of COBOL code.

See Java Augmented Syntax (JAS) for more information.

Embedded Java Code

P3/COBOL is Java-centric realization of the COBOL language. That means that what is written by the programmer in COBOL generates pure-Java code to perform precisely the operation(s) specified in the COBOL language. To the rest of the application environment, the P3/COBOL program is indistinguishable from any other Java class (or program). Often, in a mixed language environment such as that targeted by P3/COBOL, the need arises to express an operation in the "native" language of the environment, in this case Java. P3/COBOL provides a unique and seamless way to do that. Called "embedded Java", you can, at any time within the procedure division of the COBOL program, program using the native Java language and then fall back into the COBOL language. This allows, among other things, the ability to easily instantiate Java classes and invokes methods in the most readable, natural way without having to express inherently non-COBOL actions in a stilted and often makeshift COBOL manner. Furthermore, while in the embedded Java mode, the COBOL program may still have full access the COBOL data items by using “COBOL embedded in Java” capability. Together this provides the means to not only provide small sections of Java-logic in a COBOL program as appropriate, but also to essentially "wrap" a Java function or algorithm in a COBOL wrapper that appears to all of the COBOL programs as a pure COBOL program.

See Java Extensions for more information.

Built-in Embedded SQL (ESQL)

Most modern business applications choose to store persistent information in relational databases. This is done for a variety of reasons, not the least of which is that the RDBMS is essentially language independent. P3/COBOL provides a built-in capability to allow the embedding of static and some dynamic SQL directly within the COBOL program. This is often done using proprietary pre-compilers provided by the RDBMS supplier, but the P3/COBOL approach avoids the need for pre-compilation by compiling ESQL into native Java JDBC functions. Any database that supports the JDBC interface may be used, including Oracle, DB2, MySQL, and many others.

See Embedded SQL for more information.

Universal Data Import and Export

Another of the problems of COBOL business logic embedded in a modern application framework is the fact that while COBOL represents data in a form that is ideal for business calculations and manipulations, it is completely foreign to every other programming language and system likely to share the same framework. Piecemeal solutions to this problem have been tried over the past few years, with varying degrees of success. Building on this experience of successes and failures, P3/COBOL’s developers include two new statements that can be used to import and export COBOL information to any other form without obscuring the program logic and without the need for a collection of special-purpose subprograms and features.

See Importing and Exporting XML Data for more information.


1 Syntax checking only.