PreviousCompleting and Running Your Web Application Creating a Web Database ApplicationNext

Chapter 10: Creating a Web Application from a COBOL Application

You use Internet Application Wizard to convert an existing COBOL application into a Web application.


You need to have read the chapter Start Here for the Tutorials, worked through the first session Using Net Express, and read the chapter Introduction to Web Applications, before you do this session.


10.1 Overview

You use Internet Application Wizard to generate forms and a COBOL program to handle them, from the Linkage Section of an existing COBOL program. The form-handling program and the original program together are your server-side program.

The existing COBOL program could be a legacy program, or you could have written it as the first step in creating this new application.

The existing program needs to be a subprogram, in which the data for the user interface is defined in the Linkage Section. Typically, it is a file-handling or database-handling program, and in the existing application the screen handling was done by another program which called this program, passing it user queries and getting back answers. In the new Web-based application the generated forms and program take the place of that original screen-handling program.

Internet Application Wizard is not suitable for converting a Windows GUI application into a Web application. The chapter Introduction in the online book Migration Cookbook discusses this task.

In this session you start with an existing COBOL subprogram, acctopen.cbl, which accesses account data held in a COBOL indexed file. When your converted application runs, your end-user sees an HTML form with one field. The end-user types in an account number and clicks Submit Query, and is returned a form showing the name of the sales representative handling the account and details of the most recent order on that account. The application looks this up in the data files acctsasc.vsm and acctsasc.idx in d:\Program Files\MERANT\Net Express\Base\Demo\Formx.

10.2 Preparation

If you have closed Net Express, open it as before. If any project window or other windows are open, close them.

It doesn't matter whether you initially have your Web browser and/or Solo running.

If you're reading this book in your Web browser, you should start a new instance of your browser (use the New function on its File menu) so that you can still see the book during this chapter.

10.3 Sample Session

In this sample session you:

  1. Create the project, forms, and program
  2. Add field properties
  3. Build the application
  4. Run the application

10.3.1 Creating the Project, Forms and Program

