|
|
| Author |
Message |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
To be more specific,
I have coded Program 'A1' which calls Program 'A2' and Program 'A2' calls Program 'B' all are dynamic calls, after one invocation by Program 'A1' if i cancel Program 'B' will it initialize WS-END-OF-CB002003.
The syntax must be
CANCEL (IDENTIFIER-1,
lITERAL-11....)
Please suggest the above approach is correct or not.
Thanks,
murali. |
|
| Back to top |
|
 |
References
|
|
 |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
Now It's working Fine.
Thanks Dick Brenholtz and Robert Sample. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Senior Member
Joined: 20 Oct 2006 Posts: 3385 Location: germany
|
|
|
|
| glad you were able to solve it. Have a good weekend. |
|
| Back to top |
|
 |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
I have one doubt,what could be the chances of the Program 'B' to hold the value which is being stored on first call? whether it could be the compiler option which made the program to do so?
Thanks,
Murali |
|
| Back to top |
|
 |
dbzTHEdinosauer
Senior Member
Joined: 20 Oct 2006 Posts: 3385 Location: germany
|
|
|
|
what you are asking is
'if a compiler option would override the existence or non-existence of the INITIAL phrase in the PROGRAM-ID clause'.
I don't think so. |
|
| Back to top |
|
 |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
| I'm confused about the behavior of the program, i guess it may be due to compiler options. I'm not sure. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Senior Member
Joined: 20 Oct 2006 Posts: 3385 Location: germany
|
|
|
|
| Quote: |
| I'm confused about the behavior of the program |
you are not going to get any help here if you do not describe the behavior that is confusing you. |
|
| Back to top |
|
 |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
If a sub program(dynamic call) is called twice, for the first call normally a sub program(goback) returning the control back to main program the local variable will contain the initial values for second call. In my case why that program retains the values (first call) in second call. Please let me know.
Thanks,
Murali. |
|
| Back to top |
|
 |
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 4214 Location: Atlanta, GA
|
|
|
|
What are the compile options? What does the CALL statement look like? Is program B linked into program A or is it an independent module?
You've stated that the call is dynamic, but you've provided no proof of this. A static call will retain values, and unless you've read and understood the COBOL Programming Guide and Language Reference manuals on dynamic calls, it is easy to think a static call is dynamic. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Senior Member
Joined: 20 Oct 2006 Posts: 3385 Location: germany
|
|
|
|
a dynamic call will also perform the same.
the only time a CALLed module
does not retain working-storage values, generated during the invocation,
on second, third call is - the CALLed program is CANCELed
- the CALLed program has the INITIAL phrase as part of the PROGRAM-ID statement
- the CALLed program has code in procedure division that modifies working-storage variables before start of processing
Murali,
you want the working-storage variables at an initialized value for each invocation:
you don't want to change the sub-module
you need to CANCEL the module after return to the CALLing module each time. |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 13541 Location: 221 B Baker St
|
|
|
|
Hello,
Not quite the same (but gives predictable results) is always passing these fields from the caller to the called module. There would be no question of the value and if someone changes the way the module is called one day, the program will still perform consistently.
This was the standard for subroutine processing at several sites i've supported.
fwiw. . . |
|
| Back to top |
|
 |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
Proof for Dynamic call,
| Code: |
2200-GET-POSSIBLE-MATCHES.
MOVE '2200-GET-POSSIBLE-MATCHES' TO WS-PARAGRAPH-NM.
MOVE ZERO TO IP-B002-ADDR-COUNT.
MOVE ZERO TO IP-B002-CSPCLT-COUNT.
CALL WS-R243B002 USING LK-ECA-HEADER,
LK-R243B002-DATA-IN,
LK-R243B002-DATA-OUT.
IF LK-ECA-RETURN-CD = '0000'
|
working storage declaration
| Code: |
01 WS-CALLED-PROGRAMS.
05 WS-R243B002 PIC X(08) VALUE 'R243B002'.
05 WS-R243B003 PIC X(08) VALUE 'R243B003'.
05 WS-R243B004 PIC X(08) VALUE 'R243B004'.
05 WS-R243B005 PIC X(08) VALUE 'R243B005'.
|
Program WS-R243B002 is reffered as PROGRAM 'B' and compiled with dynam option.
Thanks,
Murali. |
|
| Back to top |
|
 |
Marso
Active Member
Joined: 13 Mar 2006 Posts: 610 Location: Israel
|
|
|
|
Did anybody notice that the question was about LOCAL-STORAGE area ?
| pkmurali wrote: |
| the Local-storage values remains the same when program 'A' calls Program 'B' second time. |
|
|
| Back to top |
|
 |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 143
|
|
|
|
Hope i have given the proof for Dynamic call ( apart from calling statement the compiler is not specified as DYNAM so in default it would be NODYNAM), But still i am not clear about how the sub program behaving like an static call.
I believe, the below statement is correct,
A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).
What could be the reason for this sort of behaviour any changes in program Genes  |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 13541 Location: 221 B Baker St
|
|
|
|
Hello,
| Quote: |
| What could be the reason for this sort of behaviour |
Unless i've missed something, what you are saying is that everything is working as documented  |
|
| Back to top |
|
 |
|
|