Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

I want to use the data in the called pgm in the call pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rsm_deepak

New User


Joined: 06 Apr 2005
Posts: 31
Location: visakhapatnam

PostPosted: Tue Jul 25, 2006 11:25 am    Post subject: I want to use the data in the called pgm in the call pgm
Reply with quote

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

mainframemouli

New User


Joined: 01 Mar 2005
Posts: 52
Location: Mysore

PostPosted: Tue Jul 25, 2006 11:46 am    Post subject: Re: I want to use the data in the called pgm in the call pgm
Reply with quote

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

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Tue Jul 25, 2006 11:57 am    Post subject: Re: I want to use the data in the called pgm in the call pgm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Paasing symbolic parameter to instrea... Anirudh Anand JCL & VSAM 1 Thu Jul 27, 2017 1:22 pm
No new posts Passing data from REXX to C programme... chong.zhou CLIST & REXX 3 Wed Jul 26, 2017 9:11 pm
No new posts copying data without knowing location arunsoods DFSORT/ICETOOL 11 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Could we identify the called modules ... elixir1986 COBOL Programming 5 Fri Jul 14, 2017 1:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us