To invoke a COBOL factory method or Java static method in a COBOL method or client program, code the class-name as the first operand of the INVOKE statement.
For example, a client program could invoke one of the overloaded CheckingAccount factory methods called createCheckingAccount to create a checking account with account number 777777 and an opening balance of $300 by coding this statement:
Invoke CheckingAccount "createCheckingAccount" using by value 777777 300 returning aCheckingAccount
To invoke a factory method from within the same class in which you define the factory method, you also use the class-name as the first operand in the INVOKE statement.
Code the name of the method to be invoked either as a literal or as an identifier whose value at run time is the method-name. The method-name must be an alphanumeric or national literal or a category alphabetic, alphanumeric, or national data item, and is interpreted in a case-sensitive manner.
If an invoked method is not supported in the class that you name in the INVOKE statement, a severity-3 Language Environment condition is raised at run time unless you code the ON EXCEPTION phrase in the INVOKE statement.
The conformance requirements for passing arguments to a COBOL factory method or Java static method in the USING phrase, and receiving a return value in the RETURNING phrase, are the same as those for invoking instance methods.
Example: defining a factory (with methods)
related tasks
Invoking methods (INVOKE)
Using national data (Unicode) in COBOL
Coding interoperable data types in COBOL and Java
related references
INVOKE statement (Enterprise COBOL Language Reference)