PreviousCreating a Web Application Creating a Web Application from a COBOL ApplicationNext

Chapter 9: Completing and Running Your Web Application

In the previous session you used HTML Wizard and Form Designer to design a form, and Internet Application Wizard to generate a COBOL program. You now edit the COBOL program generated and add your business logic. You then run and debug the completed application, using your Web browser and the supplied Web server software, Solo. You run both on your own machine.


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


9.1 Overview

Internet Application Wizard generates a COBOL source program in a .cbl file, containing code to input and output the form. You then edit this .cbl file to add your business logic to process the data from the form and create data to be output. Of course, you can simply add CALL statements to call other programs, and so keep your business logic completely separate from this form-handling program.

9.2 Preparation

If you have closed Net Express, open it as before. If you have closed the project, open it as described in the chapter Start Here for the Tutorials. If you use Open, the project to open is Goform in the directory d:\Program Files\MERANT\Net Express\Base\Demo\Goform. By default the Open dialog box shows files of type .app, .cbl, and .cpy, so the file Goform should be visible.

If you have any Web server software running on your computer, other than Solo, close it. Otherwise you might have problems running Solo.

It doesn't matter whether you initially have your Web browser open.

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.

9.3 Sample Session

In this sample session you:

  1. Edit the COBOL Program
  2. Build the application
  3. Start Solo
  4. Run the Application
  5. Debug the Application

9.3.1 Editing the COBOL Program

You could use any text editor to add your business logic to the COBOL program. We will use the IDE.

  1. Double-click myprog.cbl in the project window.

    A text window opens with the source of the program. You may need to resize the window to see the source clearly. Look at Hide All Copyfiles on the View menu and ensure that the button-like icon beside it is shown depressed (if it isn't, click it).

    Take a few minutes to look through the Procedure Division and read the comments to see what it does.

  2. Click Hide All Copyfiles on the View menu.

    This turns off "Hide All Copyfiles" and so expands them. The copyfiles were generated by Internet Application Wizard together with the .cbl file.

    (Turning off "Hide All Copyfiles" affects only COPY statements that have previously been expanded using Copyfile on the File menu, or that were in the source when the program was previously compiled. The program was compiled when the project was built in the section Testing the Form in the previous session, so it expands them all.)

    Take a moment to look through the expanded copyfiles.

    The Convert-Input Section performs the Input-Conversion Section, which moves data from the data items associated with the form to the program's own work areas. Similarly, the Mypage-Cvt Section moves data to the data items associated with the form. Comments in the source tell you what is in each copyfile.

    Remember that this program uses the same form for both input and output. The two entry fields are called F-INPUT1 and F-INPUT2. You can see that on input the data entered in the two entry fields will be moved to INPUT1 and INPUT2, and on output the contents of INPUT1 and INPUT2 will be moved to the two entry fields.

  3. In the Process-Business-Logic Section, move the cursor to the blank line above the EXIT statement and press Enter to create an empty line. Move the cursor to column 12, above the "e" of EXIT, and insert:
    string "Hello " Input1 delimited by size into Input2

    In a real application you would probably put a call here to a subprogram to process data from the form and calculate or look up data to display.

  4. Close the text window. Click Yes on the message asking if you want to save the file.

9.3.2 Building the Application

To build the application:

  1. Click Rebuild All on the Project menu.

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

9.3.3 Running the Application

To run the application:

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

    Because this application uses only one form, the Start Animating dialog box shows the executable file as the place to start execution.

  2. Click OK on the Start Animating dialog box.

    This starts Solo and your Web browser, and then runs your program, just as if an end-user had clicked a link to the executable. Your program displays its form. The IDE is automatically minimized.

    If you have any problems getting Solo to run, restore the minimized IDE and 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 Enter Name field, type your name and click Submit Query.

    The program runs. It puts your name after the "Hello " in the Greeting field, then redisplays the form in your Web browser.

  4. Click in the Enter name field, replace your name with another name and click Submit Query.

    The program runs again, displaying "Hello " followed by the new name.

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

Note: When you run a GUI application, you might not be able to see its window because it is hidden behind the Net Express window. Click the application's button on the taskbar to bring it to the foreground.


9.3.4 Debugging the Application

To debug the application:

  1. Click Start Animating on Net Express's Animate menu.

  2. Click OK on the Start Animating dialog box.

    Your Web browser starts, and the source of myprog.cbl appears in the IDE, ready for debugging. Typically you want to run through the program once to display the form before you really start debugging.

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

    The IDE is minimized, then the program runs without animation and displays its form in your Web browser. The form is in its initial state (it replaces the one left from the previous section, which still has the output data in it).

    Run is the function used for running an application within the IDE. It is also used while debugging, to execute up to a breakpoint without animation. When debugging a server-side program, it treats reentering the program at the beginning as a breakpoint.

  4. In your Web browser, click in the Enter name field, type your name and click Submit Query.

    The minimized IDE is restored, with the source of myprog.cbl ready for debugging again.

  5. Use on the toolbar to step through myprog.cbl until you are about to execute the STOP RUN statement.

    The program is not very long - stepping through it will probably take you less than a minute. The Embedded HTML (the EXEC HTML statement) may take a few seconds to execute.

  6. Step the STOP RUN statement.

    The IDE is minimized and the completed Web form is displayed, with the Greeting field updated.

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

9.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.

PreviousCreating a Web Application Creating a Web Application from a COBOL ApplicationNext