채널 및 컨테이너 예제

이 예제는 이름이 PAYR인 COBOL 서버 프로그램을 호출하는 Payroll이라는 Java 클래스를 발췌한 것입니다. Payroll 클래스는 com.ibm.cics.server.Channel과 com.ibm.cics.server.Container 클래스를 사용하여 채널과 채널의 컨테이너에 대한 작업을 합니다.

그림 1. JCICS com.ibm.cics.server.Channel과 com.ibm.cics.server.Container 클래스를 사용하여 채널을 COBOL 서버 프로그램에 전달하는 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();
     ...
}