Building Java records using the JZOS Record Generator utility

When you are developing a Java™ program to link to a CICS® program with a COMMAREA or access a VSAM file, you need to map the binary record structure from a language copybook to Java data types. These examples demonstrate how the JZOS Record Generator is used to generate Java records from a COBOL copybook.

About this task

The IBM® JZOS Batch Toolkit for z/OS® SDK is a set of tools that are designed to help integrate Java applications with z/OS services. One of the key features that it provides is a record class generator, which imports language copybooks or Assembler DSECTs. The generator creates helper classes that marshal the data to and from the record structure. You can automate the creation of these records as a batch job on z/OS and use the generated record in a COMMAREA structure to be passed on a link from a CICS Java program to a language program. The JZOS generator is a Java based tool that takes the ADATA as input from a language compiler. The generator generates Java code to access the fields in the record structure. The ADATA provides additional information about a program. It is used by JZOS to produce the data mappings, and by other tools for symbolic debugging and cross-referencing.

The following procedure uses COBOL for demonstration purposes, but you can use any CICS supported language structure.

Procedure

  1. Download the IBM JZOS toolkit from the JZOS Record Generator site.
  2. Extract the JZOS COBOL Record Generator Users Guide.
  3. Extract jzos_recgen.jar and transfer the JAR to a directory on your zFS, as it is required by the batch job to generate records from the language source.
  4. Create a record, by modifying the compile process to produce ADATA output. To produce the ADATA, you must add the ADATA keyword to the COBOL PARM statement and then direct the output to a preallocated SYSADATA data set. This ADATA data set is used as input for the Java record generation. The following JCL example provides a sample COBOL V5.1 compile job with the ADATA PARM option and SYSADATA DD, based on the sample in the CICS convert and compile job DFHZITCL.
    //ASMCOBJ JOB (H251620-TSOO),CLASS=A,MSGCLASS=T,NOTIFY=&SYSUID,
    // MSGLEVEL=(1,1),REGION=500M
    // SET PROG=‘EDUPGM'
    //COBOL EXEC PGM=IGYCRCTL,REGION=200M,
    // PARM=(NODYNAM,RENT,LIST,MAP,XREF,ADATA,
    // 'CICS(''SP,COBOL3'')')
    //STEPLIB DD DSN=PP.COBOL390.V510.SIGYCOMP,DISP=SHR
    // DD DSN=CICSTS.530.SDFHLOAD,DISP=SHR
    //SYSLIB DD DSN=USER.CICS.DSECT,DISP=SHR
    // DD DSN=USER.CICS.COPY,DISP=SHR
    // DD DSN=CICSTS.530.SDFHCOB,DISP=SHR
    // DD DSN=CICSTS.530.SDFHMAC,DISP=SHR
    // DD DSN=CICSTS.530.SDFHSAMP,DISP=SHR
    //SYSADATA DD DSN=USER.CICS.COBADATA(&PROG),DISP=SHR
    //SYSPRINT DD SYSOUT=A
    //SYSLIN DD DSN=&&LOADSET,DISP=(MOD,PASS),
    // UNIT=SYSDA,SPACE=(TRK,(3,3))
    //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT5 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT6 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT7 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT8 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT9 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT10 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT11 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT12 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT13 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT14 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSUT15 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSMDECK DD UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSIN DD DSN=USER.CICS.SOURCE(&PROG),DISP=SHR
    /*
    //COPYLINK EXEC PGM=IEBGENER,COND=(7,LT,COBOL)
    //SYSUT1 DD DSN=CICSTS.530.SDFHSAMP(DFHEILID),DISP=SHR
    //SYSUT2 DD DSN=&©LINK,DISP=(NEW,PASS),
    // DCB=(LRECL=80,BLKSIZE=400,RECFM=FB),
    // UNIT=SYSDA,SPACE=(400,(20,20))
    //SYSPRINT DD SYSOUT=A
    //SYSIN DD DUMMY
    //*
    //LKED EXEC PGM=IEWL,REGION=200M,
    // PARM='LIST,XREF,RENT,MAP',COND=(7,LT,COBOL)
    //SYSLIB DD DSN=CICSTS.530.SDFHLOAD,DISP=SHR
    // DD DSN=PP.ADLE370.ZOS201.SCEELKED,DISP=SHR
    //SYSUT1 DD UNIT=SYSDA,DCB=BLKSIZE=1024,
    // SPACE=(1024,(200,20))
    //SYSPRINT DD SYSOUT=A
    //SYSLIN DD DSN=&©LINK,DISP=(OLD,DELETE)
    // DD DSN=&&LOADSET,DISP=(OLD,DELETE)
    // DD DDNAME=SYSIN
    //SYSLMOD DD DSN=USER.CICS70.LOADLIB,DISP=SHR
    //SYSIN DD *
    NAME &PROG(R)
    /*
  5. Optional: If needed, link edit the load module for deployment into CICS.
  6. Create a job step by using BPXBATCH to start the Java RecordClassGenerator utility class from the jzos_recgen.jar. Use the ADATA as the input and name the wanted language structure. For demonstration purposes, assume that the following record is generated: com.ibm.cicsdev.bean.JZOSCommareaWrapper.java . The record wrappers the DFHCOMMAREA structure from your COBOL program. The inputs to the job are parametrized, which allows scripting later.
    //JZOS EXEC PGM=BPXBATCH
    //STDENV DD *
    JAVAHOME=/java/java71_64/J7.1_64
    PKG=com.ibm.cicsdev.bean
    DIR=com/ibm/cicsdev/bean
    PROG=EDUPGM
    //STDOUT DD SYSOUT=*
    //STDERR DD SYSOUT=*
    //STDPARM DD *
    cd /u/cics1/jzos;
    $JAVAHOME/bin/java
    -cp ./jzos_recgen.jar
    com.ibm.jzos.recordgen.cobol.RecordClassGenerator
    adataFile="//'USER.CICS.COBADATA(${PROG})'"
    symbol=DFHCOMMAREA
    outputDir=.
    package=${PKG}
    class=JZOSCommareaWrapper;
    /*
  7. Build the generated source code JZOSCommareaWrapper.java created in step 6.
    The source-code is the wrapper code that marshals data between Java and the COBOL record-structure, it can be compiled by using the javac utility. The class file that is produced from the compile step can then be packaged into a JAR by using the Java provided jar utility. To achieve this, add the following statements to the end of the BPXBATCH job step to perform these steps:
    $JAVAHOME/bin/javac 
    ${DIR}/JZOSCommareaWrapper.java;
    $JAVAHOME/bin/jar -cvf ${PROG}.jar 
    ${DIR}/JZOSCommareaWrapper.class; 

    The resulting JCL can be used as part of a build system and rebuild the record when any changes are made to the copybooks. The built JAR (EDUPGM.jar) can be transferred to your source code management system or downloaded for use in the Eclipse development environment.

Results

You generated your Java record classes based on the structure of your COMMAREA ready to be used within an Application.

For more information, see Developing Java applications by using JZOS APIs.



config_java_jzos.html | Timestamp icon Last updated: Monday, 5 June 2017