skip to main content

Procedure Division Statements : INVOKE

INVOKE
General Format
INVOKE {Identifier-1} {Method-name-1}
       {SELF        }
       {SUPER       }
  [ USING { [ BY {REFERENCE} ] { {Identifier-3} [ AS {Class-Name-1} ] } ... } ... ]
                 {CONTENT  }     {Literal-2   }      {native-type }
                 {VALUE    }     {OMITTED     } 
  [ {RETURNING} INTO Identifier-4 ] [ AS Class-Name-1 ]
    {GIVING   }
  [ ON {EXCEPTION} Imperative-Statement-1]
       {OVERFLOW }
  [ NOT ON {EXCEPTION} Imperative-Statement-2]
[END-INVOKE]
Alternate syntax
The same feature provided by the INVOKE statement can be obtained with the following alternate syntax:
[TRY]
   {Identifier-1}:>{Method-name-1} [({ [ BY {REFERENCE} ] { {Identifier-3} [ AS {Class-Name-1} ] } ... } ... )]
   {Class-name-1}                           {CONTENT  }     {Literal-2   }      {native-type }
   {SELF        }                           {VALUE    }     {OMITTED     }
   {SUPER       }                                           {NULL        }
[CATCH EXCEPTION Imperative-Statement-1]
[END-TRY]
Syntax rules
1.
2.
3.
4.
5.
A.
B.
C.
D.
E.
F.
6.
7.
8.
9.
10.
11.
12.
GIVING and RETURNING are synonymous.
13.
EXCEPTION and OVERFLOW are synonymous.
14.
BY REFERENCE, BY VALUE and BY CONTENT are supported only for standard COBOL variables and not for OBJECT REFERENCE items.
General rules
1.
2.
3.
 
NOTE - The first argument corresponds to the first formal parameter, the second to the second, and the nth to the nth.
 
4.
5.
6.
A.
B.
C.
D.
E.
7.
8.
9.
10.
Examples
Invoke methods of a Java Class to get System Information:
configuration section.
    class Sys as "java.lang.System".
working-storage section.
77  buffer      pic x(50).
procedure division.
    invoke Sys "getProperty" using "os.name" giving buffer.
    display "Operating System: " buffer.
    invoke Sys "getProperty" using "os.arch" giving buffer.
    display "OS Architecture: " buffer.
    invoke Sys "getProperty" using "java.version" giving buffer.
    display "Java Version: " buffer.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left