IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

STATIC & DYNAMIC Call in the same Program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
narendraprasadyadav

New User


Joined: 13 Mar 2005
Posts: 2

PostPosted: Sun Mar 13, 2005 6:00 pm
Reply with quote

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
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1210
Location: India

PostPosted: Sun Mar 13, 2005 8:55 pm
Reply with quote

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
View user's profile Send private message
brahmanandareddy

New User


Joined: 16 Dec 2004
Posts: 44
Location: Hyderabad

PostPosted: Mon Mar 14, 2005 10:29 am
Reply with quote

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
View user's profile Send private message
mainframemouli

New User


Joined: 01 Mar 2005
Posts: 52
Location: Mysore

PostPosted: Mon Mar 14, 2005 12:36 pm
Reply with quote

This is dynamic call

Quote:
CALL PGM-NAME USING RECORD-1.


This is static

Quote:
CALL "SUBPROG2" USING RECORD-2
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Mon Mar 14, 2005 2:33 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top