Debugging PL/I ApplicationsNext"

Chapter 1: Overview of PL/I Option

This chapter describes the principal features of the Mainframe Express PL/I Option.

1.1 Introduction

PL/I Option lets you work with PL/I programs in Mainframe Express in a similar way to COBOL programs:

1.2 Using PL/I Option

The methods for working with PL/I programs are similar to those for COBOL programs.

When you install PL/I Option, the following changes are made to the IDE:

The output from the PL/I compiler and linker is displayed in the Mainframe Express Output window in the usual way. However, the VisualAge PL/I debugger uses its own windows, outside of the Mainframe Express IDE, to display debugging information and let you interact with the debugger.

More information on debugging is given in the chapter Debugging PL/I Applications and sample tutorial sessions are included in the chapters Getting Started with PL/I Applications and Getting Started with CICS and PL/I Applications. Also, comprehensive online help is available from the Help menu within the VisualAge PL/I debugger or from the Windows desktop by clicking Start>Programs>Micro Focus Mainframe Express 2.0>IBM VisualAge PLI Help.

1.3 Defining a PL/I Application

The following list summarizes the things you need to do when defining a project for a PL/I application:

  1. Create the project for a PL/I application, add modules to the project and create new modules in the same way as for any other application.

  2. When you have created the project, make sure that Project uses PL/I is checked on the PL/I page on the Project Settings dialog box. If all PL/I and Assembler modules in the application uses 31-bit addressing, make sure that Project only uses AMODE 31 load modules is also checked on the PL/I page. If some modules use 24-bit addressing, you need to specify this individually on the Build Settings dialog box. For more information see the section Addressing Modes later in this chapter.

  3. You can set the default build settings for all PL/I modules in the application on the PL/I page of the Build Settings for Project dialog box or the Build Settings for PL/I dialog box. You can then override these settings for individual modules on the Build Settings for module dialog box.

  4. On the General page of the PL/I page of the Build Settings dialog box:

    • Specify the PL/I dialect or language level used in your PL/I modules.

    • Specify the system environment that you want Mainframe Express to emulate when you run the application. MVS means TSO and JCL. You can also select IMS or CICS.

    • Specify the lowest level of message that you want the PL/I compiler to report.

    • Specify the maximum number of messages to be reported by the compiler. If this number is exceeded, the compiler terminates.

    • Specify the syntax used for INCLUDE statements in the source code.

    • Specify whether you want the compiler to generate optimized code; for example, to improve the performance of a debugged module.

    • Specify whether you want the compiler to generate debug information. If you don't select this option, you won't be able to use the PL/I debugger.

    The compiler directives for the build settings that you have selected with the controls described above are shown in a field on the dialog box. You can also specify explicitly any other compiler directives you want that are not set by these controls.

  5. On the Link page of the PL/I page of the Build Settings dialog box:

    • Specify whether you want the module to be linked automatically after compilation. You can specify this for the main source module if a single load module is to be created from one or more source modules in the project. Alternatively, if you have compiled two or more source modules separately and want to link them into a single load module for execution, you will need to include them in a .lin module and use the PL/I linker to link the object modules.

    • If you specify automatic linking and you need to specify the AMODE, you can also do this on the Link page.

  6. On the Preproc page of the PL/I page of the Build Settings dialog box:

    • Select any preprocessors that you want to use during compilation. The choices you have here depend on which Mainframe Express options are installed and what you specified when you created the project or in the Project Settings dialog box.

    • If you select the EXEC CICS preprocessor, you can request that a source deck is generated.

    • If you select the EXEC SQL preprocessor, you can specify SQL preprocessor directives. The choice of directives depends on whether you are using SQL Option for DB2 or Host Compatibility Option.

    • If you select the macro preprocessor, you can request that a source deck is generated and that the macro source and cross-reference table are included in the listing file.

  7. On the Listing page of the PL/I page of the Build Settings dialog box, specify whether you want the compiler to produce a listing file and the contents of that file. The listing file is saved in a Listing output folder, under Output Libraries in the Workgroup View.

  8. If you did not specify automatic linking on the PL/I page, you need to use the PL/I linker after compilation. So, on the Linker page of the Build Settings dialog box:

    • Specify PL/I as the language.

    • Specify whether you want the linker to generate debug information. If you don't select this option, you won't be able to use the PL/I debugger.

    • Specify any other options you require.

  9. Build the modules in the usual way to make them ready for debugging. When you build or rebuild a project that contains PL/I programs, Mainframe Express builds the modules in the following order:

    1. IMS DBD
    2. CICS BMS
    3. Assembler - not autolinked
    4. Assembler - autolinked
    5. COBOL
    6. IMS MFS
    7. IMS PSB
    8. JCL
    9. PL/I - not autolinked
    10. PL/I - autolinked
    11. Linker

  10. When you are ready to debug the PL/I application, click Start Debugging on the Debug menu. On the Start Debugging dialog box, make sure that Enable PL/I debugging is checked. If you don't check this check box, the PL/I debugger will not be invoked.

