Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Retaining Values of working Storage variables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Retaining Values of working Storage variables
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

Senior Member


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

PostPosted: Sat Sep 13, 2008 2:30 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sun Sep 14, 2008 2:39 am    Post subject:
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    Post subject: Reply to: Retaining Values of working Storage variables
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: 1187
Location: Bangalore,India

PostPosted: Mon Sep 15, 2008 2:23 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Sep 15, 2008 7:30 pm    Post subject:
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: 1243
Location: Israel

PostPosted: Mon Sep 15, 2008 7:56 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Sep 16, 2008 12:58 am    Post subject:
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    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 LIBDEF not working in called proc packerm CLIST & REXX 0 Fri Sep 15, 2017 7:22 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts ISREDIT MACRO NOT WORKING! :cry: kirank889 TSO/ISPF 3 Thu Aug 03, 2017 5:46 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us