The first step is to declare object variables for the ECI interfaces to
be used. See the
COM chapter of
CICS Transaction Gateway: Programming Reference for
details of the available interfaces. Declarations are usually made in the
General Declarations section of a Visual Basic program:
Dim ECI As CclOECI
Dim Connect As CclOConn
Dim Flow As CclOFlow
Dim Buffer As CclOBuf
Dim UOW As CclOUOW
The required ECI objects are then instantiated using the Visual Basic
New function.
This can be done in the
Form_Load subroutine or at some later stage
in response to some user action. Note that a CclOECI object must be created
first.
Sub ECILink_Click()
Set ECI = New CclOECI
Set Connect = New CclOConn
Set Flow = New CclOFlow
Set Buffer = New CclOBuf
Details of the CICS
® server to be used – server name (as configured
in the
Gateway initialization file) , userid
and password – are supplied via the
Details method on the Connect object.
The Buffer object is initialized with some data to be sent to CICS:
Connect.Details "CICSNAME", "sysad", "sysad"
Buffer.SetString "Hello"
Now we are ready to make the call to CICS. The
Link method takes as parameters
the Flow object, the name of the CICS server program to be invoked, the
Buffer object and a UOW object. In this example a null variable is supplied
for the UOW parameter, so this call will not be part of a recoverable Unit
Of Work. The contents of the Buffer returned from CICS are output to a Visual Basic text
box
"Text1":
Connect.Link Flow, "ECIWTO", Buffer, UOW
Text1.Text = Buffer.String
Finally the CICS COM
objects are deleted:
Set Connect = Nothing
Set Flow = Nothing
Set Buffer = Nothing
End Sub
This example sends and receives a simple text string. In practice, the
Buffer object would contain more complex data (for example C data structure).
For binary data the Buffer.SetData and Buffer.Data methods are
provided to allow the contents to be accessed as a Byte array.
A typical client application could access CICS through one or more Connect.Link calls
and construct a 'business object' for use in end-user Basic programs. One
approach to this would be to implement the 'business object' as a separate
COM automation server containing the logic to process the contents of the
CclOBuffer objects.