View previous topic :: View next topic
|
Author |
Message |
rsm_deepak
New User
Joined: 06 Apr 2005 Posts: 30 Location: visakhapatnam
|
|
|
|
1) Call the sub pgm.
2) Read and store the data in the sub pgm..
3) Pass the control to main pgm.
4) Read the data which is stored in the sub pgm....
Can I know how to declare the Variables in the Data division in both Main and Sub Pgms
i.e., how the importance of linkage section will be in both of the pgms. |
|
Back to top |
|
|
mainframemouli
New User
Joined: 01 Mar 2005 Posts: 52 Location: Mysore
|
|
|
|
Passing the variable from main to sub program
------------------------------------------------------
1. Declare the variables u need to manipulate in the main program Working storage section.
01 ws-interface-records
-inc copybook1
( It may be a copybook , that contains the variables to be passed )
2. call 'sub-program' using copybook1
3. declare the copybook in the Called program ( ie ) sub-program Linkage section
Lk section
01 lk-interface-records
-inc copybook1
3. In the sub-program
Procedure division using copybook1
4. manipulate the variables in the called sub-program.
5. Check the return code for the sub-program call in the main program. |
|
Back to top |
|
|
Aji
New User
Joined: 03 Feb 2006 Posts: 53 Location: Mumbai
|
|
|
|
hi
Please go thrpugh the code given below.
working-storage section.
01 a pic 99 value 0.
01 b pic 99 value 0.
01 tot pic 999 value 0.
procedure division.
p1.
accept a.
accept b.
call "addtwo" using a b tot.
cancel "addtwo".
display tot.
stop run.
ADDTWO.cbl
working-storage section.
linkage section.
01 a pic 99.
01 b pic 99.
01 tot pic 999.
procedure division using a b tot.
p1.
compute tot = a + b.
exit program.
Here the value of a and b are passed from first program to ADDTWO.cbl
and computation is done and TOT is retured to the called program and displayed there. If you have any doubts in the above code pls revert back.
Regards
Aji Cherian |
|
Back to top |
|
|
|