For complete documentation about building COBOL applications,
including Object Oriented (OO) COBOL, see Enterprise COBOL for z/OS, V4R2, Programming Guide.
For compiling with JCL, IBM® provides
a set of cataloged procedures to reduce the amount of JCL coding that
you need to write. If the cataloged procedures do not meet your needs,
you can write your own JCL. Using JCL, you can compile a single program
or compile several programs as part of a batch job. See Invoking z/OS Batch Runtime for more information.
The compiler translates your COBOL program into language that the
computer can process (object code). The compiler also lists errors
in your source statements and provides supplementary information to
help you debug and tune your program. Use compiler-directing statements
and compiler options to control your compilation. After compiling
your program, you need to review the results of the compilation and
correct any compiler-detected errors.
To build Java™ programs, use
the javac command to create the classes and the jar command
for packaging. This documentation focuses on building a typical use
case that updates a traditional COBOL program to call out to Java methods in which either or
both can use DB2®.
The JCL example shown in
Figure 1 is
a modification of a sample COBOL DB2 phone
program that ships as part of IBM DB2 for z/OS®.
This program is typically
found in hlq.sdsnsamp(DSN8BC3) and is
often used in the DB2 installation
verification program (IVP). The COBOL source is modified to invoke
a simple Java "Hello World"
method that also selects rows from the DB2 catalog
using the SYSIBM schema. The following are implications on the DB2 provided COBOL build procedure
to run in the
z/OS
Batch Runtime container:
- The Language Environment® Runtime library CEE.SCEERUN must be in
the JOBLIB for the Java JNI
support.
- The ATTACH(RRSAF) must be in the preprocessor
portion of the catalogued procedure. Although optional, this forces
the generation of RRS attach entry point at compile time. Omit this
option for attach-neutral code generation. The z/OS Batch Runtime requires the use of RRS attach
to be bound at compile (as in this example), link (include DSNRLI),
or runtime (include DSNULI).
- The use of Java from COBOL
source requires the compile options RENT,DLL,THREAD.
- The long names required for the Java JNI
imply use of PDSE libraries by the binder (rather than traditional
PDS load libraries).
- The input to the Binder requires both the Enterprise COBOL Java linkage and JNI export (*.x)
files.
Figure 1. Example:
JCL for COBOL DB2 phone program//COBBUILD JOB (MOP,1458),'STEVE',CLASS=A,REGION=0M,
// MSGLEVEL=(1,1),MSGCLASS=X,TIME=1440,NOTIFY=&SYSUID
//*
//**********************************************************************
//* NAME = DSNTEJ2C -- MODIFIED FOR RRS AND Java BATCH CONTAINER RUN *
//* BUILD ONLY WITH APP CALL TO JAVA *
//* DESCRIPTIVE NAME = DB2 SAMPLE APPLICATION W CALL TO JAVA *
//* PHASE 2 *
//* COBOL *
//* *
//* LICENSED MATERIALS - PROPERTY OF IBM *
//* 5635-DB2 *
//* (C) COPYRIGHT 1982, 2006 IBM CORP. *
//* *
//* STATUS = VERSION 9 *
//* *
//* FUNCTION = THIS JCL PERFORMS THE PHASE 2 COBOL SETUP FOR THE *
//* SAMPLE APPLICATIONS. IT PREPARES AND EXECUTES *
//* COBOL BATCH PROGRAMS. *
//* *
//* THIS JOB IS RUN AFTER PHASE 1. *
//* *
//* *
//* CHANGE ACTIVITY = *
//* *
//**********************************************************************
//JOBLIB DD DISP=SHR,DSN=DSN910.NEWFUNC.SDSNEXIT
// DD DISP=SHR,DSN=DSN910.SDSNLOAD
// DD DISP=SHR,DSN=CEE.SCEERUN
//*
//* PREPARE COBOL PHONE PROGRAM
//PH02CS03 EXEC DSNHNCOB,MEM=XMPCOBJV,
// COND=(4,LT),
// PARM.PC=('HOST(IBMCOB)',APOST,APOSTSQL,SOURCE,
// NOXREF,'SQL(DB2)','DEC(31)','ATTACH(RRSAF)'),
// PARM.COB=(NOSEQUENCE,LIB,QUOTE,RENT,'PGMNAME(LONGUPPER)',
// DLL,THREAD)
//PC.DBRMLIB DD DSN=DSN910.DBRMLIB.DATA(XMPCOBJV),
// DISP=SHR
//PC.SYSLIB DD DSN=SUIMGJB.PRIVATE.DSN910.SRCLIB.DATA,
// DISP=SHR
//PC.SYSIN DD DSN=SUIMGJB.PRIVATE.JCL.CNTL(XMPCOBJV),
// DISP=SHR
//COB.SYSLIB DD DSN=SUIMGJB.PRIVATE.JNI.COPY,
// DISP=SHR
//LKED.SYSLMOD DD DSN=SUIMGJB.PRIVATE.LIBRARY(XMPCOBJV),
// DISP=SHR
//LKED.RUNLIB DD DSN=DSN910.RUNLIB.LOAD,
// DISP=SHR
//LKED.SYSIN DD *
INCLUDE SYSLIB(DSNRLI)
INCLUDE RUNLIB(DSN8MCG)
INCLUDE '/home/cob42/cobol/lib/igzcjava.x'
INCLUDE '/usr/lpp/java/J6.0/lib/s390/j9vm/libjvm.x'
//