View previous topic :: View next topic
|
Author |
Message |
narendraprasadyadav
New User
Joined: 13 Mar 2005 Posts: 2
|
|
|
|
hi,
this is naren.
i hav one cobol program from this i want to call two sub programs a & b
one dynamically and other static canu pls tell me how can i do this |
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
Static and dynamic CALL statements can both be specified in the same program. In the Static CALL the subprogram invoked being link-edited with the main program into one load module. The Dynamic CALL statement results in the dynamic invocation of a separate load module.
When a dynamic CALL statement and a static CALL statement to the same
subprogram are issued within one program, a second copy of the subprogram is loaded into storage. Because this doesn't guarantee that the subprogram will be left in its last-used state, results may be unpredictable.
Example:
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 PGM-NAME PIC X(8).
01 RECORD-2 PIC X.
01 RECORD-1.
05 PAY PIC S9(5)V99.
05 HOURLY-RATE PIC S9V99.
05 HOURS PIC S99V9.
PROCEDURE DIVISION.
MOVE "SUBPROG1" TO PGM-NAME.
CALL PGM-NAME USING RECORD-1.
CANCEL PGM-NAME.
CALL "SUBPROG2" USING RECORD-2.
STOP RUN. |
|
|
Back to top |
|
|
brahmanandareddy
New User
Joined: 16 Dec 2004 Posts: 44 Location: Hyderabad
|
|
|
|
Hi mcmillan,
Can u tell me which prog is called dynamically and which prog is called statically in the above prog...I am little bit confused.
Thank You,
Brahmananda Reddy. K. |
|
Back to top |
|
|
mainframemouli
New User
Joined: 01 Mar 2005 Posts: 52 Location: Mysore
|
|
|
|
This is dynamic call
Quote: |
CALL PGM-NAME USING RECORD-1. |
This is static
Quote: |
CALL "SUBPROG2" USING RECORD-2 |
|
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
it all depends upon the compiler option i guess..if you won't give any compiler option then all call will be dynamic whichever you use.Where as you can specify the static call while compiling the program. SYSLMOD contains the load module of a program. so while compiling you program if you provide the object module of both the program and then link it then it will be a static call otherwise if you link independently the load module of the called program is taken at run time then it will be dynamic call. |
|
Back to top |
|
|
|