Sending and receiving data

Having connected a CclOTerminal object to the required CICS® server the Terminal, Session, Screen and Field COM classes are used to start a transaction on CICS and navigate through 3270 panels, accessing 3270 fields as required by the application.

The required CICS transaction is started using its four character transaction code. Initial transaction data can also be supplied on the Terminal.Start method, in this example no data is required. To access the 3270 data returned by CICS, a screen object is obtained from the terminal object, and a variety of methods can be used to obtain fields from the screen and read and update text and attributes in the fields:
        Sub EPIStart_Click()
            'Start CESN transaction
            Terminal.Start Session, "CESN", ""
            'Get the screen object
            Set Screen = Terminal.Screen
            'Output the text from some 3270 fields
            Set Field = Screen.FieldByIndex(5)
            List1.AddItem Field.Text
            Set Field = Screen.FieldByIndex(6)
            List1.AddItem Field.Text

The CESN transaction is waiting for input from the user, the program could enter text into some fields and continue the transaction, in this example we simply end the transaction by sending PF3 to CICS.

            'Send PF3 back to CICS to end CESN
            Screen.SetAID cclPF3
            Terminal.Send Session
            'Output the text from a 3270 field
            Set Field = Screen.FieldByIndex(1)
            List1.AddItem Field.Text
        End Sub
Finally, disconnect the terminal, and then terminate the EPI. After you have disconnected the terminal it is recommended that you set Session, Terminal and EPI to Nothing. Disconnect the terminal before setting these objects; you cannot disconnect a terminal that you have set to Nothing.
        Sub EPIDone_Click()
            Terminal.Disconnect
            'Delete the EPI COM objects
            Set Field = Nothing
            Set Screen = Nothing
            Set Session = Nothing
            Set Terminal = Nothing
            Set EPI = Nothing
        End Sub