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

Can I change the main-pgm variable in Sub-pgm


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

New User


Joined: 06 Jun 2007
Posts: 5
Location: Bangalore

PostPosted: Thu Apr 10, 2008 11:46 pm
Reply with quote

I have a question regarding COBOL sub programs.

I have a working-storage variable of main program say WS-VAR1 which is also used in the sub program. So can I change that variable in the sub program say WS-VAR2?

Dilip.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Apr 11, 2008 12:24 am
Reply with quote

Yes and no. For a more precise answer please provide more information.....
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Fri Apr 11, 2008 10:09 am
Reply with quote

Hi,

Do you want to change the variable name or the content of the variable.

Changing variable name

if u want to change the variable name you can change, but there must be one-one mapping in linkage section of main program and sub program.
It doesnot depends on working-storage variable, because WS variables are local to main and subprogram.


Changing content of variable in subprogram

You can go for

Code:
CALL 'SUBPROGRSM' using BY REFFERENCE LN-VAR1


and then you can hange the content of variable in SUBPROGRAM it reflects in MAINPROGRAM too.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Apr 11, 2008 3:49 pm
Reply with quote

dilip,

Quote:
I have a working-storage variable of main program say WS-VAR1 which is also used in the sub program. So can I change that variable in the sub program say WS-VAR2?


As CICS Guy pointed out, please explain your requirement.

What actually is WS-VAR2? shd it not be WS-VAR1 as you have said that you uise same workinig storage in both the programs.
Back to top
View user's profile Send private message
muppanenidilip
Warnings : 1

New User


Joined: 06 Jun 2007
Posts: 5
Location: Bangalore

PostPosted: Fri Apr 11, 2008 6:27 pm
Reply with quote

when we use " call by content " & "call by reference"

can any body help me?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Apr 11, 2008 8:48 pm
Reply with quote

muppanenidilip wrote:
when we use " call by content " & "call by reference"
This would have been a lot quicker if you had started with this question...
With the BY REFERENCE phrase, yes....
With the BY CONTENT phrase, no....
And with the BY VALUE phrase, I'll leave that for you to decide....Please post back your answer.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts 3270 personal communications. Can't c... TSO/ISPF 2
No new posts SELECT from data change table DB2 5
No new posts Trying to change copybook in online c... CICS 4
Search our Forums:

Back to Top