What are the ways for passing a variables? tell me all the possibilities please.

Questions by Suganj   answers by Suganj

Showing Answers 1 - 1 of 1 Answers

ranju

  • May 1st, 2007
 

Variables can be passed
1) by content
   The called program accesses and processes a copy of the variables from
calling program's storage and cannot change actual value of the variables
   in the caller's storage.


2) by reference
   The called program accesses and processes the variables in the calling
programs storage and so can change the value of the variable.


eg:
 CALLING PROGRAM
*************** 
 ID DIVISION.


 
 WORKING-STORAGE SECTION.
 77 l-subpgm-1 pic x(8) value ‘SUBPGM1’.
 01 l-parm1.
    05 l-name pic x(30).
    05 l-emp-no pic 9(4).
 01 l-parm2.
    05 l-salary pic s9(9)v99 comp-3.
    05 l-hra pic s9(9)v99 comp-3.
    05 l-leave pic s9(2)v9 comp-3.
 01 l-parm3.
    05 l-gross pic s9(9)v99 comp-3.
    05 l-deduct pic s9(9)v99 comp-3.
 PROCEDURE DIVISION.
  ....
    CALL l-SUBPGM1 USING
         BY CONTENT l-parm1 l-parm2
         BY REFERENCE l-parm3.


CALLED PROGRAM
************** 
 ID DIVISION.
 PROGRAM-ID. 1-SUBPGM1.
 …
 LINKAGE SECTION.
 01 L-parm3.
    05 l-gross pic s9(9)v99 comp-3.
    05 l-deduct pic s9(9)v99 comp-3.
 01 L-parm1.
    05 l-name pic x(30).
    05 l-emp-no pic 9(4).
 01 L-parm2.
    05 l-salary pic s9 (9) v99 comp-3.
    05 l-hra pic s9(9)v99 comp-3.
    05 l-leave pic s9(2)v9 comp-3.
 PROCEDURE DIVISION USING
 L-parm1 L-parm2 L-parm3

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions