Highlighted
Absent Member.
Absent Member.
1134 views

CALLing a sub-program - W-S values can be different second time round

Jump to solution

I have a small Project that contains 3 programs

PROGA is the 'driver' and sets up a common data file and then calls PROGB which processes and then PROGB calls PROGC and further work is done

PROGC then returns to PROGB which then returns to PROGA

PROGA then sets up a fresh load of data and calls PRGB again, and so on

This all works well and is extremely fast

However, the behaviour of PROGB changes because some of it's WORKING-STORAGE values are not being loaded as intended

For example, if I have the WS entry as this

77  FLAG-A   PIC  X(001) VALUE 'N'.

and PROGB sets it to 'Y' during it's first run, FLAG-A is not being loaded as value 'N' when PROGB is called for the second and further times

My workaround is to discover this each time and MOVE 'N' TO FLAG-A early in the processing for PROGB which works

However, I most probably do not have a parameter set correctly

Is there a specific way to CALL or prepare in advance a program and force the setup of the W-S values per item?  I would expect that when PROGB is loaded for the second and ensuing times that it is laid down 'clean' and all values are set as per the sources code's settings

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: CALLing a sub-program - W-S values can be different second time round

Jump to solution

Thanks Chris.  I have used CANCEL before but not IS INITIAL.  I am now.

View solution in original post

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: CALLing a sub-program - W-S values can be different second time round

Jump to solution

Sorry, forgot to include that I am using Micro Focus Visual COBOL Personal Edition 2.2 Visual Studio 2012

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: CALLing a sub-program - W-S values can be different second time round

Jump to solution

The default behavior for the CALL statement is that the program you call will always be left in its last used state.

If you wish for the program to be in its first used state when you call it then you should either cancel the program prior to calling it again using the CANCEL statement or add the IS INITIAL clause to the program-id of the subprogram in which case it will always be initialized each time it is called.

Thanks..

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: CALLing a sub-program - W-S values can be different second time round

Jump to solution

Thanks Chris.  I have used CANCEL before but not IS INITIAL.  I am now.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.