Linking with IBM AS400 Tables
We can convert IBM iSeries (AS400) DB2 Table into dBase Format, download and Link or Import into MS-Access Databases. The downloading procedure must be created and run from AS400 Menus. If it requires several steps before the output file being transferred to local drive then it can be automated with Macro Scripts. The key strokes can be recorded and modified in such a way that the target file goes to a specific location on the Local Machine with a predefined name that remains linked with the Microsoft Access Database.
If you have sufficient Access Privileges to iSeries (AS400) Main Frame Tables you can Link them directly into your MS-Access Database. We are going to look into this method with ODBC based procedure shortly.
Normally, Reports are generated from AS400 and provided to Users as Hard Copies, or converted into Report Spool File in Text Form, if Soft Copy is requested for. We can download this File either in Text form or upload it into Microsoft Excel (may not Parse the data correctly into Number or Date etc.) with iSeries Report Down-Loader Program. AS400 tables also can be downloaded directly into Microsoft Excel and in this process, if the number of lines are more than 65535 (the limitation of Microsoft Excel Worksheet) it will create more than one Worksheet automatically to accommodate all the data into Excel File.
Later on, we will look into a VBA Program to upload the AS400 Report Spool File directly into Microsoft Access Table, after removing Report Headers and other unwanted lines.
But for now, let us go through the steps for Linking IBM iSeries DB2 Tables into MS-Access Database. The example images are created from Windows2000 Workstation.
Creating ODBC System DSN
- Select Start Menu – – > Settings – – > Control Panel – – > Administrative Tools – -> double-Click on Data Sources (ODBC).
The ODBC Data Source Administrator Settings will be displayed. See the Image given below. The Following Steps will walk you through the procedure:
- Select System DSN Tab on the ODBC Data Source Administrator.
- Click Add . . . Button to display a list of Data Source Drivers.
- Select Client Access ODBC Driver (32-bit) from the displayed list in the Create New Data Source Control and Click Finish.
- Type a name in the Data Source name Control. I have inserted the name myData as Data Source Name. We have to look for this name when we attempt to link the Table to MS-Access.
- Click on the Server Tab.
- Type the specific iSeries Folder Name where your data table resides in the Library List Control. If more than one Library is there then separate them with Comas.
- Put a check mark on the Read-Only (Select statements only) option under Connection Type, to ensure that we have no intention to modify the data in iSeries Table.
- Click Apply followed by OK Button. The System Data Source Name myData appears in the System DSN Tab. See the image below.
- Click OK to close the ODBC Configuration Main Control (the Apply button remains disabled in this case).
Linking to MS-Access Database
- Open your MS-Access Database.
- Select File – -> Get External Data – – > Link Table or Import Option.
- Select ODBC Databases in the Files of Type control in the Common Dialog Control and Click Link (or Import) Button as the case may be.
- Select Machine Data Source Tab on the ODBC Control and find the Data Source Name myData that you have created, select it and click OK.
You will be prompted for AS400 User-ID and password. Key-in your User ID, Password and Click OK.
A List will open up showing all the Table Names available in the AS400 iSeries Machine Prefixed with the Library Name following by a period.
- Select the Table(s) to Link and Click OK.
The Fields of the selected Table will be displayed suggesting to highlight one or more fields for indexing, if needed.
- Highlight the Field(s), if you would like to create a Unique Index for the Table, otherwise Click OK without selecting any.
The selected Table will be linked (or Imported as the case may be) into your Database.
If the table remains linked, whenever you attempt to use the table after opening your MS-Access Database for the first time it will prompt for the AS400 iSeries UserID and Password and after that the login is valid for the current Session.
If you don’t want this to happen in the middle of some processing steps it is better to invoke the login immediately after opening the Database. To do this, create a Query or Form or Report using the linked iSeries Table that opens with an Autoexec Macro or the Form in Startup, or even better write a VBA routine to open the linked table which will invoke the login and the User is prompted for keying in her User ID and Password at the beginning of the current session itself. This will take care of the rest of the Session.