チャネルとコンテナーの例

この例は、PAYR という名前の COBOL サーバー・プログラムを呼び出す、Payroll と呼ばれる Java クラスの抜粋を示しています。Payroll クラスは、JCICS com.ibm.cics.server.Channel クラスと com.ibm.cics.server.Container クラスを使用して、チャネルとそのコンテナーを処理します。

図 1. COBOL サーバー・プログラムにチャネルを渡すために JCICS com.ibm.cics.server.Channel クラスと com.ibm.cics.server.Container クラスを使用する Java クラス
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();
     ...
}