Monday, May 9, 2016

MISMO Myth Busted: We Can Use MISMO With COBOL Systems

Disclaimer: I first learned COBOL when it was designed in 1959, by CODASYL. My father brought two stacks of books home when the company he worked for switched from a UNIVAC II to an IBM 305 (RAMAC) mainframe, one stack on COBOL and one on FORTRAN.  I was in seventh grade and had decided to become a physicist. COBOL was as ugly to me then as it is now. I learned a lot of FORTRAN. But never really did any major work in COBOL.

COBOL standard was modified in 1961, 1965, 1968, 1974, 1985 and last changed in 2002 when it gained object oriented capability. In 2007 IBM added proprietary changes to their product that allows interaction with XML.


Organizations that use IBM mainframes have access to these improvements. The improvments are part of the z/OS 1.12 operating system. A COBOL environment that is Enterprise COBOL for z/OS version 4.2.  will have these capabilities. These tools can be used to provide a “Web Servce” connection to aCICS back-end application programs.

IBM has a PDF on the design and use of IBM CICS Web Services.[1]. Tooling exists to connect WebServices to CICS.  This support is for the CICS component to be either client or provider of the service.

Figure CICS as Web Service Provider

IBM provides the tooling to create the file system objects needed to configure and deploy a CICS component to act as a Web Service provider. The XML data in the Web Service call is translated into the internal binary data representation used within CICS. The structured data of the XML is cast as a COBOL Data Division.
Figure 2 CICS as Web Service Client

The tooling also supports making XML from the data in a CICS transaction.
One of the key components of the IBM tooling is the WSDL file. (Web Service Definition Language).  Basically a WSDL file contains the XML schema that defines.  If one wanted to create a CICS transaction that accepts the entire MISMO data model then one would create a WSDL that contained the entire thing.  As a practical matter no one would ever want do to that, but it would be possible.

Let’s suppose that we wanted to use the ULDD subset of the MISMO Reference Model as defined by Fannie Mae and Freddie Mac and use it to board loans into some system named ABC. Now ABC is a completely batched system.  The owner of the system uses CICS to create the batch files that get run over night.  A new CICS Web Service could be created that interfaces with ABC using the same batch structures in place now.

Let’s explore how the CICS tooling handles different issues in the XML Schema of a WSDL.
The MISMO RM frequently uses the structure that allows any number of repeating elements.  The number of repeats is known only at execution time.  Traditional COBOL must know the number of recurring data items at design time. How does the CICS Web Service tooling bridge this gap? 

Actually there are three methods in-line, CICS containers and new COBOL reserved phrases GET CONTAINER, PUT CONTAINER

“In-line” In this scenario, CICS tooling maps the variably recurring data into a simple array together with a num field to indicate the number of instances of the data that are actually present. 

The application program can the access the instance of the data as they would a normal array, with the restriction that the num field must be used appropriately.

MISMO provides a SequenceNumber attribute on each instance of the XML that can be used and the num field.

CICS tooling also uses “in-line” when there is an optional data point in the XML schema.

In-line will work when the trading partner has defined the maximum number of repeats they will produce or consume.  When maxOccurs=’unbounded’ in-line will not work.

The “Container” approach is best used for optional data points. In this method that data structure for one optional XML data point becomes two COBOL fields.
Becomes [2]
WORKING-STORAGE SECTION.
01 W-S-VARIABLES.
03 NAME-PTR USAGE IS POINTER.
03 X-PTR USAGE IS POINTER.
03 IX PIC S9(8) COMP-4 VALUE 1.
03 NAME-COUNT PIC S9(9) COMP-4 VALUE 0.
*
LINKAGE SECTION.
01 X PIC X(659999).
*
01 NAME.
05 productName PIC X(255).
*
EXEC CICS GET CONTAINER(NAME-cont OF WS-STARTI)
SET(NAME-PTR)
FLENGTH(NAME-FLENGTH)
RESP(RESP)
RESP2(RESP2)
END-EXEC.
*
* Get addressability to NAME-cont
SET ADDRESS OF X TO NAME-PTR
SET ADDRESS OF NAME TO ADDRESS OF X
*
* Work through NAME-cont processing the data fields within
* each NAME record
*
PERFORM WITH TEST AFTER
UNTIL NAME-COUNT = NAME-num OF WS-STARTI
**
* Display productName field
DISPLAY 'productname is now: ' productName
*
* Move to the next NAME record
ADD LENGTH OF NAME TO IX
SET NAME-PTR TO ADDRESS OF X(IX:1)
SET ADDRESS OF NAME TO NAME-PTR
ADD 1 TO NAME-COUNT
END-PERFORM.

The last of the three methods is the new reserved phrases added to the IBM implementation of COBOL. Here is the COBOL example

The last of the three methods is the new reserved phrases added to the IBM implementation of COBOL. Here is the COBOL example
WORKING-STORAGE SECTION.
01 NAME-COUNT PIC S9(9) COMP-4 VALUE 0.
*
01 NAME.
05 productName PIC X(255).
*
01 NAME-FLENGTH PIC S9(8) BINARY.
01 WS-BYTE-OFFSET PIC S9(8) BINARY.
*
MOVE LENGTH OF NAME INTO NAME-FLENGTH.
MOVE ZERO TO WS-BYTE-OFFSET.
*
PERFORM WITH TEST AFTER
UNTIL NAME-COUNT = NAME-num OF WS-STARTI

EXEC CICS GET CONTAINER(NAME-cont OF WS-STARTI)
INTO(NAME)
FLENGTH(NAME-FLENGTH)
BYTEOFFSET(WS-BYTE-OFFSET)
RESP(RESP)
RESP2(RESP2)
END-EXEC.
* Display productName field
DISPLAY 'productname is now: ' productName
*
ADD NAME-FLENGTH TO WS-BYTE-OFFSET.
ADD 1 TO NAME-COUNT
END-PERFORM.
This method is shorter and more general


Conclusion: Myth Busted.  A COBOL based organization could interact with other systems via web service support of CICS using all or part of the MISMO reference Model.


[2] COBOL as improved functionality over the years. However, it is still ugly.

No comments:

Post a Comment