Wednesday 19 August 2015

Static call and Dynamic call

Static call:

  • It specifies sub-program as literal (in quotes).
      CALL 'PGM-NAME' USING DATA-ITEM1 DATA-ITEM2
  • Based on the above declaration, linker will link object code of sub prog to main prog.
  • Main program and sub program loads are available in the load module of main program.
  • It occupies more memory while loading into main memory because the load is huge.
  • Processing is fast because both the loads are available at the same time and there is no need to load separately.
  • If the sub program is modified, the main program needs to be recompiled to link again.
  • Compiler option is NODYNAM.

Dynamic call:


  • It specifies sub-program as working-storage field where we pass the program name.
       CALL WS-PGM-NAME USING DATA-ITEM1 DATA-ITEM2
  • Main program and sub program loads are available separately.
  • It occupies less memory while loading into main memory, hence load size is small.
  • Processing is slow because each module is loaded separately. First main load module will be loaded and when the sub program is called, then the main load module will be replaced with sub program load and again when control comes back to main program then again main module will be loaded.
  • If the sub program is modified, the main program do not need to be recompiled.
  • Compiler option is DYNAM.

CALL BY REFERENCE:


  • Same memory area will be used for parameters both main and sub program.
  • Main program shares the address of parameters to sub program.
  • Any changes done to the value in sub program will reflect in main program.
  • Applicable for both static and dynamic calls.
       Syntax : CALL 'pgm-name' USING BY REFERENCE var-1 var-2...

CALL BY CONTENT:


  • Main program shares the contents of parameter to sub program.
  • Any changes to the content in sub program will not reflect in main program as it is internal to sub program.
  • Applicable for both static and dynamic calls.
       Syntax : CALL 'pgm-name' USING BY CONTENT var-1 var-2

CALL BY VALUE :


  • Main program shares the value of parameter(or literal) to sub program.
  • Any changes to the value in sub program will not reflect in main program because sub program will have access to only temporary copy of the sending item.
  • Applicable for both static and dynamic calls.
       Syntax : CALL 'pgm-name' USING BY CONTENT var-1 var-2

No comments:

Post a Comment