[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
A special characteristic of local subprograms is that the source file must start with a compiler directive: $SET NESTCALL, where the $ character must be placed in position 7. At the end of every program in the source file it is necessary to specify which program is being ended (scope rules).
- It has a LINKAGE SECTION immediately prior to the PROCEDURE DIVISION.
- The PROCEDURE DIVISION refers to parameters in the LINKAGE SECTION.
- It has instructions to return to the calling program.
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
$SET NESTCALL
*
identification division.
* ------ program identification.
program-id. subprog.
author. kik.
environment division.
* ------ program environment.
configuration section.
special-names.
console is crt
decimal-point is comma.
data division.
* ------ variable declarations .
working-storage section.
77 teller pic 9 comp.
procedure division.
* ------ executable instructions.
main section.
display space.
display "Hello world from main program"
line 1 position 30.
perform varying teller from 1 by 1
until teller > 3
call "ENTER" using teller
end-perform.
stop run.
end program subprog.
* See next page for the subprogram.
*
* A local COBOL program.
*
identification division.
program-id. enter initial.
environment division.
* ------ program environment.
configuration section.
special-names.
console is crt
decimal-point is comma.
data division.
working-storage section.
77 text-field pic x(10).
77 disp-line pic 99 comp.
linkage section.
01 tel pic 9 comp.
* Note: the data description must be identical
* with the description in the calling program.
procedure division using tel.
enter section.
The-begin.
display "In subprogram" line 5 position 10.
accept text-field line 10 position 10.
add 10, tel giving disp-line.
display text-field line disp-line position 10.
The-end.
goback.
[This chapter] [TOC] [Tutorial]