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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Can I change the main-pgm variable in Sub-pgm
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: 2150
Location: At my coffee table

PostPosted: Fri Apr 11, 2008 12:24 am    Post subject:
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: 276
Location: Bang,iflex

PostPosted: Fri Apr 11, 2008 10:09 am    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Fri Apr 11, 2008 3:49 pm    Post subject: Reply to: Can I change the main-pgm variable in Sub-pgm
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    Post subject: COBOL Subprograms
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: 2150
Location: At my coffee table

PostPosted: Fri Apr 11, 2008 8:48 pm    Post subject: Re: COBOL Subprograms
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    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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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