|Creating a Web Application from a COBOL Application
|Creating a Windows GUI Application
You use Internet Application Wizard to create a Web interface to an existing database.
You need to have read the chapter Start Here for the Tutorials, worked through the first session Using NetExpress, and read the chapter Introduction to Web Applications, before you do this session.
You use Internet Application Wizard to create forms and server-side programs so you can access an existing database via the Web.
The database must have been created with a database system for which Open Database Connectivity (ODBC) support is available. This includes most major databases, such as Oracle, Sybase, Informix, DB2, Microsoft SQL (pronounced "sequel") Server, and Microsoft Access.
Using Internet Application Wizard you don't need to do any form design or programming yourself. The Wizard looks at the database structure and creates the forms and server-side programs for you. You just set some options about what kinds of operation are allowed.
The application generated can both query and - if you choose this option - update the database. You can still use your original database tool to query and update the database too.
NetExpress includes several sample databases, including a Microsoft Access database containing details of a wholesaler's customers. The customers are retail outlets. In this session, you create a Web application to query and update this database.
The database is accessed via the data source name (DSN) NetExpress Sample2, which represents the sample Microsoft Access database d:\NetExpress\Base\Demo\SMPLDATA\access\sample.mdb. (For details of ODBC and how DSN's are assigned, see the help for your ODBC Administrator, accessible via the Control Panel on your Windows desktop.)
In this session, when talking about the database we will keep to database terminology and use the terms row and column. We will use the corresponding terms record and field when data is displayed in the forms on the Web browser.
If you have closed NetExpress, open it as before. If any project window or text 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 NetExpress, but if you go straight ahead and create the application NetExpress 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.
The page that now appears lists the data sources on your computer. At the right are a number of tabs. Make sure the Query tab is at the front. (It should be, as it's the default.)
The list expands to show the tables in this database.
The list expands to show the columns in the table called Customer.
A SQL (pronounced "sequel") SELECT statement is generated and displayed on the right. SQL is a language for querying databases. NetExpress includes a feature called OpenESQL, a compiler preprocessor that enables SQL to be included in COBOL source. You don't need to know SQL to use the Internet Application Wizard, as the Wizard generates it for you.
The statement is not yet complete. It will be completed in the next step, and then used as the basis for the SQL statements included in the COBOL source program that the Internet Application Wizard generates.
Checkmarks appear by all the column names, and the statement in the Query field is completed. This statement will cause all columns from the Customer table to be displayed.
Although you are creating this query for inclusion in a COBOL program, you can run it now, interactively, as follows.
The Results tab comes to the front, displaying all the columns from all the rows in the Customer table.
The SQL statements being generated for inclusion in the source program are equivalent to this one, but they also handle selection criteria that can be specified at run time by the user, to select which rows - that is, which customers' details - will be displayed. These statements will cause data from the table to be read into the program's Working-Storage Section, from where other COBOL statements will move them to the Web form.
This dialog box is also used by another facility in NetExpress, the OpenESQL Assistant. You use this facility to create SQL queries either to run interactively or to include in a COBOL source program that you write yourself.
To learn how to create more complex queries than the one we've just created, after finishing this book you should read the tutorial on the OpenESQL Assistant in the online book Database Access.
On the page that now appears you specify what Web forms you want your application to have.
Cross-platform specifies the method NetExpress 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. Remember your forms will be seen by users with different browsers. We will accept this default.
There are two standard forms. The single-record view (also known as simply "record view") form displays the data from one row of the table; in our case, one customer's details. The table view form displays the data from several rows, in a tabular layout. We will accept the default, which is to have both forms.
On the page that now appears you specify whether your user can only query the database, or can update it too. We will accept the default, which is to let the user update it.
The page that now appears shows a summary of what you have selected.
The Internet Application Wizard generates the forms and programs, 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. The 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 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 retailform.htm or retaillist.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 programs that the Wizard generated.
To build the application:
NetExpress saves and compiles the programs, and builds the executable files. Wait until the message "Rebuild Complete" appears in the Output window before continuing.
To run the application:
This starts Solo and your Web browser, and then runs the program Retailform. The program displays its form, the single-record view form retailform.htm. The IDE is automatically minimized.
Initially, the form shows the customer details from the first row in the table, the one with CustID = ALWAO.
Depending on the font size in your Web browser, you may not always see all five characters of the Customer ID in the record view form. For example, ALWAO may appear as ALWA, or MERRG as MERR. You will see the full Customer ID if you scroll the CustID field sideways by clicking in it and using the left and right arrow keys.
The table view form retaillist.htm is loaded into the browser. It shows the first ten customers in the table, ALWAO through CONSH.
The single-record view form retailform.htm is loaded again.
Both the forms have standard controls for moving backward and forward through the table. The record view form retailform.htm also has functions for updating and querying the table. Some of these are optional when you are creating the forms - we accepted all the defaults to have them all included.
In this section we'll try out some of these standard controls. Make sure you still have the single-record view form displayed. The Order By field has defaulted to CustID. This causes rows from the table to appear in the order of CustID.
You may need to make your Web browser full screen to see the displayed forms properly.
The form shows the next customer in the table, the one with CustID = ANDRC.
The table view form is loaded, showing ten customers starting from ANDRC.
The form shows the end of the table, that is, the last ten customers TOPOF through WITAE.
The form is redisplayed, but it has not changed. In table view, if you try to go beyond the end of the table, you don't move.
The form shows the beginning of the table, that is, the first ten customers ALWAO through CONSH.
The form shows the next ten customers EASTC through HANOP.
The record view is loaded, showing the customer EASTC.
The form shows the last customer in the table, WITAE.
The form shows the first customer in the table, ALWAO. In record view, if you try to go beyond the end of the table, you go back to the start of the table.
The form shows the first customer whose CustID is alphabetically greater than or equal to what you put in the CustID field. It is customer BERGS.
The table view is loaded, showing ten customers starting from BERGS
The single-record form appears showing customer EASTC.
In creating the application, we accepted the default, which is to let the user update the database. You use the single-record view form to insert, delete, or update records.
The record is redisplayed.
The table view is loaded again, and you can see that the database has been updated with the change you made.
You can use the fields at the top of the record view form to filter out records you don't want to see, and to specify which field you want records ordered on.
To display only customers in Canada, displaying them in order of city:
The record view form appears. You could now click Clear Screen to clear the customer data fields before setting the filter, but it's not necessary - only the fields you specify will be looked at anyway.
The form shows the first (in order of city) customer in the table who is in Canada. This is MERRG, in East Vancouver.
The Filter By field has automatically changed to "(existing)". This ensures that in the next few steps (until you change this field) the set of rows already selected will be used - these steps just change the position in the table, they don't set a new filter.
The form shows the first (in city order) Canadian customer in a city whose name is greater than or equal to "T". This is BOTTM, in Tsawassen.
The table view form is loaded. It now displays, in city order, Canadian customers from the one in Tsawassen onward. There are three of them.
Now let's set a new filter. To do this you will change the Filter By field from "(existing)" to a field-name again.
The form shows the first (in city order) UK customer, ISLAT in Hedge End.
The table view form is loaded. It now displays, in city order, the first ten UK customers.
Now let's get the full table back, and get it in order of Customer ID again.
The form is redisplayed showing the first (in order of Customer ID) customer in the table.
The table view form is loaded showing the first ten customers. You've got the full table displayed again, in order of Customer ID.
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 NetExpress 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 © 1998 Micro Focus Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
|Creating a Web Application from a COBOL Application
|Creating a Windows GUI Application