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

Static call- working storage value


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

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Fri Apr 25, 2008 12:00 pm
Reply with quote

I have 1 pgm A which is a main pgm and this main pgm A calls subpgm B and in subpgm B i have some working storage sections in that i have some value.
so my question is whether those value in PGM B's working storage sections are accesible for PGM A or not in case of static call.
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 25, 2008 12:23 pm
Reply with quote

Hi,
Quote:


so my question is whether those value in PGM B's working storage sections are accesible for PGM A or not in case of static call.



Both the case is not possible.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Fri Apr 25, 2008 12:38 pm
Reply with quote

Hi,

Please search the froum on 'static call', you would get many useful links..one such link is ..

www.ibmmainframes.com/viewtopic.php?t=29802&highlight=static+call
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Fri Apr 25, 2008 12:42 pm
Reply with quote

Hello,

vasanthkumarhb wrote:
Both the case is not possible.
What about this..
Code:
MOVE '10' TO VAR-1
CALL SUB-PGM-A USING VAR-1
IN SUB-PGM-A MOVE '20' TO VAR-1
COME OUT OF THE SUB-PGM
DISPLAY VAR-1 IN MAIN PROGRAM
VAR-1 = '20'

Call By Reference is Default means the sub program changes are shared by the main program

Further, Call By Content or Value means the sub program changes are local to the sub program only, the same code above displays VAR-1 = '10' if you code
Code:
CALL SUB-PGM-A BY CONTENT USING VAR-1
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 25, 2008 12:50 pm
Reply with quote

Hi Anuj,


I know the post by you works, if we have coded LINKAGE-SECTION and the variables are declared, we can us CALL BY REFFERENCE or CALL BY CONTENT or CONTEXT what ever.

Code:

I have 1 pgm A which is a main pgm and this main pgm A calls subpgm B and in subpgm B i have some [b]working storage sections [/b]in that i have some value.


Can we do these operations on working-storage section, please let me know, that will be helpfull to me too.
Back to top
View user's profile Send private message
earsha

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Fri Apr 25, 2008 1:06 pm
Reply with quote

thank you all for your replies but i need more specific answers .
cosider scenerion:

in sub pgm b i m loading 1 table which has 2 values no and name
from main pgm a i m calling pgm b by passing no and want o/p as name form b for that no.
so if in pgm b i will load table once so when 2nd time pgm a calls to pgm b will that table still accessible?
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Apr 25, 2008 1:07 pm
Reply with quote

Hi Anuj,

[quote="earsha"]]whether those value in PGM B's working storage sections are accesible for PGM A or not
Quote:


The WORKING STORAGE section of the called program will be local to that program only.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Apr 25, 2008 1:38 pm
Reply with quote

Quote:

so if in pgm b i will load table once so when 2nd time pgm a calls to pgm b will that table still accessible?


unless you CANCEL a CALLed/LOADed sub-program, or use the INITIAL phrase in the ID clause,

the CALLed programs memory will be as it was from the last CALL.

So, yes:

CALL B with a function code - 1 - load table, 2- find name-given no, 3-find no-given name.

Pgm B would have three functions.
Back to top
View user's profile Send private message
kalukakkad

New User


Joined: 10 Mar 2005
Posts: 81

PostPosted: Fri Apr 25, 2008 1:42 pm
Reply with quote

You can define the table as EXTERNAL.

But you have to define the table in both prog A and prog B and with the exact same structure.

e.g.

Prog-A

WORKING-STORAGE SECTION.
01 WS-NUM-PASS PIC 9(03).
01 WS-TABLE EXTERNAL.
05 WS-NO PIC 9(03).
05 WS-NAME PIC X(20).

PROCEDURE DIVISION.

MOVE 123 TO WS-NUM-PASS.
CALL 'PGM-B' using WS-NUM-PASS.
DISPLAY 'Name = ' WS-NAME
STOP RUN.

Prog-B

WORKING-STORAGE SECTION.
01 WS-TABLE EXTERNAL.
05 WS-NO PIC 9(03).
05 WS-NAME PIC X(20).

LINKAGE SECTION.
01 LS-NUM-PASS PIC 9(03).

PROCEDURE DIVISION USING LS-NUM-PASS.

use LS-NUM-PASS to populate the WS-TABLE with no. and name.

GOBACK
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Apr 25, 2008 2:36 pm
Reply with quote

the OP just wants to know if the working-storage in a CALLed module will remain for subsequent CALLs.

though the OP's first post seemed to indicate that he wants addressability to the CALLed program's working storage, the later posts by the OP indicated otherwise.

Though EXTERNAL is a nifty thing, there are other methodologies to provide addressability for working-storage of one module to another. POINTERS for instance.

After several posts, the OP appears to only want assurance that after he has CALLed the submodule to build a look-up table, the table will remain populated for subsequent CALLs.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Apr 25, 2008 2:38 pm
Reply with quote

Besides, using external means that the table actually exists in the CALLing program, instead of the CALLed program.
Back to top
View user's profile Send private message
mymains
Currently Banned

New User


Joined: 24 Apr 2008
Posts: 5
Location: Banglore

PostPosted: Fri Apr 25, 2008 2:39 pm
Reply with quote

Yea itz possible Ersha
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 25, 2008 3:00 pm
Reply with quote

Hi,

mymains wrote:
Yea itz possible Ersha



Please elaborate your answer.
Back to top
View user's profile Send private message
earsha

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Fri Apr 25, 2008 3:46 pm
Reply with quote

but then is it possible that called module will copy the value of its working storage section into linkage and then calling module will used that
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Apr 25, 2008 3:54 pm
Reply with quote

Hi,

Please let us know what exactly are you trying to achieve. icon_question.gif
Then we can understand your questions clearly.

earsha wrote:
but then is it possible that called module will copy the value of its working storage section into linkage and then calling module will used that

Yes. You can copy the values of working storage values of the called module to the linkage section of the called module. Those values can be used in the calling module.
Please let me know if I am creating more confusion. icon_redface.gif
Back to top
View user's profile Send private message
earsha

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Fri Apr 25, 2008 4:32 pm
Reply with quote

thank you all i m clear with the answer.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Fri Apr 25, 2008 9:18 pm
Reply with quote

earsha wrote:
thank you all i m clear with the answer.
And what's that..?
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 db2 vs static data COBOL Programming 1
No new posts Call an hlasm from REXX in batch and ... CLIST & REXX 4
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
Search our Forums:

Back to Top