1.4 PL/I Sample Applications

The following list shows the sample applications that are supplied with PL/I Option. For each application, a readme.txt file is supplied which describes how to create a project and execute the applications.

Application
Summary
PLIBATCH The PLIBATCH application demonstrates the use of mixed-language programming and I/O operations with a shared DB2 subsystem.

The Readme file is in folder \mfuser\projects\demo\plibatch.

The source files are in folder \mfuser\projects\demo\plibatch\source.

The data files are in folder \mfuser\projects\demo\plibatch\data.

PLICICS The PLICICS application demonstrates an online CICS application written in PL/I.

The Readme file is in folder \mfuser\projects\demo\plicics.

The source files are in folder \mfuser\projects\demo\plicics\source.

The data files are in folder \mfuser\projects\demo\plicics\data.

PLIIMS The PLIIMS application demonstrates an online IMS application written in PL/I and performing SQL calls.

The Readme file is in folder \mfuser\projects\demo\pliims.

The source files are in folder \mfuser\projects\demo\pliims\source.

The data files are in folder \mfuser\projects\demo\pliims\data.

1.5 Mixed-language Applications

You can mix PL/I, COBOL and Assembler programs in a single application. Mainframe Express supports this for PL/I .dll modules, COBOL .int (intermediate) and .gnt (optimized) modules, and Assembler .390 modules. It does not support the linking of PL/I and COBOL programs in the same .dll module.

When one module in a mixed-language application calls another, Mainframe Express looks for the module to load in a specific order:

  1. COBOL (.gnt or .int)
  2. Assembler (.390)
  3. PL/I (.dll)

This takes care of the situation where, for example, there is an Assembler module and a PL/I module of the same name: Mainframe Express finds and loads the Assembler module first.

If you enable PL/I debugging in a mixed PL/I and COBOL application, only COBOL .int modules are debuggable; COBOL .gnt modules are run at full speed without being debugged.

For more information about mixed PL/I and Assembler applications, see the section Using PL/I with Assembler Option later in this chapter.

1.6 Addressing Modes

As with COBOL and Assembler programs, an addressing mode (AMODE) can be defined for each PL/I load module. This is done at link time.

PL/I uses a different method for representing mainframe addresses than COBOL and Assembler. This can cause a problem if a pointer is passed as a parameter between a PL/I program and COBOL or Assembler program. You can avoid this problem in either of two ways:

Mainframe Express automatically manages the passing of pointers between PL/I and the system environment, such as CICS and IMS.

1.7 Pointer Conversion

You need to use the PL/I pointer-conversion functions supplied with Mainframe Express if not all programs in the application use 31-bit addressing mode (AMODE 31) and a pointer is passed as a parameter between a PL/I program and a COBOL or Assembler program. These functions are supplied in a macro file that you can include in your PL/I source modules. It is named idapconv.inc in the \mfe\source folder.

You do not need to change your PL/I source modules to remove these functions before you recompile the modules on the mainframe. The functions are treated as null operations on the mainframe.

