You can set the cobol error handler so that any unmonitored error will call a specified program. See example below where MP08003 is our standard error handler;

WORKING-STORAGE SECTION.

COPY QUSEC OF QSYSINC-QLBLSRC.

01 WS01-ERROR-HANDLER-API.
05 WS01-EH-Y PIC S9(9) VALUE ZERO.
05 WS01-EH-PROGRAM PIC X(20) VALUE 'MP08003 *LIBL '.
05 WS01-EH-SCOPE PIC X VALUE 'C'.
05 WS01-EH-LIBRARY PIC X(10).
05 WS01-EH-PREVIOUS PIC X(20).

COPY C4PYWS90.

PROCEDURE DIVISION.

CM00-CONTROL SECTION.
****************************************************************
* MAIN PROGRAM CONTROL *
****************************************************************
CM000-START.

* Set the error handler

MOVE 16 TO BYTES-PROVIDED OF QUS-EC.

* Call the API to register the exit program.

CALL 'QLRSETCE' USING WS01-EH-PROGRAM
WS01-EH-SCOPE
WS01-EH-LIBRARY
WS01-EH-PREVIOUS
QUS-EC.

* Check for an error

IF BYTES-AVAILABLE OF QUS-EC > ZERO
MOVE 'CBL-ErrHlr' TO WS99-FILE-NAME
MOVE 'Failed to set the Cobol error handler'
TO WS99-FILE-KEY
PERFORM 9990-IO-ERROR.

GOBACK.

CM999-EXIT.
EXIT.


Best regards,

Mark Austin
IT Consultant
Universal Music Publishing Group
Bond House, 347-353 Chiswick High Road, London W4 4HS
Tel: +44 (0)208 742 5520 / Fax: +44 (0)208 742 5699
mark.austin@xxxxxxxxxx

Universal Music Publishing International Limited
Registered in England. Number 02050403
Registered Office: 347-353 Chiswick High Road, London W4 4HS
-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx [mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of geir.kildal@xxxxxxxxxx
Sent: 12 February 2010 07:48
To: cobol400-l@xxxxxxxxxxxx
Subject: [COBOL400-L] Errors when calling programs


Hi.

In a COBOL-program, I'm calling a Pascal-program(no source avalible!).
Now and again this Pascal-pgm returns a PSE-message which, of course,
makes my COBOL-pgm stop.

I want to take control over this in my COBOL-pgm, and issue a programmed
error message instead.

I can slightly remember someting about coding an 'on-error'-routine in
COBOL?
Or other ways to come around this, please?


Mvh.

Geir Kildal

"Keep it simple!"


--
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.



"**Confidentiality**
The information contained in this e-mail is confidential, may be privileged and is intended solely for the use of the named addressee. Access to this e-mail by any other person is not authorised. If you are not the intended recipient, you should not disclose, copy, distribute, take any action or rely on it and you should please notify the sender by reply. Any opinions expressed are not necessarily those of the company.

We may monitor all incoming and outgoing emails in line with current legislation. We have taken steps to ensure that this email and attachments are free from any virus, but it remains your responsibility to ensure that viruses do not adversely affect you.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 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.