## Converting Legacy Applications to Java

### Charles F. Townsend

Synkronix, Inc.
4683 Chabot Drive, Suite 211
Pleasanton, CA 94588
Phone: 1-888-SYN-KRON
http://www.synkronix.com

COBOL

The report of the death of COBOL is premature; I can see a long fruitful life ahead for COBOL!

COBOL remains as the best implementation language for business applications, and will remain in that place for the foreseeable future.

Market Analysis

COBOL is a third generation computer programming language that is used worldwide. It is the dominant language for business application and processing. Over eighty percent of the world’s business runs on COBOL (GartnerGroupä , 1997). This huge number represents almost every industry on the planet from banking and insurance to manufacturing. The investment in such technologies, staff and hardware is estimated to be greater than $5 trillion dollars worldwide (Micro Focusä Press Release, Sept. 1997). Over 180 billion lines of COBOL code are still in use today with an estimated 5 million lines per year added (GartnerGroupä , 1997). Applications written in COBOL include:

- Inventory management
- Order processing
- Accounts receivable and payable
- Retail
- Shipping
- Manufacturing
- Financial
- And the list goes on….

Technology Today

The normal application is anything but normal. We continue to create multi-dimensional applications where the legacy host is complimented with an array of diverse applications and software environments. Some of these applications do actually work together! There continues to be pressure to pull together departmental computers or applications and bring them under control of the IT infrastructure so that all the compute power MIPS can be utilized and to enable data access.

Environment Division

The COBOL environment continues to change and with this new requirements to support an even more diverse application base. The investment made in COBOL is substantial and what are we to do with it.

- Throw the investment away, abandon the investment either in a staged or at once in a "cold turkey" approach.
- Add to the investment using a GUI builder making the application a client/server solution.
- Bridge to the future by adding Java capabilities.

Jazzing Up COBOL

Alternatives for Jazzing up COBOL can be separated into three categories. Screen scraping based products, framework based products and full converter/compiler based products.

- Screen Scrapers -- allow customers to analyze their current terminal based operation and create a platform independent graphical user interface that will act as a "front-end" to the original application. These create a Javaä based front-end that relays messages to the terminal application. This solution does provide a method to access legacy applications on new platforms and provides an advantage that accounts for the maintenance and support costs of porting legacy application to new platforms.

Screen scraping increases network traffic tremendously and will increase the workload on the customer’s mainframe and mid-range servers. As such, an increased workload will translate into higher server maintenance and upgrade costs as well as increased system complexity due to the introduction of new front-end application code that must now be maintained in Javaä .

- Frameworks allow customers to create new Javaä applications that can be interfaced with legacy programs through special constructs. Existing legacy applications continue to reside on the mainframe and/or mid-range servers throughout the enterprise. Access to new platforms is achieved with new applications written in Javaä . New Java applications communicate with existing server-based applications through the special framework constructs.

The framework effectively allows communications between older applications residing on the server and new applications residing on clients. The disadvantage of this approach is that it requires that the staff be re-trained or recruit new staff that can create Javaä applications necessary to interface with the framework. This approach increases the complexity of the enterprise since three disparate systems must work in unison: the original legacy applications, the framework product and the new Javaä based client programs. Complexity may increase overall maintenance and support costs, and require additional staff.

- Compilers and Converters -- Compiler or converter based products are those products that change the original source. These compilers provide the capability to move from one programming language to another as well as provide the support needed to run the application in the new programming language. The question is whether the resultant product requires the user to work within the old or new programming paradigm.

PERCobolä

Synkronixä has developed and delivered to the marketplace PERCobolä a COBOL to Javaä compiler and development environment for the Javaä Virtual Machine (JVM). PERCobolä offers to users the ability to generate Javaä programs from ANSI 85 COBOL code. Enabling the functionality and portability found only in Javaä applets or applications.

PERCobolä is a robust solution, which incorporates features that enable mission critical production applications. PERCobolä has added COBOL language extensions and functions necessary in enterprise and distributed computing today.

PERCobolä compiles COBOL into Javaä on legacy platforms. The resulting Javaä code is distributed over the Enterprise. Legacy investment is retained as new applications (E-Commerce and Data Marts) are more easily built around current COBOL. Business systems. IT costs are reduced and sales and customer satisfaction is increased by leveraging emerging platforms (Network Computerä and the Internet/Intranet/Extranet.)

PERCobolä Product Description

The compiler is the basic building block of all such computer software. Customers require the highest quality and stability from a product. In all cases, the compiler and runtime system must behave in a consistent and predictable way each time a program is executed. PERCobolä compiler and runtimes to meet or exceed both industry standards and de-facto standards.

PERCobolä is a fully ANSI 1985 X3.23b compliant COBOL compiler which generates Javaä source code. The resulting Javaä source code can then be compiled using any JDK 1.1+ compliant Javaä Compiler and will run on any JDK 1.1+ implementation of the Javaä virtual machine as either an applet or application.

A diagram of the COBOL-to-Javaä mapping produced by PERCobolä

PERCobolä includes a freely distributed Synkronixä proprietary Javaä runtime library, which enable COBOL, program behavior to function consistently across the various Javaä environments. These runtimes are optimized for performance and include support for COBOL data and file types (sequential, relative, indexed) on both local machines and across networks. The runtimes are small (200K compiled) which allow quick downloads across congested networks.

PERCobolä Workflow Diagram

Additional tools included with PERCobolä packages allow COBOL programmers to work with COBOL while executing in a Java environment. These tools may include an integrated development environment, debugging tools and various programming utilities. The addition of these value-added components with PERCobolä creates a true COBOL development solution and not simply a "converter."

COBOL language extensions have been added to allow COBOL programmers access to features that in many cases were previously available only in "modern" programming languages. These features include TCP/IP programming, event driven GUI programming, multi-threaded programming and pointers.