The VisualAge PL/I pointer format is known as the DFT (default) type. The Mainframe Express pointer format is known as the MFPM (Mainframe Pointer Manager) type. The two functions for pointer conversion are:

You can use them as PL/I function references in the usual way, as shown in the following examples.

1.8 MVS Control Blocks

The MVS control blocks emulated by Mainframe Express are described in the chapter MVS Control Blocks in your IDE Technical Guide.

Mainframe Express supplies bilingual macros for Assembler and PL/I to define the MVS control blocks. They are located in the folder \mfe\source. The macros have the same name as the control blocks and have the .mac file extension. They describe the key problem program state fields. Only fields that are supported are named in the macros; the others are defined as "fillers".

1.8.1 Low-memory Address Emulation in PL/I

The MVS control blocks are located from the Communications Vector Table (CVT) which is located from the Prefixed Save Area (PSA) which starts at byte 0. On the mainframe, the PSA can be addressed directly. On the PC, a protection exception is raised if a PL/I application uses a pointer with a value of zero. To avoid this, you should use the idalpsa macro to locate the PSA. This macro sets a given pointer to the address of the PSA. It operates correctly on both PC and System/390 hardware.

The idalpsa macro is contained in the idalpsa.inc file that is supplied with Mainframe Express in the folder \mfe\source. Include this file after the first PROCEDURE statement or after the PACKAGE statement and check Macros on the Preproc page of the PL/I page of the Build Settings dialog box.

You can invoke the idalpsa macro as a PL/I function. For example:

some_pointer = idalpsa(some_pointer);

sets some_pointer to the address of the PSA.

1.8.2 Sample Projects

The following list shows the sample projects that are supplied with Mainframe Express to illustrate how to access the MVS control blocks in a PL/I program. For each project, a readme.txt file is supplied which describes how to create the project and run it.

Project
Summary
CTLBLKP The CTLBLKP project contains a PL/I program which calls an Assembler routine to extract information from the MVS control blocks.

The Readme file is in folder \mfuser\projects\demo\ctlblkp.

The source files are in folder \mfuser\projects\demo\ctlblkp\source.

CTLPLI The CTLPLI project contains a PL/I program which uses the idalpsa macro to locate the PSA and then extracts information from the MVS control blocks.

The Readme file is in folder \mfuser\projects\demo\ctlpli.

The source files are in folder \mfuser\projects\demo\ctlpli\source.

1.9 Entry Point Mapping

For PL/I programs, all entry points are automatically known to the Entry Point Mapping facility after the program is linked. Thus, unlike COBOL and Assembler programs, you do not need to specify any entry points explicitly.

Like Assembler, you can use the ALIAS command to create an alias Entry Point Mapping entry automatically during the static link process for a load module.

For more information, see the section Entry Point Mapping for COBOL and Assembler Programs in the chapter Compatibility with the Mainframe Environment in your User's Guide.

1.10 Language Environment Support

Mainframe Express emulates a subset of Language Environment (LE) for PL/I as well as COBOL. For full information on the support provided, see the chapter Language Environment (LE) Support chapter in your IDE Technical Guide.

1.11 Using PL/I with Assembler Option

The chapter Compiling and Linking Assembler Modules in the Assembler Option Technical Guide provides a full description of how modules can be linked together, including the difference between static linking (which takes place at build time) and dynamic linking (which takes place at run time). The following section contains information that you need to consider when using PL/I and Assembler modules in the same application.

1.11.1 Assembler Modules that call PL/I Modules

You cannot statically link Assembler modules with PL/I modules in one executable program. However, there are two methods of dynamically linking to PL/I modules:

1.11.2 Link File INCLUDE Command

You need an INCLUDE command in your link (.lin) file for each PL/I module that you want to be linked with the main module to produce one .390 file. The INCLUDE command is documented in full in the online help; click Help Topics on the Mainframe Express Help menu, then on the Contents tab click Reference, Assembler Option, Link File Commands. With PL/I Option installed, the TYPE parameter can take the value PLI, indicating that you want to include a PL/I object module (.pli)

