Using objects

The following example shows how you create a TSQ object and invoke the delete method on the temporary storage queue object you have just created, catching the exception thrown if the queue is empty:
// 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;
    }
}
Important: