The following example shows how you might make dynamic calls that use CALL identifier.
The first program, dl1.cbl, uses CALL identifier to call the second program, dl1a.cbl.
* Simple dynamic call to dl1a
Identification Division.
Program-id. dl1.
*
Environment Division.
Configuration Section.
Input-Output Section.
File-control.
*
Data Division.
File Section.
Working-storage Section.
01 var pic x(10).
Linkage Section.
*
Procedure Division.
move "Dl1A" to var.
display "Calling " var.
call var.
move "dl1a " to var.
display "Calling " var.
call var.
stop run.
End program dl1.
* Called by dl1.cbl using CALL identifier.
IDENTIFICATION DIVISION.
PROGRAM-ID. dl1a.
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
OBJECT-COMPUTER. ANY-THING.
*
DATA DIVISION.
WORKING-STORAGE SECTION.
77 num pic 9(4) binary value is zero.
*
PROCEDURE DIVISION.
LA-START.
display "COBOL DL1A function." upon console.
add 11 to num.
display "num = " num
goback.
To create and run the example above, do these steps:
Unless you compile using the PGMNAME(MIXED) option, executable program-names are changed to uppercase.
Because the CALL identifier target must match the name of the called program, the executable module in the above example is generated as DL1A, not as dl1a.
related references
PGMNAME