C H A P T E R 5 |
Compiling COBOL and PL/I Programs and Assembling Maps |
You can use the Development System Compilation Menu to compile COBOL and PL/I programs and to assemble BMS maps.
This chapter contains the following topics:
On the Development System Compilation Menu, you can select files to edit or compile or set Copylib directories. FIGURE 5-1 shows the functions available from the Compilation Menu.
The Compilation menu shown in FIGURE 5-2 is similar to the standard file selection screen in Sun MTP.
|
Press PF4 on the Development System main menu.
The two display criteria fields at the top of the screen are:
Descriptions of the file information fields are located in TABLE 2-2.
|
1. Move the cursor to the selection field to the left of the file name and type an uppercase or lowercase S beside the file name.
2. Press the function key for the action you want to perform.
The following table describes the function keys on the Compilation Menu.
Executes the kixed shell script, which opens the selected file, by default, in the vi editor. If you select multiple files, the last file selected is edited first and the first file selected is edited last. The kixed script is invoked automatically for each file. |
|
Closes the Compilation Menu and returns to the Development System main menu. |
|
Refreshes the data in the file list portion of the screen. After you modify a file's attributes, press PF4 to update the screen. |
|
Displays the Copylib Settings screen. See COBOL Copylib Settings. |
|
Displays an options screen, depending on the file selected: .clt, .cbl or .cl2 files: Displays the Set Compiler Options screen for COBOL. See Compiling COBOL Programs. pl2, .pl1, .pli or .ppl files: Displays the Set Compiler Options screen for PL/I. See Compiling Online PL/I Programs. .bms files: Displays the Set Assembler Options Screen. See Assembling BMS Maps. |
|
Displays the previous page of files. If the top of the file list is displayed, this message is displayed: |
|
Displays the next page of files. If the bottom of the file list is displayed, this message is displayed: |
|
Redisplays the contents of the directory, sorted by file name. |
|
Redisplays the contents of the directory, sorted in descending sequence by the file modification date. |
|
Redisplays the contents of the directory, sorted in descending sequence by the file size. |
|
No action takes place unless a file is selected. If a file is selected, either the Compiler or the Assembler screen is displayed, depending on the file extension. If a directory is selected, the directory changes to the selected directory and the files in that directory are displayed. |
The Copylib Settings screen enables you to set a maximum of eight directories that are searched for copybooks referenced in the COBOL source code. Directories are searched in the following order:
2. Directories defined on the Copylib Settings screen
3. Directories defined by the COBCPY environment variable
Refer to the COBOL documentation for information about the COBCPY environment variable.
|
Press PF5 on the Compilation menu.
The screen (FIGURE 5-3) contains eight fields to enter directories that contain the copybooks. The first element in the directory name can be an environment variable, designated with a dollar sign ($). The environment variable can be followed by other subdirectories separated by slashes (/).
The Copylib settings, as well as other user-specific options, are maintained in the file $KIXSYS/user-name.tbl, where user-name is the user's login name. The options are saved from session to session.
You can set COBOL compiler options and compile your programs either from the Compilation Menu or from the command line.
To compile batch programs using the command line interface, see Chapter 15.
The Set Compiler Options screen for COBOL enables you to customize the actions of the compiler.
1. Select a COBOL program file on the Compilation menu (FIGURE 5-2).
2. Press PF6 to display the Set Compiler Options screen.
Modify the screen values if you need to.
Some compiler options and directives are set automatically based on the extension of the selected file. You set others by modifying the default values on the screen.
The following options and directives for online programs are set based on the file extension:
.clt: -v ibmcomp perform-type=osvs defaultbyte=0 cics
.cl2: -v ibmcomp perform-type=osvs defaultbyte=0
The following options and directives for batch programs are set based on the file extension:
.cbl: -v ibmcomp perform-type=osvs defaultbyte=32
Note - Do not try to compile translated online programs with .cbl extensions. |
The options and directives on the Set Compiler Options screen for COBOL are listed in the following table with the corresponding COBOL directive. Refer to your COBOL documentation for more information about using COBOL directives.
The options and directives you set on the Set Compiler Options screen, as well as other user-specific directives, are saved in a file called $KIXSYS/user-name.tbl, where user-name is the user's login name. These directives are saved from session to session.
You can set other directives in the $COBDIR/cobopt file. You can also change the default COBOL directives by modifying the $UNIKIX/bin/kixcob shell script.
Press PF4 on the Set Compiler Options screen to execute the kixcob shell script, which calls the COBOL compiler.
If .clt or .cl2 programs are selected, they are translated and compiled. If .cbl programs are selected, they are compiled, but not translated. If multiple files were selected, the files are compiled in reverse order; the last file selected is compiled first.
When compiling is complete, the editor displays the results of the compile and translation in the default editor (vi).
Before you can compile an online program using the command-line interface, you must process it using the kixclt translator. After the program is translated successfully, you can compile it. When compiling programs, you usually use a set of directives on a regular basis. These directives vary according to the type of COBOL (OS/VS, COBOL2) programs being compiled. Some of these directives are required by Sun MTP to ensure that the programs compile properly. Refer to your COBOL documentation for a description of the compiler options and directives.
kixclt is the Sun MTP Common Language Translator. It locates and includes all copy files before translating CICS COBOL statements to COBOL statements. Therefore, you must set the COBCPY environment variable before running kixclt. $COBCPY points to the location of your COBOL copybooks, mapset copybooks (if any), and to the Sun MTP copybook directory. For example:
To translate an OS/VS COBOL program named myprog.clt and produce an output file named myprog.cbl, type the following command:
If errors occur during translation, you must correct the program and translate it again.
Refer to the Sun Mainframe Transaction Processing Software Reference Guide for a description of kixclt and its options.
Use the following directives to compile online COBOL2 programs. Refer to the COBOL documentation for other compiler options you might require.
Use the following directives to compile online OS/VS COBOL programs. Refer to the COBOL documentation for other compiler options you might require.
You can type directives on the command line or you can specify the name of a file containing a list of directives.
Example: The following command to compile a COBOL2 program contains all its directives and four options (-iaPV) on the command line.
$ cob -C 'arithmetic"osvs"' -C 'defaultbyte"0"' -C ibmcomp -C nocics -C notrunc -C vsc2 -iaPV myprog.cbl |
Example: The following command to compile an OS/VS COBOL program contains its directives in a file named cobopts, and four options (-iaPV) on the command line.
You can also create shell scripts to compile a single program or all the programs in one directory.
The following example illustrates a script for compiling one program. The COBOPT environment variable must be set to the appropriate directives file.
for source do echo ---$source cob -iaPV $source if [ $? -ne 0 ] then echo "Error in compilation of: " $source exit fi done |
CODE EXAMPLE 5-2 illustrates a script that translates and compiles all online programs in a directory. The script also captures log files indicating an error or successful completion. Programs are compiled only after successful translation.
The $UNIKIX/test/primer/cobol directory contains a shell script build_ACCT.sh, which builds the sample accounting application. You can use it as a model to build your own scripts.
As an alternative to using script files, you can use a makefile to compile COBOL programs. The advantage of using a makefile is that it can selectively compile only those programs whose source has changed.
Note - Before using a makefile, you must understand the concepts of the make function. |
The following code example illustrates a makefile that translates and compiles COBOL programs whose source code has changed since the last time the makefile was executed.
You must compile your COBOL programs for execution in .gnt mode for a production system. The .gnt files are native code and execute faster than .int code.
In a test environment, if you want to use Micro Focus Animator, refer to the Micro Focus documentation for the appropriate options.
The Set Compiler Options screen for PL/I shown in FIGURE 5-5 enables you to customize the actions of the Open PL/I compiler.
|
1. Select a PL/I program file on the Compilation menu (FIGURE 5-2).
The following compiler options are set automatically based on the extension of the selected file.
Open PL/I with EXEC CICS commands and database (Oracle) commands. |
Note - Do not mix Liant Open PL/I filename extensions with COBOL filename extensions in a single set of selections. If you do, the error message Illegal file extension for compile is displayed. |
Other options are set by modifying the default values on the screen. The options on the Set Compiler Options screen for PL/I are listed in the following table with the corresponding Liant Open PL/I options. Refer to the Open PL/I User's Guide for more information.
Allows CodeWatch to debug EXEC CICS precompiler-generated code |
These options plus other user-specific options are maintained in a file called $KIXSYS/user-name.tbl, where user-name is the user's login name. The options are saved from session to session.
|
Press PF4 on the Set Compiler Options screen.
This executes the kixpl1 shell script, which calls the Liant Open PL/I compiler, the Oracle pre-compiler (.ppl extension), or the preprocessing translator, depending on the filename extension of the source file. If multiple files are selected, the files are compiled in reverse order; the last file selected is compiled first.
When the compilation completes, the results of the compile and translation are displayed in the default editor (vi).
You can set BMS Assembler options and assemble your BMS maps either from the Compilation Menu or from the command line.
The Set Assembler Options screen enables you to customize the BMS assembler's actions.
1. Select a file with a .bms extension on the Compilation menu (FIGURE 5-2).
Edit the following values on the screen:
Press PF4 on the Set Assembler Options screen.
This executes the kixasm shell script, which calls the BMS assembler, kixbms. If multiple files are selected, the files are assembled in reverse order; the last file selected is assembled first.
After each file is assembled, the default editor (vi) displays the results of the assembly.
Use the kixbms command to assemble BMS maps. You can specify one or more files with .bms extensions to assemble; kixbms creates map files with .map extensions.
Example: Type the following command at the command prompt to assemble a BMS map named mymap.bms and produce a copy member for inclusion in the programs. The output is a file named mymap.map.
See Chapter 9 for more information about managing maps and refer to the Sun Mainframe Transaction Processing Software Reference Guide for a description of all the kixbms options.
Copyright © 2004, Sun Microsystems, Inc. All rights reserved.