├── LICENSE ├── MAINTAINERS.md ├── README.md ├── blog ├── blog.md └── graphics │ ├── JCICS.png │ └── JavaExceptions-1-e1484928035395.png ├── etc ├── Link │ ├── DFHCSD.txt │ └── README.md ├── README.md ├── Serialize │ ├── DFHCSD.txt │ └── README.md ├── TDQ │ ├── DFHCSD.txt │ └── README.md ├── TSQ │ ├── DFHCSD.txt │ └── README.md ├── Terminal │ ├── DFHCSD.txt │ └── README.md └── VSAM │ ├── DEFVSAM.jcl │ ├── DFHCSD.txt │ └── README.md ├── projects ├── README.md ├── com.ibm.cicsdev.link.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── META-INF │ │ └── cics.xml │ └── com.ibm.cicsdev.link.osgibundle ├── com.ibm.cicsdev.link.resources.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── JAVALIN1.program │ ├── JAVALIN2.program │ ├── JAVALIN3.program │ ├── JLN1.transaction │ ├── JLN2.transaction │ ├── JLN3.transaction │ └── META-INF │ │ └── cics.xml ├── com.ibm.cicsdev.link │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── README.md │ ├── build.properties │ ├── lib │ │ └── EDUPGM.jar │ └── src │ │ └── com │ │ └── ibm │ │ └── cicsdev │ │ └── link │ │ ├── LinkProg1.java │ │ ├── LinkProg2.java │ │ ├── LinkProg3.java │ │ ├── LinkProgCommon.java │ │ ├── LinkServEC01.java │ │ └── LinkServEduchan.java ├── com.ibm.cicsdev.serialize.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── META-INF │ │ └── cics.xml │ └── com.ibm.cicsdev.serialize.osgibundle ├── com.ibm.cicsdev.serialize.resources.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── JAVASYN1.program │ ├── JSY1.transaction │ └── META-INF │ │ └── cics.xml ├── com.ibm.cicsdev.serialize │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── README.md │ ├── build.properties │ └── src │ │ └── com │ │ └── ibm │ │ └── cicsdev │ │ └── serialize │ │ └── SerializeExample1.java ├── com.ibm.cicsdev.tdq.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── META-INF │ │ └── cics.xml │ └── com.ibm.cicsdev.tdq.osgibundle ├── com.ibm.cicsdev.tdq.resources.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── JAVATDQ1.program │ ├── JAVATDQ2.program │ ├── JAVATDQ3.program │ ├── JTD1.transaction │ ├── JTD2.transaction │ ├── JTD3.transaction │ └── META-INF │ │ └── cics.xml ├── com.ibm.cicsdev.tdq │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── README.md │ ├── build.properties │ ├── lib │ │ └── TdqRecord.jar │ └── src │ │ └── com │ │ └── ibm │ │ └── cicsdev │ │ └── tdq │ │ ├── TDQCommon.java │ │ ├── TDQExample1.java │ │ ├── TDQExample2.java │ │ └── TDQExample3.java ├── com.ibm.cicsdev.terminal.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── META-INF │ │ └── cics.xml │ └── com.ibm.cicsdev.terminal.osgibundle ├── com.ibm.cicsdev.terminal.resources.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── JAVATRM1.program │ ├── JTM1.transaction │ └── META-INF │ │ └── cics.xml ├── com.ibm.cicsdev.terminal │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── META-INF │ │ └── MANIFEST.MF │ ├── README.md │ ├── build.properties │ └── src │ │ └── com │ │ └── ibm │ │ └── cicsdev │ │ └── terminal │ │ └── TerminalExample1.java ├── com.ibm.cicsdev.tsq.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── META-INF │ │ └── cics.xml │ └── com.ibm.cicsdev.tsq.osgibundle ├── com.ibm.cicsdev.tsq.resources.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── JAVATSQ1.program │ ├── JAVATSQ2.program │ ├── JAVATSQ3.program │ ├── JAVATSQ4.program │ ├── JTS1.transaction │ ├── JTS2.transaction │ ├── JTS3.transaction │ ├── JTS4.transaction │ └── META-INF │ │ └── cics.xml ├── com.ibm.cicsdev.tsq │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── README.md │ ├── build.properties │ ├── lib │ │ └── TsqRecord.jar │ └── src │ │ └── com │ │ └── ibm │ │ └── cicsdev │ │ └── tsq │ │ ├── TSQCommon.java │ │ ├── TSQExample1.java │ │ ├── TSQExample2.java │ │ ├── TSQExample3.java │ │ └── TSQExample4.java ├── com.ibm.cicsdev.vsam.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── META-INF │ │ └── cics.xml │ └── com.ibm.cicsdev.vsam.osgibundle ├── com.ibm.cicsdev.vsam.resources.cicsbundle │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── JAVAVES1.program │ ├── JAVAVES2.program │ ├── JAVAVES3.program │ ├── JAVAVES4.program │ ├── JAVAVES5.program │ ├── JAVAVKS1.program │ ├── JAVAVKS2.program │ ├── JAVAVKS3.program │ ├── JAVAVKS4.program │ ├── JAVAVKS5.program │ ├── JAVAVRR1.program │ ├── JAVAVRR2.program │ ├── JAVAVRR3.program │ ├── JAVAVRR4.program │ ├── JAVAVRR5.program │ ├── JVE1.transaction │ ├── JVE2.transaction │ ├── JVE3.transaction │ ├── JVE4.transaction │ ├── JVE5.transaction │ ├── JVK1.transaction │ ├── JVK2.transaction │ ├── JVK3.transaction │ ├── JVK4.transaction │ ├── JVK5.transaction │ ├── JVR1.transaction │ ├── JVR2.transaction │ ├── JVR3.transaction │ ├── JVR4.transaction │ ├── JVR5.transaction │ └── META-INF │ │ └── cics.xml └── com.ibm.cicsdev.vsam │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.pde.core.prefs │ ├── META-INF │ └── MANIFEST.MF │ ├── README.md │ ├── build.properties │ ├── lib │ └── vsam.jar │ └── src │ └── com │ └── ibm │ └── cicsdev │ └── vsam │ ├── StockPartHelper.java │ ├── VsamExampleCommon.java │ ├── esds │ ├── EsdsExample1.java │ ├── EsdsExample2.java │ ├── EsdsExample3.java │ ├── EsdsExample4.java │ ├── EsdsExample5.java │ └── EsdsExampleCommon.java │ ├── ksds │ ├── KsdsExample1.java │ ├── KsdsExample2.java │ ├── KsdsExample3.java │ ├── KsdsExample4.java │ ├── KsdsExample5.java │ └── KsdsExampleCommon.java │ └── rrds │ ├── RrdsExample1.java │ ├── RrdsExample2.java │ ├── RrdsExample3.java │ ├── RrdsExample4.java │ ├── RrdsExample5.java │ └── RrdsExampleCommon.java └── src ├── Cobol ├── EC01.cbl └── EDUCHAN.cbl └── README.md /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers 2 | 3 | - Phil Wakelin [@PhilWakelin](https://github.com/PhilWakelin) 4 | - Ian Burnett [@ian-burnett](https://github.com/ian-burnett) 5 | 6 | *Last reviewed:* November 2024 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cics-java-jcics-samples 2 | 3 | Sample CICS Java programs demonstrating how to use the JCICS API in an OSGi JVM server environment. 4 | 5 | ## Samples overview 6 | 7 | * [`com.ibm.cicsdev.link`](projects/com.ibm.cicsdev.link) - Performing CICS LINK operations using both commareas, and channels and containers. 8 | * [`com.ibm.cicsdev.serialize`](projects/com.ibm.cicsdev.serialize) - Serializing access to a common resource using the CICS ENQ and DEQ mechanism. 9 | * [`com.ibm.cicsdev.tdq`](projects/com.ibm.cicsdev.tdq) - Accessing transient data queues. 10 | * [`com.ibm.cicsdev.terminal`](projects/com.ibm.cicsdev.terminal) - Reading in data from a terminal for an OSGi application. 11 | * [`com.ibm.cicsdev.tsq`](projects/com.ibm.cicsdev.tsq) - Accessing temporary storage queues. 12 | * [`com.ibm.cicsdev.vsam`](projects/com.ibm.cicsdev.vsam) - Accessing KSDS, ESDS, and RRDS VSAM files. 13 | 14 | ## Repository structure 15 | 16 | * [`etc/`](etc) - Supporting materials used to define CICS and z/OS resources needed for the samples. 17 | * [`projects/`](projects) - Complete Eclipse projects suitable for importing into a CICS Explorer environment. 18 | * [`src/`](src) - Supporting source code for non-Java programs. 19 | 20 | ## Pre-requisites 21 | 22 | * Java SE 1.8 or later on the workstation 23 | * Eclipse with the IBM CICS SDK for Java or any IDE that supports usage of the Maven Central artifact [com.ibm.cics:com.ibm.cics.server.](https://search.maven.org/artifact/com.ibm.cics/com.ibm.cics.server) 24 | 25 | ## Configuration 26 | 27 | The sample Java classes are designed to be added to an OSGi bundle and deployed into a CICS OSGi JVM server, but can also be used as the basis for extending Web applications deployed into a Liberty JVM server. 28 | 29 | ### Starting a JVM server in CICS 30 | 31 | 1. Enable Java support in the CICS region by adding the `SDFJAUTH` library to the `STEPLIB` concatenation and setting `USSHOME` and the `JVMPROFILE` SIT parameters. 32 | 1. Define an OSGi JVM server called `DFHJVMS` using the CICS-supplied sample definition in the CSD group `DFH$OSGI`. 33 | 1. Copy the CICS supplied `DFHOSGI.jvmprofile` zFS file to the zFS directory specified by the `JVMPROFILE` SIT parameter, and ensure the `JAVA_HOME` variable is set correctly. 34 | 1. Install the `DFHJVMS` resource defined in step 2 and ensure it becomes enabled. 35 | 36 | 37 | ### Import the resources into your IDE 38 | 39 | 1. Ensure you have an Eclipse-based IDE with the CICS Explorer SDK installed. 40 | 1. Import the relevant projects into your Eclipse environment as described in [Adding the resources to Eclipse](/projects#adding-the-resources-to-eclipse). 41 | 1. Follow the instructions in the [Generated resources](/projects#generated-resources) section to add any required binary libraries to the build path. 42 | 43 | 44 | ### To deploy the samples into a CICS region 45 | 46 | 1. Using the CICS Explorer export the `com.ibm.cicsdev.*.cicsbundle` projects to a zFS directory. The sample definitions use the following style of zFS location `/u/cics1/com.ibm.cicsdev.link.cicsbundle_1.0.0`. 47 | 1. Define and install CICS `BUNDLE` resource defintions referring to the deployed bundle directory in step 1, and ensure all resources are enabled. 48 | 1. Create the required transaction and program definitions using either the supplied `DFHCSD.txt` files as input to a CSD define job, or using the supplied CICS bundle projects. 49 | 1. See the individual project directories for any additional supporting resources required. 50 | 51 | ## License 52 | 53 | This project is licensed under [Apache License Version 2.0](LICENSE). 54 | 55 | ## Reference 56 | 57 | * CICSDev tutorial archive [Getting to Grips with JCICS](blog/blog.md) 58 | * For further details on using the IBM Record Generator for Java see this [tutorial](https://developer.ibm.com/tutorials/build-java-records-from-cobol-with-ibm-record-generator/) 59 | * For details on how to define a CICS OSGi JVM server refer to the Knowledge Center topic [Configuring an OSGi JVM server](http://www.ibm.com/support/knowledgecenter/SSGMCP_5.3.0/com.ibm.cics.ts.java.doc/JVMserver/config_jvmserver_app.html) 60 | -------------------------------------------------------------------------------- /blog/graphics/JCICS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cicsdev/cics-java-jcics-samples/90cbc8817b35f3fbc775acf898e639b0f4e40136/blog/graphics/JCICS.png -------------------------------------------------------------------------------- /blog/graphics/JavaExceptions-1-e1484928035395.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cicsdev/cics-java-jcics-samples/90cbc8817b35f3fbc775acf898e639b0f4e40136/blog/graphics/JavaExceptions-1-e1484928035395.png -------------------------------------------------------------------------------- /etc/Link/DFHCSD.txt: -------------------------------------------------------------------------------- 1 | 2 | DEFINE PROGRAM(EC01) GROUP(JCICSAMP) 3 | DESCRIPTION(JCICS LINK sample backend) 4 | CONCURRENCY(REQUIRED) API(CICSAPI) 5 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 6 | EXECKEY(CICS) 7 | JVMCLASS(com.ibm.cicsdev.link.LinkServEC01) 8 | 9 | DEFINE PROGRAM(EDUCHAN) GROUP(JCICSAMP) 10 | DESCRIPTION(JCICS LINK sample backend) 11 | CONCURRENCY(REQUIRED) API(CICSAPI) 12 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 13 | EXECKEY(CICS) 14 | JVMCLASS(com.ibm.cicsdev.link.LinkServEduchan) 15 | 16 | DEFINE PROGRAM(JAVALIN1) GROUP(JCICSAMP) 17 | DESCRIPTION(JCICS LINK sample) 18 | CONCURRENCY(REQUIRED) API(CICSAPI) 19 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 20 | EXECKEY(CICS) 21 | JVMCLASS(com.ibm.cicsdev.link.LinkProg1) 22 | 23 | DEFINE PROGRAM(JAVALIN2) GROUP(JCICSAMP) 24 | DESCRIPTION(JCICS LINK sample) 25 | CONCURRENCY(REQUIRED) API(CICSAPI) 26 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 27 | EXECKEY(CICS) 28 | JVMCLASS(com.ibm.cicsdev.link.LinkProg2) 29 | 30 | DEFINE PROGRAM(JAVALIN3) GROUP(JCICSAMP) 31 | DESCRIPTION(JCICS LINK sample) 32 | CONCURRENCY(REQUIRED) API(CICSAPI) 33 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 34 | EXECKEY(CICS) 35 | JVMCLASS(com.ibm.cicsdev.link.LinkProg3) 36 | 37 | DEFINE TRANSACTION(JLN1) GROUP(JCICSAMP) 38 | DESCRIPTION(JCICS LINK sample) 39 | PROGRAM(JAVALIN1) 40 | TASKDATALOC(ANY) 41 | 42 | DEFINE TRANSACTION(JLN2) GROUP(JCICSAMP) 43 | DESCRIPTION(JCICS LINK sample) 44 | PROGRAM(JAVALIN2) 45 | TASKDATALOC(ANY) 46 | 47 | DEFINE TRANSACTION(JLN3) GROUP(JCICSAMP) 48 | DESCRIPTION(JCICS LINK sample) 49 | PROGRAM(JAVALIN3) 50 | TASKDATALOC(ANY) 51 | 52 | DEFINE BUNDLE(JCICSLIN) GROUP(JCICSAMP) 53 | DESCRIPTION(JCICS LINK sample) 54 | BUNDLEDIR(/u/cics1/com.ibm.cicsdev.link.cicsbundle_1.0.0) 55 | -------------------------------------------------------------------------------- /etc/Link/README.md: -------------------------------------------------------------------------------- 1 | Supporting materials used in conjunction with the JCICS LINK samples. 2 | 3 | * DFHCSD.txt - Output from a DFHCSDUP EXTRACT operation to define the programs and transactions required. 4 | 5 | -------------------------------------------------------------------------------- /etc/README.md: -------------------------------------------------------------------------------- 1 | etc 2 | === 3 | Supporting materials used in conjunction with the JCICS samples. Each folder provides supporting materials for the following projects: 4 | 5 | * [Link](Link) - com.ibm.cicsdev.link 6 | * [Serialize](Serialize) - com.ibm.cicsdev.serialize 7 | * [TDQ](TDQ) - com.ibm.cicsdev.tdq 8 | * [TSQ](TSQ) - com.ibm.cicsdev.tsq 9 | * [Terminal](Terminal) - com.ibm.cicsdev.terminal 10 | * [VSAM](VSAM) - com.ibm.cicsdev.vsam 11 | 12 | -------------------------------------------------------------------------------- /etc/Serialize/DFHCSD.txt: -------------------------------------------------------------------------------- 1 | 2 | DEFINE PROGRAM(JAVASYN1) GROUP(JCICSAMP) 3 | DESCRIPTION(Java synchronization sample) 4 | CONCURRENCY(REQUIRED) API(CICSAPI) DYNAMIC(NO) 5 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 6 | EXECKEY(CICS) 7 | JVMCLASS(com.ibm.cicsdev.serialize.SerializeExample1) 8 | 9 | DEFINE TRANSACTION(JSY1) GROUP(JCICSAMP) PROGRAM(JAVASYN1) 10 | DESCRIPTION(Java synchronization sample) 11 | TASKDATALOC(ANY) 12 | 13 | DEFINE BUNDLE(JCICSYNC) GROUP(JCICSAMP) 14 | DESCRIPTION(JCICS synchronization sample) 15 | BUNDLEDIR(/u/cics1/com.ibm.cicsdev.serialize.cicsbundle_1.0.0) 16 | 17 | -------------------------------------------------------------------------------- /etc/Serialize/README.md: -------------------------------------------------------------------------------- 1 | Supporting materials used in conjunction with the JCICS serialization samples. 2 | 3 | * DFHCSD.txt - Output from a DFHCSDUP EXTRACT operation to define the programs and transactions required. 4 | 5 | -------------------------------------------------------------------------------- /etc/TDQ/DFHCSD.txt: -------------------------------------------------------------------------------- 1 | 2 | DEFINE PROGRAM(JAVATDQ1) GROUP(JCICSAMP) 3 | DESCRIPTION(Java TDQ sample) 4 | CONCURRENCY(REQUIRED) API(CICSAPI) 5 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 6 | EXECKEY(CICS) 7 | JVMCLASS(com.ibm.cicsdev.tdq.TDQExample1) 8 | 9 | DEFINE PROGRAM(JAVATDQ2) GROUP(JCICSAMP) 10 | DESCRIPTION(Java TDQ sample) 11 | CONCURRENCY(REQUIRED) API(CICSAPI) 12 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 13 | EXECKEY(CICS) 14 | JVMCLASS(com.ibm.cicsdev.tdq.TDQExample2) 15 | 16 | DEFINE PROGRAM(JAVATDQ3) GROUP(JCICSAMP) 17 | DESCRIPTION(Java TDQ sample) 18 | CONCURRENCY(REQUIRED) API(CICSAPI) 19 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 20 | EXECKEY(CICS) 21 | JVMCLASS(com.ibm.cicsdev.tdq.TDQExample3) 22 | 23 | DEFINE TRANSACTION(JTD1) GROUP(JCICSAMP) 24 | DESCRIPTION(Java TDQ sample) 25 | PROGRAM(JAVATDQ1) 26 | TASKDATALOC(ANY) 27 | 28 | DEFINE TRANSACTION(JTD2) GROUP(JCICSAMP) 29 | DESCRIPTION(Java TDQ sample) 30 | PROGRAM(JAVATDQ2) 31 | TASKDATALOC(ANY) 32 | 33 | DEFINE TRANSACTION(JTD3) GROUP(JCICSAMP) 34 | DESCRIPTION(Java TDQ sample) 35 | PROGRAM(JAVATDQ3) 36 | TASKDATALOC(ANY) 37 | 38 | DEFINE BUNDLE(JCICSTDQ) GROUP(JCICSAMP) 39 | DESCRIPTION(Java TDQ sample) 40 | BUNDLEDIR(/u/cics1/com.ibm.cicsdev.tdq.cicsbundle_1.0.0) 41 | 42 | DEFINE TDQUEUE(MYQ1) GROUP(JCICSAMP) 43 | DESCRIPTION(Intrapartition TDQ for JCICS samples) 44 | TYPE(INTRA) 45 | -------------------------------------------------------------------------------- /etc/TDQ/README.md: -------------------------------------------------------------------------------- 1 | Supporting materials used in conjunction with the JCICS TDQ samples. 2 | 3 | * DFHCSD.txt - Output from a DFHCSDUP EXTRACT operation to define the programs and transactions required. 4 | 5 | -------------------------------------------------------------------------------- /etc/TSQ/DFHCSD.txt: -------------------------------------------------------------------------------- 1 | 2 | DEFINE PROGRAM(JAVATSQ1) GROUP(JCICSAMP) 3 | DESCRIPTION(Java TSQ sample) 4 | CONCURRENCY(REQUIRED) API(CICSAPI) 5 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 6 | EXECKEY(CICS) 7 | JVMCLASS(com.ibm.cicsdev.tsq.TSQExample1) 8 | 9 | 10 | DEFINE PROGRAM(JAVATSQ2) GROUP(JCICSAMP) 11 | DESCRIPTION(Java TSQ sample) 12 | CONCURRENCY(REQUIRED) API(CICSAPI) 13 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 14 | EXECKEY(CICS) 15 | JVMCLASS(com.ibm.cicsdev.tsq.TSQExample2) 16 | 17 | DEFINE PROGRAM(JAVATSQ3) GROUP(JCICSAMP) 18 | DESCRIPTION(Java TSQ sample) 19 | CONCURRENCY(REQUIRED) API(CICSAPI) 20 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 21 | EXECKEY(CICS) 22 | JVMCLASS(com.ibm.cicsdev.tsq.TSQExample3) 23 | 24 | DEFINE PROGRAM(JAVATSQ4) GROUP(JCICSAMP) 25 | DESCRIPTION(Java TSQ sample) 26 | CONCURRENCY(REQUIRED) API(CICSAPI) 27 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 28 | EXECKEY(CICS) 29 | JVMCLASS(com.ibm.cicsdev.tsq.TSQExample4) 30 | 31 | DEFINE TRANSACTION(JTS1) GROUP(JCICSAMP) 32 | DESCRIPTION(Java TSQ sample) 33 | PROGRAM(JAVATSQ1) 34 | TASKDATALOC(ANY) 35 | 36 | DEFINE TRANSACTION(JTS2) GROUP(JCICSAMP) 37 | DESCRIPTION(Java TSQ sample) 38 | PROGRAM(JAVATSQ2) 39 | TASKDATALOC(ANY) 40 | 41 | DEFINE TRANSACTION(JTS3) GROUP(JCICSAMP) 42 | DESCRIPTION(Java TSQ sample) 43 | PROGRAM(JAVATSQ3) 44 | TASKDATALOC(ANY) 45 | 46 | DEFINE TRANSACTION(JTS4) GROUP(JCICSAMP) 47 | DESCRIPTION(Java TSQ sample) 48 | PROGRAM(JAVATSQ4) 49 | TASKDATALOC(ANY) 50 | 51 | DEFINE BUNDLE(JCICSTSQ) GROUP(JCICSAMP) 52 | DESCRIPTION(JCICS TSQ SAMPLE) 53 | BUNDLEDIR(/u/cics1/com.ibm.cicsdev.tsq.cicsbundle_1.0.0) 54 | -------------------------------------------------------------------------------- /etc/TSQ/README.md: -------------------------------------------------------------------------------- 1 | Supporting materials used in conjunction with the JCICS TSQ samples. 2 | 3 | * DFHCSD.txt - Output from a DFHCSDUP EXTRACT operation to define the programs and transactions required. 4 | 5 | -------------------------------------------------------------------------------- /etc/Terminal/DFHCSD.txt: -------------------------------------------------------------------------------- 1 | 2 | DEFINE PROGRAM(JAVATRM1) GROUP(JCICSAMP) 3 | DESCRIPTION(Java terminal sample) 4 | CONCURRENCY(REQUIRED) API(CICSAPI) DYNAMIC(NO) 5 | JVM(YES) JVMSERVER(DFHJVMS) DATALOCATION(ANY) 6 | JVMCLASS(com.ibm.cicsdev.terminal.TerminalExample1) 7 | 8 | DEFINE TRANSACTION(JTM1) GROUP(JCICSAMP) PROGRAM(JAVATRM1) 9 | DESCRIPTION(Java terminal sample) 10 | TASKDATALOC(ANY) 11 | 12 | DEFINE BUNDLE(JCICTERM) GROUP(JCICSAMP) 13 | DESCRIPTION(JCICS terminal sample) 14 | BUNDLEDIR(/u/cics1/com.ibm.cicsdev.terminal.cicsbundle_1.0.0) 15 | 16 | -------------------------------------------------------------------------------- /etc/Terminal/README.md: -------------------------------------------------------------------------------- 1 | Supporting materials used in conjunction with the JCICS terminal samples. 2 | 3 | * DFHCSD.txt - Output from a DFHCSDUP EXTRACT operation to define the programs and transactions required. 4 | 5 | -------------------------------------------------------------------------------- /etc/VSAM/DEFVSAM.jcl: -------------------------------------------------------------------------------- 1 | //DEFVSAM JOB MSGLEVEL=(1,1),MSGCLASS=A,REGION=4M,MEMLIMIT=0M, 2 | // NOTIFY=&SYSUID. 3 | //* 4 | //DEFINE EXEC PGM=IDCAMS 5 | //SYSPRINT DD SYSOUT=* 6 | //SYSIN DD * 7 | 8 | DELETE JAVAED.TEST.KSDS.STOCK CLUSTER PURGE 9 | DELETE JAVAED.TEST.ESDS.STOCK CLUSTER PURGE 10 | DELETE JAVAED.TEST.RRDS.STOCK CLUSTER PURGE 11 | 12 | SET MAXCC = 0 13 | 14 | DEFINE CLUSTER ( - 15 | NAME ( JAVAED.TEST.KSDS.STOCK ) - 16 | RECORDS ( 100 10 ) - 17 | INDEXED - 18 | KEYS ( 8 0 ) - 19 | RECORDSIZE ( 80 80 ) - 20 | ) 21 | 22 | DEFINE CLUSTER ( - 23 | NAME ( JAVAED.TEST.ESDS.STOCK ) - 24 | RECORDS ( 100 10 ) - 25 | NONINDEXED - 26 | KEYS ( 8 0 ) - 27 | RECORDSIZE ( 80 80 ) - 28 | ) 29 | 30 | DEFINE CLUSTER ( - 31 | NAME ( JAVAED.TEST.RRDS.STOCK ) - 32 | RECORDS ( 100 10 ) - 33 | NUMBERED - 34 | RECORDSIZE ( 80 80 ) - 35 | ) 36 | 37 | /* 38 | // 39 | -------------------------------------------------------------------------------- /etc/VSAM/README.md: -------------------------------------------------------------------------------- 1 | Supporting materials used in conjunction with the JCICS VSAM samples. 2 | 3 | * DEFVSAM.jcl - Sample job to define the KSDS, ESDS, and RRDS VSAM files required. 4 | * DFHCSD.txt - Output from a DFHCSDUP EXTRACT operation to define the programs and transactions required. 5 | 6 | -------------------------------------------------------------------------------- /projects/README.md: -------------------------------------------------------------------------------- 1 | projects 2 | === 3 | 4 | Complete Eclipse projects demonstrating how to use the JCICS API in an OSGi JVM server environment. 5 | 6 | 7 | ## Overall project structure 8 | 9 | * `com.ibm.cicsdev.*` - Eclipse project containing the Java source code. 10 | * `com.ibm.cicsdev.*.cicsbundle` - Eclipse project for a CICS bundle that can be deployed into a CICS region. 11 | * `com.ibm.cicsdev.*.resources.cicsbundle` - Eclipse project for a CICS bundle that defines the required 12 | program and transaction resources for the sample. 13 | 14 | 15 | ## Samples overview 16 | 17 | * [`com.ibm.cicsdev.link`](com.ibm.cicsdev.link) - Performing CICS LINK operations using both commareas, 18 | and channels and containers. 19 | * [`com.ibm.cicsdev.serialize`](com.ibm.cicsdev.serialize) - Serializing access to a common resource using 20 | the CICS ENQ and DEQ mechanism. 21 | * [`com.ibm.cicsdev.tdq`](com.ibm.cicsdev.tdq) - Accessing transient data queues. 22 | * [`com.ibm.cicsdev.terminal`](com.ibm.cicsdev.terminal) - Reading in data from a terminal for an OSGi application. 23 | * [`com.ibm.cicsdev.tsq`](com.ibm.cicsdev.tsq) - Accessing temporary storage queues. 24 | * [`com.ibm.cicsdev.vsam`](com.ibm.cicsdev.vsam) - Accessing KSDS, ESDS, and RRDS VSAM files. 25 | 26 | 27 | ## Adding the resources to Eclipse 28 | 29 | 1. Using an Eclipse development environment import the project from the project folder using the menu 30 | **File** -> **Import** -> **Existing Projects into Workspace**. 31 | 1. Define and set a CICS Target Platform for the workspace using the menu **Window** -> **Preferences** -> 32 | **Target Platform**. 33 | 34 | 35 | ## Generated resources 36 | 37 | 38 | The TS, TD, VSAM and LINK sample projects manipulate byte-oriented record structures using Java classes 39 | generated using the IBM Record Generator for Java. The generated classes can be found packaged in a JAR 40 | file, found in the `lib/` subdirectory of the relevant project. Only the compiled helper classes are 41 | required to compile and run the application, however the generated source files are included for reference. 42 | 43 | If you are manually adding source files to your Eclipse development environment, you will need to add the 44 | generated JAR file to the build path in order to compile the samples, using the project context menu 45 | **Build Path** -> **Configure Build Path** -> **Libraries**. 46 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.link.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | encoding/com.ibm.cicsdev.link.osgibundle=UTF-8 4 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-04T15:14:04.215Z 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.cicsbundle/com.ibm.cicsdev.link.osgibundle: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.link.resources.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/JAVALIN1.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/JAVALIN2.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/JAVALIN3.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/JLN1.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/JLN2.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/JLN3.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link.resources.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-11T10:54:14.028Z 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.link 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | com.ibm.cics.explorer.sdk.CICSJavaOSGiBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | pluginProject.equinox=false 3 | pluginProject.extensions=false 4 | resolve.requirebundle=false 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Sample JCICS code for use of LINK 4 | Bundle-SymbolicName: com.ibm.cicsdev.link 5 | Bundle-Version: 1.0.0 6 | Bundle-Vendor: IBM 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | CICS-MainClass: com.ibm.cicsdev.link.LinkProg1, 9 | com.ibm.cicsdev.link.LinkProg2, 10 | com.ibm.cicsdev.link.LinkProg3, 11 | com.ibm.cicsdev.link.LinkServEduchan, 12 | com.ibm.cicsdev.link.LinkServEC01 13 | Import-Package: com.ibm.cics.server;version="[1.401.0,3.0.0)", 14 | com.ibm.jzos.fields;resolution:=optional 15 | Automatic-Module-Name: com.ibm.cicsdev.link 16 | Bundle-ClassPath: lib/EDUPGM.jar, 17 | . 18 | 19 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/README.md: -------------------------------------------------------------------------------- 1 | com.ibm.cicsdev.link 2 | === 3 | 4 | Provides examples for performing CICS LINK operations using both commareas, and channels and containers. 5 | 6 | * `LinkProg1` - a class that demonstrates linking to the COBOL application `EC01` using a COMMAREA. 7 | * `LinkProg2` - a class that demonstrates linking to the COBOL application `EDUPGM` using a COMMAREA mapped using a JZOS generated record. 8 | * `LinkProg3` - a class that demonstrates linking to COBOL application `EDUCHAN` using channels and containers. 9 | * `LinkProgCommon` - superclass used to provide common services for the `LinkProg` samples. 10 | * `LinkServerEduchan` - A Java version of the `EDUCHAN` COBOL program used as the back-end to `LinkProg3`. 11 | * `LinkServerEC01` - A Java version of the `EC01` COBOL program used as the back-end to `LinkProg1`. 12 | 13 | 14 | ## Supporting files 15 | 16 | * `lib/EDUPGM.jar` - a pre-built JAR containing the JZOS generated record that maps the copybook structure used in the `EDUPGM` COBOL sample. The generated class `JZOSCommareaWrapperclass` is used in the `LinkProg2` example to map the fields in the COMMAREA used by the COBOL program `EDUPGM`. 17 | * [`/etc/Link`](../../etc/Link) - contains the output of a DFHCSDUP EXTRACT operation needed to define the required programs and transactions. 18 | * [`/src/Cobol`](../../src/Cobol) - contains the COBOL programs `EC01` and `EDUCHAN` required by these samples. 19 | * [cics-java-jzosprog repo](https://github.com/cicsdev/cics-java-jzosprog/tree/main/src/Cobol) - repository containing the `EDUPGM` COBOL program. 20 | 21 | 22 | ## Configuration 23 | 24 | 1. Compile and deploy the COBOL programs `EC01`, `EDUPGM`, and `EDUCHAN`. 25 | 1. Define appropriate PROGRAM definitions, or enable program autoinstall. 26 | 1. Optionally add a CICS Java program definition for LinkServEduchan called EDUCHAN if you wish to replace the EDUCHAN COBOL sample with the Java implementation. 27 | 1. Optionally add a CICS Java program definition for LinkServEC01 called EC01 if you wish to replace the EC01 COBOL sample with the Java implementation. 28 | 29 | 30 | ## Running the Example 31 | 32 | At a 3270 terminal screen, enter the transaction you wish to run, for example JLN1 will run the LINK example 1. 33 | 34 | JLN1 35 | 36 | and the following output will be returned 37 | 38 | JLN1 - Starting LinkProg1 39 | Returned from link to EC01 with 19/08/16 09:17:01 40 | 41 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | lib/EDUPGM.jar 6 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/lib/EDUPGM.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cicsdev/cics-java-jcics-samples/90cbc8817b35f3fbc775acf898e639b0f4e40136/projects/com.ibm.cicsdev.link/lib/EDUPGM.jar -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/src/com/ibm/cicsdev/link/LinkProg1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.link; 12 | 13 | import java.io.UnsupportedEncodingException; 14 | import java.text.MessageFormat; 15 | 16 | import com.ibm.cics.server.CicsConditionException; 17 | import com.ibm.cics.server.InvalidRequestException; 18 | import com.ibm.cics.server.Program; 19 | import com.ibm.cics.server.Task; 20 | 21 | /** 22 | * Provides a simple example of LINKing to a CICS program using JCICS, 23 | * passing a byte array for a COMMAREA. 24 | * 25 | * This class executes in an OSGi JVM server environment. 26 | */ 27 | public class LinkProg1 extends LinkProgCommon 28 | { 29 | /** 30 | * Name of the COBOL program to be invoked. 31 | */ 32 | private static final String PROG_NAME = "EC01"; 33 | 34 | /** 35 | * Length of commarea returned by program EC01. 36 | */ 37 | private static final int CA_LEN = 18; 38 | 39 | /** 40 | * CCSID of the CICS region. 41 | */ 42 | private static final String CCSID = System.getProperty("com.ibm.cics.jvmserver.local.ccsid"); 43 | 44 | /** 45 | * Constructor used to pass data to superclass constructor. 46 | * 47 | * @param prog - the program reference we will be manipulating in this example. 48 | */ 49 | private LinkProg1(Program prog) 50 | { 51 | super(prog); 52 | } 53 | 54 | /** 55 | * Main entry point to a CICS OSGi program. 56 | * This can be called via a LINK or a 3270 attach. 57 | * 58 | * The fully-qualified name of this class should be added to the 59 | * CICS-MainClass entry in the parent OSGi bundle's manifest. 60 | */ 61 | public static void main(String[] args) 62 | { 63 | // Get details about our current CICS task 64 | Task task = Task.getTask(); 65 | task.out.println(" - Starting LinkProg1"); 66 | 67 | // Create a reference to the Program we will invoke 68 | Program prog = new Program(); 69 | 70 | // Specify the properties on the program 71 | prog.setName(PROG_NAME); 72 | 73 | // Don't syncpoint between remote links, this is the default 74 | // Setting true ensures each linked program runs in its own UOW and 75 | // allows the a remote server program to use a syncpoint command 76 | prog.setSyncOnReturn(false); 77 | 78 | // Create a new instance of the class 79 | LinkProg1 lp = new LinkProg1(prog); 80 | 81 | // Init commarea and invoke the LINK to CICS program 82 | // Commarea byte array should be as long as the DFHCOMMAREA structure in COBOL 83 | // Commarea will be padded with nulls which ensures CICS can null truncate DPL flows 84 | byte[] ca = new byte[CA_LEN]; 85 | lp.linkProg(ca); 86 | 87 | // Build output string from commarea assuming returned data encoded in CICS local EBCDIC ccsid 88 | String resultStr; 89 | try { 90 | resultStr = new String(ca,CCSID); 91 | } catch (UnsupportedEncodingException ue) { 92 | throw new RuntimeException(ue); 93 | } 94 | 95 | // Completion message 96 | String msg = MessageFormat.format("Returned from link to {0} with {1}", prog.getName(), resultStr); 97 | task.out.println(msg); 98 | } 99 | 100 | 101 | /** 102 | * Link to the CICS COBOL program catching any errors from CICS 103 | * The invoked CICS progra will retrun the date and time 104 | * 105 | * @param ca - byte array for input and output COMMAREA. 106 | */ 107 | private void linkProg(byte[] ca) { 108 | 109 | try { 110 | // Execute the LINK to the CICS program 111 | // The COMMAREA byte array is updated after the call and does not need to be returned 112 | this.prog.link(ca); 113 | } 114 | catch (InvalidRequestException ire) { 115 | // Ignore invalid request and just log 116 | Task.getTask().out.println("Invalid request on link - INVREQ"); 117 | } 118 | catch (CicsConditionException cce) { 119 | throw new RuntimeException(cce); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/src/com/ibm/cicsdev/link/LinkProg2.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.link; 12 | 13 | import java.text.MessageFormat; 14 | 15 | import com.ibm.cics.server.CicsConditionException; 16 | import com.ibm.cics.server.Program; 17 | import com.ibm.cics.server.Task; 18 | import com.ibm.cicsdev.bean.JZOSCommareaWrapper; 19 | 20 | /** 21 | * Provides a simple example of LINKing to a CICS program using JCICS, 22 | * passing a byte array for a COMMAREA. In this example, the COMMAREA 23 | * byte array is constructed using a JZOS generated class. 24 | * 25 | * This class executes in an OSGi JVM server environment. 26 | */ 27 | public class LinkProg2 extends LinkProgCommon 28 | { 29 | /** 30 | * Name of the COBOL program to be invoked. 31 | */ 32 | private static final String PROG_NAME = "EDUPGM"; 33 | 34 | /** 35 | * Constructor used to pass data to superclass constructor. 36 | * 37 | * @param prog - the program reference we will be manipulating in this example. 38 | */ 39 | private LinkProg2(Program prog) 40 | { 41 | super(prog); 42 | } 43 | 44 | /** 45 | * Main entry point to a CICS OSGi program. 46 | * This can be called via a LINK or a 3270 attach. 47 | * 48 | * The fully qualified name of this class should be added to the CICS-MainClass 49 | * entry in the parent OSGi bundle's manifest. 50 | */ 51 | public static void main(String[] args) 52 | { 53 | // Get details about our current CICS task 54 | Task task = Task.getTask(); 55 | task.out.println(" - Starting LinkProg2"); 56 | 57 | // Create a reference to the Program we will invoke 58 | Program prog = new Program(); 59 | 60 | // Specify the properties on the program 61 | prog.setName(PROG_NAME); 62 | 63 | // Don't syncpoint between remote links, this is the default 64 | // Setting true ensures each linked program runs in its own UOW and 65 | // allows the a remote server program to use a syncpoint command 66 | prog.setSyncOnReturn(false); 67 | 68 | // Create a new instance of the class 69 | LinkProg2 lp = new LinkProg2(prog); 70 | 71 | // build commarea byte array using JZOS record 72 | JZOSCommareaWrapper cw = lp.buildCommarea(); 73 | 74 | // Invoke the LINK to CICS program converting the record to a byte array 75 | lp.linkProg(cw.getByteBuffer()); 76 | 77 | // Get output data from commarea 78 | // Use the getters from the commarea record to access the output fields 79 | // in the returned commarea 80 | String resultStr = cw.getResultText(); 81 | Integer resultCode = cw.getResultCode(); 82 | 83 | // Completion message 84 | String msg = MessageFormat.format("Returned from link to {0} with rc({1}) {2}", 85 | prog.getName(), resultCode, resultStr); 86 | task.out.println(msg); 87 | } 88 | 89 | 90 | /** 91 | * Link to the CICS COBOL program and catch any errors from CICS. 92 | * 93 | * @param commarea - byte array as input and output commarea 94 | */ 95 | private void linkProg(byte[] commarea) { 96 | 97 | try { 98 | // LINK to the CICS program 99 | this.prog.link(commarea); 100 | } 101 | catch (CicsConditionException cce) { 102 | // Crude error handling to keep logic simple 103 | throw new RuntimeException(cce); 104 | } 105 | } 106 | 107 | /** 108 | * Build the commarea using the supplied JZOS wrapper 109 | * and set the input fields as required. 110 | * 111 | * @return JZOS COMMAREA record for EDUPGM copybook 112 | */ 113 | private JZOSCommareaWrapper buildCommarea() { 114 | 115 | // Create a new instance of the generated class 116 | JZOSCommareaWrapper cw = new JZOSCommareaWrapper(); 117 | cw.setBinaryDigit(1); 118 | cw.setCharacterString("hello"); 119 | cw.setNumericString(1234); 120 | cw.setPackedDigit(123456789); 121 | cw.setSignedPacked(-100); 122 | cw.setBool("1"); 123 | 124 | // Return the constructed object 125 | return cw; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/src/com/ibm/cicsdev/link/LinkProgCommon.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.link; 12 | 13 | import com.ibm.cics.server.Program; 14 | 15 | /** 16 | * Superclass used to provide common services used in all of the examples. 17 | * 18 | * For the sake of brevity, this example does not include comprehensive 19 | * error-handling logic. See the CICS Java samples around error-handling 20 | * for more details on catching CICS Exceptions in Java. 21 | */ 22 | public abstract class LinkProgCommon 23 | { 24 | /** 25 | * A field to hold a reference to the CICS program 26 | * this instance will access. 27 | */ 28 | protected final Program prog; 29 | 30 | /** 31 | * Constructor used to initialise this class with some common data 32 | * 33 | * @param tsq - a reference to the temporary storage queue we will 34 | * be manipulating in this example. 35 | */ 36 | protected LinkProgCommon(Program p) 37 | { 38 | // Save reference to the CICS program 39 | this.prog = p; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.link/src/com/ibm/cicsdev/link/LinkServEC01.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.link; 12 | 13 | import java.io.UnsupportedEncodingException; 14 | import java.text.SimpleDateFormat; 15 | import java.util.Date; 16 | 17 | import com.ibm.cics.server.CommAreaHolder; 18 | import com.ibm.cics.server.Task; 19 | 20 | /** 21 | * Provides a Java implementation that is functionally equivalent to the COBOL 22 | * EC01 sample program. 23 | */ 24 | public class LinkServEC01 25 | { 26 | /** 27 | * Length of the COMMAREA returned by this program. 28 | */ 29 | private static final int CA_LEN = 18; 30 | 31 | /** 32 | * Abend code used if the COMMAREA is too short. 33 | */ 34 | private static final String CA_LEN_ABCODE = "LEN"; 35 | 36 | /** 37 | * CCSID of the CICS region. 38 | */ 39 | private static final String LOCALCCSID = System.getProperty("com.ibm.cics.jvmserver.local.ccsid"); 40 | 41 | /** 42 | * Time formatter. 43 | */ 44 | private static final SimpleDateFormat dfTime = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); 45 | 46 | /** 47 | * Main entry point to a CICS OSGi program. 48 | * 49 | * The fully qualified name of this class should be added to the 50 | * CICS-MainClass entry in the parent OSGi bundle's manifest. 51 | * 52 | * This program is a Java version of the COBOL EC01 sample. It expects to be 53 | * invoked with a COMMAREA of 18 bytes and returns the date. 54 | */ 55 | public static void main(CommAreaHolder cah) { 56 | 57 | // Get a reference to the current CICS task 58 | Task task = Task.getTask(); 59 | 60 | // Check input area is long enough, else abend task 61 | if (cah.getValue().length < CA_LEN) { 62 | task.abend(CA_LEN_ABCODE); 63 | } 64 | 65 | // Get time for return to caller 66 | Date timestamp = new Date(); 67 | 68 | try { 69 | // Create byte array in local encoding 70 | byte ba[] = dfTime.format(timestamp).getBytes(LOCALCCSID); 71 | 72 | // Copy into the byte array provided by the CommAreaHolder object 73 | System.arraycopy(ba, 0, cah.getValue(), 0, ba.length); 74 | } catch (UnsupportedEncodingException uee) { 75 | // Simple error handling for example 76 | throw new RuntimeException(uee); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.serialize.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | com.ibm.cicsdev.serialize.cicsbundle 14 | 15 | 16 | majorVersion 17 | 1 18 | 19 | 20 | microVersion 21 | 0 22 | 23 | 24 | minorVersion 25 | 0 26 | 27 | 28 | 29 | 30 | 31 | com.ibm.cics.bundle.ui.bundlenature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | encoding/com.ibm.cicsdev.serialize.osgibundle=UTF-8 4 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-12-13T15:47:28.565Z 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.cicsbundle/com.ibm.cicsdev.serialize.osgibundle: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.resources.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.serialize.resources.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | com.ibm.cicsdev.serialize.resources.cicsbundle 14 | 15 | 16 | majorVersion 17 | 1 18 | 19 | 20 | microVersion 21 | 0 22 | 23 | 24 | minorVersion 25 | 0 26 | 27 | 28 | 29 | 30 | 31 | com.ibm.cics.bundle.ui.bundlenature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.resources.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.resources.cicsbundle/JAVASYN1.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.resources.cicsbundle/JSY1.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize.resources.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-12-13T15:49:54.727Z 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.serialize 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | com.ibm.cics.explorer.sdk.CICSJavaOSGiBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | pluginProject.equinox=false 3 | pluginProject.extensions=false 4 | resolve.requirebundle=false 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Sample JCICS serialization code 4 | Bundle-SymbolicName: com.ibm.cicsdev.serialize 5 | Bundle-Version: 1.0.0 6 | Bundle-Vendor: IBM 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | Import-Package: com.ibm.cics.server;version="[1.401.0,3.0.0)" 9 | Bundle-ClassPath: . 10 | CICS-MainClass: com.ibm.cicsdev.serialize.SerializeExample1 11 | Automatic-Module-Name: com.ibm.cicsdev.serialize 12 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/README.md: -------------------------------------------------------------------------------- 1 | com.ibm.cicsdev.serialize 2 | === 3 | 4 | Provides an example for serializing access to a common resource using the CICS ENQ and DEQ mechanism. 5 | 6 | * `SerializeExample1` - a simple class to demonstrate using the CICS ENQ and DEQ mechanism from a JCICS environment. 7 | 8 | 9 | ## Supporting files 10 | 11 | * [`/etc/Serialize`](../../etc/Serialize) - contains the output of a DFHCSDUP EXTRACT operation needed to define the required programs and transactions. 12 | 13 | 14 | ## Running the Example 15 | 16 | At a 3270 terminal screen, enter the transaction you wish to run, for example JSY1 will run example 1. 17 | 18 | JSY1 19 | 20 | and the following output will be returned 21 | 22 | JSY1 - Starting SerializeExample1 23 | Attempting to acquire resource lock MYAPP.SYNC.RES1 24 | Resource lock has been acquired 25 | Resource lock has been released 26 | Completed SerializeExample1 27 | 28 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.serialize/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.tdq.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | encoding/com.ibm.cicsdev.tdq.osgibundle=UTF-8 4 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-04T15:15:01.777Z 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.cicsbundle/com.ibm.cicsdev.tdq.osgibundle: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.tdq.resources.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/JAVATDQ1.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/JAVATDQ2.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/JAVATDQ3.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/JTD1.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/JTD2.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/JTD3.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq.resources.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-11T11:00:30.401Z 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.tdq 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | com.ibm.cics.explorer.sdk.CICSJavaOSGiBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | pluginProject.equinox=false 3 | pluginProject.extensions=false 4 | resolve.requirebundle=false 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Sample JCICS code for use of transient data queues 4 | Bundle-SymbolicName: com.ibm.cicsdev.tdq 5 | Bundle-Version: 1.0.0 6 | Bundle-Vendor: IBM 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | CICS-MainClass: com.ibm.cicsdev.tdq.TDQExample1, 9 | com.ibm.cicsdev.tdq.TDQExample2, 10 | com.ibm.cicsdev.tdq.TDQExample3 11 | Import-Package: com.ibm.cics.server;version="[1.401.0,3.0.0)", 12 | com.ibm.jzos.fields;resolution:=optional 13 | Automatic-Module-Name: com.ibm.cicsdev.tdq 14 | Bundle-ClassPath: lib/TdqRecord.jar, 15 | . 16 | 17 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/README.md: -------------------------------------------------------------------------------- 1 | com.ibm.cicsdev.tdq 2 | === 3 | 4 | This project contains various sample programs to demonstrate use of the JCICS API for manipulating a transient 5 | data queue (TDQ). A TDQ is a queue of data items that is stored in sequential queues. Transient queues are 6 | resources whose name may contain up to 4 characters and must be defined before use, unlike temporary storage 7 | queues that can be dynamically defined. 8 | 9 | * **Intrapartition** queues are accessible only by CICS transactions within the CICS region 10 | * **Extrapartition** queues are sequential data sets on tape or disk. 11 | * Intrapartition and extrapartition queues can be referenced through **indirect** destinations to provide 12 | flexibility in program maintenance. Queue definitions can be changed without having to recompile existing 13 | programs. 14 | 15 | All of the examples in this repository use an intrapartition queue named `MYQ1`. 16 | 17 | * `TDQExample1` - a simple class that writes Java strings to a TDQ and then reads them back. 18 | * `TDQExample2` - an alternative implementation of `TDQExample1` that writes and reads Java strings, but performing all of the codepage conversion manually. This avoids the pre-requisite of CICS TS V5.1, but is slightly more work to code in Java. 19 | * `TDQExample3` - a more complex example that writes structured records to a TDQ and then reads them back. 20 | * `TDQCommon` - Superclass used to provide common services for the TDQ samples. 21 | 22 | For the sake of brevity, all of the examples lack comprehensive error-handling logic. 23 | To demonstrate exactly where an exception may be thrown when using the JCICS API, one `try { ... } catch { ... }` 24 | block has been included per API call that may thrown an exception. 25 | 26 | 27 | ## Supporting files 28 | 29 | * `lib/TdqRecord.jar` - a pre-built JAR containing the JZOS generated record that maps the copybook structure used in `TDQExample3` (includes source). 30 | * [`/etc/TDQ`](../../etc/TDQ) - contains the output of a DFHCSDUP EXTRACT operation needed to define the required programs and transactions. 31 | 32 | 33 | ## Structured record 34 | 35 | The class `TdqRecord` is produced by the JZOS record generator utility from a COBOL copybook. This class 36 | is used in example 3 to write a structured record to the TDQ. The `TdqRecord` class is used to 37 | demonstrate how a Java application would interact with non-Java implementations when communicating using a TDQ. 38 | 39 | The COBOL structure that is mapped by the `TdqRecord` class is as follows: 40 | 41 | 01 TDQ-RECORD. 42 | 03 RECORD-ID PIC 9(8) COMP. 43 | 03 BINARY-DIGIT PIC 9(4) COMP. 44 | 03 CHARACTER-STRING PIC X(30). 45 | 03 NUMERIC-VALUE PIC 9(18). 46 | 03 PACKED-DEC PIC 9(15) COMP-3. 47 | 03 SIGNED-PACKED PIC S9(12) COMP-3. 48 | 49 | 50 | ## Configuration 51 | 52 | Note you must define an intrapartition transient data queue named `MYQ1` before using these samples. 53 | The simplest way to define this TDQ is using the `CECI` transaction: 54 | 55 | CECI CREATE TDQUEUE(MYQ1) ATTRIBUTES('TYPE(INTRA)') 56 | 57 | Press send twice - firstly to confirm the command, and secondly to receive the message: 58 | 59 | STATUS: COMMAND EXECUTION COMPLETE 60 | 61 | 62 | ## Running the Example 63 | 64 | At a 3270 terminal screen, enter the transaction you wish to run, for example JTD1 will run TDQ example 1. 65 | 66 | JTD1 67 | 68 | and the following output will be returned 69 | 70 | JTD1 - Starting TDQExample1 71 | Read data from queue "TDQ write from JCICS item 1" 72 | Read data from queue "TDQ write from JCICS item 2" 73 | Read data from queue "TDQ write from JCICS item 3" 74 | Read data from queue "TDQ write from JCICS item 4" 75 | Read data from queue "TDQ write from JCICS item 5" 76 | Completed TDQExample1 77 | 78 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | lib/TdqRecord.jar 6 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/lib/TdqRecord.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cicsdev/cics-java-jcics-samples/90cbc8817b35f3fbc775acf898e639b0f4e40136/projects/com.ibm.cicsdev.tdq/lib/TdqRecord.jar -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/src/com/ibm/cicsdev/tdq/TDQCommon.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tdq; 12 | 13 | import java.text.MessageFormat; 14 | 15 | import com.ibm.cics.server.CicsConditionException; 16 | import com.ibm.cics.server.InvalidQueueIdException; 17 | import com.ibm.cics.server.TDQ; 18 | import com.ibm.cics.server.Task; 19 | 20 | /** 21 | * Superclass used to provide common services used in all of the TDQ 22 | * examples. 23 | */ 24 | public abstract class TDQCommon 25 | { 26 | /** 27 | * A field to hold a reference to the CICS transient 28 | * data queue this instance will access. 29 | */ 30 | protected final TDQ tdq; 31 | 32 | /** 33 | * Constructor used to initialise this class with some 34 | * common data used by all TDQ examples. 35 | * 36 | * @param tdq - a reference to the transient data queue we will 37 | * be manipulating in this example. 38 | */ 39 | protected TDQCommon(TDQ tdq) 40 | { 41 | // Save reference to the TDQ 42 | this.tdq = tdq; 43 | 44 | // Delete any old TDQ that's lying around 45 | deleteQueue(); 46 | } 47 | 48 | /** 49 | * Deletes all the data associated with the instance transient data queue. 50 | */ 51 | private void deleteQueue() 52 | { 53 | try { 54 | // Empty the TDQ 55 | this.tdq.delete(); 56 | } 57 | catch (InvalidQueueIdException iqe) { 58 | 59 | // QIDERR occurs when the queue cannot be found. 60 | // Unlike the TSQ case, this is NOT an acceptable condition, 61 | // because TDQs cannot be generated dynamically 62 | String msg = MessageFormat.format("Could not find queue \"{0}\"", this.tdq.getName()); 63 | Task.getTask().out.println(msg); 64 | 65 | // Crude error handling - propagate an exception back to caller 66 | throw new RuntimeException(iqe); 67 | } 68 | catch (CicsConditionException cce) { 69 | // All other errors 70 | // Crude error handling - propagate an exception back to caller 71 | throw new RuntimeException(cce); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/src/com/ibm/cicsdev/tdq/TDQExample1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tdq; 12 | 13 | import java.text.MessageFormat; 14 | 15 | import com.ibm.cics.server.CicsConditionException; 16 | import com.ibm.cics.server.DataHolder; 17 | import com.ibm.cics.server.TDQ; 18 | import com.ibm.cics.server.Task; 19 | 20 | /** 21 | * Example to demonstrate writing reading simple text-based records 22 | * to and from a TDQ using JCICS. 23 | */ 24 | public class TDQExample1 extends TDQCommon 25 | { 26 | /** 27 | * Name of the TDQ to use. 28 | */ 29 | private static final String TDQ_NAME = "MYQ1"; 30 | 31 | /** 32 | * Number of items to write to the queue. 33 | */ 34 | private static final int DEPTH_COUNT = 5; 35 | 36 | /** 37 | * Main entry point to this CICS Java program. 38 | */ 39 | public static void main(String[] args) 40 | { 41 | // Get details about our current CICS task 42 | Task task = Task.getTask(); 43 | task.out.println(" - Starting TDQExample1"); 44 | 45 | // Create a reference to the TDQ 46 | TDQ tdq = new TDQ(); 47 | tdq.setName(TDQ_NAME); 48 | 49 | // Create a new instance of this class 50 | TDQExample1 ex = new TDQExample1(tdq); 51 | 52 | // Write text to the queue 53 | ex.writeToQueue(); 54 | 55 | // Read text from the queue 56 | ex.readFromQueue(); 57 | 58 | // Completion message 59 | task.out.println("Completed TDQExample1"); 60 | } 61 | 62 | /** 63 | * Constructor used to pass data to superclass constructor. 64 | * 65 | * @param tdq - the transient data queue reference we will 66 | * be manipulating in this example. 67 | */ 68 | public TDQExample1(TDQ tdq) 69 | { 70 | super(tdq); 71 | } 72 | 73 | /** 74 | * Write some sample data to the instance TDQ. 75 | */ 76 | public void writeToQueue() 77 | { 78 | // Write several items to the queue 79 | for (int i = 1; i <= DEPTH_COUNT; i++) { 80 | 81 | // Construct a message for writing to the queue 82 | String msg = MessageFormat.format("TDQ write from JCICS item {0}", i); 83 | 84 | try { 85 | // Write the data to the TDQ 86 | // No codepage conversion required for this method 87 | // Requires CICS TS V5.1 and later (JCICS 1.401.0) 88 | this.tdq.writeString(msg); 89 | } 90 | catch (CicsConditionException cce) { 91 | // Crude error handling - propagate an exception back to caller 92 | throw new RuntimeException(cce); 93 | } 94 | } 95 | } 96 | 97 | /** 98 | * Simple read of string data from a TDQ. 99 | */ 100 | public void readFromQueue() 101 | { 102 | // A holder object to receive the data from CICS 103 | DataHolder holder = new DataHolder(); 104 | 105 | for ( int i = 1; i <= DEPTH_COUNT; i++ ) { 106 | 107 | try { 108 | // Read the queue sequentially (destructive read) 109 | this.tdq.readData(holder); 110 | } 111 | catch (CicsConditionException cce) { 112 | // Crude error handling - propagate an exception back to caller 113 | throw new RuntimeException(cce); 114 | } 115 | 116 | // Assume this is a valid character string in the CICS local CCSID 117 | // Requires CICS TS V5.1 and later (JCICS 1.401.0) 118 | String strData = holder.getStringValue(); 119 | 120 | // Write out to the console 121 | String msg = MessageFormat.format("Read data from queue \"{0}\"", strData); 122 | Task.getTask().out.println(msg); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/src/com/ibm/cicsdev/tdq/TDQExample2.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tdq; 12 | 13 | import java.io.UnsupportedEncodingException; 14 | import java.text.MessageFormat; 15 | 16 | import com.ibm.cics.server.CicsConditionException; 17 | import com.ibm.cics.server.DataHolder; 18 | import com.ibm.cics.server.TDQ; 19 | import com.ibm.cics.server.Task; 20 | 21 | /** 22 | * Example to demonstrate writing reading simple text-based records 23 | * to and from a TDQ using JCICS, with manual maintenance of codepages. 24 | */ 25 | public class TDQExample2 extends TDQCommon 26 | { 27 | /** 28 | * Name of the TDQ to use. 29 | */ 30 | private static final String TDQ_NAME = "MYQ1"; 31 | 32 | /** 33 | * Number of items to write to the queue. 34 | */ 35 | private static final int DEPTH_COUNT = 5; 36 | 37 | /** 38 | * Resolved at runtime to be the CCSID of the region. 39 | */ 40 | private static final String CCSID = 41 | System.getProperty("com.ibm.cics.jvmserver.local.ccsid"); 42 | 43 | /** 44 | * Main entry point to this CICS Java program. 45 | */ 46 | public static void main(String[] args) 47 | { 48 | // Get details about our current CICS task 49 | Task task = Task.getTask(); 50 | task.out.println(" - Starting TDQExample2"); 51 | 52 | // Create a reference to the TDQ 53 | TDQ tdq = new TDQ(); 54 | tdq.setName(TDQ_NAME); 55 | 56 | // Create a new instance of this class 57 | TDQExample2 ex = new TDQExample2(tdq); 58 | 59 | // Write text to the queue 60 | ex.writeToQueue(); 61 | 62 | // Read text from the queue 63 | ex.readFromQueue(); 64 | 65 | // Completion message 66 | task.out.println("Completed TDQExample2"); 67 | } 68 | 69 | /** 70 | * Constructor used to pass data to superclass constructor. 71 | * 72 | * @param tdq - the transient data queue reference we will 73 | * be manipulating in this example. 74 | */ 75 | public TDQExample2(TDQ tdq) 76 | { 77 | super(tdq); 78 | } 79 | 80 | /** 81 | * Write some sample data to the instance TDQ. 82 | */ 83 | public void writeToQueue() 84 | { 85 | // Write several items to the queue 86 | for (int i = 1; i <= DEPTH_COUNT; i++) { 87 | 88 | // Data to write to the TDQ 89 | byte[] data; 90 | 91 | // Construct a message for writing to the queue 92 | String msg = MessageFormat.format("TDQ write from JCICS item {0}", i); 93 | 94 | try { 95 | // Convert the string to a byte[] 96 | data = msg.getBytes(CCSID); 97 | } 98 | catch (UnsupportedEncodingException uee) { 99 | // Crude error handling - propagate an exception back to caller 100 | throw new RuntimeException(uee); 101 | } 102 | 103 | try { 104 | // Write the data to the TDQ 105 | this.tdq.writeData(data); 106 | } 107 | catch (CicsConditionException cce) { 108 | // Crude error handling - propagate an exception back to caller 109 | throw new RuntimeException(cce); 110 | } 111 | } 112 | } 113 | 114 | /** 115 | * Simple read of string data from a TDQ. 116 | */ 117 | public void readFromQueue() 118 | { 119 | // A holder object to receive the data from CICS 120 | DataHolder holder = new DataHolder(); 121 | 122 | for ( int i = 1; i <= DEPTH_COUNT; i++ ) { 123 | 124 | try { 125 | // Read the queue sequentially (destructive read) 126 | this.tdq.readData(holder); 127 | } 128 | catch (CicsConditionException cce) { 129 | // Crude error handling - propagate an exception back to caller 130 | throw new RuntimeException(cce); 131 | } 132 | 133 | // Extract the byte[] data 134 | byte[] data = holder.getValue(); 135 | 136 | // String object to create 137 | String strData; 138 | 139 | try { 140 | // Assume this is a valid character string in the CICS local CCSID 141 | strData = new String(data, CCSID); 142 | } 143 | catch (UnsupportedEncodingException uee) { 144 | // Crude error handling - propagate an exception back to caller 145 | throw new RuntimeException(uee); 146 | } 147 | 148 | // Write out to the console 149 | String msg = MessageFormat.format("Read data from queue \"{0}\"", strData); 150 | Task.getTask().out.println(msg); 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tdq/src/com/ibm/cicsdev/tdq/TDQExample3.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tdq; 12 | 13 | import java.text.MessageFormat; 14 | 15 | import com.ibm.cics.server.CicsConditionException; 16 | import com.ibm.cics.server.DataHolder; 17 | import com.ibm.cics.server.TDQ; 18 | import com.ibm.cics.server.Task; 19 | import com.ibm.cicsdev.bean.TdqRecord; 20 | 21 | /** 22 | * Example to demonstrate writing reading simple text-based records 23 | * to and from a TDQ using JCICS. 24 | */ 25 | public class TDQExample3 extends TDQCommon 26 | { 27 | /** 28 | * Name of the TDQ to use. 29 | */ 30 | private static final String TDQ_NAME = "MYQ1"; 31 | 32 | /** 33 | * Number of items to write to the queue. 34 | */ 35 | private static final int DEPTH_COUNT = 5; 36 | 37 | /** 38 | * Main entry point to this CICS Java program. 39 | */ 40 | public static void main(String[] args) 41 | { 42 | // Get details about our current CICS task 43 | Task task = Task.getTask(); 44 | task.out.println(" - Starting TDQExample3"); 45 | 46 | // Create a reference to the TDQ 47 | TDQ tdq = new TDQ(); 48 | tdq.setName(TDQ_NAME); 49 | 50 | // Create a new instance of this class 51 | TDQExample3 ex = new TDQExample3(tdq); 52 | 53 | // Write text to the queue 54 | ex.writeToQueue(); 55 | 56 | // Read text from the queue 57 | ex.readFromQueue(); 58 | 59 | // Completion message 60 | task.out.println("Completed TDQExample3"); 61 | } 62 | 63 | /** 64 | * Constructor used to pass data to superclass constructor. 65 | * 66 | * @param tdq - the transient data queue reference we will 67 | * be manipulating in this example. 68 | */ 69 | public TDQExample3(TDQ tdq) 70 | { 71 | super(tdq); 72 | } 73 | 74 | /** 75 | * Write of byte[] data to the instance TDQ. 76 | */ 77 | public void writeToQueue() 78 | { 79 | // Create a wrapper object to write to the queue 80 | // This class has been generated using the JZOS record generator utility 81 | TdqRecord data = new TdqRecord(); 82 | 83 | // Populate with some dummy data 84 | data.setBinaryDigit(42); 85 | data.setCharacterString("TDQ test example"); 86 | data.setNumericValue(123456789); 87 | data.setPackedDec(123); 88 | data.setSignedPacked(-99); 89 | 90 | // Write several items to the queue 91 | for (int i = 1; i <= DEPTH_COUNT; i++) { 92 | 93 | // Update record for this iteration 94 | data.setRecordId(i); 95 | 96 | // Extract the byte data from the wrapper object 97 | // The generated class handles any codepage conversion required 98 | byte[] record = data.getByteBuffer(); 99 | 100 | try { 101 | // Write the data to the TDQ 102 | this.tdq.writeData(record); 103 | } 104 | catch (CicsConditionException cce) { 105 | // Crude error handling - propagate an exception back to caller 106 | throw new RuntimeException(cce); 107 | } 108 | } 109 | 110 | } 111 | 112 | /** 113 | * Read of byte[] data from a TDQ. 114 | */ 115 | public void readFromQueue() 116 | { 117 | // A holder object to receive the data from CICS 118 | DataHolder holder = new DataHolder(); 119 | 120 | // Read data from the queue 121 | for (int i = 1; i <= DEPTH_COUNT; i++) { 122 | 123 | try { 124 | // Read the data from CICS 125 | this.tdq.readData(holder); 126 | } 127 | catch (CicsConditionException cce) { 128 | // Crude error handling - propagate an exception back to caller 129 | throw new RuntimeException(cce); 130 | } 131 | 132 | // Obtain the raw bytes from the TDQ item 133 | byte[] itemData = holder.getValue(); 134 | 135 | // Convert to Java object form 136 | // This class has been generated using the JZOS record generator utility 137 | TdqRecord record = new TdqRecord(itemData); 138 | 139 | // Break the record apart 140 | String msg = MessageFormat.format("Record: ({0}) ({1}) ({2}) ({3}) ({4}) ({5})", 141 | record.getRecordId(), 142 | record.getBinaryDigit(), 143 | record.getCharacterString(), 144 | record.getNumericValue(), 145 | record.getPackedDec(), 146 | record.getSignedPacked()); 147 | 148 | // Write out the record to the terminal 149 | Task.getTask().out.println(msg); 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.terminal.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | encoding/com.ibm.cicsdev.terminal.osgibundle=UTF-8 4 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-04T15:15:33.327Z 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.cicsbundle/com.ibm.cicsdev.terminal.osgibundle: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.resources.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.terminal.resources.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | com.ibm.cicsdev.terminal.resources.cicsbundle 14 | 15 | 16 | majorVersion 17 | 1 18 | 19 | 20 | microVersion 21 | 0 22 | 23 | 24 | minorVersion 25 | 0 26 | 27 | 28 | 29 | 30 | 31 | com.ibm.cics.bundle.ui.bundlenature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.resources.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.resources.cicsbundle/JAVATRM1.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.resources.cicsbundle/JTM1.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal.resources.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-11T11:05:46.741Z 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.terminal 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | com.ibm.cics.explorer.sdk.CICSJavaOSGiBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Sample JCICS terminal code 4 | Bundle-SymbolicName: com.ibm.cicsdev.terminal 5 | Bundle-Version: 1.0.0 6 | Bundle-Vendor: IBM 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | CICS-MainClass: com.ibm.cicsdev.terminal.TerminalExample1 9 | Import-Package: com.ibm.cics.server;version="[1.401.0,3.0.0)" 10 | Bundle-ClassPath: . 11 | Automatic-Module-Name: com.ibm.cicsdev.terminal 12 | 13 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/README.md: -------------------------------------------------------------------------------- 1 | com.ibm.cicsdev.terminal 2 | === 3 | 4 | Provides some sample Java code to show how to parse arguments when a Java program is used as an 5 | initial program on a transaction, and the transaction is started from a terminal. 6 | 7 | The code first checks we are associated with a terminal, and then performs `receive()` call 8 | to obtain the data supplied at the terminal. 9 | 10 | This data is then broken down using the `java.util.StringTokenizer` class to split the 11 | supplied arguments on word boundaries. 12 | 13 | * `TerminalExample1` - a simple class to demonstrate receiving arguments from a terminal in a JCICS environment. 14 | 15 | ## Supporting files 16 | 17 | * [`/etc/Terminal`](../../etc/Terminal) - contains the output of a DFHCSDUP EXTRACT operation needed to define the required programs and transactions. 18 | 19 | 20 | ## Running the Example 21 | 22 | At a 3270 terminal screen, enter the transaction you wish to run, followed by some optional arguments. 23 | 24 | JTM1 Hello from CICS! 25 | 26 | and the following output will be returned (assuming upper-casing is enabled for the terminal): 27 | 28 | JTM1 Hello from CICS! - Starting TerminalExample1 29 | Arg 0 : JTM1 30 | Arg 1 : HELLO 31 | Arg 2 : FROM 32 | Arg 3 : CICS! 33 | Completed TerminalExample1 34 | 35 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.terminal/src/com/ibm/cicsdev/terminal/TerminalExample1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.terminal; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.StringTokenizer; 16 | 17 | import com.ibm.cics.server.CicsConditionException; 18 | import com.ibm.cics.server.DataHolder; 19 | import com.ibm.cics.server.EndOfChainIndicatorException; 20 | import com.ibm.cics.server.Task; 21 | import com.ibm.cics.server.TerminalPrincipalFacility; 22 | 23 | /** 24 | * Provides an example of receiving arguments to a transaction at a 3270 terminal. 25 | */ 26 | public class TerminalExample1 27 | { 28 | /** 29 | * Main entry point to a CICS OSGi program. 30 | */ 31 | public static void main(String[] args) throws CicsConditionException 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | 36 | // Retrieve the raw string from the terminal 37 | // This will need to be issued before we write anything out 38 | String strTerm = getTerminalString(); 39 | 40 | // Now we can report status to the terminal 41 | task.out.println(" - Starting TerminalExample1"); 42 | 43 | // Do we have terminal arguments? 44 | if (strTerm != null) { 45 | 46 | // Parse to individual elements 47 | String[] termArgs = parseTerminalString(strTerm); 48 | 49 | // Display arguments 50 | for (int i = 0; i < termArgs.length; i++) { 51 | task.out.println( String.format("Arg %d : %s", i, termArgs[i]) ); 52 | } 53 | } 54 | 55 | // Completion message 56 | task.out.println("Completed TerminalExample1"); 57 | } 58 | 59 | /** 60 | * Verifies the current task is associated with a terminal and then 61 | * receives the input data. The received data is converted to a Java 62 | * string and returned. 63 | * 64 | * @return a String containing the data input at the terminal. If the 65 | * transaction's principal facility is not a terminal, then null 66 | * will be returned. 67 | */ 68 | private static String getTerminalString() throws CicsConditionException 69 | { 70 | // Get the current task's principal facility 71 | Object pf = Task.getTask().getPrincipalFacility(); 72 | 73 | // Are we of a suitable type? 74 | if ( pf instanceof TerminalPrincipalFacility ) { 75 | 76 | // Cast to correct type 77 | TerminalPrincipalFacility tpf = (TerminalPrincipalFacility) pf; 78 | 79 | // Create a holder object to store the data 80 | DataHolder holder = new DataHolder(); 81 | 82 | try { 83 | // Perform the receive from the terminal 84 | tpf.receive(holder); 85 | } 86 | catch (EndOfChainIndicatorException e) { 87 | // Normal operation - ignore this one 88 | } 89 | catch (CicsConditionException cce) { 90 | // Propagate all other problems 91 | throw cce; 92 | } 93 | 94 | // Convert the received data into a valid String 95 | // Assume this is a valid character string in the CICS local CCSID 96 | // Requires CICS TS V5.1 and later (JCICS 1.401.0) 97 | return holder.getStringValue(); 98 | } 99 | else { 100 | // Not a terminal principal facility 101 | return null; 102 | } 103 | } 104 | 105 | /** 106 | * Breaks down the input string into 107 | * @param strTerm 108 | * @return 109 | */ 110 | private static String[] parseTerminalString(String strTerm) 111 | { 112 | // A place to store the output collection 113 | List args = new ArrayList<>(); 114 | 115 | // Tokenize the input string using standard whitespace characters 116 | StringTokenizer tok = new StringTokenizer(strTerm); 117 | 118 | // Add each of the tokens to the output collection 119 | while ( tok.hasMoreTokens() ) { 120 | args.add(tok.nextToken()); 121 | } 122 | 123 | // Convert the collection to an array 124 | return args.toArray( new String[args.size()] ); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.tsq.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | encoding/com.ibm.cicsdev.tsq.osgibundle=UTF-8 4 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-04T15:15:33.327Z 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.cicsbundle/com.ibm.cicsdev.tsq.osgibundle: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.tsq.resources.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | com.ibm.cicsdev.tsq.resources.cicsbundle 14 | 15 | 16 | majorVersion 17 | 18 | 19 | 20 | microVersion 21 | 22 | 23 | 24 | minorVersion 25 | 26 | 27 | 28 | 29 | 30 | 31 | com.ibm.cics.bundle.ui.bundlenature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JAVATSQ1.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JAVATSQ2.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JAVATSQ3.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JAVATSQ4.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JTS1.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JTS2.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JTS3.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/JTS4.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq.resources.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-11-11T11:05:46.741Z 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.tsq 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | com.ibm.cics.explorer.sdk.CICSJavaOSGiBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | pluginProject.equinox=false 3 | pluginProject.extensions=false 4 | resolve.requirebundle=false 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Sample JCICS code for use of temporary storage queues 4 | Bundle-SymbolicName: com.ibm.cicsdev.tsq 5 | Bundle-Version: 1.0.0 6 | Bundle-Vendor: IBM 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | CICS-MainClass: com.ibm.cicsdev.tsq.TSQExample1, 9 | com.ibm.cicsdev.tsq.TSQExample2, 10 | com.ibm.cicsdev.tsq.TSQExample3, 11 | com.ibm.cicsdev.tsq.TSQExample4 12 | Import-Package: com.ibm.cics.server;version="[1.401.0,3.0.0)", 13 | com.ibm.jzos.fields;resolution:=optional 14 | Automatic-Module-Name: com.ibm.cicsdev.tsq 15 | Bundle-ClassPath: lib/TsqRecord.jar, 16 | . 17 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/README.md: -------------------------------------------------------------------------------- 1 | com.ibm.cicsdev.tsq 2 | === 3 | 4 | This repository contains various Java sample programs to demonstrate use of the JCICS API for manipulating 5 | a temporary storage queue (TSQ). 6 | 7 | A TSQ is a set of data items that can be read and reread in any sequence. TSQ resources can be dynamically 8 | created at runtime, unlike transient data queues that must be defined in advance. 9 | 10 | All of the examples in this repository use the sample queue named `MYTSQ`. 11 | 12 | * `TSQExample1` - a simple class that writes Java strings to a TSQ and then reads them back. 13 | * `TSQExample2` - an alternative implementation of `TSQExample1`, that writes and reads Java strings, but performs all 14 | of the byte array to string conversion manually. This avoids the pre-requisite of CICS TS V5.1, but is slightly more work to code in Java. 15 | * `TSQExample3` - a more complex example that uses a JZOS generated record to write a structured record to a TSQ and then read it back. 16 | * `TSQExample4` - an extension of the `TSQExample3` sample program, which populates a TSQ, updates items within the queue, then 17 | reads them back to confirm. 18 | * `TSQCommon` - superclass used to provide common services for the TSQ samples. The constructor of this class will 19 | delete any existing TSQ before executing the test, in order to avoid multiple executions of the program from producing 20 | incorrect results. 21 | 22 | For the sake of brevity, all of the examples lack comprehensive error-handling logic. 23 | To demonstrate exactly where an exception may be thrown when using the JCICS API, 24 | one `try { ... } catch { ... }` block has been included per API call that may throw an exception. 25 | 26 | 27 | ## Supporting files 28 | 29 | * `lib/TsqRecord.jar` - a pre-built JAR containing the JZOS generated record that maps the copybook structure used in `TSQExample3` (includes source). 30 | * [`/etc/TSQ`](../../etc/TSQ) - contains the output of a DFHCSDUP EXTRACT operation needed to define the required programs and transactions. 31 | 32 | 33 | ## Structured record 34 | 35 | The COBOL structure that is mapped by the TsqRecord class is as follows: 36 | 37 | 01 TSQ-RECORD. 38 | 03 RECORD-ID PIC 9(8) COMP. 39 | 03 BINARY-DIGIT PIC 9(4) COMP. 40 | 03 CHARACTER-STRING PIC X(30). 41 | 03 NUMERIC-VALUE PIC 9(18). 42 | 03 PACKED-DEC PIC 9(15) COMP-3. 43 | 03 SIGNED-PACKED PIC S9(12) COMP-3. 44 | 45 | 46 | ## Running the Example 47 | 48 | At a 3270 terminal screen, enter the transaction you wish to run, for example JTS1 will run TSQ example 1. 49 | 50 | JTS1 51 | 52 | and the following output will be returned 53 | 54 | JTS1 - Starting TSQExample1 55 | Read data from queue "TSQ write from JCICS item 1" 56 | Read data from queue "TSQ write from JCICS item 2" 57 | Read data from queue "TSQ write from JCICS item 3" 58 | Read data from queue "TSQ write from JCICS item 4" 59 | Read data from queue "TSQ write from JCICS item 5" 60 | Completed TSQExample1 61 | 62 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | lib/TsqRecord.jar 6 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/lib/TsqRecord.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cicsdev/cics-java-jcics-samples/90cbc8817b35f3fbc775acf898e639b0f4e40136/projects/com.ibm.cicsdev.tsq/lib/TsqRecord.jar -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/src/com/ibm/cicsdev/tsq/TSQCommon.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tsq; 12 | 13 | import com.ibm.cics.server.CicsConditionException; 14 | import com.ibm.cics.server.InvalidQueueIdException; 15 | import com.ibm.cics.server.TSQ; 16 | 17 | /** 18 | * Superclass used to provide common services used in all of the TSQ 19 | * examples. 20 | * 21 | * For the sake of brevity, this example does not include comprehensive 22 | * error-handling logic. See the CICS Java samples around error-handling 23 | * for more details on catching CICS Exceptions in Java. 24 | */ 25 | public abstract class TSQCommon 26 | { 27 | /** 28 | * A field to hold a reference to the CICS temporary 29 | * storage queue this instance will access. 30 | */ 31 | protected final TSQ tsq; 32 | 33 | /** 34 | * Constructor used to initialise this class with some 35 | * common data used by all TSQ examples. 36 | * 37 | * @param tsq - a reference to the temporary storage queue we will 38 | * be manipulating in this example. 39 | */ 40 | protected TSQCommon(TSQ tsq) 41 | { 42 | // Save reference to the supplied TSQ 43 | this.tsq = tsq; 44 | 45 | // Delete any old TSQ that's lying around 46 | deleteQueue(); 47 | } 48 | 49 | /** 50 | * Deletes a temporary storage queue. 51 | */ 52 | private void deleteQueue() 53 | { 54 | try { 55 | // Delete the TSQ 56 | this.tsq.delete(); 57 | } 58 | catch (InvalidQueueIdException iqe) { 59 | // QIDERR occurs when the queue cannot be found 60 | // This is an acceptable condition in this program 61 | } 62 | catch (CicsConditionException cce) { 63 | // All other errors 64 | // Crude error handling - propagate an exception back to caller 65 | throw new RuntimeException(cce); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/src/com/ibm/cicsdev/tsq/TSQExample1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tsq; 12 | 13 | import java.text.MessageFormat; 14 | 15 | import com.ibm.cics.server.CicsConditionException; 16 | import com.ibm.cics.server.ItemHolder; 17 | import com.ibm.cics.server.TSQ; 18 | import com.ibm.cics.server.TSQType; 19 | import com.ibm.cics.server.Task; 20 | 21 | /** 22 | * Simple example to demonstrate writing and reading a Java String to 23 | * and from a TSQ using JCICS. 24 | */ 25 | public class TSQExample1 extends TSQCommon 26 | { 27 | /** 28 | * Name of the TSQ to use. 29 | */ 30 | private static final String TSQ_NAME = "MYTSQ"; 31 | 32 | /** 33 | * Number of items to write to the queue. 34 | */ 35 | private static final int DEPTH_COUNT = 5; 36 | 37 | /** 38 | * Main entry point to a CICS OSGi program. 39 | * 40 | * The FQ name of this class should be added to the CICS-MainClass entry in 41 | * the parent OSGi bundle's manifest. 42 | */ 43 | public static void main(String[] args) 44 | { 45 | // Get details about our current CICS task 46 | Task task = Task.getTask(); 47 | task.out.println(" - Starting TSQExample1"); 48 | 49 | // Create a reference to the TSQ 50 | TSQ tsq = new TSQ(); 51 | 52 | // Specify the queue name and that we are using main storage 53 | tsq.setName(TSQ_NAME); 54 | tsq.setType(TSQType.MAIN); 55 | 56 | // Create a new instance of this class 57 | TSQExample1 ex = new TSQExample1(tsq); 58 | 59 | // Write text to the queue 60 | ex.writeToQueue(); 61 | 62 | // Read text from the queue 63 | ex.readFromQueue(); 64 | 65 | // Completion message 66 | task.out.println("Completed TSQExample1"); 67 | } 68 | 69 | /** 70 | * Constructor used to pass data to superclass constructor. 71 | * 72 | * @param tsq - the temporary storage queue reference we will 73 | * be manipulating in this example. 74 | */ 75 | public TSQExample1(TSQ tsq) 76 | { 77 | super(tsq); 78 | } 79 | 80 | /** 81 | * Write of Java string data to a TSQ. 82 | */ 83 | public void writeToQueue() 84 | { 85 | // Write several items to the queue 86 | for (int i = 1; i <= DEPTH_COUNT; i++) { 87 | 88 | // Construct a message for writing to the queue 89 | String msg = MessageFormat.format("TSQ write from JCICS item {0}", i); 90 | 91 | try { 92 | // Write the data to the TSQ 93 | // No codepage conversion required for this method 94 | // Requires CICS TS V5.1 and later (JCICS 1.401.0) 95 | this.tsq.writeString(msg); 96 | } 97 | catch (CicsConditionException cce) { 98 | // Crude error handling - propagate an exception back to caller 99 | throw new RuntimeException(cce); 100 | } 101 | } 102 | } 103 | 104 | /** 105 | * Simple read of string data from a TSQ. 106 | */ 107 | public void readFromQueue() 108 | { 109 | // A holder object to receive the data from CICS 110 | ItemHolder holder = new ItemHolder(); 111 | 112 | // Read data from the queue 113 | for (int i = 1; i <= DEPTH_COUNT; i++) { 114 | 115 | try { 116 | // Read the data from CICS (TSQ indices are 1-based) 117 | this.tsq.readItem(i, holder); 118 | } 119 | catch (CicsConditionException cce) { 120 | // Crude error handling - propagate an exception back to caller 121 | throw new RuntimeException(cce); 122 | } 123 | 124 | // Assume this is a valid character string in the CICS local CCSID 125 | // Requires CICS TS V5.1 and later (JCICS 1.401.0) 126 | String strData = holder.getStringValue(); 127 | 128 | // Write out to the console 129 | String msg = MessageFormat.format("Read data from queue \"{0}\"", strData); 130 | Task.getTask().out.println(msg); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/src/com/ibm/cicsdev/tsq/TSQExample2.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tsq; 12 | 13 | import java.io.UnsupportedEncodingException; 14 | import java.text.MessageFormat; 15 | 16 | import com.ibm.cics.server.CicsConditionException; 17 | import com.ibm.cics.server.ItemHolder; 18 | import com.ibm.cics.server.TSQ; 19 | import com.ibm.cics.server.TSQType; 20 | import com.ibm.cics.server.Task; 21 | 22 | /** 23 | * Simple example to demonstrate writing and reading a Java String to 24 | * and from a TSQ using JCICS, with manual maintenance of codepages. 25 | */ 26 | public class TSQExample2 extends TSQCommon 27 | { 28 | /** 29 | * Name of the TSQ to use. 30 | */ 31 | private static final String TSQ_NAME = "MYTSQ"; 32 | 33 | /** 34 | * Number of items to write to the queue. 35 | */ 36 | private static final int DEPTH_COUNT = 5; 37 | 38 | /** 39 | * Resolved at runtime to be the CCSID of the region 40 | */ 41 | private static final String CCSID = 42 | System.getProperty("com.ibm.cics.jvmserver.local.ccsid"); 43 | 44 | /** 45 | * Main entry point to a CICS OSGi program. 46 | * 47 | * The FQ name of this class should be added to the CICS-MainClass entry in 48 | * the parent OSGi bundle's manifest. 49 | */ 50 | public static void main(String[] args) 51 | { 52 | // Get details about our current CICS task 53 | Task task = Task.getTask(); 54 | task.out.println(" - Starting TSQExample2"); 55 | 56 | // Create a reference to the TSQ 57 | TSQ tsq = new TSQ(); 58 | 59 | // Specify the queue name and that we are using main storage 60 | tsq.setName(TSQ_NAME); 61 | tsq.setType(TSQType.MAIN); 62 | 63 | // Create a new instance of this class 64 | TSQExample2 ex = new TSQExample2(tsq); 65 | 66 | // Write text to the queue 67 | ex.writeToQueue(); 68 | 69 | // Read text from the queue 70 | ex.readFromQueue(); 71 | 72 | // Completion message 73 | task.out.println("Completed TSQExample2"); 74 | } 75 | 76 | /** 77 | * Constructor used to pass data to superclass constructor. 78 | * 79 | * @param tsq - the temporary storage queue reference we will 80 | * be manipulating in this example. 81 | */ 82 | public TSQExample2(TSQ tsq) 83 | { 84 | super(tsq); 85 | } 86 | 87 | /** 88 | * Write of Java string data to a TSQ. 89 | */ 90 | public void writeToQueue() 91 | { 92 | // Write several items to the queue 93 | for (int i = 1; i <= DEPTH_COUNT; i++) { 94 | 95 | // Data to write to the TSQ 96 | byte[] data; 97 | 98 | // Construct a message for writing to the queue 99 | String msg = MessageFormat.format("TSQ write from JCICS item {0}", i); 100 | 101 | try { 102 | // Convert the string to a byte[] 103 | data = msg.getBytes(CCSID); 104 | } 105 | catch (UnsupportedEncodingException uee) { 106 | // Crude error handling - propagate an exception back to caller 107 | throw new RuntimeException(uee); 108 | } 109 | 110 | try { 111 | // Write the data to the TSQ 112 | this.tsq.writeItem(data); 113 | } 114 | catch (CicsConditionException cce) { 115 | // Crude error handling - propagate an exception back to caller 116 | throw new RuntimeException(cce); 117 | } 118 | } 119 | } 120 | 121 | /** 122 | * Simple read of string data from a TSQ. 123 | */ 124 | public void readFromQueue() 125 | { 126 | // A holder object to receive the data from CICS 127 | ItemHolder holder = new ItemHolder(); 128 | 129 | // Read data from the queue 130 | for (int i = 1; i <= DEPTH_COUNT; i++) { 131 | 132 | try { 133 | // Read the data from CICS (TSQ indices are 1-based) 134 | this.tsq.readItem(i, holder); 135 | } 136 | catch (CicsConditionException cce) { 137 | // Crude error handling - propagate an exception back to caller 138 | throw new RuntimeException(cce); 139 | } 140 | 141 | // Extract the byte[] data 142 | byte[] data = holder.getValue(); 143 | 144 | // String object to create 145 | String strData; 146 | 147 | try { 148 | // Assume this is a valid character string in the CICS local CCSID 149 | strData = new String(data, CCSID); 150 | } 151 | catch (UnsupportedEncodingException uee) { 152 | // Crude error handling - propagate an exception back to caller 153 | throw new RuntimeException(uee); 154 | } 155 | 156 | // Write out to the console 157 | String msg = MessageFormat.format("Read data from queue \"{0}\"", strData); 158 | Task.getTask().out.println(msg); 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.tsq/src/com/ibm/cicsdev/tsq/TSQExample4.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2016 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.tsq; 12 | 13 | import com.ibm.cics.server.CicsConditionException; 14 | import com.ibm.cics.server.ItemErrorException; 15 | import com.ibm.cics.server.ItemHolder; 16 | import com.ibm.cics.server.TSQ; 17 | import com.ibm.cics.server.TSQType; 18 | import com.ibm.cics.server.Task; 19 | import com.ibm.cicsdev.bean.TsqRecord; 20 | 21 | /** 22 | * Extends the {@link TSQExample3} class by including a method which 23 | * updates items in the queue. 24 | */ 25 | public class TSQExample4 extends TSQExample3 26 | { 27 | /** 28 | * Name of the TSQ to use. 29 | */ 30 | private static final String TSQ_NAME = "MYTSQ"; 31 | 32 | /** 33 | * Main entry point to a CICS OSGi program. 34 | * 35 | * The FQ name of this class should be added to the CICS-MainClass entry in 36 | * the parent OSGi bundle's manifest. 37 | */ 38 | public static void main(String[] args) 39 | { 40 | // Get details about our current CICS task 41 | Task task = Task.getTask(); 42 | task.out.println(" - Starting TSQExample4"); 43 | 44 | // Create a reference to the TSQ 45 | TSQ tsq = new TSQ(); 46 | 47 | // Specify the queue name and that we are using main storage 48 | tsq.setName(TSQ_NAME); 49 | tsq.setType(TSQType.MAIN); 50 | 51 | // Create a new instance of this class 52 | TSQExample4 ex = new TSQExample4(tsq); 53 | 54 | // Write some initial data to the TSQ 55 | ex.writeToQueue(); 56 | 57 | // Update the TSQ with a browse and rewrite 58 | ex.updateQueue(); 59 | 60 | // Read from the TSQ to confirm update 61 | ex.readFromQueue(); 62 | 63 | // Completion message 64 | task.out.println("Completed TSQExample4"); 65 | } 66 | 67 | /** 68 | * Constructor used to pass data to superclass constructor. 69 | * 70 | * @param tsq - the temporary storage queue reference we will 71 | * be manipulating in this example. 72 | */ 73 | public TSQExample4(TSQ tsq) 74 | { 75 | super(tsq); 76 | } 77 | 78 | /** 79 | * Browses through a queue created by {@link TSQExample3} and updates each record. 80 | * 81 | * Each item in the queue is assumed to have a layout specified by the generated 82 | * {@link TsqRecord} class. 83 | */ 84 | public void updateQueue() 85 | { 86 | // Current item we are reading (TSQ indices are 1-based) 87 | int currentItem = 1; 88 | 89 | // Holder to receive data from TSQ 90 | ItemHolder holder = new ItemHolder(); 91 | 92 | // Loop until we break out at end of queue 93 | while ( true ) { 94 | 95 | try { 96 | // Browse through the queue sequentially 97 | this.tsq.readNextItem(holder); 98 | } 99 | catch (ItemErrorException iee) { 100 | // ITEMERR represents end of browse - normal condition here 101 | break; 102 | } 103 | catch (CicsConditionException cce) { 104 | // Crude error handling - propagate an exception back to caller 105 | throw new RuntimeException(cce); 106 | } 107 | 108 | // Extract the record 109 | // This class has been generated using the JZOS record generator utility 110 | TsqRecord record = new TsqRecord(holder.getValue()); 111 | 112 | // Update the record ID and character fields 113 | record.setRecordId(record.getRecordId() + 100); 114 | record.setCharacterString("Updated: " + record.getCharacterString()); 115 | 116 | try { 117 | // Write record back to the queue 118 | this.tsq.rewriteItem(currentItem, record.getByteBuffer()); 119 | } 120 | catch (CicsConditionException cce) { 121 | // Crude error handling - propagate an exception back to caller 122 | throw new RuntimeException(cce); 123 | } 124 | 125 | // Next queue item 126 | currentItem++; 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.vsam.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | encoding/com.ibm.cicsdev.vsam.osgibundle=UTF-8 4 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-12-13T15:47:28.565Z 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.cicsbundle/com.ibm.cicsdev.vsam.osgibundle: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.vsam.resources.cicsbundle 4 | 5 | 6 | 7 | 8 | 9 | com.ibm.cics.bundle.ui.bundlebuilder 10 | 11 | 12 | bundleID 13 | 14 | 15 | majorVersion 16 | 17 | 18 | microVersion 19 | 20 | 21 | minorVersion 22 | 23 | 24 | 25 | 26 | 27 | com.ibm.cics.bundle.ui.bundlenature 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//META-INF/cics.xml=UTF-8 3 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVES1.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVES2.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVES3.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVES4.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVES5.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVKS1.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVKS2.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVKS3.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVKS4.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVKS5.program: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVRR1.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVRR2.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVRR3.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVRR4.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JAVAVRR5.program: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVE1.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVE2.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVE3.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVE4.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVE5.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVK1.transaction: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVK2.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVK3.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVK4.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVK5.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVR1.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVR2.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVR3.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVR4.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/JVR5.transaction: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam.resources.cicsbundle/META-INF/cics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016-12-13T15:49:54.727Z 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.ibm.cicsdev.vsam 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | com.ibm.cics.explorer.sdk.CICSJavaOSGiBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/.settings/org.eclipse.pde.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | pluginProject.equinox=false 3 | pluginProject.extensions=false 4 | resolve.requirebundle=false 5 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Sample JCICS VSAM code 4 | Bundle-SymbolicName: com.ibm.cicsdev.vsam 5 | Bundle-Version: 1.0.0 6 | Bundle-Vendor: IBM 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | Import-Package: com.ibm.cics.server;version="[1.401.0,3.0.0)", 9 | com.ibm.jzos.fields;resolution:=optional 10 | Bundle-ClassPath: lib/vsam.jar, 11 | . 12 | CICS-MainClass: com.ibm.cicsdev.vsam.ksds.KsdsExample1, 13 | com.ibm.cicsdev.vsam.ksds.KsdsExample2, 14 | com.ibm.cicsdev.vsam.ksds.KsdsExample3, 15 | com.ibm.cicsdev.vsam.ksds.KsdsExample4, 16 | com.ibm.cicsdev.vsam.ksds.KsdsExample5, 17 | com.ibm.cicsdev.vsam.esds.EsdsExample1, 18 | com.ibm.cicsdev.vsam.esds.EsdsExample2, 19 | com.ibm.cicsdev.vsam.esds.EsdsExample3, 20 | com.ibm.cicsdev.vsam.esds.EsdsExample4, 21 | com.ibm.cicsdev.vsam.esds.EsdsExample5, 22 | com.ibm.cicsdev.vsam.rrds.RrdsExample1, 23 | com.ibm.cicsdev.vsam.rrds.RrdsExample2, 24 | com.ibm.cicsdev.vsam.rrds.RrdsExample3, 25 | com.ibm.cicsdev.vsam.rrds.RrdsExample4, 26 | com.ibm.cicsdev.vsam.rrds.RrdsExample5 27 | Automatic-Module-Name: com.ibm.cicsdev.vsam 28 | 29 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/README.md: -------------------------------------------------------------------------------- 1 | com.ibm.cicsdev.vsam 2 | === 3 | 4 | Provides examples for using VSAM files from a JCICS environment. 5 | All examples have a ESDS, KSDS, and RRDS variant. 6 | The numbered example classes are driving classes, with the ExampleCommon classes performing the JCICS calls. 7 | 8 | * `*Example1` - Writes a single record to a file. 9 | * `*Example2` - Reads a single record from a file. 10 | * `*Example3` - Updates a single record in a file. 11 | * `*Example4` - Deletes a single record in a file (not ESDS). 12 | * `*Example5` - Browses a VSAM file. 13 | * `*ExampleCommon` - Various routines that perform the required JCICS calls. 14 | 15 | ## Supporting files 16 | 17 | * `lib/vsam.jar` - a pre-built JAR containing the JZOS generated record that maps the copybook structure used in all the VSAM samples (includes source). 18 | * [`/etc/VSAM`](../../etc/VSAM) - contains sample JCL to define the required VSAM files, and the output of a DFHCSDUP EXTRACT operation needed to define the required programs and transactions. 19 | 20 | 21 | ## Running the Example 22 | 23 | At a 3270 terminal screen, enter the transaction you wish to run, for example JVK1 will run the VSAM KSDS example 1. 24 | 25 | JVK1 26 | 27 | and the following output will be returned 28 | 29 | JVK1 - Starting KsdsExample1 30 | VSAM KSDS record addition example 31 | Wrote record with key 0x0003E712 32 | Completed KsdsExample1 33 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | lib/vsam.jar 6 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/lib/vsam.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cicsdev/cics-java-jcics-samples/90cbc8817b35f3fbc775acf898e639b0f4e40136/projects/com.ibm.cicsdev.vsam/lib/vsam.jar -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/VsamExampleCommon.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam; 12 | 13 | import com.ibm.cics.server.InvalidRequestException; 14 | import com.ibm.cics.server.RolledBackException; 15 | import com.ibm.cics.server.Task; 16 | 17 | 18 | /** 19 | * An abstract class that provides services common across all of the VSAM 20 | * sample classes. 21 | */ 22 | public abstract class VsamExampleCommon 23 | { 24 | /** 25 | * Example of committing a unit of work within an OSGi JVM server. 26 | * 27 | * When performing a commit in Java, the following two exceptions may be thrown: 28 | * 29 | *
    30 | *
  • RolledBackException - CICS was unable to commit the current 31 | * UoW because a remote system was unable to commit.
  • 32 | * 33 | *
  • InvalidRequestException - This can happen in Java on a commit 34 | * for one of two reasons: 35 | *
      36 | *
    1. Task.commit() was called in a program that is linked to from a remote system 37 | * that has not specified the SYNCONRETURN option, or if it has been linked to 38 | * locally and is defined with EXECUTIONSET=DPLSUBSET.
    2. 39 | *
    3. Task.commit() was called in a Java environment where we also have a JTA 40 | * transaction active. (This is not an issue in an OSGi JVM server).
    4. 41 | *
  • 42 | * 43 | *
44 | */ 45 | public void commitUnitOfWork() 46 | { 47 | try { 48 | // Issue a CICS syncpoint 49 | Task.getTask().commit(); 50 | } 51 | catch (RolledBackException rbe) { 52 | // See javadoc for description 53 | // For this example, propagate the error out of the Java program 54 | throw new RuntimeException(rbe); 55 | } 56 | catch (InvalidRequestException ire) { 57 | // See javadoc for description 58 | // For this example, propagate the error out of the Java program 59 | throw new RuntimeException(ire); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/esds/EsdsExample1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.esds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate adding a record to a VSAM ESDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link EsdsExampleCommon}. 22 | */ 23 | public class EsdsExample1 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting EsdsExample1"); 36 | task.out.println("VSAM ESDS record addition example"); 37 | 38 | // Create a new instance of the common ESDS class 39 | EsdsExampleCommon ex = new EsdsExampleCommon(); 40 | 41 | // Create a new random record for writing to the file 42 | StockPart sp = StockPartHelper.generate(); 43 | 44 | // Add a new record to the file 45 | long rba = ex.addRecord(sp); 46 | 47 | // Write out the RBA of the new record 48 | task.out.println( String.format("Wrote record with RBA 0x%016X", rba) ); 49 | 50 | // Unit of work containing the write will be committed at normal end of task 51 | 52 | // Completion message 53 | task.out.println("Completed EsdsExample1"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/esds/EsdsExample2.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.esds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | import com.ibm.cicsdev.vsam.ksds.KsdsExampleCommon; 17 | 18 | 19 | /** 20 | * Simple example to demonstrate reading a record from a VSAM ESDS file using JCICS. 21 | * 22 | * This class is just the driver of the test. The main JCICS work is done in the 23 | * common class {@link KsdsExampleCommon}. 24 | */ 25 | public class EsdsExample2 26 | { 27 | /** 28 | * Main entry point to a CICS OSGi program. 29 | * 30 | * The FQ name of this class should be added to the CICS-MainClass entry in 31 | * the parent OSGi bundle's manifest. 32 | */ 33 | public static void main(String[] args) 34 | { 35 | // Get details about our current CICS task 36 | Task task = Task.getTask(); 37 | task.out.println(" - Starting EsdsExample2"); 38 | task.out.println("VSAM ESDS record read example"); 39 | 40 | // Create a new instance of the common ESDS class 41 | EsdsExampleCommon ex = new EsdsExampleCommon(); 42 | 43 | // Add a new record to the file so we have something to work with 44 | StockPart spNew = StockPartHelper.generate(); 45 | long rba = ex.addRecord(spNew); 46 | 47 | // Commit the current unit of work to harden new record to the file 48 | ex.commitUnitOfWork(); 49 | 50 | // Write out the RBA of the record we have just written 51 | task.out.println( String.format("Wrote record with RBA 0x%016X", rba) ); 52 | 53 | // Now read the record with the specified RBA 54 | StockPart spRead = ex.readRecord(rba); 55 | 56 | // Display the read description 57 | String strMsg = "Read record with description %s"; 58 | task.out.println( String.format(strMsg, spRead.getDescription().trim()) ); 59 | 60 | // Completion message 61 | task.out.println("Completed EsdsExample2"); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/esds/EsdsExample3.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.esds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate updating a record in a VSAM ESDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link EsdsExampleCommon}. 22 | */ 23 | public class EsdsExample3 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting EsdsExample3"); 36 | task.out.println("VSAM ESDS record update example"); 37 | 38 | // Create a new instance of the common ESDS class 39 | EsdsExampleCommon ex = new EsdsExampleCommon(); 40 | 41 | 42 | /* 43 | * Create a record in the file so we have something to work with. 44 | */ 45 | 46 | // Keep track of the RBA of the new record 47 | long rba; 48 | 49 | // Scoping of local variables 50 | { 51 | // Add a new record to the file 52 | StockPart sp = StockPartHelper.generate(); 53 | rba = ex.addRecord(sp); 54 | 55 | // Commit the unit of work 56 | ex.commitUnitOfWork(); 57 | 58 | // Write out the RBA and description 59 | String strMsg = "Wrote to RBA 0x%016X with description %s"; 60 | task.out.println( String.format(strMsg, rba, sp.getDescription().trim()) ); 61 | } 62 | 63 | 64 | /* 65 | * Now update this known record with a new description. 66 | */ 67 | 68 | // Scoping of local variables 69 | { 70 | // Generate a new part description 71 | String strDesc = StockPartHelper.generateDescription(); 72 | 73 | // Update the known record with a specified description 74 | StockPart sp = ex.updateRecord(rba, strDesc); 75 | 76 | // Display the updated description 77 | String strMsg = "Updated record with description %s"; 78 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 79 | } 80 | 81 | // Unit of work containing the update will be committed at normal end of task 82 | 83 | // Completion message 84 | task.out.println("Completed EsdsExample3"); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/esds/EsdsExample4.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.esds; 12 | 13 | import com.ibm.cics.server.Task; 14 | 15 | 16 | /** 17 | * This is a dummy test class to remain consistent with the KSDS and RRDS examples. 18 | * 19 | * Records cannot be deleted from an ESDS dataset, either in JCICS or in the 20 | * EXEC CICS API. 21 | */ 22 | public class EsdsExample4 23 | { 24 | public static void main(String[] args) 25 | { 26 | // Get details about our current CICS task 27 | Task task = Task.getTask(); 28 | task.out.println(" - Starting EsdsExample4"); 29 | task.out.println("VSAM ESDS record delete example"); 30 | 31 | // VSAM ESDS does not allow record deletion 32 | task.out.println("Record deletion not permitted for VSAM ESDS files"); 33 | 34 | // Completion message 35 | task.out.println("Completed EsdsExample4"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/esds/EsdsExample5.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.esds; 12 | 13 | import java.util.List; 14 | 15 | import com.ibm.cics.server.Task; 16 | import com.ibm.cicsdev.bean.StockPart; 17 | import com.ibm.cicsdev.vsam.StockPartHelper; 18 | 19 | /** 20 | * Simple example to demonstrate browsing a VSAM ESDS file using JCICS. 21 | * 22 | * This class is just the driver of the test. The main JCICS work is done in the 23 | * common class {@link EsdsExampleCommon}. 24 | */ 25 | public class EsdsExample5 26 | { 27 | /** 28 | * Number of records to add and then browse through. 29 | */ 30 | private static final int RECORDS_TO_BROWSE = 5; 31 | 32 | /** 33 | * Main entry point to a CICS OSGi program. 34 | * 35 | * The FQ name of this class should be added to the CICS-MainClass entry in 36 | * the parent OSGi bundle's manifest. 37 | */ 38 | public static void main(String[] args) 39 | { 40 | // Get details about our current CICS task 41 | Task task = Task.getTask(); 42 | task.out.println(" - Starting EsdsExample5"); 43 | task.out.println("VSAM ESDS file browse example"); 44 | 45 | // Create a new instance of the common example class 46 | EsdsExampleCommon ex = new EsdsExampleCommon(); 47 | 48 | 49 | /* 50 | * Create some records in the file so we have something to work with. 51 | */ 52 | 53 | // ESDS records are always stored in the sequence they were added 54 | long rbaFirst = -1; 55 | 56 | // Add 5 records 57 | for ( int i = 0; i < RECORDS_TO_BROWSE; i++ ) { 58 | 59 | // Add a new record to the file 60 | StockPart sp = StockPartHelper.generate(); 61 | long rba = ex.addRecord(sp); 62 | 63 | // Write out the RBA of the new record 64 | task.out.println( String.format("Wrote to RBA 0x%016X", rba) ); 65 | 66 | // Keep track of the RBA of the first insert 67 | if ( rbaFirst == -1 ) { 68 | rbaFirst = rba; 69 | } 70 | } 71 | 72 | // Commit the unit of work to harden the inserts to the file 73 | ex.commitUnitOfWork(); 74 | 75 | 76 | /* 77 | * Browse through the file, starting at the lowest RBA. 78 | * 79 | * The above code will have guaranteed sufficient records exist. 80 | */ 81 | 82 | // Browse through the records, starting at the lowest known RBA 83 | List list = ex.browse(rbaFirst, RECORDS_TO_BROWSE); 84 | 85 | // Iterate over this list 86 | for ( StockPart sp : list ) { 87 | 88 | // Display the description 89 | String strMsg = "Read record with description %s"; 90 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 91 | } 92 | 93 | // Completion message 94 | task.out.println("Completed EsdsExample5"); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/ksds/KsdsExample1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.ksds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate adding a record to a VSAM KSDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link KsdsExampleCommon}. 22 | */ 23 | public class KsdsExample1 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting KsdsExample1"); 36 | task.out.println("VSAM KSDS record addition example"); 37 | 38 | // Create a new instance of the common KSDS class 39 | KsdsExampleCommon ex = new KsdsExampleCommon(); 40 | 41 | // Create a new random record for writing to the file 42 | StockPart sp = StockPartHelper.generate(); 43 | 44 | // Add a new record to the file 45 | ex.addRecord(sp); 46 | 47 | // Write out the part ID 48 | task.out.println( String.format("Wrote record with key 0x%08X", sp.getPartId()) ); 49 | 50 | // Unit of work containing the write will be committed at normal end of task 51 | 52 | // Completion message 53 | task.out.println("Completed KsdsExample1"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/ksds/KsdsExample2.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.ksds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | 18 | /** 19 | * Simple example to demonstrate reading a record from a VSAM KSDS file using JCICS. 20 | * 21 | * This class is just the driver of the test. The main JCICS work is done in the 22 | * superclass {@link KsdsExampleCommon}. 23 | */ 24 | public class KsdsExample2 25 | { 26 | /** 27 | * Main entry point to a CICS OSGi program. 28 | * 29 | * The FQ name of this class should be added to the CICS-MainClass entry in 30 | * the parent OSGi bundle's manifest. 31 | */ 32 | public static void main(String[] args) 33 | { 34 | // Get details about our current CICS task 35 | Task task = Task.getTask(); 36 | task.out.println(" - Starting KsdsExample2"); 37 | task.out.println("VSAM KSDS record read example"); 38 | 39 | // Create a new instance of the common example class 40 | KsdsExampleCommon ex = new KsdsExampleCommon(); 41 | 42 | // Add a new record to the file so we have something to work with 43 | StockPart spNew = StockPartHelper.generate(); 44 | ex.addRecord(spNew); 45 | 46 | // Keep track of the key 47 | int key = spNew.getPartId(); 48 | 49 | // Write out the original description 50 | task.out.println( String.format("Wrote record with key 0x%08X", key) ); 51 | 52 | // Commit the current unit of work harden new record to the file 53 | ex.commitUnitOfWork(); 54 | 55 | // Now read the record with the specified key 56 | StockPart spRead = ex.readRecord(key); 57 | 58 | // Display the read description 59 | String strMsg = "Read record with description %s"; 60 | task.out.println( String.format(strMsg, spRead.getDescription().trim()) ); 61 | 62 | // Completion message 63 | task.out.println("Completed KsdsExample2"); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/ksds/KsdsExample3.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.ksds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate updating a record in a VSAM KSDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link KsdsExampleCommon}. 22 | */ 23 | public class KsdsExample3 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting KsdsExample3"); 36 | task.out.println("VSAM KSDS record update example"); 37 | 38 | // Create a new instance of the common example class 39 | KsdsExampleCommon ex = new KsdsExampleCommon(); 40 | 41 | 42 | /* 43 | * Create a record in the file so we have something to work with. 44 | */ 45 | 46 | // Keep track of the key of the new record 47 | int key; 48 | 49 | // Scoping of local variables 50 | { 51 | // Add a new record to the file 52 | StockPart sp = StockPartHelper.generate(); 53 | ex.addRecord(sp); 54 | 55 | // Commit the unit of work 56 | ex.commitUnitOfWork(); 57 | 58 | // Get hold of the new part ID 59 | key = sp.getPartId(); 60 | 61 | // Write out the key and description 62 | String strMsg = "Wrote to key 0x%08X with description %s"; 63 | task.out.println( String.format(strMsg, key, sp.getDescription().trim()) ); 64 | } 65 | 66 | 67 | /* 68 | * Now update this known record with a new description. 69 | */ 70 | 71 | // Scoping of local variables 72 | { 73 | // Generate a new part description 74 | String strDesc = StockPartHelper.generateDescription(); 75 | 76 | // Now update the known record with a specified description 77 | StockPart sp = ex.updateRecord(key, strDesc); 78 | 79 | // Display the updated description 80 | String strMsg = "Updated record with description %s"; 81 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 82 | } 83 | 84 | // Unit of work containing the update will be committed at normal end of task 85 | 86 | // Completion message 87 | task.out.println("Completed KsdsExample3"); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/ksds/KsdsExample4.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.ksds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate deleting a record from a VSAM KSDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link KsdsExampleCommon}. 22 | */ 23 | public class KsdsExample4 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting KsdsExample4"); 36 | task.out.println("VSAM KSDS record delete example"); 37 | 38 | // Create a new instance of the common example class 39 | KsdsExampleCommon ex = new KsdsExampleCommon(); 40 | 41 | 42 | /* 43 | * Create a record in the file so we have something to work with. 44 | */ 45 | 46 | // Keep track of the generated key 47 | int key; 48 | 49 | // Scoping of local variables 50 | { 51 | // Add a new record to the file 52 | StockPart sp = StockPartHelper.generate(); 53 | ex.addRecord(sp); 54 | 55 | // Commit the unit of work 56 | ex.commitUnitOfWork(); 57 | 58 | // Get hold of the new part ID 59 | key = sp.getPartId(); 60 | 61 | // Write out the key 62 | task.out.println( String.format("Wrote to key 0x%08X", key) ); 63 | } 64 | 65 | 66 | /* 67 | * Delete the record. 68 | */ 69 | 70 | // Scoping of local variables 71 | { 72 | // Now delete this known record 73 | StockPart sp = ex.deleteRecord(key); 74 | 75 | // Display the result 76 | String strMsg = "Deleted record with description %s"; 77 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 78 | } 79 | 80 | // Unit of work containing the delete will be committed at normal end of task 81 | 82 | // Completion message 83 | task.out.println("Completed KsdsExample4"); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/ksds/KsdsExample5.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.ksds; 12 | 13 | import java.util.List; 14 | 15 | import com.ibm.cics.server.Task; 16 | import com.ibm.cicsdev.bean.StockPart; 17 | import com.ibm.cicsdev.vsam.StockPartHelper; 18 | 19 | /** 20 | * Simple example to demonstrate browsing a VSAM KSDS file using JCICS. 21 | * 22 | * This class is just the driver of the test. The main JCICS work is done in the 23 | * common class {@link KsdsExampleCommon}. 24 | */ 25 | public class KsdsExample5 26 | { 27 | /** 28 | * Number of records to add and then browse through. 29 | */ 30 | private static final int RECORDS_TO_BROWSE = 5; 31 | 32 | /** 33 | * Main entry point to a CICS OSGi program. 34 | * 35 | * The FQ name of this class should be added to the CICS-MainClass entry in 36 | * the parent OSGi bundle's manifest. 37 | */ 38 | public static void main(String[] args) 39 | { 40 | // Get details about our current CICS task 41 | Task task = Task.getTask(); 42 | task.out.println(" - Starting KsdsExample5"); 43 | task.out.println("VSAM KSDS file browse example"); 44 | 45 | // Create a new instance of the common example class 46 | KsdsExampleCommon ex = new KsdsExampleCommon(); 47 | 48 | 49 | /* 50 | * Create some records in the file so we have something to work with. 51 | */ 52 | 53 | // Keep track of the lowest generated key 54 | int key = Integer.MAX_VALUE; 55 | 56 | // Add records, keeping track of the lowest key 57 | for ( int i = 0; i < RECORDS_TO_BROWSE; i++ ) { 58 | 59 | // Add a new record to the file 60 | StockPart sp = StockPartHelper.generate(); 61 | ex.addRecord(sp); 62 | 63 | // Get the key of the new record 64 | int newKey = sp.getPartId(); 65 | 66 | // Write out the key and description 67 | task.out.println( String.format("Wrote to key 0x%08X", newKey) ); 68 | 69 | // Decide if this is lowest key so far 70 | key = newKey < key ? newKey : key; 71 | } 72 | 73 | // Commit the unit of work to harden the inserts to the file 74 | ex.commitUnitOfWork(); 75 | 76 | 77 | /* 78 | * Browse through the file, starting at the lowest key. 79 | * 80 | * Note the next n records we find may not necessarily be the n records we 81 | * added above. It will depend on what existing records were already in 82 | * the KSDS file. 83 | * 84 | * The above code will have guaranteed that at least RECORDS_TO_BROWSE 85 | * records exist. 86 | */ 87 | 88 | // Browse through the records, starting at the lowest known key 89 | List list = ex.browse(key, RECORDS_TO_BROWSE); 90 | 91 | // Iterate over this list 92 | for ( StockPart sp : list ) { 93 | 94 | // Display the description 95 | String strMsg = "Read record with description %s"; 96 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 97 | } 98 | 99 | // Completion message 100 | task.out.println("Completed KsdsExample5"); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/rrds/RrdsExample1.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.rrds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate adding a record to a VSAM RRDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link RrdsExampleCommon}. 22 | */ 23 | public class RrdsExample1 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting RrdsExample1"); 36 | task.out.println("VSAM RRDS record addition example"); 37 | 38 | // Create a new instance of the common ESDS class 39 | RrdsExampleCommon ex = new RrdsExampleCommon(); 40 | 41 | // Unlike the KSDS and ESDS examples, we need an empty file before we start 42 | ex.emptyFile(); 43 | 44 | // Create a new random record for writing to the file 45 | StockPart sp = StockPartHelper.generate(); 46 | 47 | // Add a new record to the file at RRN 1 48 | long rrn = 1; 49 | 50 | // Perform the add 51 | ex.addRecord(rrn, sp); 52 | 53 | // Write out the new RRN 54 | task.out.println( String.format("Wrote record with RRN 0x%016X", rrn) ); 55 | 56 | // Unit of work containing the write will be committed at normal end of task 57 | 58 | // Completion message 59 | task.out.println("Completed RrdsExample1"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/rrds/RrdsExample2.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.rrds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | 18 | /** 19 | * Simple example to demonstrate reading a record from a VSAM RRDS file using JCICS. 20 | * 21 | * This class is just the driver of the test. The main JCICS work is done in the 22 | * common class {@link RrdsExampleCommon}. 23 | */ 24 | public class RrdsExample2 25 | { 26 | /** 27 | * Main entry point to a CICS OSGi program. 28 | * 29 | * The FQ name of this class should be added to the CICS-MainClass entry in 30 | * the parent OSGi bundle's manifest. 31 | */ 32 | public static void main(String[] args) 33 | { 34 | // Get details about our current CICS task 35 | Task task = Task.getTask(); 36 | task.out.println(" - Starting RrdsExample2"); 37 | task.out.println("VSAM RRDS record read example"); 38 | 39 | // Create a new instance of this class 40 | RrdsExampleCommon ex = new RrdsExampleCommon(); 41 | 42 | // Unlike the KSDS and ESDS examples, we need an empty file before we start 43 | ex.emptyFile(); 44 | 45 | // We will always add and read RRN 1 46 | long rrn = 1; 47 | 48 | // Add a new record to the file so we have something to work with 49 | StockPart spNew = StockPartHelper.generate(); 50 | ex.addRecord(rrn, spNew); 51 | 52 | // Write out the RRN of the new record 53 | task.out.println( String.format("Wrote record with RRN 0x%016X", rrn) ); 54 | 55 | // Commit the current unit of work to harden new record to the file 56 | ex.commitUnitOfWork(); 57 | 58 | // Now read the record with the specified key 59 | StockPart spRead = ex.readRecord(rrn); 60 | 61 | // Display the read description 62 | String strMsg = "Read record with description %s"; 63 | task.out.println( String.format(strMsg, spRead.getDescription().trim()) ); 64 | 65 | // Completion message 66 | task.out.println("Completed RrdsExample2"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/rrds/RrdsExample3.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.rrds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | /** 18 | * Simple example to demonstrate updating a record in a VSAM RRDS file using JCICS. 19 | * 20 | * This class is just the driver of the test. The main JCICS work is done in the 21 | * common class {@link RrdsExampleCommon}. 22 | */ 23 | public class RrdsExample3 24 | { 25 | /** 26 | * Main entry point to a CICS OSGi program. 27 | * 28 | * The FQ name of this class should be added to the CICS-MainClass entry in 29 | * the parent OSGi bundle's manifest. 30 | */ 31 | public static void main(String[] args) 32 | { 33 | // Get details about our current CICS task 34 | Task task = Task.getTask(); 35 | task.out.println(" - Starting RrdsExample3"); 36 | task.out.println("VSAM RRDS record update example"); 37 | 38 | // Create a new instance of the common example class 39 | RrdsExampleCommon ex = new RrdsExampleCommon(); 40 | 41 | // Unlike the KSDS and ESDS examples, we need an empty file before we start 42 | ex.emptyFile(); 43 | 44 | // We will always add and read RRN 1 45 | long rrn = 1; 46 | 47 | 48 | /* 49 | * Create a record in the file so we have something to work with. 50 | */ 51 | 52 | // Scoping of local variables 53 | { 54 | // Add a new record to the file 55 | StockPart sp = StockPartHelper.generate(); 56 | ex.addRecord(rrn, sp); 57 | 58 | // Commit the unit of work 59 | ex.commitUnitOfWork(); 60 | 61 | // Write out the key and description 62 | String strMsg = "Wrote to RRN 0x%016X with description %s"; 63 | task.out.println( String.format(strMsg, rrn, sp.getDescription().trim()) ); 64 | } 65 | 66 | 67 | /* 68 | * Now update this known record with a new description. 69 | */ 70 | 71 | // Scoping of local variables 72 | { 73 | // Generate a new part description 74 | String strDesc = StockPartHelper.generateDescription(); 75 | 76 | // Now update the known record with a specified description 77 | StockPart sp = ex.updateRecord(rrn, strDesc); 78 | 79 | // Display the updated description 80 | String strMsg = "Updated record with description %s"; 81 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 82 | } 83 | 84 | // Unit of work containing the update will be committed at normal end of task 85 | 86 | // Completion message 87 | task.out.println("Completed RrdsExample3"); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/rrds/RrdsExample4.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.rrds; 12 | 13 | import com.ibm.cics.server.Task; 14 | import com.ibm.cicsdev.bean.StockPart; 15 | import com.ibm.cicsdev.vsam.StockPartHelper; 16 | 17 | 18 | /** 19 | * Simple example to demonstrate deleting a record from a VSAM RRDS file using JCICS. 20 | * 21 | * This class is just the driver of the test. The main JCICS work is done in the 22 | * common class {@link RrdsExampleCommon}. 23 | */ 24 | public class RrdsExample4 25 | { 26 | /** 27 | * Main entry point to a CICS OSGi program. 28 | * 29 | * The FQ name of this class should be added to the CICS-MainClass entry in 30 | * the parent OSGi bundle's manifest. 31 | */ 32 | public static void main(String[] args) 33 | { 34 | // Get details about our current CICS task 35 | Task task = Task.getTask(); 36 | task.out.println(" - Starting RrdsExample4"); 37 | task.out.println("VSAM RRDS record delete example"); 38 | 39 | // Create a new instance of the common example class 40 | RrdsExampleCommon ex = new RrdsExampleCommon(); 41 | 42 | // Unlike the KSDS and ESDS examples, we need an empty file before we start 43 | ex.emptyFile(); 44 | 45 | // We will always add and delete RRN 1 46 | long rrn = 1; 47 | 48 | 49 | /* 50 | * Create a record in the file so we have something to work with. 51 | */ 52 | 53 | // Scoping of local variables 54 | { 55 | // Add a new record to the file 56 | StockPart sp = StockPartHelper.generate(); 57 | ex.addRecord(rrn, sp); 58 | 59 | // Commit the unit of work 60 | ex.commitUnitOfWork(); 61 | 62 | // Write out the key and description 63 | task.out.println( String.format("Wrote to RRN 0x%016X", rrn) ); 64 | } 65 | 66 | 67 | /* 68 | * Delete the record. 69 | */ 70 | 71 | // Scoping of local variables 72 | { 73 | // Now delete this known record 74 | StockPart sp = ex.deleteRecord(rrn); 75 | 76 | // Display the result 77 | String strMsg = "Deleted record with description %s"; 78 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 79 | } 80 | 81 | // Unit of work containing the delete will be committed at normal end of task 82 | 83 | // Completion message 84 | task.out.println("Completed RrdsExample4"); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /projects/com.ibm.cicsdev.vsam/src/com/ibm/cicsdev/vsam/rrds/RrdsExample5.java: -------------------------------------------------------------------------------- 1 | /* Licensed Materials - Property of IBM */ 2 | /* */ 3 | /* SAMPLE */ 4 | /* */ 5 | /* (c) Copyright IBM Corp. 2017 All Rights Reserved */ 6 | /* */ 7 | /* US Government Users Restricted Rights - Use, duplication or disclosure */ 8 | /* restricted by GSA ADP Schedule Contract with IBM Corp */ 9 | /* */ 10 | 11 | package com.ibm.cicsdev.vsam.rrds; 12 | 13 | import java.util.List; 14 | 15 | import com.ibm.cics.server.Task; 16 | import com.ibm.cicsdev.bean.StockPart; 17 | import com.ibm.cicsdev.vsam.StockPartHelper; 18 | 19 | /** 20 | * Simple example to demonstrate browsing a VSAM RRDS file using JCICS. 21 | * 22 | * This class is just the driver of the test. The main JCICS work is done in the 23 | * common class {@link RrdsExampleCommon}. 24 | */ 25 | public class RrdsExample5 26 | { 27 | /** 28 | * Number of records to add and then browse through. 29 | */ 30 | private static final int RECORDS_TO_BROWSE = 5; 31 | 32 | /** 33 | * Main entry point to a CICS OSGi program. 34 | * 35 | * The FQ name of this class should be added to the CICS-MainClass entry in 36 | * the parent OSGi bundle's manifest. 37 | */ 38 | public static void main(String[] args) 39 | { 40 | // Get details about our current CICS task 41 | Task task = Task.getTask(); 42 | task.out.println(" - Starting RrdsExample5"); 43 | task.out.println("VSAM RRDS file browse example"); 44 | 45 | // Create a new instance of the common example class 46 | RrdsExampleCommon ex = new RrdsExampleCommon(); 47 | 48 | // Unlike the KSDS and ESDS examples, we need an empty file before we start 49 | ex.emptyFile(); 50 | 51 | // We will always start from RRN 1 52 | long rrnStart = 1; 53 | 54 | 55 | /* 56 | * Create some records in the file so we have something to work with. 57 | */ 58 | 59 | // Add records 60 | for ( long rrn = rrnStart; rrn <= RECORDS_TO_BROWSE; rrn++ ) { 61 | 62 | // Add a new record to the file 63 | StockPart sp = StockPartHelper.generate(); 64 | ex.addRecord(rrn, sp); 65 | 66 | // Write out the key and description 67 | task.out.println( String.format("Wrote to RRN 0x%016X", rrn) ); 68 | } 69 | 70 | // Commit the unit of work to harden the inserts to the file 71 | ex.commitUnitOfWork(); 72 | 73 | 74 | /* 75 | * Browse through the file, starting at the lowest key. 76 | * 77 | * The above code will have guaranteed that sufficient records exist. 78 | */ 79 | 80 | // Browse through the records, starting at the initial RRN 81 | List list = ex.browse(rrnStart, RECORDS_TO_BROWSE); 82 | 83 | // Iterate over this list 84 | for ( StockPart sp : list ) { 85 | 86 | // Display the description 87 | String strMsg = "Read record with description %s"; 88 | task.out.println( String.format(strMsg, sp.getDescription().trim()) ); 89 | } 90 | 91 | // Completion message 92 | task.out.println("Completed RrdsExample5"); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Cobol/EC01.cbl: -------------------------------------------------------------------------------- 1 | 2 | *----------------------------------------------------------------* 3 | * Licensed Materials - Property of IBM * 4 | * SAMPLE * 5 | * (c) Copyright IBM Corp. 2016 All Rights Reserved * 6 | * US Government Users Restricted Rights - Use, duplication or * 7 | * disclosure restricted by GSA ADP Schedule Contract with * 8 | * IBM Corp * 9 | *----------------------------------------------------------------* 10 | 11 | ****************************************************************** 12 | * * 13 | * Module Name EC01.CBL * 14 | * * 15 | * CICS LINK back-end COMMAREA sample * 16 | * * 17 | * This program expects to be invoked with a COMMARAEA * 18 | * and returns the date and time. Note sample orginally supplied * 19 | * with IBM CICS Transaction Gateway. * 20 | ****************************************************************** 21 | 22 | 23 | IDENTIFICATION DIVISION. 24 | PROGRAM-ID. EC01. 25 | 26 | ENVIRONMENT DIVISION. 27 | DATA DIVISION. 28 | WORKING-STORAGE SECTION. 29 | ***************************************************************** 30 | * WORKING STORAGE STARTS HERE * 31 | ***************************************************************** 32 | 01 FILLER PIC X(32) VALUE 33 | '** WORKING STORAGE STARTS HERE**'. 34 | 35 | ***************************************************************** 36 | * THIS WS AREA CONTAINS ALL WORKING VARIABLES. * 37 | ***************************************************************** 38 | 01 FILLER PIC X(8) VALUE 'WS-'. 39 | 01 WS-DEBUG-AREA. 40 | 05 WS-RAWTIME PIC S9(15) COMP-3. 41 | 05 WS-DATE-DEBUG-AREA PIC X(8). 42 | 05 WS-TIME-DEBUG-AREA PIC X(8). 43 | 05 WS-EIBRESP-DISP PIC S9(9) 44 | SIGN LEADING SEPARATE. 45 | 05 WS-CICS-RESP OCCURS 2 TIMES 46 | PIC X(10). 47 | 05 WS-DEBUG-ON-FLAG PIC X VALUE 'Y'. 48 | 88 DEBUG-ON VALUE 'Y'. 49 | 50 | 51 | ***************** 52 | LINKAGE SECTION. 53 | ***************** 54 | 01 DFHCOMMAREA. 55 | 05 LK-DATE-OUT PIC X(8). 56 | 05 LK-SPACE-OUT PIC X(1). 57 | 05 LK-TIME-OUT PIC X(8). 58 | 05 LK-LOWVAL-OUT PIC X(1). 59 | 60 | ******************** 61 | PROCEDURE DIVISION. 62 | ******************** 63 | A-CONTROL SECTION. 64 | 65 | IF DEBUG-ON 66 | EXEC CICS HANDLE CONDITION ERROR (ZZX-CICS-ERROR-ROUTINE) 67 | END-EXEC 68 | END-IF. 69 | 70 | IF EIBCALEN < LENGTH OF DFHCOMMAREA 71 | THEN 72 | PERFORM ZZX-CICS-ERROR-ROUTINE 73 | END-IF. 74 | 75 | MOVE SPACES TO DFHCOMMAREA. 76 | 77 | EXEC CICS 78 | ASKTIME ABSTIME(WS-RAWTIME) 79 | END-EXEC. 80 | 81 | EXEC CICS 82 | FORMATTIME ABSTIME(WS-RAWTIME) 83 | DDMMYY(LK-DATE-OUT) 84 | DATESEP('/') 85 | TIME(LK-TIME-OUT) 86 | TIMESEP(':') 87 | END-EXEC. 88 | MOVE LOW-VALUES TO LK-LOWVAL-OUT. 89 | 90 | MOVE LK-DATE-OUT TO WS-DATE-DEBUG-AREA. 91 | MOVE LK-TIME-OUT TO WS-TIME-DEBUG-AREA. 92 | 93 | EXEC CICS RETURN END-EXEC. 94 | 95 | GOBACK. 96 | 97 | ******************************** 98 | ZZX-CICS-ERROR-ROUTINE SECTION. 99 | ******************************** 100 | 101 | IF EIBCALEN < LENGTH OF DFHCOMMAREA 102 | THEN 103 | EXEC CICS 104 | ABEND 105 | ABCODE('ECOM') 106 | END-EXEC 107 | ELSE 108 | EXEC CICS 109 | ABEND 110 | ABCODE('ERRO') 111 | END-EXEC 112 | END-IF. 113 | GOBACK. 114 | 115 | ZZX-EXIT. 116 | EXIT. 117 | EJECT 118 | *END OF PROGRAM 119 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | src 2 | === 3 | Supporting non-Java programs used in conjunction with the JCICS samples. 4 | 5 | See also the [cics-java-jzosprog](https://github.com/cicsdev/cics-java-jzosprog/tree/main/src/Cobol) repository for the `EDUPGM` COBOL program. 6 | 7 | --------------------------------------------------------------------------------