The PERCobolä Graphical User Interface is the only true 100% platform independent COBOL GUI in existence. Embedded SQL (EXEC-SQL) allows access to databases using Javaä JDBC drivers (and the JDBC-ODBC bridge for ODBC data sources). This eliminates the need for a SQL pre-compiler. In addition, where Javaä may be used for stored procedures in databases when programming in conjunction with databases, so too can COBOL. EXEC-HTML allows programmers to write server COBOL CGI programs to generate dynamic HTML pages. EXEC-JAVA allows any Javaä feature to be integrated within a COBOL program. In short, Synkronixä has created in PERCobolä a compiler and runtimes that allow COBOL to run on the Javaä virtual machine.

A screen shot of a demonstration program written in COBOL and compiled with Synkronixä PERCobolä .
It demonstrates a real estate search program with a dynamic graphic user interface running on a Javaä virtual machine.

PERCobolä is currently the only COBOL application development tool on the market today which allows COBOL programmers to write platform independent COBOL applets and applications. Through PERCobolä business, programmers can now create programs that can run directly on previously inaccessible platforms.

PERCobolä Product Advantages

PERCobolä is a application programming solution offering the ability to maintain business software and staff, as well as leverage software investment with new technologies and functionality in a diverse computing environment. PERCobolä permits the business programmer to continue using COBOL. PERCobolä reduces the cost and complexity of software systems by allowing users to write once and deploy anywhere.

MAINTAIN CURRENT INVESTMENT IN LEGACY APPLICATIONS

Business software applications have evolved over last few decades and are seldom considered "throw away". Software applications are in many instances thought of as corporate assets and the software inventory is critical to business. Software tools must fit within the software development infrastructure and allow for an evolutionary rather than revolutionary approach to development and maintenance. Advancement solely for technology alone is not embraced unless there is an overwhelming need, requirement or benefit. When change yields significant benefits or return on investment it will then be embraced.

One of two options can be selected for dealing with existing application inventory:

- Re-implementation using a new technology or a new programming language. This approach can be very costly and may involve significant risk. The main concern is that some aspect of the business logic could be lost in the transition.
- Creation of interfaces or frameworks that allow the isolation of existing COBOL applications. Extensions are then built that allow for communication with application extensions either as front-end client or the middle tier application server. This approach for creating application extensions often increases system complexity and in turn results in increased support and maintenance costs.

PERCobolä enables an evolutionary migration of COBOL based applications. PERCobolä uses Javaä as its runtime environment and Javaä is available on most computing platforms. The need to insulate the existing application by creating an API or a framework is reduced or eliminated because PERCobolä handles the necessary execution support through its own runtime routines.

A screen shot of PERCobolä Enterprise Edition. This shot is a demonstration of the IDE and Synkronixä GUI COBOL Debugger.
By redeveloping applications through PERCobolä customers can take advantage of the evolutionary route to maintenance and development.

Communication with other COBOL programs compiled with PERCobolä will continue to function as before and the application will still execute as if it were a COBOL program. Communication from COBOL programs to Javaä can occur through EXEC-JAVA and communication to other COBOL programs can be done through CALL statements. Communication with Javaä programs is achieved through the Callable Program Interface. Native executable programs including COBOL can be accessed through PERCobolä callable programs that implement the Java Native Interfaceä .

Evolving COBOL applications through PERCobolä allows access to new platforms more easily and cost effectively both up and down the computing hierarchy. Users can further redevelop applications through the use of additional new functions or features that may not be available in the current computing environment. For example the user could move server applications to the host and take advantage of storage or computing power or move portions of an application to the client to add new graphical user interfaces.

User interfaces written with PERCobolä are platform independent and will behave in the same manner regardless of the execution platform. The only restriction will be the graphical client support not available on a limited number of platforms. Deploying a common user interface may reduce complexity and boost productivity.

A re-deployed COBOL application is now a candidate for adding new functions and features not current available in the traditional COBOL environment. Extensions such as Electronic Commerce can be added to reach users across the Internet, Intranet or Extranet and possibly reduce transaction cost, as well as provide access to data beyond the confines of the current application infrastructure. It will enable 24 by 7 by 365 application access for sales and service.

Using PERCobolä extends the life and value of legacy applications. New COBOL extensions provided by PERCobolä open opportunities for continued usage and increase return on current investment. Coupling the strengths of COBOL and Javaä opens the possibility to fully exploit the features of both programming environments. Increasing the life of existing applications by adding Javaä will create a familiar bridge for COBOL programming staff to the future with a tool that connects both programming worlds.

MAINTAIN CURRENT INVESTMENT IN LEGACY SYSTEMS

Cost savings can be realized in an evolutionary approach to enhancing corporate software assets. Applications re-deployed with PERCobolä can change the workload configuration of the current computing infrastructure and thus allow workload balancing that was not available previously. A local client can be used to pre- or post- process information to be presented to a user. The host, server and client in a multiple tier environment can be fully utilized to optimize the capabilities of each platform. Optimizations at the client can reduce network congestion. Reduction of server processing and network traffic can yield significant savings on upgrades and maintenance to both servers and the corporate network backbone. Savings and continued usage of current systems may allow increased throughput and extend application functionality with reduced demand on system resources.

MAINTAIN CURRENT INVESTMENT IN STAFF

The Gartner Groupä estimates that there are over 3 million COBOL programmers in the world today. This number far exceeds those involved with any other programming language. This represents a valuable corporate asset with billions of dollars invested in training and education. The investment is too large to replace. These programmers are extremely familiar with IT requirements and have a valuable understanding of current systems. If business could access the new technological platforms and leverage the skills of existing COBOL programmers, then its goal could be reached with minimal disruption to the existing programming paradigm.

