Accessing System i Journal Files
26 May 09 02:55 PM | ricardom | 1 Comments   

The Problem

Recently I got the following question from one of the Technical Specialists in our field team: ‘How can I expose the change-data-capture information from the System i journal files to a process running on BizTalk Server?

The Solution

After a joyful day of research, I found a simple way to achieve this goal by using two BizTalk Adapters that are part of the Microsoft BizTalk Adapters for Host Systems package.

This blog post assumes you have familiarity with BizTalk as well as basic knowledge of System i administration.

Let’s start by creating sample data in the System i, so we can have a journal file to be used as a example. For this example, I will start creating a SQL Collection. By default, SQL Collections on the System i will automatically have a journal receiver. So, it’s time to connect to the System i by using a 5250 emulator and fire up some SQL Commands.

image

Enter the Interactive SQL dialog by typing STRSQL in the main System i menu. Using the STRSQL dialog, type the following command: CREATE COLLECTION JRNTST

This step creates a System i library named JRNTST. We will use this library in the subsequent examples.

image The JRNTST library can be inspected by using the following command: WRKOBJ OBJ(JRNTST/*ALL)

We can see that a Journal (QSQJRN) and a Journal Receiver(QSQJRNXXXX) had been created automatically as part of the collection’s creation.

Any subsequent operation inside this collection will be stored in the journal and can be captured by reading the contents of it.

There are several ways one can read the contents of the journal. In this example, we will write the contents of the journal to a physical file (using the DSPJOB command) and then read this file. For this task, we will use the BizTalk Adapter for Host Files.

Now it’s time to start configuring the BizTalk side of the solution. Let’s begin by creating a new BizTalk Application.

image

Using BizTalk Server Administration console, create a new Application called Journal Test.

The next step, is to create one send port based in the BizTalk Adapter for Host Files that will be used to execute the CL command that captures the journal contents to a physical file. This same send port will enable us to read the contents of the physical file.

image We will start by creating a new Static Solicit-Response Send Port named SendPortHF.

 

 

 image

The Send Port configuration is straightforward: We need to provide a Connection String, Target Namespace and Root Element name.

 

 

 image

The Connection Configuration dialog is launched. At this point, let’s create a new connection string.

 

 

image

We will be connecting to a System i machine over the TCP/IP protocol.

 

 

 

 image

In the Network Connection Properties page, let’s provide the name of the server as well as the port in which the System i is listening to DRDA requests.

 

image The next step is to specify the location and default library names. These values can be retrieved in the AS/400 by using the WRKRDBDIRE (Work with Relational Database Directory Entries) and WRKUSRPF (Work with User Profiles) System i commands.

imageThe Locale page will allow you to specify CCSID settings.

 

 

 

 

image

 

You should specify your credentials using the Security page.

 

 

The remaining pages of the Wizard should be left with the default values. This completes the send port configuration.

At this point, we issue the commands to output the journal to a physical file as well as to read the contents of this file by submitting the following XML documents to the BizTalk Adapter for Host Files:

image

This will cause the execution of the command DSPJRN with a option to save the output to a specific file (in the example above, RICARDO/JRNTSTOUT).

Now we need to read the contents of the journal by submitting a XML document containing a query to read the contents of the output file created earlier:

image

Conclusion

By using the ability of BizTalk Adapter for Host Files to execute System i system commands as well as to read physical and logical files we are able to read the contents of the AS/400 journal files.

Remarks

This blog post did not described the creation of the metadata that describes the System i physical file. This will be published in a future blog post.

The process described here, shows how to get access to the raw journal content. Additional parsing needs to be done to extract the actual database operations from the raw journal data.

In order to keep this blog post concise, some of the environment configuration description was skipped.

 

Regards,

Ricardo

Exposing Mainframe Applications as SQL Stored Procedures using HIS 2009 Release Candidate
25 March 09 05:41 PM | ricardom | 2 Comments   
[HIS2009] Exposing CICS Transactions as SQL Server Stored Procedures

 
Video: [HIS2009] Exposing CICS Transactions as SQL Server Stored Procedures

Filed under: ,
Acessing Offline Mainframe VSAM Data Using Host Integration Server 2009 Release Candidate
25 March 09 11:23 AM | ricardom | 2 Comments   
Talking about [HIS2009] MsHostFileClient Offline Capabilities
 
Video: [HIS2009] MsHostFileClient Offline Capabilities

We Are Going To Disneyland!
02 April 08 05:01 PM | ricardom | 1 Comments   

Yes, you read it right! The Host Integration Server Team is going to Disneyland! Ok, not the entire team and it's definitely not on vacations! And we are not going to Disneyland exactly...

On the first two weeks of June we head over Orlando to participate on Tech*Ed. You will have the chance to meet individuals from the product team on both weeks: DEV and ITPRO.

Besides the usual booth duty, we will present the following sessions:

DEV Week:

  • Delivering Enterprise Solutions Using Microsoft BizTalk Adapters for Host Systems
  • Publishing and Extending Business Rules in Mainframe (CICS and IMS) and AS/400 Programs Using Microsoft Host Integration Server

ITPRO Week:

  • SOA352 - Enabling Knowledge Workers to Access Mainframe Programs and Data
  • SOA358 - Publishing and Extending Business Rules in Mainframe (CICS and IMS) and AS/400 Programs Using Microsoft Host Integration Server
  • SOA56 TLC - Building Customer Care Solutions Using Microsoft Host Integration Server 2006 and BizTalk Adapters for Host Systems

Please join us for these sessions! It would be great to meet you folks in person!

Cheers,

Ricardo

Technorati Tags: ,
Getting SQLCODE -805 when using DB2OLEDB or MsDb2Client
07 December 07 02:27 PM | ricardom | 1 Comments   
This can be due to two things: a) The connection property "Package Collection" points to a non-existing package collection; or B) the user do not have autority to create the packages on DB2. To work around this, you should use the Data Access Tool to create those packages. In order to do this, you should launch the Connection Wizard, by either creating or altering a existing connection, and then at the last page of the wizard there is an option Create Packages. Please not that in order to do this, the customer needs to have CREATE PACKAGE authority. Packages should be created only once and can be reused, so usually a DB2 will run the Connection Wizard with his credentials in order to create those packages.
 
Some background information:
 
How to Create Packages:
 
 
Package Collection Property:
 

Package collection

The name of the DRDA target collection (AS/400 library) where the Microsoft OLE DB Provider for DB2 should store and bind DB2 packages. This could be same as the Default Schema.

The Microsoft OLE DB Provider for DB2, which is implemented as an IBM DRDA application requester, uses packages to issue dynamic and static SQL statements. Package names are not restricted and can be uppercase, lowercase, or mixed case.

The OLE DB provider creates packages dynamically in the location to which the user points using the Package Collection property. By default, the OLE DB provider will automatically create one package in the target collection, if one does not exist, at the time the user issues their first SQL statement. The package is created with GRANT EXECUTE authority to a single <AUTH_ID> only, where AUTH_ID is based on the User ID value configured in the data source. The package is created for use by SQL statements issued under the same isolation level specified when calling the OLE DB ITransactionLocal::StartTransaction or ITransactionJoin::JoinTransaction methods, as well as when setting the ADO IsolationLevel property on the Connection object.

A problem can arise in multi-user environments. For example, if a user specifies a Package Collection value that represents a DB2 collection used by multiple users, but this user does not have authority to GRANT execute rights to the packages to other users (the PUBLIC group on the DB2 system, for example), the package is created for use only by this user. This means that other users may be unable to access the required package. The solution is for an administrative user with package administrative rights to create a set of packages for use by all users. (For more information, see Creating Packages for Use with the OLE DB Provider for DB2).

The OLE DB Provider for DB2 ships with a tool program for use by administrators to create packages. The Data Access Tool is used to create packages. This tool can be run using a privileged User ID to create packages in collections accessed by multiple users. This tool creates a set of packages and grants EXECUTE privilege on these packages to the PUBLIC group representing all users on the DB2 system. The packages (for more information, see descriptions under the isoLevel parameter of the OLE DB ITransactionLocal::StartTransaction or ITransactionJoin::JoinTransaction methods, as well as the ADO IsolationLevel property) created are as follows:

AUTOCOMMITTED package (MSNC001 is only applicable on DB2/400)

READ UNCOMMITTED package (MSUR001)

READ COMMITTED package, (MSCS001)

REPEATABLE READ package, (MSRS001)

SERIALIZABLE package (MSRR001)

Note that the AUTOCOMMITTED package (MSNC001) is only created on DB2 for OS/400.

Once created, the packages are listed in the DB2 (mainframe) SYSIBM.SYSPACKAGE, the DB2 for OS/400 QSYS2.SYSPACKAGE, and the DB2 Universal Database (UDB) SYSIBM.SYSPACKAGE catalog tables.

Note that when upgrading from SNA Server 4.0, any existing SNA 4.0 packages must be re-created using the Host Integration Server CrtPkg tool to make them compatible with Host Integration Server 2006. The package names changed from SNA Server 4.0.

This property is equivalent to the DBPROP_DB2OLEDB_PACKAGECOL OLE DB property ID.

 
DB2 SQLCODE -805
 
BizTalk Adapter for DB2 and the SQLCAMESSAGE DB2 Procedure
01 November 07 04:44 PM | ricardom | 0 Comments   

QUESTION:

When there is a failure calling a Stored Procedure using the BizTalk Adapter for DB2, you may see that some other SP´s are also called. You can also see that there is no relationship between this extra calls and the one that fails.
A trace can look similar to this:

 Preparing Stored Procedure in SP section: SYSIBM.SQLPROCEDURECOLS, 337, 553, 2, DRDAProcedureColumns, sqlcallcontrol.cpp,

 Executing Stored Procedure: SYSIBM.SQLPROCEDURECOLS, 337, 553, 9, DRDAProcedureColumns, sqlcallcontrol.cpp,

 DRDA AR message: Name: SQLCA Message, SQLSTATE: 42724, SQLCODE: -444, Error Procedure: DSNX9CAC, Database: DBT1LOC, Errors: {0, 0, 0, -1, 0, 0}, Diagnostic Information: DSNAPCO8?, 337, 553, 4, DRDAProcedureColumns, messagesync.h,

 Preparing Stored Procedure in SP section: SYSIBM.SQLCAMESSAGE, 337, 553, 2, DRDAGetDiagRec, sqlcallcontrol.cpp,

 Executing Stored Procedure: SYSIBM.SQLCAMESSAGE, 337, 553, 9, DRDAGetDiagRec, sqlcallcontrol.cpp,

 DRDA AR message: Name: ENDUOWRM, Severity: Warning, Database: DBT1LOC, 337, 553, 4, DRDAGetDiagRec, messagesync.h,

 Preparing SQL Select Statement: SELECT ''  AS PROCEDURE_CAT, RTRIM(OWNER)  AS PROCEDURE_SCHEM, RTRIM(NAME)  AS PROCEDURE_NAME, RTRIM(PARMNAME)  AS COLUMN_NAME, ORDINAL AS ORDINAL_POSITION, RTRIM(ROWTYPE)  AS COLUMN_TYPE, RTRIM(TYPENAME)  AS TYPE_NAME, LENGTH AS COLUMN_SIZE, LENGTH AS, 337, 553, 4, DRDAExecDirectW, sqlselectcontrol.cpp,

 Executing SQL Select Statement: SELECT ''  AS PROCEDURE_CAT, RTRIM(OWNER)  AS PROCEDURE_SCHEM, RTRIM(NAME)  AS PROCEDURE_NAME, RTRIM(PARMNAME)  AS COLUMN_NAME, ORDINAL AS ORDINAL_POSITION, RTRIM(ROWTYPE)  AS COLUMN_TYPE, RTRIM(TYPENAME)  AS TYPE_NAME, LENGTH AS COLUMN_SIZE, LENGTH AS, 337, 553, 8, DRDAExecDirectW, sqlselectcontrol.cpp,

 Closing SQL Select Statement: SELECT ''  AS PROCEDURE_CAT, RTRIM(OWNER)  AS PROCEDURE_SCHEM, RTRIM(NAME)  AS PROCEDURE_NAME, RTRIM(PARMNAME)  AS COLUMN_NAME, ORDINAL AS ORDINAL_POSITION, RTRIM(ROWTYPE)  AS COLUMN_TYPE, RTRIM(TYPENAME)  AS TYPE_NAME, LENGTH AS COLUMN_SIZE, LENGTH AS PREC, 337, 553, 16, DRDAFreeStmt, sqlselectcontrol.cpp,

 Local Transaction Commit, 337, 553, 3, DRDAFreeStmt, transactioncontext.cpp,

ANSWER:
The call to SQLPROCEDURECOLS is executed in order to gather metadata (parameter information) from the stored procedure to be executed. If an error occurs or this system procedure is not available, we fall back to query the metadata using SELECT statements gainst the system catalog (see the three ocurrences of SELECT ''  AS PROCEDURE_CAT…). The SQLCAMESSAGE is a stored procedure that we call when a error occur so we can gather extra information about the error that occurred. With that said, the calls for the procedures SQLPROCEDURECOLS and SQLCAMESSAGE are expected and, in this case, don’t tell much about the error occuring on the original procedure that was going to be called.

DB2 Buffer Pools and the BizTalk Adapter for DB2
01 August 07 03:25 PM | ricardom | 0 Comments   

The most important factors that impacts buffer pool configuration are a) structure of the database and b) structure of the queries running against this database. These two factors will ultimately define what will be the I/O profile of these database operations. Buffer pools will reduce I/O as they will cache data avoiding load on the I/O devices.

 

With that said, it’s really difficult to provide a ‘magic number’ for this configuration parameter. DBA’s will likely tune the buffer pool based on the actual load of the database in a test environment. This tuning operation can be executed with the help of DB2’s online commands, more specifically the DISPLAY BUFFERPOOL and ALTER BUFFERPOOL commands. A brief descriptions on how to use these commands to tune the buffer pools is available at: http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db2.doc.admin/dmtbp.htm#dmtbp

 

A load on the database can be created by activating the BizTalk Adapter for DB2 in a test environment and then further analysis of I/O activities profile can indicate the need to change the default buffer pool configuration.

Tracing a DB2 Connection using HIS 2006 Trace Tool
07 December 06 01:53 PM | ricardom | 0 Comments   

Below you find the steps needed to collect trace data from a DB2 connection using the data providers shipped with HIS 2006: 

  • Navigate to the Start menu, select Run, type snatrace and hit Enter;
  • On the SNA Trace Utility window, click Clear All Traces and Purge All Trace Files;
  • In the List of Trace Items select DB2 Network Library and click the Properties button;
  • Click the Set All button in the Internal Trace, Message Trace and API Trace dialog boxes;
  • Click OK, OK and YES;
  • Execute the execute the operations that causes the error;
  • Navigate to the Start menu, select Run, type snatrace and hit Enter;
  • Click Clear All Traces;
  • Click OK;
  • In the trace folder (usually <install dir>\traces) you will find the DB trace files.

Interpreting traces will be the topic of a future post.

Search

This Blog

Syndication

Page view tracker