|Completing and Running Your Web Application||Creating a Web Database 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.
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.
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.
In this sample session you:
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:
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.
In the lower part of the dialog box, COBOL Source File is selected by default.
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.
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.
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.
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.
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.
There's no need to change the entry under Control Type, because the default, Edit, is what we want.
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.
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.
The page that now appears shows a summary of what you have selected.
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.
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.
To build the application:
Net Express compiles the programs, and builds the executable file. Wait until the message "Rebuild Complete" appears in the Output window before continuing.
To run the application:
Because this application uses separate input and output forms, the Start Animating dialog box shows the input form as the place to start execution.
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.
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.
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.
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.
|Completing and Running Your Web Application||Creating a Web Database Application|