One solution has been to retrain COBOL programmers to perform the new tasks demanded by business. This retraining represents a significant capital investment. Dataquestä projects the worldwide IT training and education market to be worth $10.8 billion in 1998. This market is estimated to grow at approximately ten percent annually. Historically this solution has not been successful since the COBOL language is very different from other procedural programming languages.

Another solution is to replace or augment the IT staff with new programmers familiar with these newer paradigms. However, recruiting new staff can be costly. Businesses that replace their staff find it difficult to support current applications and have little recourse should problems arise. A new staff may have little understanding of the behavior of existing application systems and its interaction with other applications. Maintaining two staffs can be expensive and can quickly exhaust the budget.

Business can achieve its goals and address problems with the use of PERCobolä . PERCobolä allows the COBOL programmer to write applications for new platforms in the language with which they are familiar – COBOL. Training costs are limited to the usage of the new Synkronixä COBOL language extensions and the use of the PERCobolä product itself as opposed to training and education of programmers to use entirely new frameworks, languages, tools and methodologies. PERCobolä further reduces the bulk of the costs associated with staffing since it enables business to utilize current programming staff with minimal additional staffing requirements.

REDUCING MAINTENANCE AND SUPPORT COSTS

Many businesses have added support variants of the same application on a variety of platforms including PC's, Macintoshes, UNIX and Web/Internet interfaces. Each platform has its own idiosyncrasies that force application developers to maintain separate code for the variant of the application on each platform. When an upgrade is required, it must be integrated into each platform’s program variant or version. Multiple versions of code can and in most instances do introduce problems into the support infrastructure. These are compounded with each new version. Support and system complexities are major budgetary factors. If application infrastructure could be simplified or not compounded by the addition of new technology, there might be great value in using this solution. PERCobolä addresses this problem with Javaä by providing what COBOL’s architects truly envisioned, a completely portable programming language.

Using PERCobolä , application programmers can maintain the same code base for all possible clients from terminals and PC's to the Internet where the client can be an unknown. PERCobolä eliminates platform inconsistencies using the Javaä virtual machine. Javaä implementation and execution inconsistencies are managed through the PERCobolä runtime. This obviates the concern regarding client implementation. PERCobolä eliminates most of the cost associated with maintaining platform specific code. New features are written once and will run on nearly all the Javaä virtual machines.

Return on Investment

Using PERCobolä as an application development and deployment tool is of great value in a programming environment that has a heavy dependence on COBOL. When these shops consider moving beyond the confines of a single platform or enabling for the Internet, PERCobolä users could see a significant return on investment. For example removing the requirement of reengineering a program to execute on several operating environments or platforms, the resulting application could be less complex or at a minimum could have a smaller code base. The result saves execution time and maintenance costs.

Performance

Application performance is a major concern and PERCobolä has been designed to consider the impact of the performance of newly deployed applications. PERCobolä runtimes are compact (approximately 200K compressed) and optimized for performance. Additionally platform and operating system vendors are investing enormous resources in the production of high performance Javaä virtual machines. The result of these investments should yield significantly improved Javaä performance.

