If you pass arguments to a method, specify the arguments in the USING phrase of the INVOKE statement. Code the data type of each argument so that it conforms to the type of the corresponding formal parameter in the intended target method.
| Programming language of the target method | Is the argument an object reference? | Then code the DATA DIVISION definition of the argument as: | Restriction |
|---|---|---|---|
| COBOL | No | The same as the definition of the corresponding formal parameter | |
| Java | No | Interoperable with the corresponding Java parameter | |
| COBOL or Java | Yes | An object reference that is typed to the same class as the corresponding parameter in the target method | In a COBOL client (unlike in a Java client), the class of an argument cannot be a subclass of the class of the corresponding parameter. |
See the example referenced below for a way to make an object-reference argument conform to the type of a corresponding formal parameter by using the SET statement or the REDEFINES clause.
Example: passing conforming object-reference arguments from a COBOL client
If the target method is overloaded, the data types of the arguments are used to select from among the methods that have the same name.
You must specify that the arguments are passed BY VALUE. In other words, the arguments are not affected by any change to the corresponding formal parameters in the invoked method.
The data type of each argument must be one of the types that are interoperable with Java.
related tasks
PROCEDURE DIVISION for defining a class instance method
Overloading an instance method
Coding interoperable data types in COBOL and Java
Passing data
related references
INVOKE statement
(COBOL for Windows Language Reference)
SET statement
(COBOL for Windows Language Reference)
REDEFINES clause
(COBOL for Windows Language Reference)