IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rsm_deepak

New User


Joined: 06 Apr 2005
Posts: 30
Location: visakhapatnam

PostPosted: Tue Jul 25, 2006 11:25 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 1
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top