Compiler Directives / Options

Elastic COBOL supports a number of compile-time options and runtime-options. Runtime options affect the behavior of a program while it is running, either in a stand-alone (command-line) environment, under control of the Elastic Batch Platform (batch) environment, or within the Elastic Transaction Platform (online) environment.  Other configurations and settings also affect the operation of programs.  Different file protocols affect the way COBOL files are stored and accessed and SQL properties affect database interactions.  Also, when calling subprograms other than those written in COBOL or Java calling convention settings may be required.

Compile-time options are those passed to the ecobol command invokes the compiler from a command-line environment. It accepts the same options that may be set in the Elastic COBOL Eclipse IDE under COBOL Compiler Settings. Compiler directives can be set on the compiler command line, in the Additional Parameters field of the COBOL Compile Settings for the project or within the program itself with the "$SET DIRECTIVE" or "$SET PGM-DIRECTIVE" statements ('$' in column 7 on fixed-format source files). Run-time option name can be specified with a value as environment variables set before the program starts, as a Java property (-Dname=value in a VM argument to the Java command), as command-line options (name=value after the class name) or set programmatically with the SET CONFIGURATION COBOL statement. Run-time options may also be compiled into the generated Java program with the "-run name=value" compiler directive, the "$SET RUNTIME 'name=value'" statement or $SET DIRECTIVE '-run name=value'" statement.

A variation of "$SET DIRECTIVE" is "$SET PGM-DIRECTIVE myprog.cbl directive". This is best used in an ecobol.dir file as an alternative to inserting directives into the application source. In this case, the "directive" is only applied to "myprog.cbl" - it will not be applied to any other source files.

See EBP Configuration options or ETP Configuration options for information on runtime options of those systems.

Elastic COBOL Compiler Options

The compiler options are available by typing:

ecobol -?

The ecobol.exe compiler executable and its support files (etrans.jar, ecobol.jar, ECERR.txt) are distributed with the Elastic COBOL IDE. They are contained in the Eclipse installation directory in the following subdirectories

You may copy all of these files to another location, such as your home directory's "bin" directory (xx.yy.zz is the ECOBOL version) or create symbolic links on Linux in a well -known directory to them:

  • ./com.heirloomcomputing.ecd.core_xx.yy.zz/elastic_cobol/bin/win64/x86_64/ecobol.exe or
  • ./com.heirloomcomputing.ecd.core_xx.yy.zz/elastic_cobol/bin/linux/x86_64/ecobol
  • ./com.heirloomcomputing.ecd.core_xx.yy.zz/elastic_cobol/etrans.jar
  • ./com.heirloomcomputing.ecd.core_xx.yy.zz/elastic_cobol/ecobol.jar
  • ./com.heirloomcomputing.ecd.core_xx.yy.zz/elastic_cobol/ECERR.txt

Elastic COBOL uses runtime Gnu C and C++ libraries that should already be installed on your system. If you experience errors (e.g., "Missing GLIB 2.14") you need to install these dependent libraries before running. On Linux, install with these commands

sudo yum install libglib2.0-0 libstdc++


sudo apt-get install libglib2.0-0 libstdc++


Description/Option Value


Help on Elastic COBOL Options


Help on Elastic COBOL Options


Help on Elastic COBOL Deprecated Options


Help on Elastic COBOL Acu-Style Options


Help on Elastic COBOL Simple-Style Options


Transpile COBOL to Java


Transpile COBOL to Java, then compile Java to class files (default)


Transpile COBOL to Java, then compile Java to class files, then execute the main class

-dt n

Data type compatibility with various environments (n: 0=EC, 2=Acu, 4=MPE, 5=MF, 6=RM, 7=IBMA, 8=IBME)

IBMA = IBM ASCII (e.g., IBM Power Series, AIX)



Datatype Compatible with Elastic COBOL (default)


Datatype Compatible with IBM ASCII



Datatype and file storage Compatible with IBM Enterprise COBOL ("native EBCDIC" mode)


Datatype Compatible with Micro Focus


Datatype Compatible with AcuCOBOL


Datatype Compatible with HP MPE/iX COBOL-II


Datatype Compatible with Liant RM/COBOL 7




BINARY byte truncation rather than PIC truncation




Datatypes Compatible with IBM AIX


Datatypes Compatible with IBM OS/2


Use ' for QUOTE(S) and ALL QUOTE(S)



Use " for QUOTE(S) and ALL QUOTE(S)