1.11.3 LOAD Assembler Macro

The LOAD Assembler macro is documented in full in the online help; click Help Topics on the Mainframe Express Help menu, then on the Contents tab click Reference, Assembler Option, Macro Instructions. With PL/I Option installed, the stub Assembler macro (that is generated if the LOAD macro cannot locate an Assembler module) can load and link to a PL/I module. If a PL/I module is to be loaded, the LOAD macro loads the stub Assembler module below the 16 MB line; the stub Assembler module then loads the PL/I module above or below the line, depending on its AMODE setting.

1.12 Using PL/I with CICS Option

CICS Option supports IBM mainframe PL/I application programs in conjunction with PL/I Option. You should be aware of the following PL/I-specific information when running these programs on the PC:

1.13 Using PL/I with SQL Option for DB2

SQL Option for DB2 supports IBM mainframe PL/I application programs in conjunction with PL/I Option. You should be aware of the following PL/I-specific information when running these programs on the PC.

1.13.1 Declaration Generator

You can use the Declaration Generator utility to create the PL/I definition for an SQL table in a similar way to creating a COBOL definition. The utility generates an EXEC SQL DECLARE statement and a PL/I structure in a copybook (.inc) file.

For full information on how to use the Declaration Generator, see the Declaration Generator Online Reference.

You can run the utility in batch or interactive mode. If you want to use batch mode to create a PL/I definition, specify -lpli as the language option. If you want to use interactive mode to create a PL/I definition, perform the following steps:

  1. Click SQL For DB2>Declaration Generator on the Tools menu to see the Declaration Generator dialog box.

  2. Specify Location, AuthID and Table Name to identify the table for which you want to create a copybook.

  3. In the Language group box, click PL/I.

  4. If you want to change the name of the file to which the copybook is written, type a new name in the Output File field. The Declaration Generator automatically places a default name based on the table name in this field.

    If you specify a file that already exists, you will be given the choice of appending to it or replacing it when you click Generate later.

    If you don't specify a path, the copybook is written to ProjectFolder\COPYLIB.

  5. If you want to change the name of the PL/I structure that is generated by the Declaration Generator, type a new name in the Structure Name field.

  6. If you want to add a prefix to the name of each field in the structure, type the prefix in the Field Prefix box. You can end the prefix with a special character such as an underscore (_) to separate it from the rest of the name. If you specify a prefix then, by default, a sequence number is assigned to the rest of each field name (as indicated by the Numbered radio button). For example, if you specify a prefix of EMP_ , field names are generated as shown below:
     /*  PL/I DECLARATION FOR TABLE TUTORIAL.EMPLOYEE  */
     DECLARE
       1   DCLEMPLOYEE,
           5 EMP_001 BIN FIXED(15),
           5 EMP_002 CHAR(10),
           5 EMP_003 CHAR(10);

    If you specify a field prefix and want to use the actual field names instead of numbers for the variable part of each name, select the Text radio button. Then, for example, the fields in the above structure could be generated as:

           5 EMP_E_NO  BIN FIXED(15),
           5 EMP_LNAME CHAR(10),
           5 EMP_FNAME CHAR(10);

    Remember to take into account PL/I variable-naming rules when assigning a prefix. Do not assign a prefix containing characters that are not supported by the compiler or that make the field name too long.

    If you do not specify a field prefix, the above example would be generated as:

           5 E_NO  BIN FIXED(15),
           5 LNAME CHAR(10),
           5 FNAME CHAR(10);
  7. If you want to change the default level number of 5 for the fields in the structure, click Options and specify the number in Level. For example, if you specify 3, the above example would be generated as:
           3 E_NO  BIN FIXED(15),
           3 LNAME CHAR(10),
           3 FNAME CHAR(10);
  8. If you want to generate an indicator array at the end the structure, click Options and check Generate Indicator Variables. In the above example, with three fields, this generates:
    DCL IEMPLOYEE(3) BIN FIXED(15);
  9. Click OK to close the 'PL/I' Declaration Options dialog box.

  10. If you want to save your specifications in a .dge file, which can be used as input to the Declaration Generator in batch mode, click Save As, specify a file name and click OK.

  11. To generate the PL/I copybook file, click Generate.

