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

Retaining Values of working Storage variables


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

New User


Joined: 13 Sep 2008
Posts: 4
Location: Chennai

PostPosted: Sat Sep 13, 2008 1:28 pm
Reply with quote

Hi all,
i am new to this Forum.Let me know how to retain the Values of working Storage Variable's values.

For Example,
COB1 is a COBOL Program
ASM1 is an Assembler Program

ASM1 Calling COB1 more than Once. What's a Problem means the Values of the variables in working storage isn't RETAINING.

For me, I should Retain the Values of that Variables Of COB1 icon_question.gif.

Help me!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sat Sep 13, 2008 2:30 pm
Reply with quote

Not sure if I've understood the question correcly - you can define an array, keep "storing" the valus in that for different index/subscript.
Back to top
View user's profile Send private message
Angayarkannipm

New User


Joined: 13 Sep 2008
Posts: 4
Location: Chennai

PostPosted: Sat Sep 13, 2008 3:07 pm
Reply with quote

Hi Anuj,

thanks. but that array also declared in the working Storage Section of the COBOL Program.
If i Will call the Same Program 2nd time means all the variables have it's new value(including That ARRAY). am i right?
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Sun Sep 14, 2008 12:03 am
Reply with quote

search for IS INITIAL clause in the PROGRAM-ID paragraph.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Sep 14, 2008 2:39 am
Reply with quote

Hello,

Quote:
If i Will call the Same Program 2nd time means all the variables have it's new value(including That ARRAY). am i right?
It depends on what you want to happen. . .

Quote:
the Values of the variables in working storage isn't RETAINING
RETAINING is not a feature. . .

When the cobol program is re-invoked, do you want the initial values in the COBOL or do you want the values to persist as they were at the end of the first call?
Back to top
View user's profile Send private message
Angayarkannipm

New User


Joined: 13 Sep 2008
Posts: 4
Location: Chennai

PostPosted: Mon Sep 15, 2008 1:00 pm
Reply with quote

hi,
Thanks.
Yes,i want the values to persist as they were at the end of the first call.
Back to top
View user's profile Send private message
guptae

Moderator


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

PostPosted: Mon Sep 15, 2008 2:23 pm
Reply with quote

Hello Angayarkannipm,

The working-storage section is allocated at the start of the run-unit and any data items with VALUE clauses are initialized to the appropriate value at the time. When the subprogram is called the second time, a working-storage items persist in their last used state. However, if the program is specified with INITIAL on the PROGRAM-ID, working-storage section is reinitialized each time the program is entered.
Back to top
View user's profile Send private message
Angayarkannipm

New User


Joined: 13 Sep 2008
Posts: 4
Location: Chennai

PostPosted: Mon Sep 15, 2008 2:49 pm
Reply with quote

hi,

thanks for your Replay.
In my secenrio,my main program is in Assembler and my subprogram is in COBOL and added to that i didn't use INITIAL in my PROGRAM-ID pharagraph.

while my main program reinvoked my sub program the variables in sub program is initialed automatically
Please Help me.....
Back to top
View user's profile Send private message
Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Mon Sep 15, 2008 2:51 pm
Reply with quote

Hi,
As explained in the previous posts, the working storage values will be retained if the submodule is called more than once. To avoid this we specify IS INITIAL in Program Id.

Also, if a COBOL program is calling a sub module, we can initialize working storage by using CANCEL verb after the CALL.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Sep 15, 2008 7:30 pm
Reply with quote

Hello Angayarkannipm,

To easily do what you want, pass all of the variables from the calling module.

The called module will have no values "of its own" (except constants). When control is returned to the calling module any variables that were updated in the called module will be preserved/available in the caller.

When the called module is invoked again, the caller automatically provides everything.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Sep 15, 2008 7:56 pm
Reply with quote

The COBOL program should be loaded once only.
During the load, fields are set to their default values.
As you don't have the INITIAL option in the PROGRAM-ID paragraph,
the values should be retained between the calls.

If they are not, maybe you are reloading the program ?
Please show us the pieces of code in your ASM program where you deal with the COBOL subprogram.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Sep 15, 2008 8:26 pm
Reply with quote

Hi,

Sounds likeyou want to make your subpgm "seriallly reuseable".

REUS is a link edit option. It's use comes with a few caveats. Do some research on REUS and RENT (a compiler opt).

While I don't think you want RENT, the topic contains more than a few references to REUS.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 16, 2008 12:58 am
Reply with quote

Hello,

As i mentioned before:
Quote:
To easily do what you want, pass all of the variables from the calling module.
If you try this, you will notice the overall size of the executed code will not change much and there should be no performance "hit" as the only thing that will change is addressability.

As Jack mentioned, you should not need your code to be re-entrant.

If you try having all of the variables n the caller, you would still want to make sure that the called module is not reloaded every time it is called.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
Search our Forums:

Back to Top