Skip to content

Commit c4d2b36

Browse files
committed
Bit link program sample
1 parent 4db85a9 commit c4d2b36

File tree

6 files changed

+312
-63
lines changed

6 files changed

+312
-63
lines changed

append-char-container-sample/src/main/java/sample/SampleServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
4646
// Get the current task number that this unit of work is running under
4747
Integer taskNumber = task.getTaskNumber();
4848

49-
// Add the task number to the enf of the CHAR container
49+
// Add the task number to the end of the CHAR container
5050
charContainer = charContainer.append(taskNumber.toString());
5151

5252
// Get the full contents of the container, and print this

bit-link-program-sample/README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1-
Bit Link to Program Sample
1+
# bit-link-program-sample
2+
3+
Sample RESTful web application for deployment to a Liberty JVM server in CICS. `SampleServlet` takes an Integer temperature and uses the JCICSX API to link to the `CONVERT` COBOL program to convert it from Celcius to Fahrenheit. The link uses BIT containers for both the input and the output.
4+
5+
6+
## Supporting files
7+
* [`CONVERT.cbl`](src/main/cobol/CONVERT.cbl) - A sample CICS COBOL that returns a converted temperature input using channels and containers.
8+
Download and compile the supplied COBOL program CONVERT and deploy into CICS.
9+
10+
11+
## Pre-reqs
12+
13+
* CICS TS V5.1 or later, due to the usage of the `getString()` methods.
14+
* Java SE 1.7 or later on the z/OS system
15+
* Java SE 1.7 or later on the workstation
16+
17+
18+
## Setup
19+
20+
This sample is a Maven project, which uses the [CICS Bundle Maven plugin](https://github.com/IBM/cics-bundle-maven) to package the web application in a CICS bundle and deploy this to CICS. This requires the CICS bundle deployment API to be enabled in CICS as a [prerequisite](https://www.ibm.com/support/knowledgecenter/en/SSGMCP_5.6.0/configuring/cmci/config-bundle-api.html). Alternatively, if you aren't using Maven, you could take the source from this project and use one of the other methods of deploying the application to CICS such as creating a CICS bundle project in CICS Explorer and adding the source as a dynamic web project include.
21+
22+
To run the sample as-is, fill out values in the configuration block in pom.xml
23+
```xml
24+
<configuration>
25+
<defaultjvmserver>DFHWLP</defaultjvmserver>
26+
<url>http://yourcicsurl.com:9080</url>
27+
<username>${cics-user-id}</username>
28+
<password>${cics-password}</password>
29+
<bunddef>DEMOBUNDLE</bunddef>
30+
<csdgroup>BAR</csdgroup>
31+
<cicsplex>CICSEX56</cicsplex>
32+
<region>IYCWEMW2</region>
33+
</configuration>
34+
```
35+
Running `mvn clean install` will package the web application into a CICS Bundle and install and enable it.
36+
You can then view the web server `http://yourcicsurl.com:9080/bit-link-program-sample-0.0.1-SNAPSHOT/`
37+
38+
#### Using a web browser you can issue the following HTTP GET requests
39+
40+
* http://yourcicsurl.com:9080/bit-link-program-sample-0.0.1-SNAPSHOT/75
41+
where 75 can be any integer and represents a temperate in Celcius.
42+
This will invoke the `SampleServlet` class and return the following response with the temperature converted to Fahrenheit:
43+
44+
`Returned from link to 'CONVERT'. 75 degrees celcius = 167 degrees fahrenheit`
245

3-
This sample shows how you can use the JCICSX API to LINK to a CICS Program, passing through a CHAR container, and returning BIT data as the output of the Program.

bit-link-program-sample/pom.xml

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
25
<modelVersion>4.0.0</modelVersion>
3-
6+
47
<groupId>com.ibm.cics</groupId>
58
<artifactId>bit-link-program-sample</artifactId>
69
<version>0.0.1-SNAPSHOT</version>
710
<packaging>war</packaging>
8-
11+
912
<dependencies>
1013
<dependency>
1114
<groupId>javax.servlet</groupId>
@@ -19,6 +22,8 @@
1922
<version>1.0</version>
2023
<scope>provided</scope>
2124
</dependency>
25+
26+
<!-- JCICSX dependency, used in ReverseResource.java -->
2227
<dependency>
2328
<!-- <groupId>com.ibm.cics</groupId>
2429
<artifactId>com.ibm.cics.jcicsx</artifactId> -->
@@ -29,27 +34,55 @@
2934
</dependencies>
3035

3136
<build>
32-
<pluginManagement>
33-
<plugins>
34-
<plugin>
35-
<groupId>org.apache.maven.plugins</groupId>
36-
<artifactId>maven-war-plugin</artifactId>
37-
<version>3.2.2</version>
38-
<configuration>
39-
<failOnMissingWebXml>false</failOnMissingWebXml>
40-
</configuration>
41-
</plugin>
37+
<plugins>
4238
<plugin>
4339
<groupId>org.apache.maven.plugins</groupId>
4440
<artifactId>maven-compiler-plugin</artifactId>
41+
<version>3.8.1</version>
4542
<configuration>
4643
<source>1.8</source>
4744
<target>1.8</target>
4845
</configuration>
4946
</plugin>
47+
48+
<!-- The below bundles the application as a WAR in a CICS bundle and deploys this to CICS using the CICS bundle deployment API.
49+
This is optional and can be removed if you don't wish to deploy the application this way -->
50+
<plugin>
51+
<groupId>com.ibm.cics</groupId>
52+
<artifactId>cics-bundle-maven-plugin</artifactId>
53+
<version>1.0.0</version>
54+
<executions>
55+
<execution>
56+
57+
<!-- These goals will firstly run the war packaging on the project, and then will run the deploy goal, which will happen during the verify phase of the lifecycle by default-->
58+
<goals>
59+
<goal>bundle-war</goal>
60+
<goal>deploy</goal>
61+
</goals>
62+
63+
<configuration>
64+
<!-- The bundle classifier indicates that the war should be packaged into a CICS bundle -->
65+
<classifier>cics-bundle</classifier>
66+
67+
<!-- Update the default JVM server that the application will be installed into by default, This is used when creating the bundle, and goes into the CICS bundle's manifest -->
68+
<jvmserver>DFHWLP</jvmserver>
69+
70+
<!-- Set the URL of the deploy target -->
71+
<url>http://yourcicsurl.com:9080</url>
72+
73+
<!-- We'd recommend that you use Maven's password encryption, or supply your credentials using environment variables or properties, as shown here. -->
74+
<username>${cics-user-id}</username>
75+
<password>${cics-password}</password>
76+
77+
<!-- Identify which bundle definition you're going to use from the CSD and which region and CICSPlex you want to deploy to -->
78+
<bunddef>DEMOBUNDLE</bunddef>
79+
<csdgroup>BAR</csdgroup>
80+
<cicsplex>CICSEX56</cicsplex>
81+
<region>IYCWEMW2</region>
82+
</configuration>
83+
</execution>
84+
</executions>
85+
</plugin>
5086
</plugins>
51-
</pluginManagement>
5287
</build>
53-
54-
55-
</project>
88+
</project>
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
*----------------------------------------------------------------*
2+
* Licensed Materials - Property of IBM *
3+
* SAMPLE *
4+
* (c) Copyright IBM Corp. 2016 All Rights Reserved *
5+
* US Government Users Restricted Rights - Use, duplication or *
6+
* disclosure restricted by GSA ADP Schedule Contract with *
7+
* IBM Corp *
8+
*----------------------------------------------------------------*
9+
10+
******************************************************************
11+
* *
12+
* Module Name CONVERT.CBL *
13+
* Version 1.0 *
14+
* Date 03/06/2020 *
15+
* *
16+
* CICS back-end bit channel/container sample *
17+
* *
18+
* This program expects to be invoked with a BIT container named *
19+
* INPUTDATA. INPUTDATA will contain a celcius temperature. *
20+
* and returns the following containers: *
21+
* A BIT container containing the temperatre input converted to *
22+
* fahrenheit *
23+
* A BIT container containing the CICS return code from reading *
24+
* the input container *
25+
******************************************************************
26+
27+
IDENTIFICATION DIVISION.
28+
PROGRAM-ID. CONVERT.
29+
30+
ENVIRONMENT DIVISION.
31+
CONFIGURATION SECTION.
32+
DATA DIVISION.
33+
WORKING-STORAGE SECTION.
34+
35+
* Container name declarations
36+
* Channel and container names are case sensitive
37+
01 INPUT-CONT PIC X(16) VALUE 'INPUTDATA'.
38+
01 OUTPUT-CONT PIC X(16) VALUE 'OUTPUTDATA'.
39+
01 LENGTH-CONT PIC X(16) VALUE 'INPUTDATALENGTH'.
40+
01 ERROR-CONT PIC X(16) VALUE 'ERRORDATA'.
41+
01 RESP-CONT PIC X(16) VALUE 'CICSRC'.
42+
43+
44+
* Data fields used by the program
45+
01 INPUTLENGTH PIC S9(8) COMP-4.
46+
01 DATALENGTH PIC S9(8) COMP-4.
47+
01 ABENDCODE PIC X(4) VALUE SPACES.
48+
01 CHANNELNAME PIC X(16) VALUE SPACES.
49+
01 INPUTDATA PIC S9(9) COMP-4.
50+
01 OUTPUTDATA PIC S9(9) COMP-4.
51+
01 RESPCODE PIC S9(8) COMP-4 VALUE 0.
52+
01 RESPCODE2 PIC S9(8) COMP-4 VALUE 0.
53+
01 RC-RECORD PIC S9(8) COMP-4 VALUE 0.
54+
01 ERR-RECORD.
55+
03 ERRORCMD PIC X(16) VALUE SPACES.
56+
03 ERRORSTRING PIC X(32) VALUE SPACES.
57+
58+
59+
PROCEDURE DIVISION.
60+
* -----------------------------------------------------------
61+
MAIN-PROCESSING SECTION.
62+
* -----------------------------------------------------------
63+
64+
* Get name of channel
65+
EXEC CICS ASSIGN CHANNEL(CHANNELNAME)
66+
END-EXEC.
67+
68+
* If no channel passed in, terminate with abend code NOCH
69+
IF CHANNELNAME = SPACES THEN
70+
MOVE 'NOCH' TO ABENDCODE
71+
PERFORM ABEND-ROUTINE
72+
END-IF.
73+
74+
75+
* Read content and length of input container
76+
MOVE LENGTH OF INPUTDATA TO INPUTLENGTH.
77+
EXEC CICS GET CONTAINER(INPUT-CONT)
78+
CHANNEL(CHANNELNAME)
79+
FLENGTH(INPUTLENGTH)
80+
INTO(INPUTDATA)
81+
RESP(RESPCODE)
82+
RESP2(RESPCODE2)
83+
END-EXEC.
84+
85+
* Place RC in binary container for return to caller
86+
MOVE RESPCODE TO RC-RECORD.
87+
EXEC CICS PUT CONTAINER(RESP-CONT)
88+
FROM(RC-RECORD)
89+
FLENGTH(LENGTH OF RC-RECORD)
90+
BIT
91+
RESP(RESPCODE)
92+
END-EXEC.
93+
94+
IF RESPCODE NOT = DFHRESP(NORMAL)
95+
PERFORM RESP-ERROR
96+
END-IF.
97+
98+
* Convert celcius input to fahrenheit
99+
COMPUTE OUTPUTDATA ROUNDED = (INPUTDATA * 9/5) + 32.
100+
101+
* Place converted temperature in output container
102+
103+
EXEC CICS PUT CONTAINER(OUTPUT-CONT)
104+
CHANNEL(CHANNELNAME)
105+
FROM(OUTPUTDATA)
106+
FLENGTH(LENGTH OF OUTPUTDATA)
107+
BIT
108+
RESP(RESPCODE)
109+
END-EXEC.
110+
111+
IF RESPCODE NOT = DFHRESP(NORMAL)
112+
PERFORM RESP-ERROR
113+
END-IF.
114+
115+
116+
* Return back to caller
117+
PERFORM END-PGM.
118+
119+
* -----------------------------------------------------------
120+
RESP-ERROR.
121+
MOVE 'EDUC' TO ABENDCODE
122+
PERFORM ABEND-ROUTINE.
123+
124+
PERFORM END-PGM.
125+
126+
* -----------------------------------------------------------
127+
* Abnormal end
128+
* -----------------------------------------------------------
129+
ABEND-ROUTINE.
130+
EXEC CICS ABEND ABCODE(ABENDCODE) END-EXEC.
131+
132+
* -----------------------------------------------------------
133+
* Finish
134+
* -----------------------------------------------------------
135+
END-PGM.
136+
EXEC CICS RETURN END-EXEC.
137+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 sample;
12+
13+
import javax.ws.rs.ApplicationPath;
14+
import javax.ws.rs.core.Application;
15+
16+
@ApplicationPath("/")
17+
public class CICSApplication extends Application {
18+
19+
}

0 commit comments

Comments
 (0)