Migration of Cobol Applications for Web
Migração de Aplicações Cobol para Web
Luiz Sérgio Araújo Morais - netmoraisap@gmail.com
This document contains:
Summary of the description and characteristics of the methodology.
General feature with sequence of activities.
Specification of technologies used.
System Maintenance.
Considerations on Methodology.
Requirements of the system.
List of itens that compose the solution.
Installing, Compiling, Configuring and Running
This Solution aims to show what is possible through standardization in the Development of Cobol Systems and with their subsequent migration to Web environment, have access to new technologies inherent and drop significantly the costs in the development and maintenance of these products. It is a Methodology that combines a set of known techniques to "Teach" the Cobol Programs to "Write", automatically and in real-time, Web pages from a pre-established protocol. To achieve the proposed objectives will be presented a Simple Application for Demonstration, initially in a Character and then migrated to the Web environment, using Cobol resources.
The continuation will be divided in four main phases, as shown in table 1 below:
Table 1 - Sequence of activities
As shown in Table 1, will be discussed first in general the roles within the proposed solution represented by the basic resources used for its implementation, namely, the Cobol, Http, Html, Cgi, Css and Java Script.
In a second phase, will be present an application simple of demonstration, based on character, containing only a few options, will be a model with operating conditions, producing the basic conditions so that the user can interact with the system.
In the third phase, will be presented the migration of the application for the Web, where to can observe the benefits of the methodology, with regard to development as well as the perception reduction of cost in this phase. At this point will be presented the engine access that effectively allows the provision of pages on the Web, the automatic generation of user interface, or in other words, the production of dynamic pages, which after its use are totally discarded, needed only at the time of communication with the users to the system.
In the fourth stage, the process of system maintenace, caused by a new attribute inserted into an module of the application, will be presented a change in the system of demonstration, to take idea of the behavior of the methodology forward to a new reality.
The Cobol will be used so we can write a simple application of demonstration, and this, specifically all the necessary services, such as dealing with the implementation of the interface, both in Character and Web environment. Regarding Cgi, to be the means chosen to give every support to the traffic pages between the Web Server and the User's browser. The Css, which take care of presentation aspects and positioning of elements on the pages and finally JavaScript loaded in the user browser that take care of the logic of page editing on the Web environment. In addition, the server of pages represented by Apache. Naturally for almost all the technology proposal there are other equally and even more current, such as Php, Java, Asp, etc, or using the many new features that are currently in the Cobol language. Everything depends on the cost-benefit ratio to be adopted in the solution.
A Simple Application of Demonstration:
To show what has been said so far, the following is a model of application with operating conditions that have only a few options, composing the basic requirements so that the user can interact with the system, therefore, has no practical use, except for the purpose of demonstration. It incorporates the concept of development in three layers, and the layer of interface has an element common to all modules.
The system, "Controle de Clientes" contains modules: "Cadastro de Clientes", "Atendimento a Clientes", "Parametros do Sistema", "Inclui E-mail em Clientes", "Remove E-mail de Clientes" and "Estado dos Servicos" . The modules run from a menu of options also called "Controle de Clientes' with the following basic information for each module, as shown in Table 2:
Table 2 - System tables
Clientes
Telefone
Nome
Endereco
Servico
Data
Telefone
Ocorrencia
Parametros
None
Cnpj
Endereco
In order to materialize the proposed, was created a prototype, based on a set of Cobol programs, grouped by the following prefixes: app-*, elements of the application; srv-*, services for the implementation, man-*, maintenance on the application, and tmp-*, information temporary, with distribution of the modules in layers, as shown in Table 3:
Table 3 - Distribution of the modules in layers
The third layer, the interface is common to all modules and is performed by a service, named "srv-interface.cbl/int", as shown in Figure 1. Notes to this scheme the use of the third layer, the interface, and additionally the vision that it breaks into another collection, which receives requests from applications and comes under each environment. It is clear that the process is completely transparent to the application, it only asks the interface by means of a pre-established protocol, which wants, it is not their responsibility as the must be done.
Figure 1 - Common interface for applications modules
Viewing the distribution of layers from the viewpoint of a module and using, for example, the "Cadastro de Clientes" there is the three layers as shown in Figure 2:
Figure 2 - Layers for the "Cadastro de Clientes"
For details about the Modules and Character Interface listed, see the sources code provided in the files app-cadastro-cliente.cbl, app-cadastro-cliente-dado.cpy, app-cadastro-cliente-negocio.cpy, srv-interface.cbl and srv-interface-txt.cbl. Below, the Figure 3 illustrates the implementation of this model in a terminal:
Figure 3 - Module app-cadastro-cliente.int and srv-interface-txt.int - execution
In this moment is observed the Interface "srv-interface-txt.int" running the issue based on information previously provided by the application "app-cadastro-cliente.int". This is noted the titles, names and content of field informed. Moreover, the prompt for the "Telefone" and a small ratio of keys of action. Although simple, already noticed here which was established a pattern of development, with well-defined rules, which if are accepted and meet the needs of the business, can be used for other applications. Of course no business in the real world accepts as primary requirements, but the principle is basically the same, varying only the degree of complexity of its specifications.
Migration for Web and Engine Access:
To migrate to the Web environment the solution is the implementation of the layer interface, giving it conditions to run in the new environment. Therefore, it is initiated by changing the layout of the common interface, as shown in Figure 4:
Figure 4 - Common Interface with Web module
With the emergence of module "srv-interface-htm.cbl" it is necessary to amend the module "srv-interface.cbl" that now presents itself as the Figure 5. Now it is possible to note the selection of the type of interface that should be used depending on the verification of the environment variable Cgi "GATEWAY_INTERFACE," and according to their existence, run the model "htm" or "txt".
Figure 5 - Module "srv-interface.cbl"
Then see the "srv-interface-htm.cbl" module, which generates an interface in Html to be executed by the browser. For details about the Web Interface listed, see the sources code provided in the files srv-interface.cbl and srv-interface-htm.cbl. In Figure 6, an piece of the code of temporary page, resulting from the implementation of the interface model Html with its output redirected to a file.
Figure 6 - File of transmission generated by "srv-interface-htm.cbl/int"
In terms of interface, the information is ready to be used. But lacking the side of the client. It is necessary to create a mechanism that provides access to these pages in a browser and return the information to the application. It is will be presented below.
To provide a engine access to the interface generated will be used a set of components, which through its integration allows the sending pages and receiving forms as the following:
Description of components:
Figure 7 - Components of the engine access
The components shown in Figure 7 and described below may be installed on the same machine or on different machines, depending primarily with issues such as availability resources, efficiency and security rules.
1. User Browser - Firefox : Program Web browser installed in the station of the system user. Through this the user selects the application you want to use, calls his start up, its processing and closing; these steps will be explained in module Client Applications.
2. Web Server - Apache : Server Web pages that can run Cgi programs. Its function is to establish communication between the User Browser and the Client Applications, "srv-cliente.cbl/int", receiving and sending requests in both directions.
3. Server Applications - srv-servidor.cbl/int : Works in one direction. Runs continuously, checking from time to time, any requests. Receive requests, in the start up phase of the Client Applications, requesting the initiation of a particular application, a time when executed in the background and returns to its normal function of verification of new requests.
4. Client Applications - srv-cliente.cbl/int : Works in two directions. Execute the communication between the Web Server and the Application itself. Must be, according to the proposed model, a Cgi application, which is triggered by the Web Server. Its implementation is characterized by three distinct moments. The first time, identified as initialization, which asks the Server Applications the implementation chosen. In a second, identified as processing, sends the forms received from the Web Server to the Application, wait new generated pages to be made available to the Web Server, and then exit. The processing routine remains re-executed continuously until the user requests its finalization. Here is the third time of the finalization, when the Client Applications sends a finalization page and exit.
5. Selected Application - app-controle-cliente.cbl/int - srv-interface-htm.cbl/int : This module also works in both directions. It can be materialized by any application that has been selected by the user, such as a "Controle de Clientes", materialized by "app-controle-cliente.cbl/int" and interfaced by "srv-interface-htm.cbl/int" with the ability to detect the condition to be running in a Web environment, and consequently, to communicate with the Client Applications by sending pages and receiving forms. The operation of the interface is completely transparent to the Application itself. The Interface called by the Application detect the Web environment and generating the pages that will be read by the Client Applications, providing to the Web Server, awaiting the interaction of the user, then read the forms returned, remaining in this cycle until it is requested the exit.
For details about the Server and Client Applications, described in the Access Engine, see the sources code provided in the files srv-servidor.cbl and srv-cliente.cbl, respectively.
To effectively start up the application access to the cgi folder where are the Cobol Programs and then asked to boot the server with the commands: "$ srv-servidor.sh -i", and "$ srv-servidor.sh -s" as shown in Figure 8:
Figure 8 - Module "srv-servidor.int" - start up
His execution, comparing the modes Character and Web, after informing in the browser the address, for example:
"http://localhost/cgi-bin/mfo/app-controle-cliente" can be seen in Figures 9 to 12.
Figure 9 - Controle de Clientes - Character
Figure 10 - Controle de Clientes - Web
Figure 11 - Cadastro de Clientes - Character
Figure 12 - Cadastro de Clientes - Web
After implementation you can see the interface "interface-srv-htm.int" with "srv-cliente.int", through the mechanism of access running "app-cadastro-cliente.int," or the "Cadastro de Clientes". In this new model you can see all the previous features ported to the Web environment and completely transparent to the application. It is important to note that because the Methodology used was not necessarily any change in the Application. From de viewpoint of Application, remained the same rules of Access to Data, Business and Interface. The Interface in turn, detect the new environment and "creates" the new means for its operation.
System Maintenance:
To illustrate the possible impact on the maintenance and upgrade of the application, it is assumed here that it is necessary to include a new attribute in the structure of Clientes, information from your e-mail, as shown in table 4.
Table 4 - Table Clientes
Clientes - maintenance
To implement this maintenance in the application, basically alter the layers of the system, informing the new requirements and to be doing this, have been given the opportunity to observe the degree of effort required for its effectiveness, particularly with regard to user interface. This can be done, both in Character mode as in Web mode, running the option "Inclui E-mail em Clientes", as shown in Web mode, in Figures 13 to 17 :
Figure 13 - Inclui E-mail em Clientes - Web
Initially changes to the layer of access to data, entering the attribute email in "app-cadastro-cliente-dado.cpy". Below the layer concerning the business, which returns the value of editing and where the test include the new content of the e-mail, in the module "app-cadastro-cliente-negocio.cpy" as show in the Figure 14 :
Figure 14 - Change the Data and Business Modules - Web
Continuing, the call to the interface layer, in the "app-cadastro-cliente.cbl" add up the references necessary for the release of e-mail, including the name, size, value and prompt, as Figure 15:
Figure 15 - Change the Call Interface Module - Web
And finally, compiles only the application, because the Interface of two models, both the Character and the Web, automatically recognize the changes that were made, as can be seen in Figure 16.
Figure 16 - Compiles only the application "app-cadastro-cliente.cbl" - Web
Running the application "Cadastro de Clientes", Figure 17, there is the new E-mail attribute:
Figure 17 - Running the application "Cadastro de Clientes" with E-mail attribute - Web
Considerations on Methodology:
The adoption of standards in the System Development with Cobol resources, such as the use of layers, methods based on common interface and procedures for automatic generation, bring significant results, not only in the development phase, but also in the maintenance, in addition to providing a facilitating factor in their migration to the Web environment. Because its features, allows for simpler way the iterative process of development, a large volume of tests, the creation of a corporate culture in the operation of the interface, reducing training costs and allowing greater openness to adapt to new technologies that are present .The methodology used in the solution allows scalability, such as the use of new resources Cobol and other related to Web environment. It is possible for companies of all sizes, from small to large and can be adopted in its entirety, in part or in combination with other new technologies that are present.
Requirements of the system:
For its installation and implementation is not required special hardware equipment. Just who is an equipment that supports the installation of any Linux Server distribution or Windows Server 2003 or higher. This equipment will be used as a server, but can also be used as a workstation. In this distribution should be installed:
Linux:
-The graphical environment of Linux with Kde or Gnome.
-Apache, with folder to run Cgi released.
-The Bash prompt, to start Cobol programs.
-Micro Focus Cobol 4.0 or higher, with Runtime and Compiler.
-Web Browser Mozilla Firefox 3.0 or higher.
Windows:
-Apache, with folder to run Cgi released.
-The Bash prompt for Windows, to start Cobol programs, "bash-win.zip".
-Micro Focus Cobol Net Express 3.1 or higher, with Runtime and Compiler.
-Web Browser Mozilla Firefox 3.0, Internet Explorer 6.0 or higher.
List of itens:
Then the list of files which make up the compressed file "mfo.tar.gz":
Table 5 - Description of files
Installing, Compiling, Configuring and Running:
For details on installation, compilation, configuration and execution in modes Character and Web, see the file "app-before-start.txt" compressed in the file "mfo.tar.gz". In the case of Bash for Windows, see "install.txt" in "bash-win.zip".
Luiz Sérgio Araújo Morais - netmorais@ig.com.br