Auto-detect source format (default)


Free-form source code


Fixed-form source code


Variable-form source code


UTF-8 encoding

-source:copypath pathname

Set COPY library path to parameter pathname


Allow .CBL(.cbl) file extension for copybooks (default)


Don't allow .CBL(.cbl) files as copybooks

-source:suppress name

Suppress parameter name from being reserved word

-source:ignore name

Ignore parameter name as a reserved word

-source:wordlist filename

File filename contains reserved word suppress list


Use only ANSI keywords


Based Literals are Numeric (Hex,Decimal,Octal,Binary)


Prefer HP semantics when in conflict.

-source:path pathname

Add parameter to front of PATH


Set tab size in spaces


Pause after compilation


Activate SHIFT-IN/SHIFT-OUT DBCS 0x0e, 0x0f

-source:dbcsso char

Activate parameter char as DBCS SHIFT-OUT

-source:dbcssi char

Activate parameter char as DBCS SHIFT-IN


Flag Syntax Obsolete in COBOL 2002 or X/Open


Flag Syntax Archaic in COBOL 2002


ASSIGN TO name is environment, not variable


ASSIGN TO name is variable, not environment

-out:ecoboldir pathname

pathname to directory containing ecobol.dir


Generate .java files from COBOL source, but do not generate .class files afterwards

-out:javaversion n

Compile COBOL to specified Java version and use javac -source 1.n and -target 1.n options (also see -script:javac option)


Compile COBOL to .java, then executable .class (default)


Compile COBOL to .java, .class, then execute


Include COBOL statements in .java


Do not include COBOL statements in .java (default)


Each 01 level in own constructor in .java


Spaces in an alphanumeric field are treated as zero when moved to a numeric field

-out:name name

Use parameter as name for applet/application


Designate as subprogram

-out:package name

Use parameter as generate Java package name causing Java output to contain the package statement and be placed in a corresponding directory hierarchy


Generate template HTML file


Do not generate template HTML file


Create CobolBean interface


Create Servlet interface


Do not create CobolBean interface


Disable ThreadQueue suspension

-out:dir dirname

Set output directory to parameter

-out:omapdir dirname

Set output directory of .omap files used by Eclipse Elastic COBOL IDE to parameter


Inherit from JApplet by default


Inherit from Applet by default


Suppress generated output (check only)

-out:filter n

Set output filter (n: 0=native, 1=EBC-to-ASC, 2=ASC-to-EBC, 3=breakup large classes)


No Array GET|SET Properties


Enable ASSERT functionality


Statically bind OO invokes where possible


Do not produce transient modifiers


Generate .smap file


Do not create pretty java code


Allow EXEC TRANSACTION capabilities

-out:importjava name

Generate a Java import statement with the given parameter class specification (e.g., javax.servlet.*).



Protect against table index out of bounds (default)



Do NOT protect against table index out of bounds


Set INDEX byte size to param


Set transaction message level


Set transaction message level


Generate OCCURS arrays exactly the size specifies in the DEPENDING ON variable within enclosing groups


Generate OCCURS arrays such that they allocate the maximum size within enclosing groups (default)


Generate shorter Java names for groups and elements, do not generate shared string constants, implies -out:cobolinjava


DFHEIBLK and DFHCOMMAREA variables creation (NO or YES 'default')


Merge the values of duplicate Level 88 conditions into a single condition


Generate an "ambiguous identifier" error when duplicate Level 88 condition names are referenced (default)


Convert the value of hex strings "in the wild" from EBCDIC to ASCII.

-err:file filename

Set error filename to parameter


No error output


Send errors to stdout


Send errors to stderr

-err:max n

Set maximum reported errors to parameter


Minimum error Level (0=All, 1=Warning, 2=Error)


Pedantic error messages


Generate informational messages for optimizations


Do not generate informational messages for optimizations (default)


Execute scriptfile upon completion

-script:append parameter

Append parameter to end of scriptfile


Format each line of scriptfile according to parameter

-script:javac javaccommand

Use parameter as Java Compiler string

-script:java javacommand

Use parameter as Java Runtime string


Fill initial memory with byte number or 'space'


Do not generate runtime progress bar during download


Do not generate runtime code to verify Java version


Use MF style perform


Use ANSI style perform


Disable Visible Call Failure


ACCEPT and DISPLAY statements (without an explicit UPON clause) default to CONSOLE ( graphical user interface window or ASCII terminal) rather than SYSIN/SYSOUT (standard in / standard out).

