Internal subroutine Identification Division. Program-id. Proc-a. Environment Division. ... Data Division. ... identification Division. Program-id. Proc-b. Environment Division. ... Data Division ... Procedure Division. ... End Protive Division. Program-id. Proc-c. Environment Division ... data division. ... ide Division. ... identification division. -Id. Proc-d. ... process Division. ... End Program Proc-d. End Program Proc-c. End Program Proc-a. Program A contains B, C A subroutine, where C is also included in the subroutine D. A can call B, C. C can call D. B cannot be called C, which cannot call D. If C is declared as a common, then b can call C, the syntax: program-id. Proc-c is comMMon Program.
The variables defined in the current function are only valid for the current function. You can declare all functions to all functions. 01 Data-Name Is Golbal ... file also has this statement: fd file-name is golbal ...
If the call is not a file or variable in this program, you can declare this. FD File-Name Is External ... / 01 Data-Name IS External ...
Call proc var1 [on exception code1] end-call. If you can't find the Proc program name, execute Code1 (if you have this declaration), find the parameter var1 to Proc, and execute. When the Proc returns, executes CODE2 (if there is this declaration). The parameters should be defined in the file, work storage, or connection section, should be a 01 layer data item, a 77-layer data item or a basic data item. The subroutine wants to return to the call, execute the exit program
Transfer parameters have 3 steps: First list the parameters to pass on the calling program of the call. Call Proc Var1. Then list the corresponding parameters using the USING phrase on the process of the process part of the called program. Procedure Division Using Var1. Finally, the storage section is provided in the calling section. LINKAGE Section. 01 Var1 Pic XX.
Parameter passes There is 2 mode: by Content Parametric value is changed only in the called function, and the value in the call function is constant. By Reference. Parametric values of passed are changed in the called function, and the values in the call function also change. Call proc var1 by content / reference. The subroutine is called, and the subroutine is at the last exited state (except for data in the connection section), the open file is still open. You can use the initial declaration function to be called in the initial state. Program-id. Proc-c is initial program.
If you don't want to initialize each time, you can initialize the Proc program with Cancel Proc, but do not perform Proc.