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
 

 

Working storage in Called module

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
a_khedekar

New User


Joined: 21 Dec 2003
Posts: 7

PostPosted: Fri Jun 05, 2009 10:17 pm    Post subject: Working storage in Called module
Reply with quote

I have module A (driver) which calls so many module e.g. B, C, D etc.
One of the module D gets called on specific condition from module A.

Program D has a table defined in working storage.
First time it goes inside Program D, there is logic to populate the table from Database.

When it goes inside Program D for subsequent time, I see that the table is still populated with same data.

I researched and found out that unless that Run Unit is terminated or explicit CANCEL is issued, Program D will keep all its working storage in memory intact.

My question is, can we trust the data? If we can then why do we need linkage ?

Thanks
Atul
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 05, 2009 10:36 pm    Post subject: Reply to: Working storage in Called module
Reply with quote

The following post might shed some light on your question -

http://www.ibmmainframes.com/viewtopic.php?p=192011&highlight=#192011
Back to top
View user's profile Send private message
Furor

New User


Joined: 04 Jun 2009
Posts: 30
Location: Bangalore

PostPosted: Fri Jun 05, 2009 10:37 pm    Post subject: Reply to: Working storage in Called module
Reply with quote

Please go through the below link:
Usage of INITIAL keyword.
Quote:
My question is, can we trust the data? If we can then why do we need linkage ?
How will you pass the data on every subsequent CALLs?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7912
Location: Bellevue, IA

PostPosted: Fri Jun 05, 2009 10:45 pm    Post subject:
Reply with quote

Linkage is used to pass data between calling and called program -- this data could be something that changes every call, or it could be a status code returned from the called program to the calling routine telling the success or failure of the subprogram processing.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 05, 2009 10:55 pm    Post subject: Reply to: Working storage in Called module
Reply with quote

If you're not trusting of the data, then move the table in "D" to LINKAGE, acquiring the necessary storage via "CEEGTST", save the storage-address in an EXTERNAL WS POINTER (known by all programs within the run-unit) and use this POINTER to establish addressability every time "D" is subsequently accessed. For that matter, because the POINTER is EXTERNAL, the data is available to any program within the run-unit, providing a given program has the table definition defined to their respective LINKAGE SECTION.

You should first set the EXTERNAL WS POINTER to NULL in the Main Driver program. When "D" obtains control, check whether the POINTER is NULL and if it is, then build the table. Otherwise, it's already been built.

Storage obtained via "CEEGTST" is available until the step is terminated, where the operating system will free it back. Alternatively, you could issue a CALL to "CEEFRST" (Free Storage), but that's not normally done, unless the amount of data previously acquired via "CEEGTST" was huge and your program will not be terminating shortly.

Regards,
Back to top
View user's profile Send private message
a_khedekar

New User


Joined: 21 Dec 2003
Posts: 7

PostPosted: Fri Jun 05, 2009 11:09 pm    Post subject:
Reply with quote

Sorry guys if 2nd question for linkage has confused you. Forget about my 2nd question. My actual question is first question.

Bill, my program is completely batch program. No CICS.

Also, it is not that I dont trust the data. I am making use of the data in the table without going into database again.
But some senior resource in my company is telling me that even IBM will not take guarantee that the data will be uncorrupted when I come back to Program D on subsequent calls.
So what is the guarantee that the data is uncorrupted and good to use next time.

I could not find enough material on internet using which I can prove that we can trust the data.

Thanks for all the help.

- Atul
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 05, 2009 11:36 pm    Post subject: Reply to: Working storage in Called module
Reply with quote

The concept of EXTERNAL WS being available to all programs within a run-unit, is not restricted to CICS.

The dynamic building of the table and subsequent saving of the dynamic-storage address in an EXTERNAL WS POINTER, will ensure that the table-data will be intact and untouched.

Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7912
Location: Bellevue, IA

PostPosted: Fri Jun 05, 2009 11:48 pm    Post subject:
Reply with quote

From the COBOL Programming Guide section 4.1.2:
Quote:
A subprogram is usually left in its last-used state when it terminates with EXIT PROGRAM or GOBACK. The next time the subprogram is called in the run unit, its internal values are as they were left, except that return values for PERFORM statements are reset to their initial values. (In contrast, a main program is initialized each time it is called.)

There are some cases where programs will be in their initial state:

* A subprogram that is dynamically called and then canceled will be in the initial state the next time it is called.

* A program that has the INITIAL attribute will be in the initial state each time it is called.

* Data items defined in the LOCAL-STORAGE SECTION will be reset to the initial state specified by their VALUE clauses each time the program is called.
So if you use a static call without INITIAL or LOCAL-STORAGE (or a dynamic call without issuing CANCEL) then your table will remain as it is from invocation to invocation.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jun 06, 2009 12:10 am    Post subject:
Reply with quote

Whether statically or dynamically linked, without the INITIAL clause or a CANCEL the Working-Storage will be as it was since the last invocation.

Quote:
But some senior resource in my company is telling me that even IBM will not take guarantee that the data will be uncorrupted when I come back to Program D on subsequent calls.


