| |
JCM News October 2003
Recently we have been concentrating on integrating our RPG to COBOL translator with
Comptramatics' COBOL to Java translator. Other development addressed consolidation of COBOL
data definitions to facilitate data validation and database loads. Finally, we have continued
to develop QA Test Suites for our RPG, COBOL, and Java environments.
Much work is being done these days to deploy selected applications to the internet
in order to provide measures of self service to clients, vendors, and investors. The article
below celebrates the recently approved COBOL standard by highlighting some of its features,
and in particular, Transaction Processing, the technical heart of deployment to the Internet.
If you enjoy this article, it would be great if you share it with others in your organization.
Also, please send us your feedback.
COBOL 2002 Standard and Transaction Processing
© 2003, Jonathan Beit-Aharon
The COBOL 2002 standard is packed with enhancements and new features. The
following are major groups that summarize most of these new features:
- Enhanced Input-Output include file sharing and record locking, non-contiguous keys,
required Report-Writer facility, and character-addressable Terminal (CRT)
interface.
- Internationalization enhancements include support for POSIX Locales, National Character
Sets (such as Unicode), multiple currency symbols and formatting rules, and
other features
- Inter-language Operability enhancements include “new” data types such as native
binaries and floats, affect CALL for Application Programming Interfaces (API), and
Object Orientation (already supported by a number of vendors for Graphical
User Interfaces (GUI) and access to C++ and other Class Libraries).
- Enhanced Intrinsic Functions extend the popular 1989 amendment to COBOL 1985.
- Enhanced Numeric Processing provides extremely large numeric items and “Standard
Arithmetic” facilitate portable high-precision algorithms.
- Enhanced Exception Handling for all of the above, such as new File Status
conditions and refined declaratives for the file system enhancements.
- Other enhancements such as conditional compilation and the data validation
facility that allows data definitions to contain extensive data integrity
rules (making their specification in copy books extremely attractive).
Transaction Processing (TP)
TP is a term describing a variety of environments with the following common attributes:
- Shared Data
- High Volume
- Asynchronous Activity
The major concerns in TP are preservation of data integrity, and high performance.
Preservation of data integrity is achieved by means of resource locks and their management.
Earlier COBOL standards allowed multiple users to open a file for concurrent input,
but only one user could have a file open for Output, Extend, or I-O. While this
guarantees data integrity, it is inefficient for concurrent access that includes both
inquiries and updates, particularly to files with large numbers of records. The file
sharing and record locking defined by the new standard allow transaction processing.
Locks, however, introduce the possibility of deadlocks. A two-user deadlock occurs
when user1 requests and acquires a lock on resource1, then (incrementally) requests a
lock on resource2, and isn’t granted it because resource2 is locked for user2. If at this
stage user2 was to finish processing and release resource2, normal processing would
resume, and user1 would experience only a minor delay. However, if at this point user2
requests a lock on resource1, a deadlock is established. Neither user1 nor user2 can
proceed, and both resources are going to be un-available indefinitely.
In general, a deadlock occurs when a set of two or more users/processes request and
are granted locks on an equal number of resources, and all are then blocked waiting for
another in their set, forming a closed wait-circuit.
A traffic gridlock is a classic example of a deadlock including more than two users,
and presents us with the solution to the problem: someone has to go (roll) back. Our
two requirements result in two questions that need to be addressed prior to rollback:
- How does our system detect a deadlock?
- How do we know where it is (back) we need to go?
There are two strategies for detecting deadlock. The most popular one is a simple
timeout mechanism, in which a request for a resource lock doesn’t block indefinitely,
but only for up to some time limit. A more advanced mechanism requires the lock request
that is about to enter a wait-state to first search the lock database to ascertain that
its wait state will not establish a deadlock.
The way rollback is facilitated is by establishing the beginning and end of each
transaction. At a transaction start the file system (or database) records the current
state of files (or tables), which is considered a valid state, and records activities of
the user/process that might change that state. If rollback is initiated, these activities
can be reversed, and the original valid state can be restored. If the transaction is
completed successfully, the records of the original state and the modifying actions can
be discarded. Releasing incremental locks, possibly interwoven with partial updates,
requires a careful and complex process, and it is the complexity of the rollback operation
that gives true deadlock detection an advantage over simple timeout.
TP applications developed on S/390, DEC VMS, Wang VS, and Unix, have different program
syntax and system capabilities. In other words, you couldn’t choose one environment, and
keep all the features. The new standard merges the best features in the market today, so
you should be able to port (or even merge) applications onto any compliant COBOL platform.
Prominent TP-related syntax components of the new COBOL extenstions to the SELECT
file-control entry, the OPEN statement, and other I-O statements include:
- [ LOCK MODE IS { MANUAL | AUTOMATIC }
[ WITH LOCK ON [ MULTIPLE { RECORD | RECORDS }
- [ SHARING WITH { ALL OTHER | NO OTHER | READ ONLY }
- [ RETRY { numeric TIMES | numeric SECONDS | FOREVER }
- [ WITH [ NO ] LOCK ]
- READ .... [ { ADVANCING ON | IGNORING } LOCK ]
- UNLOCK file-name [ RECORD | RECORDS ]
About J & C Migrations
Founded in 1995, J & C Migrations (www.jcmigrations.com) specializes in conversion
of applications to emulation-free standard COBOL environments.
The advantages of our code conversions include highly portable readable code that runs
on Mainframe, Unix, and MS Windows platforms.
The record definitions we extract and consolidate can be loaded into database schemas,
and the business rules extracted describe data relationships, and can be used for data
integrity validations during database loads.
Our customers include IT system integrators, government agencies, manufacturers,
distributors, and insurance companies.
|