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

Passing value To a Called Pgm.


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

New User


Joined: 14 Sep 2005
Posts: 20

PostPosted: Thu Oct 12, 2006 11:33 am
Reply with quote

Hi All,
I have a small query. Lets say in a Cobol Pgm, in Working Storage Section I have Var. lets say:

01 VAR1 Pic x(3) value 'ABC' .

Now If I pass value of VAR1 to any called Pgm & in called Pgm value gets returned to VAR1 as 'XYZ', then during the execution of main Pgm.(After the Called Pgm), If I refer to Var1 what value will it be having 'ABC' or 'XYZ'. or does this mean that before the called Pgm. is encountered value of var1 going to be 'ABC' & after the called pgm. value going to be 'XYZ'.

Thanx
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Oct 12, 2006 11:46 am
Reply with quote

Hi Vineet,

Yeap u r right before the called Pgm encountered value of var1 going to be 'ABC' & after the called pgm. value going to be 'XYZ'.
Back to top
View user's profile Send private message
vin12pr
Warnings : 1

New User


Joined: 14 Jun 2006
Posts: 56

PostPosted: Thu Oct 12, 2006 12:16 pm
Reply with quote

Hi,

It depends on how you pass the variable to the called program:

1) If you pass the variable by "CALL BY REFERENCE" ,the modified value of the variable is expected to be visible in the main program.

2) If you pass the variable by "CALL BY VALUE" , the modified value of the variable will not be visible in the main program.

Correct me if am wrong...

Thanks icon_smile.gif ,
Vinay
Back to top
View user's profile Send private message
Vineet

New User


Joined: 14 Sep 2005
Posts: 20

PostPosted: Thu Oct 12, 2006 12:50 pm
Reply with quote

Hi Ekta & Vinay thanx for the Help. I really Appreciate the effort you took to reply to my query. I have some more doubts.

1) Is it possible that while calling the called Pgm for the parameters we can have both "Call By Value" & "Call By Reference". For "Call By Value" does this means that we directly pass the value like:
Call "SubRout" using "ABC","XYZ"

And for "Call By Reference" does this mean that we pass value throug some Var. i.e. Call "SubRout" using Var1,Var2.

2) I red some where
if call by Reference: CALL PGM1 USING BY REFERENCE parm1
If Call by Value: CALL PGM1 USING BY VALUE parm1
If Call by Content: CALL PGM1 USING BY CONTENT parm1
what is meaning of "USING BY CONTENT"

Thanx
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Sun Oct 15, 2006 8:44 am
Reply with quote

Vineet,
First thing we dont code "Value" in Call statement of a Cobol program. I think above posts meant for Call by Content instead. And the changes in value of the variable should be as suugested by Vinay above.
Quote:
1) Is it possible that while calling the called Pgm for the parameters we can have both "Call By Value" & "Call By Reference".
Yes, you can have both Call by reference and Content in a single Call statement.
Quote:
For "Call By Value" does this means that we directly pass the value like:
Call "SubRout" using "ABC","XYZ"
And for "Call By Reference" does this mean that we pass value throug some Var. i.e. Call "SubRout" using Var1,Var2.
See here...
Quote:
2) I red some where
if call by Reference: CALL PGM1 USING BY REFERENCE parm1
If Call by Value: CALL PGM1 USING BY VALUE parm1
If Call by Content: CALL PGM1 USING BY CONTENT parm1
what is meaning of "USING BY CONTENT"
If you have gone thru above link... I dont think you are still looking for this answer... Are you?
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 Passing Parameters to Programs Invoke... PL/I & Assembler 5
No new posts Passing SYSPRINT to Invoked Program PL/I & Assembler 9
No new posts step by step trace 4 ISPF dialog call... TSO/ISPF 17
No new posts Passing parm from JCL to Assembler, b... PL/I & Assembler 2
No new posts Intertest Batch issue with called ass... COBOL Programming 4
Search our Forums:

Back to Top