Information for the TRM request or the TRM reply, or both, is passed to the COMTI runtime through an optional parameter that contains an array of data. Formatting for the TRM request and the TRM reply is defined within the user-defined type definitions in the COMTI type library. The name of the user-defined type must start with the characters TRMIN for the TRM request and TRMOUT for the TRM reply. This prefix is case sensitive. TRM requests and TRM replies may have multiple user-defined type definitions. For example, you may have the following user-defined type definitions:
- TRMINExample1
- TRMINExample2
- TRMINExample3
- TRMOUTSample
The format must match with the format that is used in the Concurrent Server program or Concurrent Server programs on the mainframe.
COMTI includes sample Concurrent Server programs that use the default format that the COMTI runtime will process automatically. You can use the Mscmtics.cbl program with the TCP/IP Link model. You can modify the Tcpcdrbk.cbl sample, the Tcpcgtac.cbl, and the Cicscs.cbl sample for use with the Concurrent Server (non-Link) model. The example in this section uses the TRM request format that is programmed in the Mscmtics.cbl sample and calls the sample
cedrbank method that is used in the CedarBank tutorial that is included with COMTI.
When sending the TRM request, the IBM listener expects a four-byte string with the CICS Transaction Name for the Concurrent Server program and then a one-byte FILLER that typically contains a comma. Then, in the Mscmtics.cbl sample, the format of the TRM request after the fifth byte is the following:
01 CLIENT-IN-DATA PIC X(35).
01 FILLER REDEFINES CLIENT-IN-DATA.
05 CID-USERID PIC X(8).
05 CID-PASSWORD PIC X(8).
05 CID-LINK-TO-PROG PIC X(8).
05 CID-COMMAREA-LEN PIC S9(4) COMP.
05 CID-RESERVED PIC X(9).
To give the client program full control over the data that is sent in the TRM request, you must add the following user-defined type to the COMTI type library:
UDT Name: TRMINSample (where 'Sample' can be any text)
UDT Members (the Member names that are specified here are for sample purposes):
TranID � String � PIC X(4)
CommaDelim � String � PIC X
MyUserID � String � PIC X(8)
MyPassword � String � PIC X(8)
LinkProg � String � PIC X(8)
CommLen � Integer � PIC S9(4) COMP
(with a Trailing FILLER of 9 on the COBOL Definition tab for CommLen)
As soon as the COMTI type library is saved and installed into a COM+ application package, you must enable the TRM reply feature in the client program. To do this, follow these steps:
Note This code sample is in Microsoft Visual Basic .NET.
- In your Visual Basic .NET project,
add a COM reference to the following file:
\Program Files\Host Integration Server\System\Comticontext.dll
- Add a COM reference to the COMTI type library. To do this,
run the Assembly Registration tool (Regasm.exe) against the Interop.FileName.dll file that is created in the Bin folder for the project. This registers the interop assembly in the global assembly cache. To do this, follow these steps:
- Click Start, point to All Programs, point to Microsoft Visual Studio .NET 2003, point to Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt.
- Open the Bin directory for the project, and then run the following command:
regasm interop.FileName.dll
In the Visual Basic .NET project, the following code is used:
Dim objCedar As New COMTI.TRMSample
Dim ctxArray() As Object
Dim objCOMTIContext As New COMTICONTEXTLib.ContextObject
Dim udtTRMIN As COMTI.TRMINSample
' Fill the user-defined type with the values to send to the mainframe.
udtTRMIN.TranID = "MSCS" ' Transaction to execute on the Host.
udtTRMIN.CommaDelim = ","
udtTRMIN.MyUserID = "MFUSERID"
udtTRMIN.MyPassword = "PASSWORD"
udtTRMIN.LinkProg = "CEDRBANK" ' The CICS Link to the program name.
udtTRMIN.CommLen = 41 ' The number of bytes in the COMMAREA.
' Write the user-defined type to the COMTI Context Array.
' First parameter: string with the exact name of the typelib user-defined type.
' Second parameter: the Visual Basic user-defined type that contains the data.
' Third parameter: the array object to write the data to.
objCOMTIContext.WriteContext("TRMINSample", udtTRMIN, ctxArray)
Dim Name As String
Dim Acc As String
Dim Bal As Decimal
Name = "Jane"
Acc = "1234"
Bal = 0
' Make the COMTI method call. The last parameter is the optional
' COMTI Context Array parameter.
objCedar.cedrbank(Name, Acc, Bal, ctxArray)
To view the TRM reply, a user-defined type must be defined in the COMTI type library with a user-defined type name that begins with TRMOUT. You must define a variable within the Visual Basic project for that user-defined type and you must call the
WriteContext method with the following three parameters:
- The exact user-defined type name in the COMTI type library (case sensitive)
- The Visual Basic variable for the user-defined type
- The context array object
When the COMTI method call is made with the optional context array parameter, the data from the TRM reply is passed back to the program in the Visual Basic variable for the user-defined type. For the TRMOUT user-defined type, the format may include a first data item that is numeric. This indicates the length of the message. In the COMTI Component Builder properties for the TRMOUT user-defined type, you can choose one of the following three options if the first data item is numeric:
- No length specifier present
- Length specifier includes self
- Length specifier excludes self