Professional Documents
Culture Documents
COBOL to Java
Whitepaper
Contents
CONTENTS ....................................................................................................................................... 2
1. INTRODUCTION ............................................................................................................................ 3
1.1. A FIRST LOOK INTO TRANSLATION ...............................................................................................4
2. OBJECT ORIENTED TRANSLATION ............................................................................................. 6
2.1. ARCHITECTURE OVERVIEW ........................................................................................................6
2.1.1. Online/CICS ..................................................................................................................6
2.1.2. Batch ............................................................................................................................7
2.2. BASIC MAPPING .......................................................................................................................7
2.3. DATA ACCESS LAYER................................................................................................................8
2.3.1. Database Access ..........................................................................................................8
2.3.2. Sequential File Access................................................................................................. 10
2.3.3. VSAM File Access ....................................................................................................... 10
2.4. BUSINESS L OGIC LAYER .......................................................................................................... 11
2.4.1. Data Remodeling......................................................................................................... 11
2.4.2. Code Restructuring...................................................................................................... 13
2.5. PRESENTATION LAYER ............................................................................................................ 14
2.6. FRAMEWORK ......................................................................................................................... 16
3. JCL TRANSLATION ..................................................................................................................... 17
3.1. BASIC MAPPING ..................................................................................................................... 17
3.1.1. Filename Translation ................................................................................................... 17
3.1.2. Program Name Translation .......................................................................................... 17
3.1.3. Utilities........................................................................................................................ 17
3.2. CODE SAMPLE ....................................................................................................................... 18
4. MAINTENANCE ........................................................................................................................... 19
4.1. U NDERSTANDING .................................................................................................................... 19
4.2. R E-ARCHITECTING .................................................................................................................. 20
4.3. MONITORING ......................................................................................................................... 20
5. TRANSLATION P ROCESS ........................................................................................................... 22
5.1. THE P ROCESS ....................................................................................................................... 22
5.2. THE P RODUCT ....................................................................................................................... 24
6. SUMMARY................................................................................................................................... 25
1.Introduction
Growing maintenance fees, scarcity of trained developers, expected end-of-life announcements,
cumbersome deployment processes, platform dependencies – these are just a few reasons
companies are migrating from legacy Mainframe COBOL applications to modern Java solutions.
Whether migrating management support systems, operations infrastructure or reporting
applications, the COBOL to Java migration process is usually highly complex, risky, expensive
and time consuming.
CTU (COBOL to Universal), is a product that transforms a Mainframe (MF) based legacy
application from COBOL to Java, producing object oriented Java / C# that can be easily
maintainable and can be efficiently integrated with other Java / C# applications.
CTU support the full environment of MF based COBOL application, including data bases(e.g.,
DB2, IDMS, IMS) and VSAM, TP monitors (e.g., CICS), JCL, utilities (e.g., IDCAMS) and SORT.
CTU is a fully automated solution that captures the entire source base of the application,
automatically migrates it to object oriented Java / C#. The resulting code has the exact
functionality of the migrated application and can easily be tested and implemented in production.
CTU provides significant cost savings in hardware and software (no need for emulation software
solution) and positions the IT department for continued growth and success.
This White paper provides a detailed analysis of the methodology used by BluePhoenix to
architect the product and develop it. It provides the reader with deep understanding about the
capabilities of the product and its merits, taking special emphasis on its object oriented translation
methodology.
WORKING-STORAGE SECTION.
protected boolean endOfFile = false;
01 END-OF-FILE PIC X(01) VALUE 'N'.
88 EOF-Y VALUE 'Y'.
88 EOF-N VALUE 'N'. protected int marriedPeople = 0;
01 MARRIED-PEOPLE PIC 9(5) COMP VALUE '0'.
public void run() {
try {
mainSubroutine();
} catch (ReturnException re) {
// normal termination of the program
}
}
Translated code is readable and maintainable, following Java standards and object oriented
concepts. COBOL business logic and comments are preserved and employees familiar with the
original legacy application can easily understand the translated one. In this example, the reader
can notice the separation between business logic (the program) and data layer (ProfilesDAO,
ProfilesTO, WeddingsDAO, WeddingsTO).
The next chapters provide more details about the architecture and the set of rules that are the
base of the CTU object oriented translation product.
2.1.Architecture Overview
2.1.1.Online/CICS
The converted online/CICS application is a 3-tier application, running in an application server with
a thin client in the browser. The general architecture is as follows:
Presentation Layer
JSF, Java Beans
Java classes
Web Browser
(DAO)
Each COBOL program will be converted to a Java class providing the same functionality exposed
as a service (Business Logic Layer). All database/files operations from the original COBOL code
are externalized in DAO classes and Hibernate mapping files (the Data Access Layer). The
Presentation Layer is generated by converting the legacy screens to JSF (Java Server Faces).
These layers can be implemented via a number of products in order to provide the robustness
necessary for high volume, high uptime applications. The typical overall high level architecture is
depicted in the following diagram:
2.1.2.Batch
The converted batch application doesn’t depend on any Java EE APIs, so it can run as a normal
Java application. For running batch applications, BatchSession implementation is used,
keeping information regarding the JCL context.
2.2.Basic Mapping
CTU includes a very strong mapping capability that produces an object oriented model that can
best represent the procedural code.
This mapping component produces code that can be further refined and refactored after the
migration project, to better fit into the overall framework and architecture of the system.
The following table illustrates the basic mapping from the procedural COBOL language to the
object oriented Java (in this case) language:
In some cases specific COBOL statements can be translated to different Java objects (e.g., Table
to DAO / DTO). CTU includes the logic that enables it to make the right decision and use the
most relevant object which best fits the overall architecture of the full system, taking account such
things as performance and maintainability.
Using this approach the resulted code is much easier to understand, it offers an easy ways to
maintain the code. More than that, DAO and DTO code can be reused for future enhancements
made in Java. Modifications can be made to the DAO implementation without altering other
decoupled modules of the application.
2.3.1.Database Access
For database access, Hibernate is used to facilitate usage of multiple database engines. All used
queries in a DAO are externalized to a Hibernate XML mapping file, further simplifying
maintenance of the queries.
Database DTOs are created from the SQL table definitions.
2.3.1.1.SQL Cloning
CTU also handles cloning at the SQL level. This means that if COBOL code contains more than
one SQL statement of the same type, even in different programs, only one Java method will be
created inside the specific DAO. The DTOs contain all the information related to a specific SQL
table and the DAOs represent a collection of different SQL statements used in COBOL project
related to that SQL table.
2.3.1.2.Code Sample
For the following DDL, CTU creates four artifacts: DAO, TO, Hibernate class definition, Hibernate
queries.
CREATE TABLE ACCOUNT
(ACCOUNT_ID VARCHAR(8) NOT NULL
,SURNAME VARCHAR(20)
,FIRST_NAME VARCHAR(20)
,SOLD INTEGER
,CURRENCY_SIGN VARCHAR(3)
,ACCOUNT_LEVEL CHAR(1)
,BONUS_INTERVAL SMALLINT
,PRIMARY KEY (ACCOUNT_ID)
)
DAO class: contains all the operations with the ACCOUNT table, from all programs.
public class AccountDAO {
Hibernate queries: all the queries for ACCOUNT table will be in a Hibernate mappings file.
<hibernate-mapping>
<sql-query
name="com.bphx.ctu.samples.sqldemo.data.dao.AccountDAO.updateByAccountIdRec ">
<query-param name="bonusInterval" type="short"/>
<query-param name="accountId" type="bphx.ctu.lang.hibernate.AdfVarcharType"/>
<synchronize table="ACCOUNT"/>
update ACCOUNT set
BONUS_INTERVAL = :bonusInterval
where
ACCOUNT_ID = :accountId
</sql-query>
</hibernate-mapping>
2.4.1.Data Remodeling
COBOL data structures are analyzed and remodeled to meet the following requirements:
Encapsulation
Reuse
Readability
Small memory footprint for better utilization
2.4.1.3.Data cloning
When a new COBOL program is developed and uses same data structures as an old program s,
the developer has two ways to use the existing information related to data information.
First and the most clever way is to move the data definition from the old COBOL program into a
copybook and use the copybook both in old and new COBOL programs.
But most of COBOL developers are just copying the COBOL data definitions in the new program.
Complex COBOL systems can have a lot of these kinds of structures defined again and again in
many programs.
CTU can easily handle both situations and detects data clones. Only one Java class is created
and is used in all places.
PIC X char
Numeric-edited java.lang.String
Alpha-numeric-edited java.lang.String
9(n)V9(m) bphx.ctu.lang.datatype.AdfDecimal
GRP88 PIC X(1) VALUE 'Y'. boolean / class (depending on the usage)
88 Y VALUE 'Y'.
88 N VALUE 'N'.
2.4.2.Code Restructuring
Each paragraph becomes a private method in the Java program class. Program structure and
comments are preserved during conversion, simplifying maintenance.
During code restructuring, program flow is normalized and GO TOs are removed.
2.4.2.1.Program normalization
Program normalization is a code transformation that replaces GO TOs and fall through behavior
with a statically determined code. The transformation involves minimal changes to the program
structure, and it’s not changing the original conditional statements or constructs.
As an example, let’s see how a simple processing loop is transformed:
P1.
PERFORM READ-INPUT THRU PROCESSING-END UNTIL EOF.
STOP RUN.
READ-INPUT.
DISPLAY "READING INPUT FILE"
* AT END, SKIP PROCESSING
IF EOF
GO TO PROCESSING-END.
PROCESSING.
* DO SOME PROCESSING
DISPLAY "PROCESSING".
PROCESSING-END.
DISPLAY "DONE".
For each “perform range” (e.g. statements like PERFORM READ-INPUT THRU PROCESSING-
END), a method (rngReadInput) is built that will subsequently call the paragraphs that are in the
flow order within the original program. This way, the fall through is ensured. Other perform
2.5.Presentation Layer
To maintain the same user experience, BMS Maps are migrated to equivalent web pages. In all
cases, the actual data fed into each new web interface is the same as the data fed into the legacy
screen. When the application screen display logic is executed, the resulting HTML web page
produced mimics the original 3270 screen as closely as possible. The actual screen layouts are
maintained, so users of the application do not have to be retrained.
Legacy screens are automatically converted to standard JSF (Java Server Faces) in order to be
easily deployable in any application server. Each screen is converted into the following
components:
o JSF Facelet (XHTML UI representation) – the View
o Managed Data Bean – the Model (data fields/attributes)
o Static text labels property file (separating content from layout)
As stated, the converted code will preserve the look and feel of the original application. In order to
achieve this, the generated JSF defaults to using fixed-width fonts and absolute positioning of
fields and text labels. The web application will have the same navigational features as the original
one.
PF Keys and return keys are fully supported using JavaScript event handling routines. In addition,
navigation using arrow keys is also supported allowing the user to move from one field to another
just like in the original application (without involving mouse operations or TAB key – although
these are available as well).
Before conversion
After conversion
3.1.Basic Mapping
Each job class inherits from JobScript and each Proc from ProcScript. These classes
constitute a runtime framework.
Each step becomes an inner class implementation of one of the following:
ProgStep
ClassStep
ProcStep
3.1.1.Filename Translation
A typical Mainframe DSNAME has the format aa.bb.cc.dd
A typical Unix filename has the format /aa/bb/cc.dd and windows filename has the format
C:\aa\bb\cc.dd
However it is not always practical to simply change all periods to slashes , nor is it always
practical to change all filenames in exactly the same manner.
To solve this issue, UJM supports a powerful rule based filename translation algorithm, allowing
different filename translation rules to be applied to different DSN patterns.
In the code sample below the DSNs AA.AA and BB.BB have been modified by a rule that adds
the ../files/ prefix.
3.1.3.Utilities
rd
UJM's runtime framework is supplemented by implementations of the most common IBM and 3
party utilities, such as IKJEFT01, IDCAMS, IEBGENR, IEBCOPY, etc.
3.2.Code Sample
The following input file:
//SAMPLE JOB i(ACT),'BPHX'
//*
//OPEN EXEC PGM=ECHO,PARM='SAMPLE CODE'
//SYSOUT DD SYSOUT='*'
//CALLP EXEC P1,ABC=DEF
//DD1 DD DSN=AA.AA,DISP=NEW,DCB=(LRECL=80,RECFM=FB)
//DD2 DD *
Example of multi-line
inline data
//IKJEFT EXEC PGM=IKJEFT01
//SYSTSIN DD DSN=BB.BB,DISP=OLD
Is translated as follows:
import com.bphx.runtime.jcl.*;
It is very easy for an employee familiar with the old legacy application to understand the new
translated application source. Readability and maintainability is one of the main capabilities of
BluePhoenix’s Java / C# conversion. The following main goals apply for the migration:
The general structure of the program is preserved and you can easily navigate from
legacy code to new code
Original comments are preserved throughout the translated code
All code is formatted following Java coding conventions
The code is object oriented (examples):
o Three separated layers: Data, Business, Presentation.
o Use of Java primitive types (int, char, String) enhances the readability of the
code.
o Data records are translated to a class. Similar data records are detected, and
only one class is generated for them.
o Copybook classes are reused as a single class throughout the application when
possible.
o Transfer between programs is done using the TransferObject pattern.
o Data access layer is separated. For each program, SQL statements are moved
to separate classes, Data Access Object. Programs are moving data to DAOs
using a TransferObject.
o Program flow is normalized.
o Each COBOL program is a service, exposing only main entry point. All working
storage fields are private to the program class.
o Design of the statement translation leverages, as much as possible, from the
existing J2SE library.
The application is modularized
o Each application module is translated to a Java package.
o Each module package has a standard structure (For example):
4.3.Monitoring
As a post translation service, CTU includes a web application to help manage sites running
converted JCLs.
Main features of Site Management Console (SMC):
File browser
Initiator management
Lock monitor
Log Files and Log File Viewer
Log cleaner
Configuration file management
User/Group management
5.1.The Process
The methodology related to the migration project provided by BluePhoenix includes the following
phases:
Global
Assessment
Ensures all assets are inventoried, and a
Detailed detailed plan is formed for migration
Analysis
Database
Remodeling
Parallel migration activities
Data divided into Work Packets,
Migration using BluePhoenix
automated conversion tools
Code / JCL Conversion
by Work Packets
Pre-Delivery
Testing
Regression Testing
Reconversion of
Refresh changed components
Acceptance
Deployment
Test
Global Assessment
The Global Assessment phase includes the automated inventory analysis of the customer to
establish a definitive project inventory, and to populate a repository of components to be migrated
to the target environment. This activity will be conducted using the BluePhoenix toolset and
includes analysis of the entire inventory to confirm the inventory sizing.
Detailed Analysis
Detailed Analysis includes analysis of the in-scope application inventory, data model mapping,
and the documentation of all design decisions related to the platform migration, such as
architecture decisions, current BluePhoenix toolset options, coding styles supported in toolset,
database layer/connections and error handling. If customer desires other options for conversion,
requiring enhancing the conversion toolset, the request will be analyzed during this phase.
The agreed upon data modeling rules determined during this phase will be used to automatically
create an optimized relational SQL data model to capture all explicit and implicit VSAM/IDMS/IMS
data.
This phase also includes discussing and reviewing how to deliver the transformed code in Work
Packets, and the overall system test strategy.
The CTU Product solution offering is a state of the art automates solution for the migrati on of
COBOL based Mainframe applications to new open systems environments running Java or C#.
This cost-effective CTU solution significantly decreases the risk and time involved, and enables
current developers to continue maintaining and enhancing the migrated application.
Legacy COBOL based applications are now becoming a risk to your business. Moving the
COBOL applications to another platform only prolongs this situation, since the application will still
have the same functionality and problems and run in an emulated environment. For example, you
would still need to pay third-party vendors for compilers and runtime environments. Appending
Web services and Web clients to your existing systems only increases the complexity of your
existing architecture. The best solution is to migrate away from the legacy COBOL to Java or C#
using CTU.
With BluePhoenix’s CTU modernization solution, the migrated code can serve as a client/server
application or a Web-based application, according to the company’s business requirements and
needs. Migration to the new environment utilizing an automated process retains business logic
and application flow, keeping the same functionality. The migrated application follows object
oriented principles like encapsulation, abstraction, modularization and loose coupling.
The generated code is readable and maintainable, while the runtime performance is the same or
better than the original application.
BluePhoenix’s CTU migration and modernization products and services provide an end-to-end
solution for all your COBOL migration needs—analyzing the source code, identifying external
resource use, modeling and migrating the data and finally, creating a target application based on
open standards ready for acceptance tests. BluePhoenix expert teams perform all required
design phases and architecture decisions in accordance with your company’s specific business
needs.