|
Here are the rules:
An EXIT PROGRAM statements does not change the status of any of the files
in a run unit (in other words, file would stay open) unless:
- The program issuing the EXIT PROGRAM has the INITIAL attribute. If
it does, then all files are closed.
- An EXIT PROGRAM statement with the AND CONTINUE RUN UNIT phrase is
issued in the main program of a *NEW activation group.
In this case, control returns from the main program to the caller,
which, in turn, causes the *NEW activation group to end, closing all of the
files scoped to the activation group.
A STOP RUN statement returns control to the caller. ALL files will be
closed.
A GOBACK issued from the main program behaves the same as the STOP RUN.
A GOBACK issued from a subprogram behaves the same as the EXIT PROGRAM
statement.
So, use just the EXIT PROGRAM with no STOP RUN or GOBACK.
Thank you,
Karen Hodge
Senior System Analyst
Genesys Health System
1000 Healthpark Blvd, Grand Blanc, Mi 48439
Office 810.606.5180, Fax 810.606.7204
khodge@xxxxxxxxxxx
"Greg Phillips"
<gphillips@zenith
admin.com> To
Sent by: "COBOL Programming on the
cobol400-l-bounce iSeries/AS400"
s@xxxxxxxxxxxx <cobol400-l@xxxxxxxxxxxx>
cc
03/20/2005 11:35 Subject
AM RE: [COBOL400-L] Multiple Reports
in One Spooled File
Please respond to
COBOL Programming
on the
iSeries/AS400
<cobol400-l@midra
nge.com>
Karen,
Initially, the program ended with EXIT PROGRAM, falling through to STOP RUN
in case it was "the top level program of the run unit." The quote is from
a
program comment. I then replaced EXIT PROGRAM with GOBACK, but it didn't
change anything. I think GOBACK is equivalent to EXIT PROGRAM, followed by
STOP RUN, so I'm not surprised.
>From the research I've done, I think Jon Paris has the right approach.
(Thanks Jon!) The term "COBOL run unit" as it applies to OPM COBOL seems
relevant here. The current job flow pertaining to the call level is:
CLP
loop: CALL COBOL
Return to CLP
If more processing, continue loop
end loop
CLP ENDPGM
The first interation of the COBOL program opens the printer file, produces
a
report, and doesn't close the printer file. Subsequent iterations in the
loop produce reports and don't open or close the printer file. After the
last iteration in the loop, the COBOL program is called one last time and
only closes the printer file.
I believe what's happening is that when the COBOL program ends after the
first iteration, the printer file is closed anyway because it's the end of
the COBOL run unit. I thus received the MCH3601 error on the subsequent
iteration. I believe if I didn't let the first iteration of the COBOL
program end, then the files would remain open. So I could make the COBOL
program recursive, i.e. the loop would occur from within the COBOL program
rather than the CLP.
Jon suggested a COBOL stub program that would simply call the CLP. I
gather
that if the printer file is opened in a subsequent program in the run unit,
as long as the run unit doesn't end (i.e. the stub program), then the file
will remain open -- unless the file is explicitly closed. So that's
another
alternative.
Do you use another approach to handle this in OPM? Sorry for the length of
this, but I figure it I misunderstood anything, some kind person would
correct me. <g>
- Greg
-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx
[mailto:cobol400-l-bounces@xxxxxxxxxxxx]On Behalf Of Karen L
Hodge/MIS/Genesys
Sent: Sunday, March 20, 2005 7:17 AM
To: COBOL Programming on the iSeries/AS400
Subject: RE: [COBOL400-L] Multiple Reports in One Spooled File
Re:I did this, but received an MCH3601=rror when the program
was called with the parameter set to not-first-t=me. The error was on
an
initialize statement of the printer file =ecord 01 level after the FD.
How are=ou ending the COBOL program?
How you end it would determine whe=her the printer file is closed upon
exiting the program or kept open.
<=R>
Thank you,
Karen Hodge
Senior System Analyst
Genesys He=lth System
1000 Healthpark Blvd, Grand Blanc, Mi 48439
Office 810.60=.5180, Fax 810.606.7204
khodge@xxxxxxxxxxx
-----cobol400-l-bounces@xxxxxxxxxxxx wrote: -----
<bloc=quote style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT:
5px; BO=DER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">To: "COBOL
Programming on =he iSeries/AS400" <cobol400-l@xxxxxxxxxxxx>
From: "Greg Phillips"=gphillips@xxxxxxxxxxxxxxx>
Sent by: cobol400-l-bounces@midrange.=om
Date: 03/18/2005 06:25PM
Subject: RE: [COBOL400-L] Multiple Repor=s in One Spooled File
Thanks, Karen= I did this, but received an MCH3601 error when the
program
was c=lled with the parameter set to not-first-time. The error was on
an<B=>initialize statement of the printer file record 01 level after the
FD.<BR=Apparently, the printer file was closed, even though the program
didn't<BR=explicitly do it. I'll have to put the program into debug and
see if= can
figure out how the printer file is getting closed.
Greg Ph=llips
Senior Programmer/Analyst
Zenith Administrators
221 Main St=eet, Suite 250
San Francisco, CA 94105
Phone: (415) 536-8232 F=x: (415) 227-0552
E-mail: gphillips@xxxxxxxxxxxxxxx mailto:gphillips@xxxxxxxxxxxxxxx<=A>>
Zenith's Website: www.zenithadmin.com http://www.zenithadmin.com/>
C=NFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is<B=>for the sole use of the intended recipient(s) and may contain
confidentia=
and privileged information. Any unauthorized review, use, disclo=ure or
distribution is prohibited. If you are not the intended re=ipient,
please
contact the sender by reply e-mail and destroy all copie= of the
original
message.
-----Original Message-----
From= cobol400-l-bounces@xxxxxxxxxxxx
[mailto:cobol400-l-bounces@xxxxxxxxxxxx]On=ehalf Of Karen L
Hodge/MIS/Genesys
Sent: Friday, March 18, 2005 1:4= PM
To: COBOL Programming on the iSeries/AS400
Subject: RE: [COBOL40=-L] Multiple Reports in One Spooled File
I have=sed this same type of logic to accomplish the same thing (adding
to
a =pool file) using
'regular' COBOL.
Doesn't have to be ILE.
Just pa=s the first-time, not-first-time and end switch as a parm in the
CL
and=ass it to the COBOL program.
Then condition your open and close on the=witch.
Thank you,
Karen Hodge
Senior System Analyst<=R>Genesys Health System
1000 Healthpark Blvd, Grand Blanc, Mi 48439
=ffice 810.606.5180, Fax 810.606.7204
khodge@xxxxxxxxxxx
------------------------------ <SNIP> ----------------------------------
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.