Calling and Sharing Data with Other Languages

ILE COBOL can call or be called by other ILE, OPM, and EPM languages.

This chapter describes:
  • How to call and pass data to another language from ILE COBOL
  • How control is returned to ILE COBOL from the other language
  • How to issue a CL command from an ILE COBOL program
  • How to include Structured Query Language (SQL) statements in your ILE COBOL program.
In general:
  • If your ILE COBOL program is calling another language, use a CALL statement with the USING phrase that points to the items that will constitute the parameter list. Control is returned to your program at the next statement after the CALL statement (unless the called program or any program called by it terminates the run unit).
  • If your ILE COBOL program is being called with parameters by another language, you need a USING phrase on the PROCEDURE DIVISION statement, and a Linkage Section that describes the parameters to be received. Your ILE COBOL program can return control to the calling program with a GOBACK statement or an EXIT PROGRAM statement.
  • Your ILE COBOL program can terminate the run unit with a STOP RUN statement or GOBACK statement provided that the nearest control boundary is a hard control boundary; the run unit will not be terminated if the nearest control boundary is a soft control boundary.

    For a full description of how to call an ILE COBOL program from another language, refer to that language's programming guide.

One consideration for you when passing or receiving data with non-ILE COBOL programs is the matching of the parameter lists. If your ILE COBOL program is calling a non-ILE COBOL program, you must understand what is expected in the way of input, and set up your data items accordingly. If your program is being called, you must know what will be passed, and set up your Linkage Section to accept it.

Another consideration for you is the treatment of the RETURN-CODE special register. The RETURN-CODE special register cannot be set by a non-ILE COBOL program. When the RETURN-CODE special register contains an incorrect value after control has been returned from a called program, set the RETURN-CODE special register to a meaningful value before your ILE COBOL program returns control to its caller. Otherwise, an incorrect return code will be passed back to its caller.