ILE COBOL Programmer's Guide


Calling EPM Languages

Programs written in EPM languages such as EPM C/400(R), Pascal, and FORTRAN can be called from an ILE COBOL program through a CALL to QPXXCALL.

In the following example, an ILE COBOL program uses QPXXCALL to call a Pascal procedure.

Figure 76. Calling a Pascal procedure from an ILE COBOL program.


5722WDS V5R3M0 030905 LN  IBM ILE COBOL                 CBLGUIDE/COBTOPAS        ISERIES1   03/09/15 13:38:36        Page      2
                                     S o u r c e
  STMT PL SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN  S COPYNAME   CHG DATE
     1     000100 IDENTIFICATION DIVISION.
     2     000200 PROGRAM-ID. COBTOPAS.
     3     000300 ENVIRONMENT DIVISION.
     4     000400 CONFIGURATION SECTION.
     5     000500   SOURCE-COMPUTER. IBM-ISERIES
     6     000600   OBJECT-COMPUTER. IBM-ISERIES
     7     000700 DATA DIVISION.
     8     000800 WORKING-STORAGE SECTION.
     9     000900 01  PARAMETER-LIST.
    10     001000     05  ENTRY-NAME   PIC X(100)         VALUE "SQUARE".
    11     001100     05  ENTRY-ID     PIC X(10)          VALUE "*MAIN".
    12     001200     05  PROG-NAME    PIC X(20)          VALUE "MATH".
    13     001300     05  A-REAL       PIC S9(9)  COMP-4  VALUE 0.
    14     001400     05  CLEAN        PIC S9(9)  COMP-4  VALUE 0.
    15     001500     05  INPT         PIC S99            VALUE 0.
    16     001600 PROCEDURE DIVISION.
           001700 MAINLINE.
    17     001800     DISPLAY "ENTER AREA NUMBER:".
    18     001900     ACCEPT INPT.
    19     002000     MOVE INPT TO A-REAL.
    20     002100     CALL "QPXXCALL" USING ENTRY-NAME
           002200                           ENTRY-ID
           002300                           PROG-NAME
           002400                           A-REAL.
    21     002500     DISPLAY A-REAL.
    22     002600     CALL "QPXXDLTE" USING CLEAN.
    23     002700     STOP RUN.
           002800
                           * * * * *   E N D   O F   S O U R C E   * * * * *

Figure 77. Pascal entry-point that is to be called from an ILE COBOL program.


    segment MATH;
    procedure SQUARE ( var X : integer ) ; external ;
    procedure SQUARE;
       begin
       X := X * X
    end; .

Pascal allows an ILE COBOL program to call a Pascal procedure as a subprogram. To do this, specify the Pascal procedure with the EXTERNAL directive (see Figure 77). In the above example, the first invocation the ENTRY-ID parameter of QPXXCALL will establish a Pascal Main Environment. You can use QPXXDLTE to clean up Pascal Reentrant and Main Environments. Passing zero in the CLEAN parameter to QPXXDLTE causes the current Pascal Main Environment to be deleted.

You can call an ILE COBOL program from an EPM program by using the same call semantics as you would for calling another EPM program.

External data cannot be shared between EPM programs and ILE COBOL programs.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]