IBM Support

Data Transfer Automation Objects

Troubleshooting


Problem

This document explains the use of Automation Objects with data transfer functions.

Resolving The Problem

Overview

IBM i Access Client Solutions provides Automation Objects that allow access to the data transfer functionality. The objects provide both a high-level and a low-level interface. The high-level interface provides basic methods for data transfer, with a limited amount of customization. The high-level interface is the simplest to use. The low-level interface allows greater customization of the data transfer request.

High-Level Interface

The purpose of the automation objects is to allow data transfer to be controlled with any language or application that supports Microsoft ActiveX automation.

Several advantages of using the automation objects include the following:
1. Better error handling

DOS batch files that are used to run requests do not provide the error handling capability of the automation object.
2. Can be used with system services

User ID and password information can be set programmatically. This is useful for environments where prompting for security information is not possible.
3. Asynchronous processing

Data transfer requests can be issued asynchronously.

High-Level Data Transfer Automation Objects:
o DatabaseTransfer

- Primary object for high-level interface.
- Provides methods for uploading, downloading, and running previously saved requests.
o Errors

Collection contained in the transfer object that provides error information (severity and text of error).
o DatabaseTransferResults

- Accessed as a property of the DatabaseTransfer object.
- Provides detailed summary of the results of last transfer request.
o DatabaseDataErrors

- Collection contained by the results object that describes where data errors occurred.
- Points to the location (row, column) of the error and the type of error (truncation, rounding, translation, missing data).

The DatabaseTransfer object provides the following methods to transfer data To and From the server.
o Download

- Basic method for downloading a file.
- Required parameters are system name, file to download, and PC file.
- PC file type can be specified as an optional parameter.
o Upload

- Basic method for uploading a file.
- Required parameters are system name, destination file, PC file, and a file description file.
o Transfer

- Method provided to run a previously saved request.
- Only parameter is the file name of the transfer request (download or upload).

Notes:
1. The prototype for the download function is:

DatabaseTransfer.Download(String system, String hostFile, string pcFile, cwbdtFileTypeEnum fileType)
2. Minimal code in Visual Basic to download a file:

- Dim dt As New cwbx.DatabaseTransfer
- dt.Download "MYSYSTEM", "QIWS/QCUSTCDT", "C:\MyFile.txt"
3. Prototype for the Upload function:

DatabaseTransfer.Upload(String system, String hostFile, String pcFile, String fileDescriptionFile)
4. Prototype for the Transfer function:

DatabaseTransfer.Transfer(String requestFile)
5. After any of these methods are called, the DatabaseTransferResults object can be used to retrieve statistics for the transfer including:

- CompletionTime - Time and date that the transfer completed
- RowsTransferred - Total number of rows transferred in previous request
- DataErrors - Error type and location
6. Each error in the collection contains three properties:

- Row - Row in which the data error was found.
- Column - Column in which the data error was found.
- ErrorType - Type of data error that was encountered.
7. In addition to these properties, the DatabaseTransferResults also provides Boolean properties to indicate whether errors or a warning has occurred.

- DataErrorsOccurred
- DataWarningsOccurred
8. Applications should check to see if errors have occurred based on these properties. If yes, the errors collection can be queried for details.

Low-Level Interface

The low-level interface should be used when the default options of high-level interface are not sufficient. The lower level automation objects provide access to nearly all the functionality of the Access Client Solutions Data Transfer application including asynchronous transfers. Applications can monitor for events fired by asynchronous transfers and respond appropriately.

The low-level interface provides an upload and a download transfer object.

Notes:
1. The low-level interface allows the user to change nearly all of the parameters of the data transfer request. Items such as file type, file options, data format, and so on, can all be manipulated using the objects provided.
2. Access Client Solutions Data Transfer Functions that are not provided:

- Ability to browse libraries to search for files.
- Query builder interface, which helps the data transfer user select the desired data.
- Data Transfer Upload Wizard, which scans a PC file and creates a file on the host to upload to.
3. For detailed information about the low-level interface, the Express toolkit documentation should be reviewed.

DatabaseDownLoadRequest Object

This is a flow chart of the download request object.


DatabaseDownload Objects
o DatabaseAS400File:

Contains information about which file should be selected.
o DatabaseFormatOptions:

Specifies how data should be formatted during the transfer. It includes information on date, time, and decimal separators.
o DatabaseDownloadPCFile:

Determines the name of the file to be created on the PC, as well as the type and format options. Also includes an options object that is specific to the type of file being downloaded.
o DatabaseQuerySettings:

Provides the ability to set selection criteria (Select, Where, Join, Group, and so on) for the download request and is only used if the request is processed as a data transfer (not Native SQL).
o AS400System:

Determines which server to which the request will be sent.
o DatabaseTransferResults:

Summarizes the statistics of the last download processed, and provides information about data errors.
o DatabaseUserLibaryList:

Specifies which libraries are to be searched if the database file name is unqualified.
o Errors:

Collection of error objects that contain Client Access return codes and messages.

Notes:

The DatabaseDownloadRequest object is the primary object that must be created. The other objects will be created with default values, which can be changed.

The minimum code in Visual Basic to download using the low-level interface follows:

Dim dlr as cwbx.DatabaseDownloadRequest
Set dlr.System = new cwbx.AS400System
dlr.System.Define "MYAS400"
dlr.AS400File.Name = "MYLIB/MYFILE"
dlr pcFile.Name = "C:\MyFile.txt"
dlr.Download


DatabaseUploadRequest Object

This is a flow chart of the upload request object.

DatabaseUpload Objects
o DatabaseAS400File

This contains information about the destination file, including creation information and the file name.
o DatabaseUploadPCFile

Contains information about the file to be uploaded, including name and file description file information. Includes an object that contains file-type specific options.
o AS400System

Used to specify which server to which the request will be sent.
o DatabaseTransferResults

Object containing results of the last data transfer, including rows transferred and any errors that might have occurred.
o DatabaseUserLibraryList

Contains a list of libraries to be searched when running a request with an unqualified table name.
o Errors

Collection of errors that occur during request processing.

Capabilities and Limitations
o What the automation objects can do:

- Download to a PC file.
- Download to html.
- Run previously saved transfer requests.
- Save data transfer requests for future use.
o What the automation objects cannot do:

- Download to the display.
- Download to a printer.
- No support for query builder GUI.
- Browse libraries for files.

Resources

More information about the automation objects can be found in the Programmers Toolkit provided with Access Client Solutiosn. The Toolkit contains Visual Basic code samples for every property and method for each object.

From the toolkit screen, choose the following:
1. Database
2. ActiveX
3. Select the link Data Transfer Automation Objects
For information on using the Data Transfer Automation Objects with Windows Scripting Host, see Rochester Support Technote document N1017618, Alternatives to Batch Data Transfer: Data Transfer Automation Objects; Import files with FTP/QNTC; ActiveX Data Objects. To link to N1017618 immediately, click here.

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHZAA2","label":"Data Access"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

23593814

Document Information

More support for:
IBM i

Component:
Data Access

Software version:
All Versions

Operating system(s):
IBM i

Document number:
644421

Modified date:
09 April 2025

UID

nas8N1019459

Manage My Notification Subscriptions