View previous topic :: View next topic
|
Author |
Message |
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
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 |
|
|
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
kalukakkad
New User
Joined: 10 Mar 2005 Posts: 81
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Besides, using external means that the table actually exists in the CALLing program, instead of the CALLed program. |
|
Back to top |
|
|
mymains Currently Banned New User
Joined: 24 Apr 2008 Posts: 5 Location: Banglore
|
|
|
|
Yea itz possible Ersha |
|
Back to top |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi,
mymains wrote: |
Yea itz possible Ersha |
Please elaborate your answer. |
|
Back to top |
|
|
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Hi,
Please let us know what exactly are you trying to achieve.
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. |
|
Back to top |
|
|
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
thank you all i m clear with the answer. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
earsha wrote: |
thank you all i m clear with the answer. |
And what's that..? |
|
Back to top |
|
|
|