npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adabas-tcp

v1.0.17

Published

High level Adabas access package using a TCP connection

Downloads

12

Readme

Adabas TCP

Access to an Adabas Database from Node.js using the Adabas TCP connection.

It offers the classical CRUD access methods for Adabas:

  • C reate - inserts an new Adabas record
  • R ead - read Adabas records
  • U pdate - update an Adabas record
  • D elete - delete an Adabas record

Installation

npm install adabas-tcp

Introduction

This simple example shows how to read all records of file 11 and writes the result to the console:

const Adabas = require('adabas-tcp').Adabas;

const adabas = new Adabas('localhost', 60001);
adabas.read({ fnr: 11 }).then( result => {
    console.log(result);
    adabas.close().then(  () => adabas.disconnect() );
});

What it does is to read the File Description Table of the file and add all available fields to the format buffer. The result is an array of Javascript objects:

[
  { ISN: 1,
    AA: '50005800',
    AB: { AC: 'SIMONE', AE: 'ADAM', AD: '' },
    AF: 'M',
    AG: 'F',
    AH: 712981,
    A1: { AI: [ '26 AVENUE RHIN ET DA' ], AJ: 'JOIGNY', AK: '89300', AL: 'F' },
    A2: { AN: '1033', AM: '44864858' },
    AO: 'VENT59',
    AP: 'CHEF DE SERVICE',
    AQ: [ { AR: 'EUR', AS: 963, AT: [ 138] } ],
    A3: { AU: 19, AV: 5 },
    AW: [ { AX: 19990801, AY: 19990831 } ],
    AZ: [ 'FRE', 'ENG' ]
  },
  { ISN: 2,
...

General

To hide the complexity of an Adabas call with all the buffers, short names and options from the user, this implementation offers a high level API which generates all buffers from the provided metadata.

Data Representation

The Adabas data is represented as a Javascript object. This means the read method returns a Javascript object and the insert and update methods access a Javascript object as input. Here is an example for the Javascript object for an Employees record:

const record = {
    'Personnel Id': '50001234',
    'First Name'  : 'John',
    'Name'        : 'Doe',
    'Middle Name' : 'M.',
    'City'        : 'Seattle',
    'Country'     : 'USA'
};

The type of object attributes must match the Adabas types. This means a numeric type in Adabas must be a Javascript type of number. These types are validated during the processing and an error is thrown if there are incompatibilites.

Multiple Fields

Multiple fields are represented as arrays.

Groups

A group is a Javascript object.

Periodic Groups

A periodic group is an array of Javascript objects.

Data Representation Example

Below is an example of an object:

{
    ISN: 207,
    'Personnel Id': '11100107',
    'Full Name': { 'First Name': 'HELGA', Name: 'SCHMIDT' },
    Name: 'SCHMIDT',
    Language: [ 'GER', 'FRE' ],
    Income:
        [
            { 'Currency Code': 'EUR', Salary: 18461, Bonus: [ 1025, 75] },
            { 'Currency Code': 'EUR', Salary: 16410, Bonus: [] }
        ]
}

Classes

AdabasMap

The AdabasMap class contains the metadata for the Adabas call.

AdabasMap Constructor

The constructor has the file number as parameter.

Fields

For each field that is accessed the following information must be provided:

  • type (regular field, multiple field, periodic group)
  • format
  • length
  • short name
  • options

With the options, the long name, precision, max occurrence, etc. can be provided.

Each Adabas field is defined like this:

alpha(8, 'AA', { name: 'Personnel Id' })

Meaning that the Adabas field is of type 'alpha', has a length of 8 and the short name is 'AA'. In the returned object the attribute is named 'Personnel Id'.

To add the fields to the map a function must be used. The following functions are implemented:

  • alpha (A)
  • binary (B)
  • fixed (F)
  • float (G)
  • packed (P)
  • unpacked (U)
  • wide (W)

Multiple fields must set the 'occ' attribute in the options:

alpha(3, 'AZ', { name: 'Language', occ: 5 }) // multiple field

For groups another function must be used where instead of the length a map for the group is provided:

group(FullName, 'AB', { name: 'FullName' }) // group

Periodic groups are similar to groups. The difference is that the 'occ' attribute is set in the options:

group(Income, 'AQ', { name: 'Income', occ: 6 }) // periodic group

Import

Typescript
import { Adabas, AdabasMap } from 'adabas-tcp';
Javascript
const Adabas = require('adabas-tcp').Adabas;
const AdabasMap = require('adabas-tcp').AdabasMap;

Fields Example

Here is an example for an Employees file (file number 11):

// define elements of the periodic group
const Income = new AdabasMap()
    .alpha(3, 'AR', { name: 'Currency Code' })
    .packed(5, 'AS', { name: 'Salary' })
    .packed(5, 'AT', { name: 'Bonus', occ: 5 }) // multiple field within periodic group
    ;

// define a group
const FullName = new AdabasMap()
    .alpha(20, 'AC', { name: 'First Name' })
    .alpha(20, 'AE', { name: 'Name' })
    ;

// define the adabas record
const Map = new AdabasMap(11)
    .alpha(8, 'AA', { name: 'Personnel Id' })
    .group(FullName, 'AB', { name: 'FullName' }) // group
    .alpha(20, 'AE', { name: 'Name' })
    .alpha(3, 'AZ', { name: 'Language', occ: 5 }) // multiple field
    .group(Income, 'AQ', { name: 'Income', occ: 6 }) // periodic group
    ;

Adabas

The Adabas class does the Adabas calls.

Adabas Constructor

The Adabas class has the database number as a required parameter. Options for multifetch or logging can be added:

const adabas = new Adabas('localhost', 49152, { multifetch: 20 } );

Methods

The create, read, update and delete methods need the map or a file number as parameter. If the file number is provided the File Description Table of the file is read and a map containing all fields is created from these definitions.

Each command has some parameters provided as an object to control the command. At least a map or file number must be provided. See examples below.

The following parameters are supported:

export interface CallData {
    map?: AdabasMap,
    fnr?: number,
    isn?: number,
    object?: any,
    criteria?: string,
    fields?: string[]
}

Here are examples for these methods.

create(CallData)

Parameter:

  • map/fnr: map or file number
  • object: that is stored

Store object 'create' using the map 'empl':

adabas.create( { map: empl, object: create } );
read(CallData)

Parameter:

  • map/fnr: map or file number
  • criteria: return only objects that meet the criteria
  • isn: read a single ISN
  • fields[]: limit the returned fields

Read all data from file 11:

adabas.read( { fnr: 11 } );

Read ISN 207 using the map 'empl':

adabas.read( { map: empl, isn: 207 } );
update(CallData)

Parameter:

  • map/fnr: map or file number
  • criteria: return only objects that meet the criteria
  • object: that is stored

Update the corresponding record where 'Personnel Id' equals 'Test1234' with object 'update':

adabas.update( { map: empl, criteria: 'Personnel Id=Test1234', object: update } );
delete(CallData)

Parameter:

  • map/fnr: map or file number
  • criteria: return only objects that meet the criteria

Delete record where 'Personnel Id' equals 'Test1234':

adabas.delete( {map: empl, criteria: 'Personnel Id=Test1234' } );
endTransaction()

Performs an end of transaction. The data is committed to the database.

backoutTransaction()

Performs a backout of this transaction.

close()

Performs a close of the database.

Known Problems

  • Alpha fields with length 0 and LOB fields are currently not supported.

Dislaimer

Utilities and samples shown here are not official parts of the Software AG products. These utilities and samples are not eligible for technical assistance through Software AG Global Support. Software AG makes no guarantees pertaining to the functionality, scalability , robustness, or degree of testing of these utilities and samples. Customers are strongly advised to consider these utilities and samples as "working examples" from which they should build and test their own solutions.