Portus Version 2012-12-17
 —  Reference  —

Language Structure Support

Portus currently supports the calling of C functions, COBOL subroutines and Natural subprograms. In the future, it will also support PL1 and potentially assembler in a similar way. All of these languages have the following concepts

This section of the documentation will describe how such constructs are treated by Portus.


The Portus Representation of Data

Portus externally knows everything as a single node within an XML document. XML documents can contain structures of XML nodes, arrays of XML nodes or arrays of structures so it can represent any data structure that is required. Different languages and databases have different ways of representing data and it is necessary within Portus to enable the mapping of these external fields into the type of structures that are required internally by the various drivers supported by Portus. In particular, if the Portus representation of the data is modified in a way that is incompatible with how an application program expects to be called, at best, incorrect results will be returned but more than likely the stability of Portus itself will be impacted due to program abends.

Top of page

‘Tuple’ Based Databases

A ‘tuple’ based database is simply a database technology for which the data is presented in name/value pairs or ‘tuples’. ADABAS is a tuple based database as when requests are being provided to ADABAS, or data is being returned by ADABAS, it is returned as a field name/Value pair which can easily be translated from and to the external XML structures.

Relational databases such as DB2 also work on the principle of a tuple. The data is provided using column names along with the data associated with the column. Again, this is easily mapped to the external XML field structure and does not need further explanation.

Top of page

Record Based Databases

Databases such as VSAM and IMS/DB present their data in the form of records. A record is simply a single contiguous piece of storage that contains the data related to the request. While it is held contiguously internally in the database, it will almost always be made up of multiple individual fields. The individual fields within the record are then addressed by offset, length and type. While they could be addressed in this most simple way, most if not all organizations will have a language definition of the individual fields in the form of a structure. When referencing fields in the structure, the language implementation can then calculate the offset and length of each field referenced and then process it base on its type. Portus uses these language definitions to create definitions for record based databases.

Top of page

Calling Application Programs

When calling an application program, generally there will be one or more parameters to the program. Note that while the application may treat these as input or output parameters, the application must receive all of the parameters during the call.

To be clear on this point, Portus has the concept of input parameters, output parameters, input-output parameters and parameters which are neither input nor output in its input and output messages for a service. This relates purely to the input/output messages that Portus will build for the service definition. The parameters _Must_ be passed in their entirety to the application being called regardless of their direction definition to Portus.

Depending on the programming language, parameters can be provided as:

  1. A list of individual fields (the most common way for C)

  2. A single structure containing all of the input/output information (mostly used in CICS)

  3. A list of fields or structures (used by COBOL and Natural most commonly)

Essentially it can be stated that an application program will be called with one or more parameters and each parameter may be a single field, a structure or an array. Within a structure we could have other structures or arrays while it is also possible to have arrays of structures.

While all this sounds quite complicated and involved, when it’s broken down it is not as complicated as it may seem. Portus has the concept of a level 1 field name which may itself be a field or the name of a structure. There may be multiple levels below this level 1 field but the number level 1 fields will dictate how many parameters are passed to the applications.

Top of page

Representing Individual Fields

The following are equivalent parameter definitions in various languages:

NATURAL

PARAMETER
 1 OPERATION (A3)
 1 OPERAND_1 (I4)
 1 OPERAND_2 (I4)
 1 RESULT    (I4) BY VALUE RESULT
END-DEFINE

COBOL

linkage section.
01      Operation    PIC X(3).
01      Operand1     PIC S9(9) COMP-4.
01      Operand2     PIC S9(9) COMP-4.
01      Result       PIC S9(9) COMP-4.
procedure division USING Operation Operand1 Operand2 Result.

C

int calc( char operation[3], int *operand1, int *operand2, int *result )

Each of the above represents in their respective languages:

The screenshot below illustrates the Portus representation created based on the Natural PDA area, however, this could also be used for any of the other languages:

graphics/lstruct001.png

Some points to note about this.

The principle of not deleting anything in the Portus representations of this data is critical for the consistent and stable running of the SOA Gateway. This is because Portus representation must reflect what an application program expects to receive as parameters. Any removal or changing of the order here will cause problems because it will result in a different representation being provided to the application program.

Top of page

Representing Structures

In most cases, far more data must be passed to or returned from an application than will fit in a single field. For this reason, structures are generally used to pass data backwards and forwards between applications.

The following show how individual fields along with a simple structure are represented in various languages:

NATURAL

PARAMETER
 1 INITIAL (P7)
 1 I_RATE  (P2.2)
 1 YEARS   (I2)
 1 RESULT  
   2 YEAR     (I2)  BY VALUE RESULT
   2 SIMPLE   (A17) BY VALUE RESULT
   2 COMPOUND (A17) BY VALUE RESULT