Dream Home COBOL Sample

    000000* RealEstate
    000010*
    000020* Author. Brian Sullivan.
    000030*
    000040* Copyright 1997-1998 Synkronix, Inc.  All rights reserved.
    000050*
    000060* This program display a Graphical User Interface using
    000070* Synkronix syntax from within either an application or
    000080* an applet.  Make selections of the number of bedrooms,
    000090* bathrooms, and price range to have the matching houses
    000100* displayed.
    000110*
    000120* Select houses with one more bedroom than bathroom to see
    000130* actual houses.
    000140*
    000150* The program has a typical DATA DIVISION structure for
    000160* a COBOL program, but with an unusual twist.  The FRAME
    000170* is the top of the GUI elements, with a layout (the
    000180* GridBagLayout in this case) below it as a child.
    000190*
    000200* Each graphical element in turn is a child of another
    000210* Java container.
    000220*
    000230* Most of the elements of the Graphical DATA DIVISION
    000240* are self-explanatory with a knowledge of Java; the
    000250* CONSTRAINT is the only odd one out, with a specification
    000260* of XXYYWWHHSAA
    000270*  XX: X Grid Position		S Stretching (N,H,V,B)
    000280*  YY: Y Grid Position		AA Anchor (C,N,S,E,W,NE,SE,NW,SW)
    000290*  WW: Width in Grid Positions
    000300*  HH: Height in Grid Position
    000310 IDENTIFICATION DIVISION.
    000320 PROGRAM-ID. DreamHome.
    000330 ENVIRONMENT DIVISION.
    000340 CONFIGURATION SECTION.
    000350
    000360 DATA DIVISION.
    000370 WORKING-STORAGE SECTION.
    000380
    000390 01  SEARCH-FOUND                PIC 9(3) VALUE 0.
    000400 01  SEARCH-INDEX                PIC 9(3) VALUE 0.
    000410 01  SEARCH-MINPRICE             PIC 9(7).
    000420 01  SEARCH-MAXPRICE             PIC 9(7).
    000430
    000440 01  HOUSE-ARRAY                 OCCURS 15 TIMES.
    000450     05  ADDRESS                 PIC X(70).
    000460     05  BEDROOM                 PIC 9.
    000470     05  BATHROOM                PIC 9.
    000480     05  PRICE                   PIC 9(7).
    000490     05  CITY                    PIC X.
    000500     05  OUTSIDE                 PIC X(11).
    000510     05  FLOORPLAN               PIC X(11).
    000520
    000530 01  HOUSES-LIST                 REDEFINES HOUSE-ARRAY.
    000540     05  HOUSE01.
    000550         10  ADDRESS             PIC X(70) VALUE
    000560             "17 Camelot Dr. ($100,000)".
    000570         10  BEDROOM             PIC 9 VALUE 2.
    000580         10  BATHROOM            PIC 9 VALUE 1.
    000590         10  PRICE               PIC 9(7) VALUE 100000.
    000600         10  CITY                PIC X VALUE "C".
    000610         10  OUTSIDE             PIC X(11) VALUE "house01.jpg".
    000620         10  FLOORPLAN           PIC X(11) VALUE "floor01.jpg".
    000630     05  HOUSE02.
    000640         10  ADDRESS             PIC X(70) VALUE
    000650             "2805 E. Vancouver ($750,000)".
    000660         10  BEDROOM             PIC 9 VALUE 4.
    000670         10  BATHROOM            PIC 9 VALUE 3.
    000680         10  PRICE               PIC 9(7) VALUE 750000.
    000690         10  CITY                PIC X VALUE "S".
    000700         10  OUTSIDE             PIC X(11) VALUE "house02.jpg".
    000710         10  FLOORPLAN           PIC X(11) VALUE "floor02.jpg".
    000720     05  HOUSE03.
    000730         10  ADDRESS             PIC X(70) VALUE
    000740             "822 N. Lincoln ($500,000)".
    000750         10  BEDROOM             PIC 9 VALUE 3.
    000760         10  BATHROOM            PIC 9 VALUE 2.
    000770         10  PRICE               PIC 9(7) VALUE 500000.
    000780         10  CITY                PIC X VALUE "M".
    000790         10  OUTSIDE             PIC X(11) VALUE "house03.jpg".
    000800         10  FLOORPLAN           PIC X(11) VALUE "floor03.jpg".
    000810     05  HOUSE04.
    000820         10  ADDRESS             PIC X(70) VALUE
    000830             "824 N. Lincoln ($950,000)".
    000840         10  BEDROOM             PIC 9 VALUE 5.
    000850         10  BATHROOM            PIC 9 VALUE 4.
    000860         10  PRICE               PIC 9(7) VALUE 950000.
    000870         10  CITY                PIC X VALUE "P".
    000880         10  OUTSIDE             PIC X(11) VALUE "house04.jpg".
    000890         10  FLOORPLAN           PIC X(11) VALUE "floor04.jpg".
    000900     05  HOUSE05.
    000910         10  ADDRESS             PIC X(70) VALUE
    000920             "1523 Willham South ($625,000)".
    000930         10  BEDROOM             PIC 9 VALUE 4.
    000940         10  BATHROOM            PIC 9 VALUE 3.
    000950         10  PRICE               PIC 9(7) VALUE 625000.
    000960         10  CITY                PIC X VALUE "F".
    000970         10  OUTSIDE             PIC X(11) VALUE "house05.jpg".
    000980         10  FLOORPLAN           PIC X(11) VALUE "floor05.jpg".
    000990     05  HOUSE06.
    001000         10  ADDRESS             PIC X(70) VALUE
    001010             "12 Washingtont Court. ($425,000)".
    001020         10  BEDROOM             PIC 9 VALUE 3.
    001030         10  BATHROOM            PIC 9 VALUE 2.
    001040         10  PRICE               PIC 9(7) VALUE 425000.
    001050         10  CITY                PIC X VALUE "C".
    001060         10  OUTSIDE             PIC X(11) VALUE "house06.jpg".
    001070         10  FLOORPLAN           PIC X(11) VALUE "floor01.jpg".
    001080     05  HOUSE07.
    001090         10  ADDRESS             PIC X(70) VALUE
    001100             "14932 Jefferson Rd. ($675,000)".
    001110         10  BEDROOM             PIC 9 VALUE 4.
    001120         10  BATHROOM            PIC 9 VALUE 3.
    001130         10  PRICE               PIC 9(7) VALUE 675000.
    001140         10  CITY                PIC X VALUE "M".
    001150         10  OUTSIDE             PIC X(11) VALUE "house07.jpg".
    001160         10  FLOORPLAN           PIC X(11) VALUE "floor02.jpg".
    001170     05  HOUSE08.
    001180         10  ADDRESS             PIC X(70) VALUE
    001190             "21470 Browne Dr. ($575,000)".
    001200         10  BEDROOM             PIC 9 VALUE 3.
    001210         10  BATHROOM            PIC 9 VALUE 2.
    001220         10  PRICE               PIC 9(7) VALUE 575000.
    001230         10  CITY                PIC X VALUE "S".
    001240         10  OUTSIDE             PIC X(11) VALUE "house08.jpg".
    001250         10  FLOORPLAN           PIC X(11) VALUE "floor03.jpg".
    001260     05  HOUSE09.
    001270         10  ADDRESS             PIC X(70) VALUE
    001280             "21472 Happy Valley Dr. ($1,000,000)".
    001290         10  BEDROOM             PIC 9 VALUE 5.
    001300         10  BATHROOM            PIC 9 VALUE 4.
    001310         10  PRICE               PIC 9(7) VALUE 1000000.
    001320         10  CITY                PIC X VALUE "F".
    001330         10  OUTSIDE             PIC X(11) VALUE "house09.jpg".
    001340         10  FLOORPLAN           PIC X(11) VALUE "floor04.jpg".
    001350     05  HOUSE10.
    001360         10  ADDRESS             PIC X(70) VALUE
    001370             "4538 Vancouver Ct. ($275,000)".
    001380         10  BEDROOM             PIC 9 VALUE 2.
    001390         10  BATHROOM            PIC 9 VALUE 1.
    001400         10  PRICE               PIC 9(7) VALUE 275000.
    001410         10  CITY                PIC X VALUE "P".
    001420         10  OUTSIDE             PIC X(11) VALUE "house10.jpg".
    001430         10  FLOORPLAN           PIC X(11) VALUE "floor05.jpg".
    001440     05  HOUSE11.
    001450         10  ADDRESS             PIC X(70) VALUE
    001460             "527 Rio Sancho Blvd. ($790,000)".
    001470         10  BEDROOM             PIC 9 VALUE 4.
    001480         10  BATHROOM            PIC 9 VALUE 3.
    001490         10  PRICE               PIC 9(7) VALUE 790000.
    001500         10  CITY                PIC X VALUE "C".
    001510         10  OUTSIDE             PIC X(11) VALUE "house11.jpg".
    001520         10  FLOORPLAN           PIC X(11) VALUE "floor01.jpg".
    001530     05  HOUSE12.
    001540         10  ADDRESS             PIC X(70) VALUE
    001550             "13419 Valley View Rd. ($355,000)".
    001560         10  BEDROOM             PIC 9 VALUE 2.
    001570         10  BATHROOM            PIC 9 VALUE 1.
    001580         10  PRICE               PIC 9(7) VALUE 355000.
    001590         10  CITY                PIC X VALUE "M".
    001600         10  OUTSIDE             PIC X(11) VALUE "house12.jpg".
    001610         10  FLOORPLAN           PIC X(11) VALUE "floor02.jpg".
    001620     05  HOUSE13.
    001630         10  ADDRESS             PIC X(70) VALUE
    001640             "144 Monterey Pkwy. ($590,000)".
    001650         10  BEDROOM             PIC 9 VALUE 3.
    001660         10  BATHROOM            PIC 9 VALUE 2.
    001670         10  PRICE               PIC 9(7) VALUE 590000.
    001680         10  CITY                PIC X VALUE "F".
    001690         10  OUTSIDE             PIC X(11) VALUE "house13.jpg".
    001700         10  FLOORPLAN           PIC X(11) VALUE "floor03.jpg".
    001710     05  HOUSE14.
    001720         10  ADDRESS             PIC X(70) VALUE
    001730             "121691 Ridge Rd. ($430,000)".
    001740         10  BEDROOM             PIC 9 VALUE 2.
    001750         10  BATHROOM            PIC 9 VALUE 1.
    001760         10  PRICE               PIC 9(7) VALUE 430000.
    001770         10  CITY                PIC X VALUE "S".
    001780         10  OUTSIDE             PIC X(11) VALUE "house14.jpg".
    001790         10  FLOORPLAN           PIC X(11) VALUE "floor04.jpg".
    001800     05  HOUSE15.
    001810         10  ADDRESS             PIC X(70) VALUE
    001820             "26417 Constitution Ave. ($360,000)".
    001830         10  BEDROOM             PIC 9 VALUE 3.
    001840         10  BATHROOM            PIC 9 VALUE 2.
    001850         10  PRICE               PIC 9(7) VALUE 360000.
    001860         10  CITY                PIC X VALUE "P".
    001870         10  OUTSIDE             PIC X(11) VALUE "house15.jpg".
    001880         10  FLOORPLAN           PIC X(11) VALUE "floor05.jpg".
    001890
    001900 01  MAIN-FRAME.
    001910   02 FRAME PIC X(31) VALUE "Synkronix PERCobol (Dream Home)".
    001920     05  EVENTTYPE               PIC X(2).
    001930     05  EVENTARG                PIC X(5).
    001940     05  EVENTWX                 PIC X.
    001950           05  BACKGROUND PIC X(10) VALUE "Light-Grey".
    001960           05  MENU PIC X(10) VALUE "Home Menu".
    001970	       10 FDEMO PIC X(4) VALUE "Demo".
    001980	          15 FABOUT PIC X(5) VALUE "About".
    001990		  15 FILLER PIC X(1) VALUE "-".
    002000		  15 FEXIT PIC X(4) VALUE "Exit".
    002010     05  GRIDBAG-LAYOUT.
    002020         10  SEARCH-BUTTON.
    002030             15  CONSTRAINT      PIC X(10) VALUE "04130101NC".
    002040                 20  BUTTON      PIC X(6) VALUE "Search".
    002050                     25  VISIBLE PIC X VALUE "Y".
    002060         10  VIEW-BUTTON.
    002070             15  CONSTRAINT      PIC X(10) VALUE "06130101NC".
    002080                 20  BUTTON      PIC X(4) VALUE "View".
    002090         10  BED-LABEL.
    002100             15  CONSTRAINT      PIC X(10) VALUE "01060301NC".
    002110             20  TEXTLABEL       PIC X(8) VALUE "Bedrooms".
    002120         10  BATH-LABEL.
    002130             15  CONSTRAINT      PIC X(10) VALUE "04060301NC".
    002140                 20  TEXTLABEL   PIC X(9) VALUE "Bathrooms".
    002150         10  PRICE-LABEL.
    002160             15  CONSTRAINT      PIC X(10) VALUE "07060401NC".
    002170                 20  TEXTLABEL   PIC X(11) VALUE "Price Range".
    002180         10  MIN-LABEL.
    002190             15  CONSTRAINT      PIC X(10) VALUE "10070101NC".
    002200                 20  TEXTLABEL   PIC X(3) VALUE "Min".
    002210         10  MAX-LABEL.
    002220             15  CONSTRAINT      PIC X(10) VALUE "10080101NC".
    002230                 20  TEXTLABEL   PIC X(3) VALUE "Max".
    002240         10  BED-CHOICE.
    002250             15  CONSTRAINT      PIC X(10) VALUE "01070302NC".
    002260                 20  CHOICE      PIC 9(3) VALUE 1.
    002270                     25  CHOICE-1     PIC X(11) VALUE
    002280                         "One Bedroom".
    002290                     25  CHOICE-2     PIC X(11) VALUE
    002300                         "Two Bedroom".
    002310                     25  CHOICE-3     PIC X(13) VALUE
    002320                         "Three Bedroom".
    002330                     25  CHOICE-4     PIC X(12) VALUE
    002340                         "Four Bedroom".
    002350                     25  CHOICE-5     PIC X(12) VALUE
    002360                        "Five Bedroom".
    002370         10  BATH-CHOICE.
    002380             15  CONSTRAINT      PIC X(10) VALUE "04070302NC".
    002390                 20  CHOICE      PIC 9(3) VALUE 1.
    002400                     25  CHOICE-1     PIC X(12) VALUE
    002410                         "One Bathroom".
    002420                     25  CHOICE-2     PIC X(12) VALUE
    002430                         "Two Bathroom".
    002440                     25  CHOICE-3     PIC X(14) VALUE
    002450                         "Three Bathroom".
    002460                     25  CHOICE-4     PIC X(13) VALUE
    002470                         "Four Bathroom".
    002480         10  MINPRICE.
    002490             15  CONSTRAINT      PIC X(10) VALUE "07070301HC".
    002500                20  TEXTFIELD    PIC $$,$$$,$$$ VALUE "$0".
    002510         10  MAXPRICE.
    002520             15  CONSTRAINT      PIC X(10) VALUE "07080301HC".
    002530                 20  TEXTFIELD   PIC $$,$$$,$$$ VALUE
    002540                     "$9,999,999".
    002550         10  SEARCHBOX.
    002560             15  CONSTRAINT      PIC X(10) VALUE "01101003HC".
    002570                 20  LIST        PIC 9(3).
    002580                     25  EVENTAE PIC X.
    002590                     25  ADDRESS PIC X(75) OCCURS ZERO TO 15 TIMES
    002600                                 DEPENDING ON SEARCH-FOUND.
    002610         10  HOUSEGIF.
    002620             15  CONSTRAINT      PIC X(10) VALUE "01010404NC".
    002630                 20  IMAGE       PIC X(11) VALUE "house01.jpg".
    002640                     25  WIDTH   PIC 9(3) VALUE 200.
    002650                     25  HEIGHT  PIC 9(3) VALUE 200.
    002660         10  FLOORGIF.
    002670             15  CONSTRAINT      PIC X(10) VALUE "07010404NC".
    002680                 20  IMAGE       PIC X(11) VALUE "floor01.jpg".
    002690                     25  WIDTH   PIC 9(3) VALUE 200.
    002700                     25  HEIGHT  PIC 9(3) VALUE 200.
    002710
    002720* An About frame to give information about the program.
    002730*
    002740* This shows a second frame active at the same time as
    002750* well as an example using fonts and a different
    002760* color.
    002770
    002780  01 ABOUT-FRAME.
    002790    05 FRAME PIC X(9) VALUE "Synkronix".
    002800      10 EVENTWX.
    002810      10 BACKGROUND PIC X(4) VALUE "Cyan".
    002820      10 BORDER-LAYOUT.
    002830      15 NORTH.
    002840        20 TEXTLABEL PIC X(33)
    002850	         VALUE "DreamHome (C)1998 Synkronix, Inc.".
    002860	        25 FONT PIC X(5) VALUE "Serif".
    002870	          30 BOLD-FONT PIC X.
    002880	          30 SIZE-FONT PIC 99 VALUE 24.
    002890	    15 SOUTH.
    002900	      20 TEXTLABEL PIC X(33)
    002910	         VALUE "Written by Brian Sullivan".
    002920	        25 FONT PIC X(10) VALUE "SansSerif".
    002930	          30 FOREGROUND PIC X(9) VALUE "Dark-Grey".
    002940	          30 ITALIC-FONT PIC X.
    002950	          30 SIZE-FONT PIC 99 VALUE 12.
    002960
    002970* Have only one about-frame active at a time so that
    002980* the events are always attached only to the correct frame.
    002990
    003000 01 ABOUT-FRAME-ACTIVE PIC 9 VALUE 0.
    003010
    003020 PROCEDURE DIVISION.
    003030
    003040
    003050 MAIN-ENTRY.
    003060
    003070     DISPLAY "Beginning Traditional COBOL..." UPON CONSOLE
    003080     DISPLAY "Terminating Traditional COBOL..." UPON CONSOLE
    003090     STOP RUN.
    003100
    003110
    003120 SEARCH-HANDLER.
    003130
    003140     DISPLAY "Searching..." UPON CONSOLE
    003150     DISPLAY "Bed=" CHOICE OF BED-CHOICE
    003160     DISPLAY "Bath=" CHOICE OF BATH-CHOICE
    003170     DISPLAY "Address=" LIST OF SEARCHBOX
    003180     DISPLAY "MinPrice=" TEXTFIELD OF MINPRICE
    003190     DISPLAY "MaxPrice=" TEXTFIELD OF MAXPRICE
    003200     MOVE 1 TO SEARCH-INDEX
    003210     MOVE 0 TO SEARCH-FOUND
    003220     MOVE TEXTFIELD OF MINPRICE TO SEARCH-MINPRICE
    003230     MOVE TEXTFIELD OF MAXPRICE TO SEARCH-MAXPRICE
    003240     PERFORM UNTIL SEARCH-INDEX > 15
    003250       IF BEDROOM OF HOUSE-ARRAY (SEARCH-INDEX) =
    003260          CHOICE OF BED-CHOICE AND
    003270          BATHROOM OF HOUSE-ARRAY (SEARCH-INDEX) =
    003280          CHOICE OF BATH-CHOICE AND
    003290          PRICE OF HOUSE-ARRAY (SEARCH-INDEX) >= SEARCH-MINPRICE
    003300       AND
    003310          PRICE OF HOUSE-ARRAY (SEARCH-INDEX) <= SEARCH-MAXPRICE
    003320       THEN
    003330          ADD 1 TO SEARCH-FOUND
    003340          MOVE ADDRESS OF HOUSE-ARRAY (SEARCH-INDEX)
    003350            TO ADDRESS OF SEARCHBOX (SEARCH-FOUND)
    003360          DISPLAY "Found: " ADDRESS OF HOUSE-ARRAY (SEARCH-INDEX)
    003370          DISPLAY " Cost: " PRICE OF HOUSE-ARRAY (SEARCH-INDEX)
    003380       END-IF
    003390       ADD 1 TO SEARCH-INDEX
    003400     END-PERFORM
    003410
    003420     BUILD
    003430        LIST OF SEARCHBOX
    003440     END-BUILD
    003450
    003460*    Exit the event thread.
    003470
    003480     EXIT PROGRAM.
    003490
    003500
    003510 VIEW-HANDLER.
    003520
    003530     MOVE LIST OF SEARCHBOX TO SEARCH-FOUND
    003540     DISPLAY "Viewing..." SEARCH-FOUND UPON CONSOLE
    003550     MOVE 1 TO SEARCH-INDEX
    003560     PERFORM UNTIL SEARCH-INDEX > 15
    003570       IF ADDRESS OF HOUSE-ARRAY (SEARCH-INDEX) =
    003580          ADDRESS OF SEARCHBOX (SEARCH-FOUND)
    003590       THEN
    003600          MOVE OUTSIDE OF HOUSE-ARRAY (SEARCH-INDEX)
    003610            TO IMAGE OF HOUSEGIF
    003620          MOVE FLOORPLAN OF HOUSE-ARRAY (SEARCH-INDEX)
    003630            TO IMAGE OF FLOORGIF
    003640          BUILD
    003650             IMAGE OF HOUSEGIF
    003660             IMAGE OF FLOORGIF
    003670          END-BUILD
    003680       END-IF
    003690       ADD 1 TO SEARCH-INDEX
    003700     END-PERFORM
    003710
    003720*    Exit the event thread.
    003730
    003740     EXIT PROGRAM.
    003750
    003760
    003770 FRAME-HANDLER.
    003780
    003790     HIDE
    003800        FRAME OF MAIN-FRAME
    003810     END-HIDE
    003820
    003830     EXIT PROGRAM.
    003840
    003850       ABOUT-EXIT.
    003860
    003870           HIDE
    003880	      FRAME OF ABOUT-FRAME
    003890	   END-HIDE
    003900
    003910	   MOVE 0 TO ABOUT-FRAME-ACTIVE
    003920
    003930	   EXIT PROGRAM.
    003940
    003950       ABOUT-FRAME-BUILDER.
    003960
    003970           IF ABOUT-FRAME-ACTIVE NOT = 0 THEN
    003980	      EXIT PROGRAM
    003990	   END-IF
    004000
    004010	   MOVE 1 TO ABOUT-FRAME-ACTIVE
    004020
    004030           BUILD
    004040	     FRAME OF ABOUT-FRAME
    004050	   END-BUILD
    004060
    004070	   EVENT
    004080	     FRAME OF ABOUT-FRAME ABOUT-EXIT
    004090	   END-EVENT
    004100
    004110	   EXIT PROGRAM.
    004120
    004130 APPLET-STOP.
    004140
    004150     DISPLAY "APPLET-STOP" UPON CONSOLE
    004160
    004170     HIDE
    004180        FRAME OF MAIN-FRAME
    004190     END-HIDE.
    004200
    004210
    004220 APPLET-START.
    004230
    004240     DISPLAY "APPLET-START" UPON CONSOLE
    004250
    004260     BUILD
    004270        FRAME OF MAIN-FRAME
    004280     END-BUILD
    004290
    004300     EVENT
    004310        BUTTON OF SEARCH-BUTTON SEARCH-HANDLER
    004320     END-EVENT
    004330
    004340     EVENT
    004350        BUTTON OF VIEW-BUTTON VIEW-HANDLER
    004360     END-EVENT
    004370
    004380     EVENT
    004390        LIST OF SEARCHBOX VIEW-HANDLER
    004400     END-EVENT
    004410
    004420     EVENT
    004430        FRAME OF MAIN-FRAME FRAME-HANDLER
    004440     END-EVENT
    004450
    004460     EVENT FEXIT OF FDEMO FRAME-HANDLER END-EVENT
    004470
    004480	   EVENT FABOUT OF FDEMO ABOUT-FRAME-BUILDER END-EVENT.
    004490
    004500
    004510 APPLICATION-INIT.
    004520
    004530     DISPLAY "APPLICATION-INIT" UPON SYSOUT
    004540
    004550     BUILD
    004560        FRAME OF MAIN-FRAME
    004570     END-BUILD
    004580
    004590     EVENT
    004600        BUTTON OF SEARCH-BUTTON SEARCH-HANDLER
    004610     END-EVENT
    004620
    004630     EVENT
    004640        BUTTON OF VIEW-BUTTON VIEW-HANDLER
    004650     END-EVENT
    004660
    004670     EVENT FEXIT OF FDEMO FRAME-HANDLER END-EVENT
    004680
    004690	   EVENT FABOUT OF FDEMO ABOUT-FRAME-BUILDER END-EVENT.
    004700
    004710     EVENT
    004720        FRAME OF MAIN-FRAME FRAME-HANDLER
    004730     END-EVENT.
    004740
    004750 APPLICATION-START.
    004760
    004770     DISPLAY "APPLICATION-START" UPON SYSOUT.
    004780
    004790 APPLICATION-STOP.
    004800
    004810     DISPLAY "APPLICATION-STOP" UPON SYSOUT.
    004820
    004830 APPLICATION-DESTROY.
    004840
    004850     DISPLAY "APPLICATION-DESTROY" UPON SYSOUT.

