Home > Store

COBOL Programming Using the .NET Framework

Register your product to gain access to bonus material or receive a coupon.

COBOL Programming Using the .NET Framework


  • This product currently is not for sale.
Not for Sale


  • Copyright 2002
  • Dimensions: K
  • Pages: 336
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-066843-5
  • ISBN-13: 978-0-13-066843-1

COBOL and .NET: application migration, design, implementation, and deployment.

  • COBOL for .NET: design, coding, and deployment
  • Migrating legacy COBOL code to Web environments using
  • Fujitsu(r) COBOL for .NET
  • Developing COBOL applications with Visual Studio.NET
  • Maximizing application efficiency and performance

Now that COBOL is being integrated into Microsoft's .NET platform and Visual Studio.NET toolset, developers have a powerful way to bring their COBOL expertise into the Web-enabled future. In this book, long-time Windows programming expert Dr. Ronald Reeves gives developers comprehensive guidance for writing new COBOL code for .NET environments, and migrating existing COBOL code to the .NET platform. Reeves begins by introducing the .NET framework and Visual Studio.NET development environment from the COBOL programmer's standpoint. Next, he covers every key aspect of COBOL development for .NET, including:

  • Providing interoperability between legacy "unmanaged" code and .NET managed code
  • Building next-generation Web services and applications using ASP.NET and WebForms
  • Leveraging SOAP and the Web Services Description Language (SOAP)
  • WinForms: Integrating COBOL software with powerful Windows client user interfaces
  • Building COBOL-based database applications with ADO.NET
  • Object-oriented COBOL programming using .NET extensions
  • Designing COBOL.NET applications for maximum efficiency and performance



To help you get started programming COBOL on the .NET framework and to aid your work with the book, we are making available for download the source code (328 kb, ZIP archive) appearing in the text.

Sample Content

Online Sample Chapter

Object-Oriented COBOL Programming Using the .NET Framework

Table of Contents



1. Review and Introduction to Object-Oriented COBOL Programming Using the .NET Framework.

Componentware, Cognition, and Software Development. Object and Cognitive Activities. What Is an Object? What Is a Software Object? Object-Oriented Programming with COBOL. COBOL Classes and Language Interoperability. COBOL Classes and the .NET Base Classes.

2.NET Framework.

Introduction. .NET Framework Base Classes. Common Language Runtime. Metadata and Self-Describing Components.

3. Graphical User Interface Applications Using Windows Forms.

Introduction to Windows Forms. What Is a Form? Windows Forms and Web Forms Considerations. Windows Forms Controls. Building a Windows Forms Project. Adding Control to Forms. Adding Menu Items and Pull-Downs to Windows Forms.

4. Web Applications Using ASP.NET and Web Forms.

Introduction. Looping Hello World Program. Fruit List Program. Fibonacci Program. ASP.NET Code Generation Program. Simple Control Program. Hi You Selected Program.

5. .NET COBOL Web Services.

Introduction. Web Service Generic Architecture. .NET Enterprise Servers. Moving Forward with .NET Framework. Web Service Demo Programs. Area Code Service COBOL Source Code. Advantages of Converting COBOL to Web Services.

6. Building Database Applications Using ADO.NET.

Introduction. ADO.NET Architecture. ADO.NET DataSet. ADO.NET DataTable. ADO.NET DataColumn. ADO.NET DataRow. ADO.NET DataRelation. ADO.NET ForeignKeyConstraint. ADO.NET UniqueConstraint. Sample ADO COBOL Program.

7. Migration of COBOL Legacy Systems to .NET Framework.

COBOL and Web Services. What Is SOAP and What Does It Have to Do with Web Services? How Can Users Build COBOL Web Services Using the SOAP Toolkit? Can Users Build Web Service Clients in Fujitsu COBOL? COM Modules. Microsoft Visual Basic Client. The SOAP Toolkit. Client Updates. .NET.

8. Introduction to Windows 2000.

Windows 2000 Operating System Architecture. Processes, Threads, and Jobs in Windows 2000.

Appendix A: Programming Techniques.

APIs Used with Windows 2000 Processes. Base Priority for Windows 2000. .NET Framework Namespaces. General Rules of the Language. Program Structure.

