View previous topic :: View next topic
|
Author |
Message |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Hi,
Program A is calling sub program B twice. Since Program 'B' is in Inital the Local-storage values remains the same when program 'A' calls Program 'B' second time.
What are all the possibilities to convert Program 'B' non-initial
apart from recompiling Program 'B'. (i.e. without changing Program 'B').
Please let me know.
Thanks,
Murali. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Remove "PROGRAM IS INITIAL" from the PROGRAM-ID clause? |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
I agree it will help, but my scenario is not to touch the Program 'B'. I feel 'CANCEL' will help... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
pkmurali,
you have everything ass-backwards.
INITIAL and CANCEL have the same effect. |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Dick Brenholtz
I am using a existing COBOL Program in my project(similar to Program 'B' mentioned in the previous post) which retains it's local storage variables, i can't able to find the keyword 'INITIAL' or 'CANCEL' used in the program.Since we use Endevor the compiling details are not available. Please let me know what should be done to make that program non-initial.
Thanks,
Murali. |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
pkmurali wrote: |
Hi,
Program A is calling sub program B twice. Since Program 'B' is in Inital the Local-storage values remains the same when program 'A' calls Program 'B' second time.
What are all the possibilities to convert Program 'B' non-initial
apart from recompiling Program 'B'. (i.e. without changing Program 'B').
Please let me know.
Thanks,
Murali. |
AFAIK INITIAL clause causes the variables to be 'refreshed'. i.e. the variables WILL NOT retain the values from the previous call.
According to my understanding, Using INITIAL in the called program and using CANCEL before calling the subprogram in the calling program yields the same effect. Is there really a need to change anything?? |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
My objective is to make the program 'B' to be non-initial without touching the program 'B'. Is it possible? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
does program b have PROGRAM IS INITIAL in the PROGRAM-ID clause?????
if not, then your objective has been obtained - without action.
If Program b has the INITIAL phrase in the PROGRAM-ID clause,
then you have to change Program b.
you said that there are no CANCEL Program b instructions in Program a,
so that is not an issue. |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
does program b have PROGRAM IS INITIAL in the PROGRAM-ID clause?????
NO
if not,
then if there are no CANCEL Program b instructions in Program a,
then program b's working-storage,
will
on subsequent CALLs,
have the same values as when exited on the previous invocation.
No Cancel statement coded |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
then you do not have a problem. and you don't need to take any action. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I have overlooked the possibility that Program b executes INITIALIZE instructions.
Does Program b initialize all of its working-storage via INITIALIZE instructions? |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
I have xpedited the subprogram, where WS-END-OF-CB002003 is the working storage variable.
This is the first call...
Code: |
COMMAND ===> SCROLL ===> CSR
BEFORE BREAKPOINT ENCOUNTERED
-
000067 K 05 WS-END-OF-CB002003 > N
----+----1----+----2----+----3
MORE-> 01 LK-ECA-HEADER > ..............................
----+----1----+----2----+----3
------ ----------------------------------------- Before R243B002/AMODE 31 <>
000826 ******************** 0114
=====> B PROCEDURE DIVISION USING LK-ECA-HEADER 0116
000828 LK-R243B002-DATA-IN 0117
000829 LK-R243B002-DATA-OUT. 0117
000830 ******************** 0118
000831 * 0119
000832 DSNSQL SECTION.
|
This the status at the end of the sub program...
Code: |
COMMAND ===> SCROLL ===> CSR
BEFORE BREAKPOINT ENCOUNTERED
-
000067 K 05 WS-END-OF-CB002003 > Y
** END **
------ ------------------------------------- Before R243B002:958/AMODE 31 <>
000957 0000-MAINLINE-EXIT. 0149
=====> B GOBACK. 0150
000959 / 0151
000960 1000-INITIALIZATION. 0152
000961 MOVE '1000-INITIALIZATION' TO WS-PARAGRAPH-NM. 0153
000962 0154
000963 * TEMPORARY TABLE DECLARATION 0154
|
this the second call.. where the value of WS-END-OF-CB002003 remains the same 'Y' (retaining the value after the first call).
Code: |
COMMAND ===> SCROLL ===> CSR
PROGRAM: R243B002 MODULE: R243B002 COMP DATE: 09/17/2002 COMP TIME:14:56:25
-
000067 K 05 WS-END-OF-CB002003 > Y
----+----1----+----2----+----3
MORE-> 01 LK-ECA-HEADER > ..............................
----+----1----+----2----+----3
------ ----------------------------------------- Before R243B002/AMODE 31 <>
000826 ******************** 0114
=====> B PROCEDURE DIVISION USING LK-ECA-HEADER 0116
000828 LK-R243B002-DATA-IN 0117
000829 LK-R243B002-DATA-OUT. 0117
000830 ******************** 0118
000831 * 0119
000832 DSNSQL SECTION.
000833 SQL-SKIP.
000834 GO TO SQL-INIT-END.
|
The Sub program doesn't contain 'INITIAL' or the calling program doesn't have 'CANCEL' statement. Please let me know what should be done to refresh the value for WS-END-OF-CB002003. I am not supposed to change the Sub-Program.
Thanks,
Murali. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Is the sub program statically called or dynamically called? If it is statically called, change your calling program to make it a dynamic call.
Use CANCEL after returning from the subprogram -- but note that this verb only works on dynamically called routines. |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
To Addwith,
The Sub program is treated as Stored Procedure in earlier application, but i am using it as BatchLoad. Sub-Program can be called as Stored Procedure as well as Batch Program.
Thanks,
Murali. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
now I understand the problem.
some jerk coded a stored procedure,
knowing that it would not be re-invoked during the task,
and laid crap code so that it is not re-entrant.
you are screwed Murali,
as Robert said, you can only CANCEL dynamically CALLed modules,
so your process must eat the overhead created by CANCELing and reLOADing the module for each invocation. |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
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 |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Now It's working Fine.
Thanks Dick Brenholtz and Robert Sample. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
glad you were able to solve it. Have a good weekend. |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
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
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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: 271
|
|
|
|
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
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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: 271
|
|
|
|
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: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|