Invoking COBOL Applications from EBP / JCL
EBP can invoke your Elastic COBOL applications through JCL. The following JCL snippet will invoke the program JOBA and associate two DD names with it.
//STEPID02 EXEC PGM=JOBA,PARM='the parameter string'
//SYSIN DD DUMMY
//SYSOUT DD SYSOUT=*
//DDA DD DISP=SHR,DSN=ABC00.A.B.JOBAIN
//DDB DD SYSOUT=*
The DSNs are relative to the Data LIbrary settings in the EBP configuration, the default being /data or d:\data directories. Applications define DD names with the INPUT-OUTPUT SECTION within the COBOL program and the record structure of the files with the FILE SECTION.
* compile with "-source:assignenv" to ensure aafil is not defined as a variable
select afil assign to DDA.
select bfil assign to DDB.
03 data-a pic x(80).
03 data-b pic x(80).
In order for the Elastic COBOL compiler to assign the COBOL file with the DD Name reference compile with the -source:assignenv flag:
ecobol -source:assignenv joba.cbl
Combine all of the classes of the job into a jar file together with the Elastic COBOL runtime library (and optionally license properties file) with the command:
jar -cfe joba.jar joba *.class ecobol.jar elasticcobol.properties
The elasticcobol.properties file is in your home directory. If the license file is not packaged in the jar, it will use the one on the deployment server. The ecobol.jar file will be in the library section of where you installed Elastic COBOL. If you installed Elastic COBOL under Eclipse this will be in the Eclipse "plugins" directory.
- /c/Program\ Files/eclipse/plugins/com.heirloomcomputing.ecd.core_12.12.2/
Within Eclipse File > Export using the Elastic COBOL Deploy Wizard. The resulting jar file must be placed in a JOBLIB or STEPLIB library directory or in the System Library. See EBP configuration settings to establish the System Library path.
You can also compile and deploy the batch executable from the Elastic COBOL IDE (Eclipse). First, enter the "-source:assignenv" as an Additional Parameter on the COBOL Compiler Settings dialog.
Then the Elastic COBOL Deployment Wizard will package the JAR with license file
Deploy batch programs anywhere on the deployment server. For deploying in cloud Heirloom instances, use the Cloud deployment option and select the started instance from the list. Even if this is not a Web application it may be deployed under any of the cloud servlet engines or application servers. The location of the deployment must be specified in the EBP Configuration Settings, two of which are applicable to finding executable programs:
- systemlib.n - individual directories which include, by default, the same d:\data or /data used for datasets in datalib.1..datalib.9 configuration settings
- classlib.n - the classpath directories or colon-separated (Linux) or semi-colon-separated (Windows) path variables and/or environment variables $CLASSPATH
- datalib.n - directories containing datasets, the first of which that is writable is where DISP=NEW datasets will be created.
Other EBP configuration settings control the directory ordering (A.B.C.D as A.B/C/D) and case (A.B.C.D as a.b.c.d) when datasets are created by EBP.
Multiple COBOL main and subprograms can be deployed into the same jar file. To reference them in the EBP EXEC PGM=NAME statement the NAME refers to either a jar file or a class within a jar file. Thus, the name need not be in a file called NAME.jar or name.jar. When the main program cannot be found in name.jar the JOBLIB and STEPLIB DD cards are searched for any jar (as are the EBP classlib.n configurations) that contains a class name with a static main(String ) method defined. EBP will start the program with that entry point.
HCECOBOL Cataloged Procedure
You can batch compile your COBOL programs from within EBP as well. Use the HCECOBOL built-in procedure contained in the default system PROCLIB. The procedure can compile individual .CBL files and link (i.e., create a JAR file) them together. Here's such a job:
//COMP17 JOB (HCIACCT),'COBOL COMPILE',CLASS=A,MSGCLASS=A,
//* compile and run COBOL programs using built-in
//* HCECOBOL cataloged procedure
//STEP1 EXEC HCECOBOL,PGMID=hello,GO=YES
//COPY.SYSUT1 DD *
DISPLAY "Hello JCL World" UPON SYSOUT.
END PROGRAM hello.
//GO.SYSOUT DD SYSOUT=*
The HCECOBOL cataloged procedure compiles, links and runs Elastic COBOL applications. The Elastic COBOL compiler (ecobol.exe and ecobol.jar) must be installed separately from EBP on the server machine and accessible on the pathlib configuration setting that, by default, includes the system path $PATH environment variable. The compiler license file elasticcobol.properties must also be present in the server user's home directory. Beyond that, a number of procedure keywords control the operation and data definition cards define the input and output of each step.
Up to four steps are executed in this PROC depending upon the parameters to it.
- COPY - copy the COBOL source file into temporary spool directory for the job. In general all of the intermediate files are left in the temporary spool and removed at job conclusion
- COMPILE - run the Elastic COBOL compiler
- LINK - link all available class files generated from the COMPILE step and combine them with the Elastic COBOL runtime libraries into an executable jar file. The LINK.SYSOUT DD card indicates the output of the link (jar) process but by default leaves it in the temp spool for the GO step, if included
- GO - run the resulting program if the corresponding parameter is turned on.
- COMPILE=YES|NO - compile source COBOL program (default: YES)
- LINK=YES|NO - link after compile (default: YES)
- GO=YES|NO - run the program after link (default: NO)
- PGMID - the program ID of the program being compiled (required) must match the PROGRAM-ID within the COBOL program and is the entry point (main class) when LINK=YES
- OPT - Elastic COBOL compiler options (optional)
- GOPARM - the runtime parameters to the program during GO
- REQ - Elastic COBOL required options (default -jes, -source:assignenv)
- COPY.SYSUT1 - input cobol source program (found in datalib)
- COPY.SYSOUT - IEBGENER report during pgm source copy (defaultDUMMY)
- COPY.SYSERR - IEBGENER report during pgm source copy (defaultDUMMY)
- COMPILE.SYSOUT - Elastic COBOL compiler errors/warnings
- COMPILE.SYSERR - Java compiler errors/warnings
- LINK.SYSIN - ecobol.jar + etrans.jar (found in datalib)
- LINK.SYSERR - Java jar command errors
- LINK.SYSOUT - output jar file (dflt &PGMID..jar in temp spool)
- GO.SYSOUT - output of running program (dflt SYSOUT=*)
- GO.SYSERR - error output of running program (dflt DUMMY)
- GO.ddname - other DDNames referenced in the SELECT ASSIGN clause of a file definition
- ecobol or ecobol.exe commands must be found in a directory found in the systemlib.n configuration or the STEPLIB or JOBLIB of the deck.
- javac and jar commands must be found in a directory specified in the systemlib.n configuration
- ecobol.jar and etrans.jar must be found in a directory specified in one of the EBP datalib.n configurations; e.g. datalib.4=/usr/local/lib if ecobol.jar and etrans.jar are contained in this directory
- ecobol.jar and etrans.jar must be in the Java classpath, specified in one of the EBP classlib.n configurations; e.g., classlib.4=/usr/local/lib/ecobol.jar:/usr/local/lib/etrans.jar
- EBP classlib configurations can include directories (containing class variables), explicit jar files (packed with class files) or environment variables ($PATH, $CLASSPATH). Each configuration may include multiple entries specified as colon- (Linux) or semi-colon-separated (Windows) entries.
See the following end-to-end example of constructing a COBOL application and running it under EBP in Tips & Tricks Forum
Another comprehensive example (compiling, executing and running a database program) is also attached to this forum article as test40.jcl.