The default is -run:system


ACCEPT and DISPLAY statements (without an explicit UPON clause) default to SYSIN/SYSOUT (standard in / standard out) rather than
CONSOLE (graphical user interface window or ASCII terminal).


Enable Visible Call Failure


Allow runtime to enable/disable Visible Call Failure


Disable Visible Open Failure


Enable Visible Open Failure


Allow runtime to enable/disable Visible Open Failure


Preserve REDEFINES info at runtime for Datatype


Produce tracing messages for PARAGRAPH/SECTION, CALL, GOTO, PERFORM, FILE I/O operations & SQL I/O operations


Produce tracing messages for each CALL.


Product tracing messages for each GOTO.


Produce tracing messages for each FILE I/O operation.


Produce tracing messages for each PARAGRAPH/SECTION.


Produce tracing messages for each PERFORM.


Produce tracing messages for each SQL I/O operation.


Produce a COBOL stack trace if exception occurs.


Emit full source path for program source location in trace output (not default).


Turn off all tracing messages.


Turn off tracing messages for each CALL.


Turn off tracing messages for each GOTO.


Turn off tracing messages for each FILE I/O operation.


Turn off tracing messages for each PARAGRAPH/SECTION.


Turn off tracing messages for each PERFORM.


Turn off tracing messages for each SQL I/O operation.


Enable WITH DEBUGGING MODE, allowing lines with 'D' in the indicator column to be executed.


Disable WITH DEBUGGING MODE, preventing lines with 'D' in the indicator column to be executed.

-run name=value

Generate code that sets the run-time option name to value as if -Dname=value was specified on the Java command line, as an environment variable, or in the cblconfig or run-time configurations files.

-run ebcdic_codepage=<number>

Adds a run-time parameter for the EBCDIC codepage that will be used if the 'collateAsEBCDIC' flag (can be seen below) is up. 

<number> can be either 037 or 277. 

These numbers match exactly collation sequences:


If a different codepage number is provided, 037 will be used as default.

Note that there is a slight difference between  Codepage037  and SQL_EBCDIC037_CP1_CS_AS.

This is true for codepage 277 as well.


Default share: SHARING ALL OTHER


Default share: SHARING NO OTHER


Default share: SHARING READ ONLY


Default share: no default/explicit sharing


dollar symbol ($) may be part of file name

-cache:auto | enable | disable | forbid | smart | external

-cache:0 | 1 | 2 | 3 | 4 | 5


Enable or disable various forms of group and element value caching. Disable cache is the default which means element values are fetched from the COBOL section memory (e.g., working storage, linkage section, etc.) when referenced and saved when changed. Other settings will cache those values in Java objects and invalidate/flush the values when necessary. Based on the usage and frequency of REDEFINES, OCCURS, OCCURS DEPENDING ON and access/modification of groups and elements within groups you may find that different caching algorithms (enable 1, forbid 3, smart 4) may perform better in certain instances. Using external 5 will cause memory allocation to be performed outside the Java heap. This has two effects, larger programs may benefit by having their working-storage and other sections allocated in the non-JVM garbage-collected heap usually reserved for OS malloc() and free() memory allocation and, when used with UNSAFE calling convention, it allows for persistent (non changing) pointers to COBOL variables to be passed to C-libraries invoked from COBOL. Setting auto attempts to determine the best for your program. Indicating a :section-name will enable that cache setting only for that section-type (wrk, lnk, fil, etc.).


Disable SQL Support. Abends on SQL statements


Set SQL VARYING stub len to param (len)


Set SQL VARYING stub txt to param (arr)


SQL JDBC/DB2 next() workaround


SQL IBM JDBC/DB2 workarounds


SQL workarounds for Microsoft SQL Server, specifically define cursors as scroll type SENSITIVE if they are also UPDATABLE because MS SQL Server disallows the combination of INSENSITIVE and UPDATABLE.


Use JDBC CONCUR_READ_ONLY for the concurrency setting when defining cursors (default UPDATABLE cursors)


SQL Transaction Adjust


SQL Server handles Concat (||)


SQL Ignore Right Truncation

-sql:jdbc level

JDBC level to which to generate JDBC API methods (level: 1, 23, 4)

-sql:sp name

Generate SQL Stored Procedure of type name. db2 only supported at this time.

-sql:spschema name

Schema of the stored procedure. Used at compile time stored procedure validation against the database. This parameter is optional, as the -sql:user will be used as the default.