1.13.2 SQL Communications Area

The structure of the SQL communications area (SQLCA) is defined below. It must be included in every PL/I program that contains embedded SQL.

 DECLARE
      1 SQLCA,
        2 SQLCAID CHAR(8)
        2 SQLCABC FIXED(31) BINARY,
        2 SQLCODE FIXED(31) BINARY,
        2 SQLERRM CHAR(70) VAR,
        2 SQLERRP CHAR(8),
        2 SQLERRD(6) FIXED(31) BINARY,
        2 SQLWARN,
          3 SQLWARN0 CHAR(1),
          3 SQLWARN1 CHAR(1),
          3 SQLWARN2 CHAR(1),
          3 SQLWARN3 CHAR(1),
          3 SQLWARN4 CHAR(1),
          3 SQLWARN5 CHAR(1),
          3 SQLWARN6 CHAR(1),
          3 SQLWARN7 CHAR(1),
       2 SQLEXT,
         3 SQLWARN8 CHAR(1),
         3 SQLWARN9 CHAR(1),
         3 SQLWARNA CHAR(1),
         3 SQLSTATE CHAR(5);

1.13.3 SQL Descriptor Area

The structure of the SQL descriptor area (SQLDA) is shown below. It should be included by all PL/I programs that use dynamic SQL.

 DECLARE
      1 SQLDA BASED(SQLDAPTR),
        2 SQLDAID CHAR(8),
        2 SQLDABC FIXED(31) BINARY,
        2 SQLN    FIXED(15) BINARY,
        2 SQLD    FIXED(15) BINARY,
        2 SQLVAR(SQLSIZE) REFER(SQLN)),
          3 SQLTYPE FIXED(15) BINARY,
          3 SQLLEN  FIXED(15) BINARY,
          3 SQLDATA POINTER,
          3 SQLIND  POINTER,
          3 SQLNAME CHAR(30) VAR;
  DECLARE SQLSIZE FIXED(15) BINARY;
  DECLARE SQLDAPTR POINTER;

1.14 Using PL/I with Host Compatibility Option

Host Compatibility Option supports IBM mainframe PL/I application programs in conjunction with PL/I Option. You should be aware of the following PL/I-specific information when running these programs on the PC:

1.15 Using PL/I with IMS Option

IMS Option supports IBM mainframe PL/I application programs in conjunction with PL/I Option. You should be aware of the following PL/I-specific information when running these programs on the PC:

1.15.1 PL/I Address List Format

There are two PCB address list formats for PSBs which specify LANG=PL/I. These are direct addressing and indirect addressing.

The PCB address list format applies only to main programs. It is specified under PCB address list format for LANG=PL/I on the General page of IMS System properties. This is found by right-clicking IMS System on the IMS View and clicking Properties. There are two fields, one for when the main program is PL/I and one for when the main program is not PL/I. The second field is available only when indirect addressing is specified for the first.

PSBs that don't specify LANG=PL/I are not affected by these settings and always result in a direct PCB address list.

1.16 Filtering PL/I Compiler Messages

Each time a PL/I compiler message is generated, the PL/I compiler can invoke the user exit program IBMUEXIT. This exit is controlled by the EXIT compiler directive and is set on by default.

You can use IBMUEXIT to suppress a compiler message or to change its severity. The changes made by the exit take effect before the message limit specified in the Stop after field on the General page of the PL/I page on the Build Settings dialog box (or by the FLAG directive) is evaluated.

Full information about IBMUEXIT and the IBM-supplied modules is given in the section Using User Exits in the IBM VisualAge PL/I Programming Guide. Several modules to support IBMUEXIT are supplied with PL/I Option in the folder \mfe\mfpli\source:

If you want to disable IBMUEXIT, specify the NOEXIT compiler directive in the Additional directives field on the General page of the PL/I page of the Build Settings dialog box.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

Debugging PL/I ApplicationsNext"