Appendix B: Windows Forms.

System.Window.Forms Namespace. Controls You Can Use on Windows Forms.

Appendix C: Web Namespaces.

System.Web Namespace. System.Web.UI Namespace. System.Web.UI.HtmlControls Namespace. System.Web.UI.WebControls Namespace. System.Web.Services Namespace.

Appendix D: Data Namespaces.

System.Data Namespace. System.Xml Namespace. System.Data.OleDb Namespace. System.Data.SqlClient Namespace.




Windows 2000 is a large and important system, and it is the core of a more embracing architecture that Microsoft calls Windows DNA 2000. In this context, DNA stands for Distributed interNet Applications and represents Microsoft's vision for building distributed systems. This type of architecture is focused on developing the new "digital nervous system" for enterprises. In this context, the "digital nervous system" is the corporate, digital equivalent of the human nervous system: an information system that can provide a well-integrated flow of information at the right time, to the right place in an organization. Such systems can be programmed at many levels, from the lowest level of device drivers giving access to privileged instructions to very high levels using powerful software application development tools. This book is aimed at Microsoft Windows application programming, using the new Fujitsu COBOL compiler and the Visual Studio.Net development environment. The Fujitsu COBOL and Visual Studio.Net discussions and examples are based on the Release Candidate from Microsoft. The book aims to cover most of the important areas needed for practical application development using Fujitsu COBOL, without attempting to be encyclopedic. The book is largely self-contained, including coverage of the core topics of Win32 programming required for Microsoft Windows. The book should prove suitable for programmers migrating to Microsoft Windows from other environments such as Unix and mainframes. A large part of the book addresses issues of which components actually make up the .NET Framework and the Microsoft Windows operating systems. One must realize there are numerous constraints among all the components, and one needs to try to understand from the beginning how they fit into the whole .NET Framework and the Microsoft Windows operating system.

Learning such complex technology can be quite a challenge. The documentation is vast, equivalent to tens of thousands of printed pages, and it is changing all the time. You can subscribe to various Internet discussion groups, and you will receive hundreds of emails every day. There are many, many books on different parts of this technology. But how do you grasp the whole picture? This book aims to be holistic, to provide a practical guide for the COBOL programmer who has used any COBOL compiler. The book provides a tutorial, giving you all the basic information you need to create working .NET Framework application systems. The book and companion FTP site (http://www.phptr.com/reeves) have many example programs in Fujitsu COBOL to aid you in gaining an understanding of how the whole environment fits together.

Before we get into Chapter 1, lets take a snapshot of some of the types of areas and examples covered in the book.

COBOL on the Web

With an increasing amount of business being conducted on the Web, organizations everywhere are asking themselves how to best take advantage of the enormous new business opportunities. Businesses with a lot of legacy COBOL are even more concerned, since most of their applications were built long before the Web became the business phenomenon that it is today. These businesses find that retraining their workforce to use other programming languages, as well as retooling their applications for the Web is a daunting task. COBOL vendors, including Fujitsu, have been selling a variety of solutions for migrating COBOL applications to the Web. Fujitsu's support for the .NET Framework builds on that position and takes several steps forward, allowing COBOL programmers to program directly to the Web and to easily use their existing legacy code.

ASP.NET (language = "COBOL")

ASP.NET is the Microsoft successor to Active Server Pages (ASP), which was designed to deliver dynamic Web content. ASP faced a number of weaknesses in the areas of performance and programmability, and ASP.NET makes substantial improvements in those areas. Instead of being interpreted like ASP, ASP.NET compiles pages to native code. This change results in enormous performance benefits, with only a one-time cost to compile the page when it is first deployed. The other important side effect of the design choice (to compile instead of interpret) is that it opens the door for compiled languages to provide code in ASP.NET pages. Fujitsu COBOL is taking advantage of this important benefit by allowing COBOL programmers to embed COBOL code in ASP.NET pages. The following is a sample ASP.NET page written using Fujitsu COBOL that displays "Hello COBOL world!" in increasing font sizes:

<%@ page language="COBOL" %><script runat="server">OBJECT.DATA DIVISION.WORKING-STORAGE SECTION.77 FONT-SIZE PIC S9(9) COMP-5.END OBJECT.</script><% PERFORM VARYING FONT-SIZE FROM 1 by 1 UNTIL FONT-SIZE >   7 %><font size="<%=FONT-SIZE%>"> Hello COBOL world! </font>   <br><% END-PERFORM. %>
The "<%@" characters introduce the directive that allows us to set the programming language for the page to COBOL. The <script> block allows us to introduce COBOL code that declares the FONT-SIZE variable and the characters "<%" allow us to introduce inline COBOL code to loop over the HTML that displays "Hello COBOL world!". ASP.NET also makes programming interactive content much simpler by exposing standard HTML elements as controls and allowing programmers to create new controls. Web Forms is the name given to this type of control in the .NET Framework. The sample below shows the use of several Web Forms controls in an application that displays the image of a piece of fruit based on the fruit name selected in a drop-down box.
<form runat="server"><font face="Verdana"><b>Please Select A Fruit : <b><select id="FRUITLIST" runat="server" size="1"><option value="Orange">Orange</option><option value="Apple">Apple</option><option value="Mango">Mango</option><option value="Pear">Pear</option><option value="Banana">Banana</option></select><input type="submit" value="submit" runat="server"   OnServerClick="FRUITLIST-CLICK"><p><table><tr><td><img id="FRUITIMAGE" src="images\black.gif" runat="server" /></td><td><font face="Verdana" size=6><span id="FRUITNAME" runat="server"/></font></td></tr></table></form><body></html>

The <form> tag block surrounds the set of Web Forms controls used in the page. The runat="server" attribute indicates to ASP.NET that the behavior of the control is implemented using code running on the server. This example has four Web Forms controls, whose names are specified using the "id" attribute:

  • A select control called "FRUITLIST" that displays the list of five fruits from which to choose.
  • An unnamed input button. The "OnServerClick" attribute specifies that the button has a programmed event associated with clicking it. The value of the attribute gives the name of the method that is the event-handler—in this case "FRUITLIST-CLICK."
  • An image control called "FRUITIMAGE" that is used to display the image of the selected fruit.
  • A span control called "FRUITNAME" that displays the name of the selected fruit alongside the image.

The <script> block at the top of the ASP.NET page implements the "FRUITLIST-CLICK" event handler in COBOL for the input button control. The method extracts the selected name from the "FRUITLIST" control, uses the StringBuilder class from the .NET Framework base classes to construct the path to an image file of the fruit, and sets the appropriate value for the "FRUITIMAGE" and "FRUITNAME" controls. This technology enhances the programmability of Web pages and helps to overcome limitations of static HTML technology. With this technology you can imagine constructing sophisticated Web systems, including applications like electronic storefronts, inventory management systems, shipping management, and much more. Best of all, these applications can be programmed using COBOL if that is what your workforce is trained to use.

Web Services: Programming the Web

While ASP.NET allows programmers to package dynamic contents onto server-side Web pages, Web Services go a step further. They provide the opportunity to expose programming interfaces to the Web for use by clients to package in any way they see fit. This allows businesses to truly componentize their product offerings in ways that end-users can customize to suit their own applications. The following is an example of a very simple Web Service written in COBOL:


The example is just a COBOL class definition with a method called "ADDME" that adds two numbers together. The "webservice" directive at the beginning tells the .NET Framework that we want to expose methods as Web Services and identifies the programming language in which the methods are written. (In future versions, users will probably need to use a compiler directive to specify an attribute for each method that is to be exposed as a Web Service.)

As simple as this seems, a number of technologies all have to work together for Web Services to function. For example, SOAP (Simple Object Access Protocol) is a protocol that Microsoft would like to see adopted as a standard; it is used for marshalling data using XML (eXtensible Markup Language). SOAP is needed for clients and servers to communicate their arguments and results in a format that can ultimately be transmitted over HTTP. Microsoft has also defined a Service Description Language (SDL), which describes the services being exposed and provides clients the mechanism through which they can find those services. Web services open up new opportunities for application deployment. Instead of packaging business logic applications with wrappers that predetermine the Web presentation style and content, companies can expose their business logic as a Web Service to be customized for use by their customers.

Frameworks and Language Interoperability

The .NET Framework SDK comes with base classes that implement a wide variety of operations, such as I/O, data type manipulation, and graphical application development. Because Fujitsu COBOL is targeting the .NET Framework, the language in which these base classes are implemented is immaterial. COBOL programs can use these features as if they were written in COBOL. The infrastructures for this language interoperability is a Common Language Runtime (CLR). The previous ASP.NET fruit list example has already demonstrated some of the uses of .NET Framework. The COBOL method "FRUITLIST-CLICK" was embedded in a class that inherited from base classes in the .NET Framework. This allowed direct access to inherited properties. The "StringBuilder" class is another example of a class from the .NET Framework Base Classes. The following sample shows the use of the Win Forms part of .NET Framework that allows developers to construct equivalent Win32 API-based Graphical User Interface (GUI) applications:


This very simple application brings up a frame window with the title "Hello COBOL World!". It demonstrates inheritance from the Win Forms "Form" class and use of methods and properties in the Win Forms base class.

Migrating COBOL Code to the Microsoft .NET Framework

The .NET Framework provides interoperability between code targeted for the CLR, also known as managed code, and existing native code and COM applications. This means that developers can write new managed code that makes calls to their existing code. In the case of existing COM applications, this is as simple as using a type library import tool (TLBIMP) that makes COM interfaces visible to managed code. For other native code, users simply need to provide a COBOL prototype declaration for the code they want to call. To call from native code to managed code, developers can use a type library exporter (TLBEXP) and an assembly (mechanism of packaging) registration tool (REGASM) to export their managed code as COM objects. Eventually, users will also have the option of compiling their existing code with the new compiler to run completely using the CLR. While Fujitsu Software is committed to enabling this scenario, early releases of the compiler are likely to not support all of COBOL's features. New COM-type development will probably use COM+, which has superseded COM. However, COM can still be used for component development if desired.

Delivering on the Vision

As the only COBOL vendor to currently target the new Microsoft .NET Framework environment, Fujitsu Software has a commitment to a vision of seamless interoperability and powerful programming tools. The price of this commitment is the development of an enhanced COBOL compiler with language extensions to support the new .NET Framework platform, a completely new code generator targeting Microsoft's Intermediate Language (IL or metadata) and ASP.NET support code for COBOL, among other things.

Language Extensions

The CLR is based heavily on an object-oriented programming model. This does not mean that all programs that run in the environment have to be object-oriented, but object-oriented language constructs are needed to use some features of the environment. The Fujitsu COBOL implementation will conform to the most current COBOL draft standard where possible. Some features of the CLR are not supported by the current state of the COBOL draft standard. For example, constructs like delegates, custom attributes, and visibility attributes have no existing representation in COBOL. For these constructs, Fujitsu will try to ensure that standards conforming programs are not affected by the existence of language extensions targeted to the CLR.

Code Generation

The CLR achieves its goals of interoperability, security, and robustness by operating on metadata instead of native code. This means that compilers that target the environment have to develop new code generators that generate metadata instead of native code. The CLR uses just-in-time (JIT) compilation strategies to ultimately translate code for the platform into fast native code. Enhanced interoperability also means that applications with code written in different programming languages can also be seamlessly debugged. This is an important productivity benefit, particularly since most current development environments for COBOL (with the exception of Fujitsu COBOL) make debugging cross-language applications quite cumbersome.


In addition to a new compiler, language-specific support is also required for the new ASP.NET infrastructure. Because ASP.NET compiles its pages, it has to be able to generate code to represent the HTML and ASP.NET content in the language in which the page is written. For example, the "Hello COBOL world!" ASP.NET sample shown earlier results in generated code that includes the following fragment:



The long-term benefits of integration with the Microsoft .NET Framework are that COBOL will more easily adapt to new technologies. New base classes that are developed for the .NET Framework (in any programming language) immediately become accessible to COBOL programmers. The subsequent chapters in this book will explain how the whole Windows 2000 operating system, .NET Framework, and the new Fujitsu COBOL compiler are integrated and how they work together. We will cover the use of the tools in Visual Studio.NET that are used to develop and work with new COBOL applications, as well as migration of legacy code to the new platform. The Visual Studio.NET is not an evolutionary step but a revolutionary one in a software application development platform. We believe that this will represent a revolutionary step in COBOL application development under this environment.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020