FUJITSU FS Logo
HomeMigrationsProductsServicesInformationNewsPartnersStudentPricingAbout Us
Quick Search  
spcer
 
DowloadSupport
Home > Support
Support Title   Support graphic
Support
Version 5 and 6
Support Status
Helpful Tips
Sample Programs
Version 4
Support Status
Helpful Tips
ODBC Compatibility
Release Notes 4.2
Sample Programs
Release Notes 4.0 only
Run Time Installers
Version 3
Support Status
Helpful Tips
Using ODBC
Programming Staff
Quick Start Tutorial
Sample Programs
Support FAQ's

Exercise 3:

Compile, Link, and Execute a COBOL Program


Discussion: This exercise shows the compilation, linking, and execution process using the Fujitsu COBOL 85 tools. The process is quite similar to the techniques used on mainframe computers but allows the use of a Windows Environment. The Fujitsu compiler requires linking as a separate step from compilation. By separating the linkage step, Fujitsu provides more flexibility in the use of subprograms and allows the programmer more control. This approach also allows the creation of fully executable files. The Fujitsu approach also allows the user to define the input and output files at execution time rather than having to hard code them in the program.


Step 3.1: Start Programming Staff

Open Programming Staff from the Start Menu. All of the work in the COBOL 85 is done from a program called Programming Staff (P-Staff). You can begin the program from the Start Menu in section called Fujitsu COBOL 3.0.


 

Image 125

Figure 3.1 Starting Programming Staff in Windows95.

Executing the program presents a blank window with menus. The File menu as shown in Figure 3.2 allows the user to open a previously developed source program or write a new one using the Editor. For this exercise, we will use an already written program.

Image 126

Figure 3.2 P-Staff Main Window with File Menu.

Step 3.2: Create or Retrieve a Source File

Normally you would have to create the file containing the COBOL program. We have, however, made life easier by including all of the illustrative COBOL programs and associated data files in a self-extracting file available from our Web Page. This discussion assumes that you have already downloaded those files to a diskette or your hard drive.

Clicking on the Open entry in the File Menu opens the Open Dialog Box. This dialog box is very similar to the Window95 Explorer. You will have to specify to the dialog box the exact folder containing the program you want. In this case, find the folder named "Chaptr02" on the diskette or the hard drive where you stored the programs.

Image 126a

Figure 3.3 Open Dialog Box.

You should see a listing of programs as specified above. The icons may not be as shown in Figure 3.3. The icon is not important, just be sure that the "Files of type" box reads Source Files as shown. Select the file named "Senior" and click the Open button.

The system may state that there are invalid numbers as shown in Figure 3.4. Simply click on the Yes button to renumber and go on to the program.

Image 127

Figure 3.4 Renumber Message.

Step 3.3: Retrieve a Source File

The Editor now opens the source file in a window like Figure 3.5. Notice the full path of the file is listed in the title line. The path for the input file is specified as part of the code. We will show how you can be more flexible in specifying files in later steps. The System Printer is also specified with a reserved word.

Image 128

Figure 3.5 Unmodified Source Listing.

Step 3.4: Modify the Program Files

Once the program has been entered, it is time to compile the program, but some preparation is necessary. First, close the Editor. On the Tools menu of the P-Staff window, select WINCOB. This option brings up the WINCOB dialog box shown in Figure 3.7. You will not see the program name, so you will need to click on Browse to again select the proper program. P-Staff will again bring up a window similar to Figure 3.3. You may need to change the folders in order to find the proper location of the Senior Program.

Image 129

Figure 3.6 Modified Source Code.

Step 3.5: Prepare to Compile

Once the program has been entered, it is time to compile the program, but some preparation is necessary. First, close the Editor. On the Tools menu of the P-Staff window, select WINCOB. This option brings up the WINCOB dialog box shown in Figure 3.7. You will not see the program name, so you will need to click on Browse to again select the proper program. P-Staff will again bring up a window similar to Figure 3.3. You may need to change the folders in order to find the proper location of the Senior Program.

Image 130

Figure 3.7 WINCOB Dialog Box.

Once you have found and opened the proper file, you will need to specify the program as a "Main" program. Later, you will learn how to combine programs and it is essential to know which program drives the process. Since you are just running one program, Senior is your Main program.

Click on the Options button, which brings up the Compiler Options Dialog Box. Now click on the Add button bringing up a list of compiler options. Both Boxes are shown in Figure 3.8. Type the letter "M"; this highlights the option "MAIN." Click Add to select this option.

Image 131

Figure 3.8 Compiler Options Dialog Box and Option List Box.

You will now be asked if the program should be compiled as a main program. As shown in Figure 3.9, choose main program and click OK. WINCOB returns you to the list of Options. Click on Cancel to exit the window. If you have done this procedure properly, the word MAIN should appear in the Compiler Options box. If not, you may see the word NOMAIN. In this case, highlight the work NOMAIN and click the Change button. Make sure that you have selected the "Compile program as main program" option and click OK. When the option is set correctly, click on Add. Now, you are ready to compile

Image 132

Figure 3.9 Set the Program as MAIN.

Step 3.6: Compile the Program

You are now back at the WINCOMP window as in Figure 3.7. Click OK to compile the program. You will see a window showing the progress of the compile and then an Editor window as in Figure 3.10.

This figure shows that the program has compiled successfully. Close the window; you are now ready to link the program.

Image 133

Figure 3.10 Compiler Message Window.

Step 3.7: Link the Program

After the program has compiled cleanly (that is, there are no compilation errors), you are ready to link the object program just created to produce the executable load module. From the P-Staff Window, select WINLINK from the tools menu. You will see the WINLINK dialog box shown in Figure 3.11. Be sure that EXE is selected.

Image 134

Figure 3.11 WINLINK Dialog Window.

You will need to click on Browse to find the proper file. This time, however, you will need to select a file called SENIOR.OBJ (the object program created by the compile). Once you have found it, click Add to add it to the List Box.

Figure 3.12 shows the results after adding the file. Adding the program to the list causes two things to happen. The name of the executable file is placed in the Target Area and the file is added to the list area. Notice that the target is SENIOR.EXE. The EXE extension means that this file is an executable program. Click on OK to link the file and exit WINLINK.

Image 135

Figure 3.12 Ready to Link.



You will then see a screen like Figure 3.13. Close this window and proceed on to executing the program.

Image 136

Figure 3.13 Linker Messages.

Step 3.8: Run the Program

Running the program can be quite simple. From the Tools Menu in P-Staff, select WINEXEC. This should bring up the WINEXEC dialog box as shown in Figure 3.14. The file name SENIOR.EXE should already be in the List Box. Click on the file name and it will be added to the Command Line Box.

Click on OK to run the program. Be sure your printer is on.

Image 137

Figure 3.14 WINEXEC Dialog Box.

WINEXEC will bring up a new dialog box that allows for additional flexibility in specifying files. For this exercise, you will not use the screen Figure 3.15. Click on OK to run the program.

Image 138

Figure 3.15 Environment Setup Dialog Box.

WINEXEC does not give any indication that it is running. You will see messages only if there is some problem. Thus, you will return to the P-Staff window and the program results should appear on your printer.


 © 2003 - 2008 Fujitsu Computer Systems Corporation. All Rights Reserved.