your 'senior resource' is in error.
IBM will guarantee the data if you follow the rules.
I imagine your 'senior resource' screwed-up sometime in the past,
does not know why,
and tells untruths about IBM op-system to cover-up his incompetence.
What he is telling you is that you need to continuously reload your table from DB2,
and that is patently BS.
Back to top
View user's profile Send private message
a_khedekar

New User


Joined: 21 Dec 2003
Posts: 7

PostPosted: Sat Jun 06, 2009 12:25 am    Post subject:
Reply with quote

Thanks All.
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 Jun 06, 2009 12:56 am    Post subject:
Reply with quote

a_khedekar wrote:
Thanks All.
I'm skeptical -- what's the final soulution did you use, finally? Please share that for the benefit of others.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Jun 06, 2009 1:06 am    Post subject: Reply to: Working storage in Called module
Reply with quote

Dick/Robert,

In using the dynamic-storage pitch, I was attempting to give the OP an alternative.

I understand (through many years of Vulcan Mind Melds) that once the table has been built in program "D", it remains intact and undisturbed for subsequent addressing by other callers in the run-unit, providing that a CANCEL or the "INITIAL" keyword of the PROGRAM-ID was NOT used.

And I agree 100%. The "Senior" resource is way off base with his assessment.

Regards,
Back to top
View user's profile Send private message
a_khedekar

New User


Joined: 21 Dec 2003
Posts: 7

PostPosted: Sat Jun 06, 2009 2:19 am    Post subject:
Reply with quote

Final solution as Bill said, data in the table will be trusted. Table will not be loaded again in subsequent calls.

But one more question, if the job abends, Run Unit will be terminated and data will be lost right ?

- Atul
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7912
Location: Bellevue, IA

PostPosted: Sat Jun 06, 2009 3:02 am    Post subject:
Reply with quote

Atul, yeah once the job finishes (normally or not) the data is gone. This also means the next time that program A is started up, the call will load the table again since all programs will start with their initial values in WORKING-STORAGE.
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: Sat Jun 06, 2009 3:25 am    Post subject:
Reply with quote

Hello,

Quote:
But some senior resource in my company is telling me that even IBM will not take guarantee that the data will be uncorrupted when I come back to Program D on subsequent calls.
One good thing that came from this is that you've learned not accept technical info from this "senior" as fact.

You may have to listen, but you may want to confirm that what you hear is correct. . .
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jun 06, 2009 5:25 am    Post subject:
Reply with quote

Bill,

I went a little overboard, but my main complaint was with the 'senior resource',
and probably turned a few people off. For that I am sorry.

any alternative method is ok by me.
More and more, I think we will see the need for 'dynamic extra storage'
and the methodology will slowly become accepted by more pgmrs.
Even I (the dinosaur that i am) am becoming a believer/user of such techniques.
You have a good grasp of LE facilites, they are the future in IBM,
we have to adjust and start using them.

Thx for your posts, without which I would never have explored their use
and would have stayed with my the old ways.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Jun 06, 2009 5:48 am    Post subject: Reply to: Working storage in Called module
Reply with quote

Dick,

Apologies unnecessary, I wasn't bothered one bit.

Hopefully, the OP will go back to this Senior Resource and let him know that his assessment is incorrect and he should consult the manual (such as Robert's excerpt posting).

In other words, brain needs to be engaged before opening mouth icon_smile.gif

Regards,
Back to top
View user's profile Send private message
Tom Bowman

New User


Joined: 15 Jun 2009
Posts: 3
Location: Minnesota, USA

PostPosted: Tue Jun 16, 2009 8:20 pm    Post subject:
Reply with quote

The issue I see here is going to be if you are using a static link (which prevents 'thread independence' by forcing a seperate load of the called routine by calling program(s), thus preserving memory state) or would want to use a (more memory efficient, reentrant) dynamic link (marked RENT). Renterable code MAY keep the same memory state (if not unloaded and not called by another program between your programs calls) - I would only use initial values for local WS or to initialize re-entrant memory. This concept is most useful for CICS however.

When there is an abend, all bets are off. A lot depends on the type of abend, S0C1, S806, and other memory space related abends normally are cleaned up by JES or OS. Sometimes a DB2 thread may insist on trying to run to 'completion' (which may or may not be possible), requiring one to -TERM the thread... I'd either pass the data each time I called or reload the subprogram (not very efficient, makes the loader suffer from a lot of overhead). Eventually the data will be lost, and depending on abend type is likely not relaible after an abend anyway.
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: Wed Jun 17, 2009 8:04 am    Post subject:
Reply with quote

Hello Tom and welcome to the forum,


Tom wrote:
Open the pod bay doors, HAL...


Quote:
I'm sorry Dave, I'm afraid I can't do that.
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 does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Copybook structure in Load module Vai123 COBOL Programming 7 Fri Sep 16, 2016 8:29 pm
This topic is locked: you cannot edit posts or make replies. How to supply called sub-program from... dchristensen JCL & VSAM 25 Wed Sep 14, 2016 11:36 pm
No new posts SCRNAME not working on my mainframe? mrsidhu12 TSO/ISPF 7 Thu Sep 01, 2016 2:17 pm


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