Channel and containers example

This example shows an excerpt of a Java class called Payroll that calls a COBOL server program named PAYR. The Payroll class uses the JCICS com.ibm.cics.server.Channel and com.ibm.cics.server.Container classes to work with a channel and its containers

Figure 1. Java class that uses the JCICS com.ibm.cics.server.Channel and com.ibm.cics.server.Container classes to pass a channel to a COBOL server program
import com.ibm.cics.server.*;
public class Payroll {
     ...
     Task t=Task.getTask();

     // create the payroll_2004 channel
     Channel payroll_2004 = t.createChannel("payroll-2004");
     
     // create the employee container
     Container employee = payroll_2004.createContainer("employee");
     
     // put the employee name into the container
     employee.put("John Doe");
     
     // create the wage container
     Container wage = payroll_2004.createContainer("wage");
     
     // put the wage into the container
     wage.put("2000");
     
     // Link to the PAYROLL program, passing the payroll_2004 channel
     Program p = new Program();
     p.setName("PAYR");
     p.link(payroll_2004);
     
     // Get the status container which has been returned
     Container status = payroll_2004.getContainer("status");
                                                  
     // Get the status information
     byte[] payrollStatus = status.get();
     ...
}