P3/COBOL Limits and Ranges
P3/COBOL is, of course, designed for 32/64-bit Java Virtual Machine runtime environments. For that reason, many of the limitations of P3/COBOL programs derive from limitations in the Java byte-code class files and the JVM architecture itself. Fortunately, most of these are not restrictive and it would be highly unusual for a user-written program to encounter them.
In general, most limitations result from the maximum unsigned algebraic value that can be stored in a Java int with
a zero or positive value, (used for most loop control and indexing), or approximately 2,000,000,000 (2G). Any of the
limitations that are specified as 2G (sometimes with units specified) are actually 2^31 - 1, of course, further
subject to the availability of memory (both virtual and physical) and other resources at the time the program is
compiled and/or run. In particular, a program running in a 32-bit Java environment will be restricted by available
mapped memory far more than the limits below. Additionally, the Java class architecture restricts many Java structures
to finite limits regardless of memory available (e.g., methods/class, bytes/method, constants/class). The P3/COBOL
compiler attempts to mitigate most of those architectural limits, but in some cases where they cannot or have not been
mitigated, a range specified below could be further restricted.
Similarly, any limit specified as no limit means that no limit is imposed by P3/COBOL or Java itself, but that usage
is subject to memory and other resource availability imposed by the operating system or other subsystem. This will
always impose the practical limit to such items.
| Limit | Range |
|---|---|
| Maximum total number of unique user-defined words | 2G |
| Size of user-defined words (number of characters) | 2G |
| Maximum number of user-defined data items in a program | 2G |
| Maximum length of any user-defined data item in storage (including top-level group items) | 2G bytes |
| Maximum number of occurrences of a table element | 2G |
| Maximum digits for user-defined numeric data items | 34 1 |
| Maximum decimal precision of numeric intrinsic function results | 34 digits 2 |
| Maximum decimal precision for mathematical calculations | 34 digits 2 |
| Maximum number (depth) of subscript levels | 255 6 |
| Maximum value of an index item | 2G |
| Maximum number of open files | 2G 3 |
| Maximum file Size | no limit 3 |
| Maximum file record length | 2G bytes 4 |
| Maximum key length | 2G characters 4 |
| Maximum number of keys declared for an indexed file | 2G 4 |
| Maximum number of key parts defined for a single key | 2G 4 |
| Maximum size of a key part | 2G characters 4 |
| Maximum number of programs in a single compilation unit | 2G |
| Maximum number of nested programs in a program | 2G |
| Maximum number of procedures (sections and paragraphs) in a (nested) program | 65,535 5 |
| Maximum number of sentences in a program/paragraph/section | no limit |
| Maximum number of statements in a sentence/paragraph | no limit |
| Maximum number of USING items as formal or actual arguments | 253 |
| Maximum length of a single literal value | 2G |
| Maximum length of all literals in a program | no limit |
| Maximum number of external items in a program | 2G |
| Maximum number of ACCEPT/DISPLAY characters | 2G |
| Maximum number of PERFORM iterations | 2G |
| Maximum nesting depth of IF/PERFORM/EVALUATE statements | no limit |
| Maximum number of entry points (ENTRY statements) in program | 65,535 |
1 This can be configured by the user at compile-time to be any value in the range of 1 to 63 decimal digits.
2 This can be changed to any positive integer value by runtime configuration. This runtime configuration is independent of the number of decimal digits allowed at compile time for numeric items (see note 1).
3 This limit will actually be determined by the associated file system(s) used and the operating system itself. P3/COBOL imposes no limit.
4 This limit may be reduced (sometimes substantially) by the actual file system association configured by the user at runtime.
5 Java has a limit of 65,535 methods in a single class. This effectively dictates this limit as a maximum possible. The actual limit is less than this due to methods created for other purposes.
6 Java limits the total number of array subscripts to 255. Because P3/COBOL numeric element caching uses Java arrays for storing algebraic values, this limit results.
Constant (Level-78) Expression Evaluation
Constant expressions used to define level-78 (CONSTANT) items are evaluated as signed 64-bit integers, consistent with
the behavior of Micro Focus COBOL. Intermediate results accumulate using IEEE 754R DECIMAL128 precision, but the final
value and the operands of the logical operators are constrained to the signed 64-bit integer range. A constant
expression whose value cannot be represented exactly in a signed 64-bit integer is reported as an error.
The logical operators AND, OR, EXCLUSIVE OR, and the prefix NOT operate on the 64-bit two's-complement
representation of their operands. In particular, the prefix NOT is a 64-bit bitwise complement (~x), not an
arithmetic negation. For a value x, NOT x therefore evaluates to -(x) - 1 rather than -(x). Source that relied on
the earlier arithmetic-negation behavior of NOT in a constant expression should use 0 - x or otherwise adjust the
expression.