Using JCICS
Use the classes from the JCICS library in the same way as Java™ classes. Applications
declare a reference of the required type and a new instance of a class is created using the
new
operator.
Name CICS® resources using the setName method to supply the name of the underlying CICS resource. After creating the resource, manipulate objects using standard Java constructs. Call methods of the declared objects in the usual way. Full details of the methods supported for each class are available in the supplied Javadoc.
CICS attempts to pass control to the method with a signature of main(CommAreaHolder) in the class specified by the JVMCLASS attribute of the PROGRAM resource. If this method is not found, CICS tries to invoke method main(String[]).
For more information, see Java restrictions and JCICS Javadoc information.
// Define a package name for the program
package unit_test;
// Import the JCICS package
import com.ibm.cics.server.*;
// Declare a class for a CICS application
public class JCICSTSQ
{
// The main method is called when the application runs
public static void main(CommAreaHolder cah)
{
try
{
// Create and name a Temporary Storage queue object
TSQ tsq = new TSQ();
tsq.setName("JCICSTSQ");
// Delete the queue if it exists
try
{
tsq.delete();
}
catch(InvalidQueueIdException e)
{
// Absorb QIDERR
System.out.println("QIDERR ignored!");
}
// Write an item to the queue
String transaction = Task.getTask().getTransactionName();
String message = "Transaction name is - " + transaction;
tsq.writeItem(message.getBytes());
}
catch(Throwable t)
{
System.out.println("Unexpected Throwable: " + t.toString());
}
// Return from the application
return;
}
}