Shows the contents of a sample program that executes multiple CICS program calls and uses a Commarea and extended LUW.
- File SampleCommAreaWithELUW.java:
-
import java.io.UnsupportedEncodingException;
import com.microfocus.cics.client.AbendException;
import com.microfocus.cics.client.CCLCallType;
import com.microfocus.cics.client.CommArea;
import com.microfocus.cics.client.CCLExtendMode;
import com.microfocus.cics.client.CCLParams;
import com.microfocus.cics.client.CCLVersion;
import com.microfocus.cics.client.CICSException;
import com.microfocus.cics.client.CommAreaSizeException;
import com.microfocus.cics.client.ConnectionType;
import com.microfocus.cics.client.ContainerData;
import com.microfocus.cics.client.ECIBINPConnection;
import com.microfocus.cics.client.ECIBINPRequest;
import com.microfocus.cics.client.ECIConnection;
import com.microfocus.cics.client.ECIRequest;
import com.microfocus.cics.client.ECIResponse;
import com.microfocus.cics.client.MalformedResponseException;
import com.microfocus.cics.client.AbendCodeType;
import java.util.List;
public class SampleCommAreaWithELUW {
public static void main(String[] args) throws UnsupportedEncodingException, CICSException, AbendException, MalformedResponseException, CommAreaSizeException {
SampleCommAreaWithELUW sc = new SampleCommAreaWithELUW();
sc.commareaTest1();
}
public void commareaTest1() throws CICSException, UnsupportedEncodingException, AbendException, MalformedResponseException, CommAreaSizeException {
ECIConnection aConn = null;
ECIRequest aReq = null;
ECIResponse aResp = null;
CommArea ca = null;
CCLParams theParams = null;
try {
aConn = new ECIBINPConnection()
.setConnectionType(ConnectionType.LUW)
.setHost("localhost").setPort(9003)
.setTrace(true);
aConn.open();
aReq = new ECIBINPRequest(aConn);
// set parameters
ca = new CommArea("Bonjour le monde");
theParams = new CCLParams();
theParams.setVersion(CCLVersion.CCL_VERSION_2);
theParams.setCallType(CCLCallType.CCL_SYNC);
theParams.setProgramName("OKTEST");
theParams.setUserId("SYSAD");
theParams.setPassword("SYSAD");
theParams.setCommArea(ca);
theParams.setExtendMode(CCLExtendMode.CCL_EXTENDED);
aReq.setRequestParameter(theParams);
aResp = aReq.send();
handleResponse(aResp, CommArea.ISO_8859_1);
// call CICS again
ca = new CommArea("Bonjour le monde 2");
theParams.setVersion(CCLVersion.CCL_VERSION_2);
theParams.setCallType(CCLCallType.CCL_SYNC);
theParams.setProgramName("OKTEST");
theParams.setUserId("SYSAD");
theParams.setPassword("SYSAD");
theParams.setCommArea(ca);
theParams.setExtendMode(CCLExtendMode.CCL_EXTENDED);
aReq.setRequestParameter(theParams);
aResp = aReq.send();
handleResponse(aResp, CommArea.ISO_8859_1);
// mark end of LUW
ca = new CommArea("Au Revior");
theParams.setVersion(CCLVersion.CCL_VERSION_2);
theParams.setCallType(CCLCallType.CCL_SYNC);
theParams.setProgramName("OKTEST");
theParams.setUserId("SYSAD");
theParams.setPassword("SYSAD");
theParams.setCommArea(ca);
theParams.setExtendMode(CCLExtendMode.CCL_NO_EXTEND);
aReq.setRequestParameter(theParams);
aResp = aReq.send();
handleResponse(aResp, CommArea.ISO_8859_1);
// commit
theParams.setVersion(CCLVersion.CCL_VERSION_2);
theParams.setCallType(CCLCallType.CCL_SYNC);
theParams.setProgramName("OKTEST");
theParams.setUserId("SYSAD");
theParams.setPassword("SYSAD");
theParams.setExtendMode(CCLExtendMode.CCL_COMMIT);
aReq.setRequestParameter(theParams);
aResp = aReq.send();
handleResponse(aResp, CommArea.ISO_8859_1);
} catch (CICSException e) {
System.out.println(e.getMessage());
} catch (AbendException ae) {
String abCode = ae.getAbendCode();
AbendCodeType abendCodeType = ae.getAbendCodeType();
System.out.println("Abend Code = " + abCode);
System.out.println("Abend Code Type= " + abendCodeType);
} catch (MalformedResponseException bre) {
bre.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (CommAreaSizeException ce) {
ce.printStackTrace();
} finally {
ca = null;
theParams = null;
if (aReq != null)
aReq.close();
if (aResp != null)
aResp.close();
if (aConn != null) {
try {
aConn.close();
} catch (CICSException e) {
e.printStackTrace();
}
}
}
}
private void handleResponse(ECIResponse aResp, String encoding)
throws UnsupportedEncodingException {
System.out.println("Response1 = " + aResp.getExciResp1());
System.out.println("Response2 = " + aResp.getExciResp2());
CommArea ca = aResp.getCommArea();
if (ca != null) {
byte[] caBytes = ca.getCommArea();
if (caBytes != null) {
String asciiCommArea = new String(ca.getCommArea(), encoding);
System.out.println("CommArea = " + asciiCommArea);
} else {
System.out.println("CommArea = null");
}
}
System.out.println("Abend code = " + aResp.getAbendCode());
System.out.println("Abend code type = " + aResp.getAbendCodeType());
}
}