Cobol Products
  
Home
Download
Buy
About
Contact Us
 

Cobol Tools Index
Data Viewer Index
Introduction
Features and Trial
Buy DataViewer
DataViewer Manual
Data Conversion Service
Contact Us

 
Read Cobol Data Files into C++/VB via COM API

DataAccess COM library can used by any COM-compliant program to read Cobol data files. Simple API allows you to quickly develop applications that read Cobol data directly,

Features

  • Directness and Simplicity. You interface to Cobol data files directly, without extra layers of ODBC and OLE DB. This simplifies programming a lot.

  • Speed. Since we access data files directly (no ODBC / OLE DB in between), the library is really fast.

  • Versatility. Our data model accurately reflects what is available in Cobol data file -- not more, not less. So your program can read Cobol data files using all "native" Cobol abilities with "native" speed. For inastance, fast reading by any index or combination of indices is provided.

Download Evaluation

The examples used in User Manual are in VB, so start with downloading and installing DataViewer Trial Package that contains API samples. Please note that you can use DataAccessCOM in any COM-enabled language (C++, Delphi, Access, not just VB).

You will return here after the download.

DataAccessCOM Manual

Download it from DataAccessManual.doc.

DataAccessCOM Introduction

Below we provide an introduction to DataAccessCOM API. Formal description of DataAccessCOM API is contained in comaccess.idl file.

DataFile.
To start using API, create DataFile object:

Dim reader As DataFile Set reader = New DataFile

Open file using Open function. You must open an *.FDD file that contains record layout and a link to the actual data file. Do not open the data file itself. If file cannot be opened, error is returned, you can check specific error code in Err.Number.

reader.Open ("filename.fdd")

Use function ReadNext() to read next record into DataRecord object contained in DataFile. You will access record fields through DataRecord object.

reader.ReadNext() Dim record As DataRecord Set record = reader.Record

Summary of all file operations:

reader.Open( BSTR file_name) ' open specified file reader.Close() ' close opened file reader.GotoTop() ' go to first record of the file reader.GotoBottom() ' go to last record of the file reader.ReadNext() ' read next record into reader.Record reader.ReadPrev() ' read previous record: REL only reader.ReadByRecNumber( ' read record by record number: REL only long rec_number) reader.RecCount() ' number of records in the file: REL only reader.ReadByIndex( ' read record by specified index: INDEX only long index_number, bool from_beg) reader.IndicesNo() ' number of indices in the file: INDEX only reader.IndexInUse( ' index used for sequential reads: INDEX only long index_number)

DataRecord.
To browse fields of the data record, use FieldsNo and Item methods:

Dim record As DataRecord Set record = reader.Record Dim i As Integer For i = 0 To record.FieldsNo - 1 Dim field As DataField Set field = record.Item(i) Next

Summary of all record methods:

print record.FieldsNo() ' number of fields in the record print record.Item(int index) ' get field by its index print record.Item(BSTR name) ' get field by its name print record.Blob() ' raw array of bytes for the record print record.ByteMinLength() ' minimum record length print record.ByteMaxLength() ' maximum record length

DataField.
DataRecord is a collection of DataFields. Each DataField represents a single record field. Once you get down to the field, you can extract all its properties including name and value.

Dim field As DataField Set field = record.Item(i) Set field = record.Item("field-name") print field.Name() ' field name, as specified in RDD file print field.Value() ' field value: VARIANT, can be: Integer, Float, Date print field.Blob() ' raw array of bytes for the field print field.ByteOffset() ' offset of field in the raw record print field.ByteLength() ' length of field in the raw record print field.Length() ' length of field when printed out print field.Decimals() ' position of the decimal point print field.Type() ' Modern type of the field: Int, Fixed, String, Float, Date-Time print field.Picture() ' PICTURE of the field print field.Usage() ' USAGE of the field: DISPLAY, COMP-1, ..., COMP-X print field.Sign() ' SIGN of the field: LEAD, LEAD SEP, TRAIL, TRAIL SEP print field.Alphabet() ' ALPHABET of the field: ASCII, EBCDIC, Japanese Property field.Blob() returns array of bytes that are actually stored in the field. This is raw uninterpreted field.

Licensing DataAccessCOM

If you plan to use DataAcessCOM internally on Four (4) computers or less, then you need DataAccessCOM Non-Redistributable License that is included into Data-Viewer package.

If you want to distribute application that use DataAccessCOM then you need DataAccessCOM Redistributable license. Please contact us for details.

Evaluation Package: More Languages

The example presented in different languages does the following:
* Print the list of fields,
* Print first 10 records of the data file specified by user,
* Prints the list of indices in the data file,
* Reads records by indices.

Visual Basic.
* Start the project from "Start. Programs. Siber DataViewer. COM API Samples in VB".
* Add DataAccessCOM to References:
-- Open Project. References,
-- Check Siber Systems DataAccess Type Library.

C++.
* Start the project from "Start. Programs. Siber DataViewer. COM API Samples in C++".
* Since dataaccesscom.dll was registered at install time, there is no need to register it again.
* Just compile and run the example.

Delphi.
* Start Delphi.
* Install package DataAccess.dpk.
* Open project "Project1.dpr".

Siber Systems
Copyright © 1997-2010 by Siber Systems Inc.