You could start by creating a project in the way described in the chapter Using Net Express, but if you go straight ahead and create the application Net Express will give you an opportunity to create the project. To create the application:

  1. Click New on the File menu, then select Internet Application on the New dialog box and click OK.

    The first page of the Internet Application Wizard appears. On this page you choose which of the three methods of creating an application, as described in the chapter Introduction to Web Applications, you wish to use.

  2. Select Full Application (HTML Client and Server Program).

    In the lower part of the dialog box, COBOL Source File is selected by default.

  3. Click Next.

  4. Click Yes on the message asking if you want to create a project.

  5. Make sure Empty Project is selected (it's the default, so it should be). Enter Account as the name of the project, and d:Net Express\Base\Demo\Formx as the folder to contain the project, then click Create.

    This folder was created when Net Express was installed, and the COBOL program acctopen.cbl supplied for this tutorial was installed in it. If this session has been run previously, you will be asked whether to overwrite the existing project. Click Yes.

    The page that now appears enables you to specify the existing program you are generating the form and form-handling program from.

  6. Set the Source Program field by clicking Browse and double-clicking acctopen.cbl, then click Next.

  7. Click Separate Input/Output Forms, and accept the default Cross-platform (table output), then click Next.

    Cross-platform specifies the method Net Express uses to ensure objects in your positional form are positioned as you wish. Cross-platform forms use HTML tables for this. In Dynamic HTML, style attributes are used. HTML Tables are supported by more browsers. Dynamic HTML offers more exact positioning, but is only supported by Internet Explorer 4.0 and later. Remember your forms will be seen by users with different browsers.

    The page that now appears shows the files that will be created. Two are the HTML forms for entering data and displaying results; the other is the COBOL program to handle the forms and call Acctopen.

  8. Click Next.

10.3.2 Adding Field Properties

The page that now appears shows the data items in your original program, and on the right-hand side the corresponding fields on the forms that will be generated. Initially only the top-level item is shown.

  1. Click "+" by LS-OLD-MF-REC, and then click the "+" by OMF-ORDER.

    The tree view expands to show all the items subordinate to ls-old-mf-rec, as shown in Figure 10-1.



    Figure 10-1: Data items and their Corresponding Fields

    The left-hand pane shows the data items declared in the Linkage Section of acctopen.cbl. The right-hand pane shows the corresponding fields that will be on the forms that Internet Application Wizard will generate. The Label Name column shows the labels that will appear by the fields. These have been set to the data-names from the declarations. You now replace these by more user-friendly labels, and set other properties.

  2. In the right-hand pane, click OMF-ACCTNO in the Label Name field and type Account instead. Press Enter.

    There's no need to change the entry under Control Type, because the default, Edit, is what we want. It specifies that this data item will be represented by a text entry field on the form.

    There's no need to change the entry under I/O, because the default, Both, is what we want. It specifies that this data item both receives input from and sends data to the application's form(s). Since this is an asymmetric application (having separate input and output forms), this means the corresponding field will appear on both the input and the output forms.

  3. In the right-hand pane, click OMF-SALESREP in the Label Name field and type Representative instead. Press Enter.

    There's no need to change the entry under Control Type, because the default, Edit, is what we want.

  4. Click the I/O field for OMF-SALESREP (now Representative), and select Out from the dropdown list.

    This specifies that this data item sends data to the application's form(s). Since this is an asymmetric application, this means the corresponding field will appear only on the output form.

  5. Right-click OMF-ORDER in the left-hand pane, then click Out on the popup menu.

    Setting a property of a group field in this way affects its subordinate items. The I/O column in the right-hand pane changes to show this property on these items.

  6. Click Next.

    The page that now appears shows a summary of what you have selected.

  7. Click Finish.

    The Internet Application Wizard generates the forms and program, and finishes. The names of the generated files are added to the project, then the project is scanned for dependencies. Internet Application Wizard then closes.

10.3.3 Files Created

You have now created your user interface. Internet Application Wizard has created the following files for you and added them to the project (you may have to expand the tree view in the project view by clicking the "+" signs to see them all):

The following files are shown in the right-hand pane only:

It has also added your original program acctopen.cbl to the project.

It has also added to the project the following object files, created when you build the project:

It has also created several copyfiles (extensions .cp*). Their purpose is described in comments in the .cbl file.

Although the filenames are shown above in lower case, some might appear in upper case in the project. Filenames are not case sensitive.

If you ever want to update the forms, you simply double-click on acctopen_input.htm or acctopen_output.htm in the project window, and Form Designer opens. When you save the updated form, the copyfiles are regenerated, so you should not edit them directly.You can however edit the .cbl program that the Wizard generated.

10.3.4 Building the Application

To build the application:

  1. Click Rebuild All on the Project menu.

    Net Express compiles the programs, and builds the executable file. Wait until the message "Rebuild Complete" appears in the Output window before continuing.

10.3.5 Running the Application

To run the application:

  1. Click Run on Net Express's Animate menu.

    Because this application uses separate input and output forms, the Start Animating dialog box shows the input form as the place to start execution.

  2. Click OK on the Start Animating dialog box.

    This starts Solo and your Web browser, and then loads your input form acctopen_input.htm into the browser, just as if an end-user had clicked a link to it.

    If you have any problems getting Solo to run, click Help Topics on Net Express's Help menu, then look up "Solo Troubleshooter" in the help index.

  3. In your Web browser, click in the Account Number field, type "A1", and click Submit Form. (This application is case-sensitive, so type "A1", not "a1".)

    The IDE is automatically minimized, and the program runs. It puts the name of the sales representative for account "A1" and details of the most recent order on that account into the output form, and displays the form in your Web browser.

  4. Try other numbers between "A1" and "A9" in the Account Number field.

    The file has records for accounts from A1 to A9. The existing program acctopen.cbl includes code such that if you try some other number, such as B1, you get "Not found" in the Representative field.

  5. Restore the minimized IDE, and click Stop Animating on Net Express's Animate menu.

10.4 Before Continuing

Close the project.

Close Solo, by right-clicking on the Solo icon in the taskbar tray and clicking Exit on the popup menu.

If you opened a second instance of your Web browser to display the forms, close it.

If you're planning to go straight on to another session, you can keep Net Express open.

Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousCompleting and Running Your Web Application Creating a Web Database ApplicationNext