ILE COBOL Programmer's Guide

Passing Data to an ILE CL Program or Procedure

You can pass data to a called ILE CL program or procedure by using CALL...BY REFERENCE or CALL...BY CONTENT. Refer to Passing Data Using CALL...BY REFERENCE, BY VALUE, or BY CONTENT for a description of how to use CALL...BY REFERENCE or CALL...BY CONTENT.

When data is passed to the ILE CL program using CALL...BY REFERENCE, a pointer to the data item is placed into the argument list that is accepted by the ILE CL program. When data is passed to the ILE CL program using CALL...BY CONTENT, the value of the data item is copied to a temporary location and then a pointer containing the address of the copy's temporary location is placed into the argument list that is accepted by the ILE CL program.

In your ILE COBOL program, you describe the arguments that you want to pass to the ILE CL program or procedure, in the Data Division in the same manner as you describe other data items in the Data Division. Refer to Passing and Sharing Data Between Programs for a description of how to describe the arguments that you want to pass.

In the called ILE CL program, you describe the parameters that you want to receive from the ILE COBOL program on the PARM parameter of the PGM statement. The order in which the receiving parameters are listed in the PARM parameter must the same as the order in which they are listed on the CALL statement in the ILE COBOL program. In addition to the position of the parameters, you must pay careful attention to their length and type. Parameters listed in the called ILE CL program must be declared as the same length and type as they are in the calling ILE COBOL program.

You use DCL statements to describe the receiving parameters in the called ILE CL program. The order of the DCL statements is not important. Only the order in which the parameters are specified on the PGM statement determines what variables are received. The following example shows how parameters are described in the called ILE CL program.

     PGM PARM(&P1 &P2);
     DCL VAR(&P1); TYPE(*CHAR) LEN(32)
     DCL VAR(&P2); TYPE(*DEC) LEN(15 5)
     .
     .
     .
     RETURN
     ENDPGM

Refer to the CL Programming for a description of how to describe parameters in an ILE CL program.

Data Type Compatibility between ILE CL and ILE COBOL

ILE CL and ILE COBOL have different data types. When you want to pass data between programs written in ILE CL and ILE COBOL, you must be aware of these differences. Some data types in ILE CL and ILE COBOL have no direct equivalent in the other language.

Table 19 shows the ILE COBOL data type compatibility with ILE CL.

Table 19. ILE COBOL Data Type Compatibility with ILE CL

ILE COBOL ILE CL Length Description
PIC X(n). TYPE(*CHAR) LEN(n) n A character field where n=1 to 32 766.
01 flag PIC 1.
88 flag-on VALUE B'1'.
88 flag-off VALUE B'0'.
TYPE(*LGL) 1 Holds '1' or '0'.
PIC S9(n-p)V9(p) COMP-3. TYPE(*DEC) LEN(n p) n/2+1 A packed decimal. Maximum value for n=15. Maximum value for p=9.
PIC S9(n-p)V9(p) PACKED-DECIMAL. TYPE(*DEC) LEN(n p) n/2+1 A packed decimal. Maximum value for n=15. Maximum value for p=9.
USAGE IS COMP-1 Not Supported. 4 A 4-byte internal floating-point.
USAGE IS COMP-2 Not Supported. 8 An 8-byte internal floating-point.


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