Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us