Skip to content

Commit 2718b01

Browse files
committed
Update abend code constant
1 parent 262eabe commit 2718b01

File tree

1 file changed

+48
-49
lines changed

1 file changed

+48
-49
lines changed

projects/com.ibm.cicsdev.link/src/com/ibm/cicsdev/link/LinkServEC01.java

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,56 +21,55 @@
2121
* Provides a Java implementation that is functionally equivalent to the COBOL
2222
* EC01 sample program.
2323
*/
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 current JVM.
38-
*/
39-
private static final String LOCALCCSID = System.getProperty("com.ibm.cics.jvmserver.local.ccsid");
24+
public class LinkServEC01 {
25+
/**
26+
* Length of the COMMAREA returned by this program.
27+
*/
28+
private static final int CA_LEN = 18;
4029

41-
/**
42-
* Main entry point to a CICS OSGi program.
43-
*
44-
* The fully qualified name of this class should be added to the CICS-MainClass entry in
45-
* the parent OSGi bundle's manifest.
46-
*
47-
* This program is a Java version of the COBOL EC01 sample. It expects to be invoked with
48-
* a COMMAREA of 18 bytes and returns the date.
49-
*/
50-
public static void main(CommAreaHolder cah) {
51-
52-
// Get a reference to the current CICS task
53-
Task task = Task.getTask();
30+
/**
31+
* Abend code used if the COMMAREA is too short.
32+
*/
33+
private static final String CA_LEN_ABCODE = "LEN";
5434

55-
// Check input area is long enough, else abend task
56-
if ( cah.getValue().length < CA_LEN ) {
57-
task.abend(CA_LEN_ABCODE);
58-
}
35+
/**
36+
* CCSID of the current JVM.
37+
*/
38+
private static final String LOCALCCSID = System
39+
.getProperty("com.ibm.cics.jvmserver.local.ccsid");
5940

60-
// Get time for return to caller
61-
Date timestamp = new Date();
62-
SimpleDateFormat dfTime = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
63-
64-
try {
65-
// Create byte array in local encoding
66-
byte ba[] = dfTime.format(timestamp).getBytes(LOCALCCSID);
67-
68-
// Copy into the byte array provided by the CommAreaHolder object
69-
System.arraycopy(ba, 0, cah.getValue(), 0, ba.length);
70-
}
71-
catch (UnsupportedEncodingException uee) {
72-
// Crude error handling for simple example
73-
throw new RuntimeException(uee);
74-
}
75-
}
41+
/**
42+
* Main entry point to a CICS OSGi program.
43+
*
44+
* The fully qualified name of this class should be added to the
45+
* CICS-MainClass entry in the parent OSGi bundle's manifest.
46+
*
47+
* This program is a Java version of the COBOL EC01 sample. It expects to be
48+
* invoked with a COMMAREA of 18 bytes and returns the date.
49+
*/
50+
public static void main(CommAreaHolder cah) {
51+
52+
// Get a reference to the current CICS task
53+
Task task = Task.getTask();
54+
55+
// Check input area is long enough, else abend task
56+
if (cah.getValue().length < CA_LEN) {
57+
task.abend(CA_LEN_ABCODE);
58+
}
59+
60+
// Get time for return to caller
61+
Date timestamp = new Date();
62+
SimpleDateFormat dfTime = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
63+
64+
try {
65+
// Create byte array in local encoding
66+
byte ba[] = dfTime.format(timestamp).getBytes(LOCALCCSID);
67+
68+
// Copy into the byte array provided by the CommAreaHolder object
69+
System.arraycopy(ba, 0, cah.getValue(), 0, ba.length);
70+
} catch (UnsupportedEncodingException uee) {
71+
// Crude error handling for simple example
72+
throw new RuntimeException(uee);
73+
}
74+
}
7675
}

0 commit comments

Comments
 (0)