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 6:

Using Environmental Variables to Specify Files

Discussion: In this Exercise, you will see how you can customize the input and output files used by a program at Execution time. This ability to customize means that you do not have to specify a particular file name in a program as you are writing it. You can use a file identifier as an alias for the actual file. Only when you actually run the program do you have to give the actual file name.

IBM mainframe programs use a similar process. One of the purposes of the Job Control Language (JCL) is to specify the runtime file names. P-Staff does not use JCL, but can accomplish the same effect using Environmental Variables.

You may remember that when you run WINEXEC or WINSVD an Environmental Variables window appears. In other exercises, you simply clicked on OK and continued. In this exercise, you will learn how to use that window.


 

Step 6.1: Enter File Identifiers into the Program

In order to use environmental variables, all hard-coded file names in a program need to be replaced with file descriptors. Use the Editor to open Senor.Cbl in Chaptr02.

Image 157a

Figure 6.1 Senior Program with Hard-Coded File Names.

Change the ASSIGN statement in line 80 to read ASSIGN TO INFILE. You have now replaced the file name with a file identifier.

Close the Editor and save the new version of the file.

Image 157b

Figure 6.2 Program with File Identifier.

Step 6.2: Compile and Link the Program

Following the Steps in Exercise 3, compile and link the program as usual. Use WINCOB to compile the program. Make sure that the compile option MAIN is specified. You do not have to have the TEST option on.

Link the file in WINLINK. There are no special options needed to link the program.

Now, you are ready to execute the program.

Step 6.3: Set Environmental Variables

From P-Staff, select WINEXEC and find the executable program Senior.

Image 158

Figure 6.3 WINEXEC Window Ready to Execute Senior.

Click on OK to bring up the Environment window.

Step 6.4: Enter the Environmental Variables and Run the Program

The next window is the Runtime Environment Setup window where you enter the environmental variables. Enter "INFILE=SENIOR.DAT" into the Environmental Variables Information box and click Set.

Image 159

Figure 6.4 Runtime Environment Setup Dialog Box.

At this point, the Runtime Environment dialog box should look like this:

Image 160

Figure 6.5 INFILE Variable Added to Environment Variable List.

You can save the variable if you choose. If you do not save the variable, you will have to reenter it each time you execute the program. If the file name should change, you can correct the variable at any time.

Click OK to run the program as before. There should not be any difference in running the program. If you receive any messages, make sure your spelling of the Environmental Variable is correct.


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