Using Host file provider - MsHostFileClient in HIS 2006 for VSAM and other mainframe files
Hostfile provider :
Microsoft.HostIntegration.MsHostFileClient.Dll in HIS 2006
Purpose :
Provide access( read , update, Query data) to Mainframe Host files like :
VSAM files :
( RRDS, VRRDS, KSDS, KAIX, ESDS, EAIX)
Libraries :
( PDS, PDSE)
FLAT files :
FB and VB
Using Hostfiles Provider needs :
1. Assembly designed in TI which looks like the one attached .
Assembly needs to be registered and GACed
2. Connection String pointing to Host
1 ) configure SNA for APPC communication to Mainframe
2) Create connection string using Data access Tool for Mainframe file System( Select Connection string properties as configured in step above )
3. Host Data file
Can be created by FTP or submitting JCL to create new file.
4. C# App with sample code :
using
Microsoft.HostIntegration.MsHostFileClient;
using
System.Reflection;
namespace
ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
HostFileConnection cn = new HostFileConnection();
string cnstring = @"Provider=SNAOLEDB;User ID=XYZ;Password=xyz;APPC Remote LU Alias=REMOTE;APPC Local LU Alias=LOCAL;APPC Mode Name=MODENM;Network Transport Library=SNA;Host CCSID=37;PC Code Page=1252;Network Port=999;Process Binary as Character=False;Persist Security Info=True;Cache Authentication=False;Default Library=XYZ;Host Column Description File=;Repair Host Keys=False;Strict Validation=False;";
cn.ConnectionString = cnstring;
try
{
string query = "SELECT INT1 FROM VBREC";
HostFileRecordSet rs;
HostFileCommand cmd = new HostFileCommand();
cmd.Connection = cn;
cmd.CommandText = query;
cmd.CommandType = System.Data.CommandType.Text;
// This code would set :Metadata="VBlock, Version=1.0.0.0, Culture=neutral,
// PublicKeyToken=9218ec74baad7731" in connection string
cn.Metadata = Assembly.LoadFile(@"C:\HISTests\DataTests\Binaries\HostFileProvider\VBlock.DLL");
cn.Open();
rs = cmd.ExecuteRecordSet();
int i = 0;
while (rs.Read())
{
System.Console.WriteLine(rs.GetValue(i));
i++;
}
}
catch (Exception e)
{
System.Console.WriteLine(e.Message);
}
finally
{
cn.Close();
}
Comments
- Anonymous
March 22, 2007
Thanks for the sample code. Is there any way to simply connect to a file on the local file system via the Host File Provider? I would like to do everything except the actual connection to the mainframe. They transmit the flat file, defined by a COBOL copybook, to me via FTP, so I already have it on hand. I just want to use these tools to access the data in it. Thanks for any help you can offer. - Anonymous
March 23, 2007
Hi Tom,Unfortunately not. The provider is meant to work only through IBM protocols.if you have no necessity to work with Online files , you can always transefer them into SQL tables through LOAD and then use SQL provider to Access the tables.is there any specific reason you would like to process files offline. If not we can discuss this further.Asmita