Dream Home Java Sample

    // Imports
    import com.synkronix.cobol.*;
    import java.util.*;
    import java.net.*;
    import java.sql.*;
    import java.awt.*;
    import java.awt.image.*;

    /**
     * Generated by PERCobol(TM) Cobol to Java Cross-Compiler

     * PERCobol(TM) is Copyright 1996-1998 Synkronix, Inc.
     * COBOL PROGRAM-ID hello_world
     * @version 1.3
     */
    public class hello_world extends cobolThread
    {
          public int majorPercobolVersion() { return 1; }
          public int minorPercobolVersion() { return 1; }
        /**
         * @return Program/Class name in Java style.
         */
        public String getProgramName()
        {
            return "hello_world";
        }

        // Allocate Cobol style memory
        static private Memory memory=new Memory(getMemorySize());	// Cobol shared memory
        static private Vector entryPoint=new Vector(32); // Entry points of new instances

        static public synchronized void addEntry(int n)
        {
            entryPoint.addElement(new Integer(n));
        }

        static public synchronized int getEntry()
        {
            if(!(entryPoint.isEmpty()))
            {
                int n=((Integer)(entryPoint.firstElement())).intValue();
                entryPoint.removeElementAt(0);
                return n;
            }
            return 0;
        }

        public void run()
        {
            run(-1,getEntry());
        }

        public void run(int setCurrentThread)
        {
            run(setCurrentThread,getEntry());
        }

        static public hello_world newThread()
        {
            addEntry(0);
            hello_world newInstance=new hello_world();
            newInstance.start();
            return newInstance;
        }

        static public hello_world newThread(int entryParagraph)
        {
            addEntry(entryParagraph);
            hello_world newInstance=new hello_world();
            newInstance.start();
            return newInstance;
        }

        public void newThreadThis(int paragraph)
        {
            newThread(paragraph);
        }

        static public void runInstance()
        {
            addEntry(0);
            hello_world newInstance=new hello_world();
            newInstance.start();
            try
            {
                newInstance.join();
            }
            catch(Throwable e)
            {
                ;
            }
        }

        // DATA DIVISION

        // Static initialization of variables
        static
        {
            // Variable declaration (long-form):

            // String cobol_name, String picture, String initial_value,
            // byte type, byte usage, byte sign, byte sync,
            // int place, int scale, Memory memory,
            // int pointer_in_memory, int item_size,
            // int characters_in_picture, int sibling_offset,
            // Variable parent, Variable first_child, Variable first_sibling,
            // boolean justify, boolean blank_when_zero,
            // int minimum_subscript, int maximum_subscript, Variable depending_on

            Variable.validate("9JJALLLTAT9WXVCP5Z","PERCobol(TM) COBOL runtimes Copyright 1998 Synkronix, Inc.");

            // BEGIN file declarations
            // END file declarations

        } // end static initializer

         //---------------\\
        // COBOL PARAGRAPH \\____ MAIN-PARAGRAPH ____
        public final int main_paragraph_Label=1;
        private int main_paragraph_Alter=main_paragraph_Label;

        public int main_paragraph()
        {
            System.out.println("Hello World from Java via COBOL."+"");
            return 0; // fall through
        } // END PARAGRAPH

        protected char currencyCharacter='$';
        protected char decimalCharacter='.';
        protected char commaCharacter=',';

        // Generated methods

        public void cancel()
        {
            // Reset all variables to initial state, close all open files.
        } // end cancel

        public Variable getMasterVariable()
        {
            return null;
        }

        public void registerProgram()
        {
            cobolThread.registerProgram(getProgramName(),this,"C:\\PERCOBOL\\samples\\helloworld\\hello.cob");
        }
        static public int performStatic(int begin,int end)
        {
            hello_world program=new hello_world();
            return program.perform(begin,end);
        }

        public int perform(int begin,int end)
        {
            for(;;)
            {
                switch(begin)
                {

                    case 0: // Initial Paragraph
                    memory.setCurrency(currencyCharacter);
                    memory.setComma(commaCharacter);
                    memory.setDecimal(decimalCharacter);

                    // END DECLARATIVES
                    case 1:
                    begin=main_paragraph();
                    if(begin!=0) break;
                    if(end==main_paragraph_Label) return 0;

                    // END USER SECTIONS/PARAGRAPHS
                    default: return -1;
                } // end switch
            } // end forever
        } // end perform(int,int)

        static private int getMemorySize()
        {
            return 0;
        }
        protected int sqlExceptionHandler(SQLException sqlException,int notFoundLabel,int errorLabel)
        {
            String sqlResult=sqlException.getSQLState();
            if(sqlResult!=null)
            {
                sqlstate.move(sqlResult);
                sqlResult=sqlResult.substring(0,2);
            }
            else
            {
                sqlResult="01";
                sqlstate.move("01000");
            }
            if(sqlResult.equals("01"))
            {
                sqlcode.move(100);
                if(notFoundLabel!=-1) return notFoundLabel; // WHENEVER NOT FOUND HANDLER
            }
            else
            if(sqlResult.equals("02"))
            {
                sqlcode.move(100);
                if(notFoundLabel!=-1) return notFoundLabel; // WHENEVER NOT FOUND HANDLER
            }
            else
            if(!sqlResult.equals("00"))
            {
                sqlcode.move(-1);
                if(errorLabel!=-1) return errorLabel; // WHENEVER ERROR HANDLER
            } // end if
            return -1;
        } // end sqlExceptionHandler

        static public String localNameConverter[][]=
        {
            {
                "hello_world","hello_world"
            }
        };

        public String getGlobalName(String localName)
        {
            for(int i=0;i<localNameConverter.length;i++)
            {
                if(localName.equals(localNameConverter[i][0]))
                return localNameConverter[i][1];
            }
            return null;
        }
    } // END PROGRAM