-sql:spname name

Name of the stored procedure. Used at compile time stored procedure validation against the database. This parameter is required for COBOL stored procedure compiles.

-sql:logmode NO|YES

SQL Logging (NO, YES)


SQL group items treated as single item


SQL group items treated as multiple items


SQL Warning not obtained from JDBC


SQL DECLARE CURSOR always static


SQL DECLARE CURSOR dynamic when possible (default)


Pass SQL option, -sql:opt ? for dump

-sql:mode ANSI|ORACLE|DB2

SQL Process statements and return results in given parameter mode (ANSI, ORACLE, DB2). DB2 mode simulates DB2 for z/OS on other databases such that error DB2 SQLCODEs are translated from SQLSTATEs and SAVEPOINT-protected INSERT/UPDATE/DELETE statements do not abort transactions upon error

-sql:cc NO|YES

SQL Close on Commit to parameter (YES, NO)


SQL END OF FETCH value (100,1403)

-sql:unsafenull NO|YES

SQL Unsafe Null (NO,YES)




Check SQL syntax against database URL (e.g., jdbc:postgresql://localhost/mydb)


Check SQL syntax against database USER (e.g.,  postgres)


Check SQL syntax against database PASSWORD (e.g.,  mypw)


Check SQL syntax against database DRIVER (e.g.,  org.postgresql.Driver)

-sql:protect_include <param>

Protect SQL with an autosave and rollback in case of exception. Param values can be 



Identifiers for the SQL statement in a program which can take the following forms:

ProgramName,SectionName,ParaName,SQL statement sequence #

SectionName,ParaName,SQL statement sequence #

ParaName,SQL statement sequence #

For e.g.: 

-sql:protect_include ALL

-sql:protect_include UPDATE

-sql:protect_include DROP

-sql:protect_include program1,sectionA,paraB,4

-sql:protect_include paraC,4


-sql:protect_exclude <param>

Similar to -sql:protect_include above but excludes autosave/rollback protection.

The param value ALL is not supported


Instruct compiler to use Intrinsic functions when CURRENT TIME/DATE/TIMESTAMP is used


Specify Tables and corresponding Identity Columns

For e.g.:

 -sql:identityinfo tableA:colA

 -sql:identityinfo tableB:colB

 -sql:identityinfo tableA:colA,tableB:colB,tableC:colC


Setting this flag will cause the compiler to generate code that will

set the COBOL RETURN-CODE to 0 after a non error SQL statement execution.


Listing file XML form to programid.xml


Listing file XML includes source body


Listing file XML includes 'define' tag


Listing file set to mainfile.list


Listing file includes cross-reference


Listing file cross-reference includes verbs


Listing file cross-reference includes info lines


Listing file cross-reference includes all options


Listing files output directory

-cp pathlist

Use parameter as classpath during Java compile


Optimize for extremely large (> 100KLOC) input files

-opt:break n

Implies -opt:large. Break up output Java classes every n lines instead of the default 10000

-opt:break para

Implies -opt:large. Break up output Java classes every COBOL paragraph. Output classes are also named after the paragraph name.

-opt:break section

Implies -opt:large. Break up output Java classes  every COBOL procedure division section. Output classes  are also named after the section name.


(Default) Generates a optimized version of the initialize statement. A single java initialize statement is created corresponding to each COBOL initialize statement for group fields


Generates a non optimized version of the initialize statement. Multiple java initialize statements is created corresponding to each COBOL initialize statement for group fields


Optimize OCCURS arrays (tables) such that no Java array is actually generated, but simulated  as an object with getters and setters. This is faster for sparse arrays, i.e., large OCCURS x TIMES where x is large but only a few of the elements are actually used. Also required when redefining a table and subsequent indexes are out-of-bounds.


Generate COBOL OCCURS arrays (tables) as Java arrays (default).


Do generate unused group and element variables in the Java output


Do not generate unused group and element variables in the Java source code (default)


By default COBOL programs use the ASCII collating sequence to do string comparisons, in this mode "1" < "a". This flag sets the compiled program to use the EBCDIC collating sequence which means that "1" > "a". 

Alternatively it is possible to use the COBOL configuration section to set this collating sequence, this also gives more options to provide custom collating sequences.

configuration section.
program collating sequence is mainframe.
alphabet mainframe is ebcdic.


Elastic COBOL Runtime Options

These have been moved to their own article Heirloom COBOL Runtime Options


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk