skip to main content

Procedure Division Statements : CALL

CALL
General Format
Format 1
CALL {CLIENT} Program-Name
  [ HANDLE IN Handle-1 ] 
  [ USING { [ BY {REFERENCE} ] { {Parameter} } ... } ... ]
                 {CONTENT  }     {OMITTED  }
                 {VALUE    }     
  [ {RETURNING} INTO Return-Val ]
    {GIVING   }
  [ ON {EXCEPTION} Statement-1]
       {OVERFLOW }
  [ NOT ON {EXCEPTION} Statement-2]
  [END-CALL]
Format 2
CALL RUN Program-Name
  [ USING { [ BY {REFERENCE} ] { {Parameter} } ... } ... ]
                 {CONTENT  }     {OMITTED  }
                 {VALUE    }     
  [ {RETURNING} INTO Return-Val ]
    {GIVING   }
  [ ON {EXCEPTION} Statement-1]
       {OVERFLOW }
  [ NOT ON {EXCEPTION} Statement-2]
  [END-CALL]
Format 3
CALL PROGRAM Program-Name
  [ USING { [ BY {REFERENCE} ] { {Parameter} } ... } ... ]
                 {CONTENT  }     {OMITTED  }
                 {VALUE    }     
  [ {RETURNING} INTO Return-Val ]
    {GIVING   }
  [ ON {EXCEPTION} Statement-1]
       {OVERFLOW }
  [ NOT ON {EXCEPTION} Statement-2]
  [END-CALL]
Syntax Rules
All Formats
1.
2.
3.
4.
Formats 1 and 2
5.
General Rules
All Formats
1.
2.
 
NOTE - The first argument corresponds to the first formal parameter, the second to the second, and the nth to the nth.
3.
4.
A.
B.
5.
6.
A.
ii.
B.
7.
8.
9.
10.
11.
12.
The program identified by Program-Name is searched among the paths specified by the iscobol.code_prefix setting. If the code-prefix is not set, then the program is searched in the Classpath.
13.
Extensions in Program-Name are automatically stripped by the runtime.
14.
Paths in Program-Name are resolved only if the program is searched in the code-prefix.
Format 1
1.
A.
B.
C.
D.
E.
F.
the runtime decorates the subroutine name in a shared library name (e.g. foo may become foo.dll or libfoo.so, depending on the O.S.) and tries to load it. If the library is successfully loaded, then the runtime looks for a function with the same name (foo), otherwise
G.
2.
When a program is called asynchronously, it’s good practice to pass parameters BY VALUE. Passing parameters BY REFERENCE may produce unexpected results.
When a program is called asynchronously, the runtime looks for it only locally ignoring iscobol.remote.code_prefix.
3.
4.
CALL "/lib/foo.a(member.o)"
5.
CALL "foo.dll/0"
Use the following syntax to load a DLL library with PASCAL convention:
CALL "foo.dll/1"
The choosen convention will be adopted by the runtime when calling the functions stored in the loaded DLL library, regardless of the iscobol.dll_convention setting.
Format 2
1.
2.
Format 3
1.
CALL PROGRAM works as the CHAIN statement. It causes the current run unit to terminate and initiates a new run unit, but in this case USING parameters are passed to data items specified in the Linkage Section.
Recursive calls
A program may directly or indirectly call itself. Such a CALL statement is considered a recursive call. By default, isCOBOL shares the program data with all recursive calls. Set iscobol.recursion_data_global (boolean) * to false in order to make isCOBOL create a new copy of data for each instance of the program.
Examples
Format 1 - Call a program passing parameters, receiving return code and validating exception.
call "program1" using parm-1 parm-2
  giving ret-code
  on exception display message "Could not call program1"
Format 1- Call a program on a different thread to run it in parallel with calling program saving the thread handle in p1-handle.
working-storage section.
77 p1-handle  usage handle of thread.
procedure division.
  call thread "program1" handle in p1-handle
Format 1 - Call a program client side when running from thin-client
call client "program1"
Format 2 - Call a program and run it in parallel with current one (on different thread).
call run "program1"
Format 3 - Call a program terminating the current run unit and starting a new one
call program "program1"

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