END-DEFINE

COBOL

       LINKAGE SECTION.
       01  INITIAL-AMOUNT          PIC S9(7)  COMP-3.
       01  I-RATE                  PIC S99V99 COMP-3.
       01  YEARS                   PIC S9(4) COMP.
       01  RESULT.
           02  RESULT-TABLE.
               03  YEAR                PIC S9(5) COMP .
               03  SIMPLE              PIC ZZ,ZZZ,ZZZ,ZZ9.99 DISPLAY .
               03  COMPOUND            PIC ZZ,ZZZ,ZZZ,ZZ9.99 DISPLAY .
      *
       PROCEDURE DIVISION USING INITIAL-AMOUNT I-RATE YEARS RESULT .

C

typedef struct {                
  short year;          
  char simple[17];          
  char compound[17];          
  } result_h ;                    

int interest ( int *INITIAL, int *I_RATE, int *YEARS, struct result_h *result )

The equivalent representation of this parameter list in Portus is as follows:

graphics/lstruct002.png

It will be noted that the INITIAL, I_RATE, YEARS and RESULT fields are at level 1 while the elements of the RESULT structure YEAR, SIMPLE and COMPOUND are at level 2. This will result in 4 parameters being passed to the application code with the 4th parameter being a structure. The following should be noted:

Top of page

Representing Arrays

Arrays are a very common way of providing a lot of the same information or returning lists from application programs. The following example builds on the previous example to return an array of 50 structures. To return simply an array of values, the ‘structure’ would simply contain one element.

NATURAL

PARAMETER
 1 INITIAL (P7)
 1 I_RATE  (P2.2)
 1 YEARS   (I2)
 1 RESULT  (1:50)
   2 YEAR     (I2)  BY VALUE RESULT
   2 SIMPLE   (A17) BY VALUE RESULT
   2 COMPOUND (A17) BY VALUE RESULT
END-DEFINE

COBOL

       LINKAGE SECTION.
       01  INITIAL-AMOUNT          PIC S9(7)  COMP-3.
       01  I-RATE                  PIC S99V99 COMP-3.
       01  YEARS                   PIC S9(4) COMP.
       01  RESULT.
           02  RESULT-TABLE          OCCURS 50.
               03  YEAR                PIC S9(5) COMP .
               03  SIMPLE              PIC ZZ,ZZZ,ZZZ,ZZ9.99 DISPLAY .
               03  COMPOUND            PIC ZZ,ZZZ,ZZZ,ZZ9.99 DISPLAY .
      *
       PROCEDURE DIVISION USING INITIAL-AMOUNT I-RATE YEARS RESULT .

C

typedef struct {                
  short year;          
  char simple[17];          
  char compound[17];          
  } result_h ;                    

int interest ( int *INITIAL, int *I_RATE, int *YEARS, struct result_h *result[50] )

The above is represented in Portus in the following way:

graphics/lstruct003.png

Again, the application program is expecting a 4th parameter with 50 instances of the following array above. Removing a field from the structure or changing the number of array occurrences without changing the application will result in invalid results and potentially will destabilise the system. Once again if the field should not appear in the input or output messages for the service, simply set the field’s direction to ‘none’ and leave the structure intact.

Top of page

Representing Redefines

Redefines ultimately involve the mapping of a base field to one or more different layouts. The base field in this case is the original field upon which the redefine(s) are based. Redefines are used for a number of reasons:

NATURAL

PARAMETER
 1 BASE-FIELD (B200)
 1 REDEFINE BASE-FIELD
 2 FIELD1 (A20)
 2 FIELD2 (B4)
 2 FIELD3 (I4)
 2 FIELD4 (B50)
END-DEFINE

COBOL

LINKAGE SECTION.
01  BASE-FIELD PIC X(200).
01  FILLER  REDEFINES BASE-FIELD.
    02 FIELD1 PIC X(20).
    02 FIELD2 PIC 9(4) BINARY.
    02 FIELD3 PIC 9(8) COMPUTATIONAL.
    02 FIELD4 PIC 9(50) BINARY.

C

union {

   unsigned char base_field[200];

   struct  { 
      char          field1[20];  
      unsigned char field2[4];
      int           field3;
      unsigned char field4[50];
   } redef_base;

} base;

This is represented in Portus as follows:

graphics/lstruct004.png

Some notes about this:

Top of page

Summary

When dealing with Portus views/XRDs created based on application program parameter lists or structures, follow these simple rules:

Top of page