TAA Tools
CLPSTDERR       STANDARD ERROR HANDLING                TAASUBC

The CLP  Standard Error  Handling tool  has no source  other than  this
documentation  member.    The intent  is  that  you  would access  this
member  from the  SEU browse  function and  copy in  the code  when you
want the standard error handling code.

Two forms of standard  error handling are provided.   The CL source  is
in the correct form  to be copied into a CL program.   A description of
the two techniques follows the code:

Simple error handling
---------------------

  /* Enter after the last DCL */
             MONMSG     MSGID(CPF0000) EXEC(GOTO STDERR)
              .
              .              /* Your program */
              .
             RETURN     /* Normal end of program */
 STDERR:                /* Standard error handling routine */
             SNDESCMSG  MSG('Program aborted on +
                          an unexpected escape message')
             ENDPGM
   /* End of technique for a CLP Simple Error Handling */

Tool error handling
-------------------

             /* Technique for a CLP Standard Error Handling */
             DCL        &XERRORSW *LGL           /* Standard error */
             DCL        &XMSGID *CHAR LEN(7)     /* Standard error */
             DCL        &XMSG *CHAR LEN(512)     /* Standard error */
             DCL        &XMSGDTA *CHAR LEN(512)  /* Standard error */
             DCL        &XMSGF *CHAR LEN(10)     /* Standard error */
             DCL        &XMSGFLIB *CHAR LEN(10)  /* Standard error */
             DCL        &XKEYVAR *CHAR LEN(4)    /* Standard error */
             DCL        &XKEYVAR2 *CHAR LEN(4)   /* Standard error */
             DCL        &XRTNTYPE *CHAR LEN(2)   /* Standard error */
             MONMSG     MSGID(CPF0000) EXEC(GOTO STDERR1) /* Std err */
             MONMSG     MSGID(TAA0000) EXEC(GOTO STDERR1) /* Std err */
     /* Your program code */
             RETURN     /* Normal end of program */
             SNDESCMSG  MSG('STDERR1 routine entered +
                          unexpectedly. You should have a RETURN +
                          in your program before the routine')
                        /********************************************/
                        /*                                          */
 STDERR1:               /*       Standard error handling            */
                        /*                                          */
                        /********************************************/
             IF         &XERRORSW SNDPGMMSG MSGID(CPF9999) +
                          MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
             CHGVAR     &XERRORSW '1' /* Set to fail on error */
             RCVMSG     MSGTYPE(*EXCP) RMV(*NO) KEYVAR(&XKEYVAR)
 STDERR2:    RCVMSG     MSGTYPE(*PRV) MSGKEY(&XKEYVAR) RMV(*NO) +
                          KEYVAR(&XKEYVAR2) MSG(&XMSG) +
                          MSGDTA(&XMSGDTA) MSGID(&XMSGID) +
                          RTNTYPE(&XRTNTYPE) MSGF(&XMSGF) +
                          SNDMSGFLIB(&XMSGFLIB)
             IF         (&XRTNTYPE *NE '02') GOTO STDERR3
             IF         (&XMSGID *NE ' ') SNDPGMMSG +
                          MSGID(&XMSGID) MSGF(&XMSGFLIB/&XMSGF) +
                          MSGDTA(&XMSGDTA) MSGTYPE(*DIAG)
             IF         (&XMSGID *EQ ' ') SNDPGMMSG +
                          MSG(&XMSG) MSGTYPE(*DIAG)
             RMVMSG     MSGKEY(&XKEYVAR2)
 STDERR3:    RCVMSG     MSGKEY(&XKEYVAR) MSGDTA(&XMSGDTA) +
                          MSGID(&XMSGID) MSGF(&XMSGF) +
                          SNDMSGFLIB(&XMSGFLIB)
             SNDPGMMSG  MSGID(&XMSGID) MSGF(&XMSGFLIB/&XMSGF) +
                          MSGDTA(&XMSGDTA) MSGTYPE(*ESCAPE)
             ENDPGM
             /* End of technique for a CLP Standard Error Handling */

Simple error handling
---------------------

This  form will send an  escape message to the  previous program on any
non-monitored escape message.  It has two advantages:

  **   All non-monitored  escape  messages  are  handled  so  the  user
       never gets a  chance to respond to the  CPA0701 Inquiry message.
       The  program aborts without  the operator being  allowed to make
       a  decision  and  a  general  escape  message  is  sent  to  the
       previous program.

       This prevents a batch  job queue from being held  waiting for an
       operator  decision  and avoids  the  problem  of an  interactive
       user  being  allowed  to  answer an  Inquiry  message  where the
       Ignore option could cause  more harm that aborting  the program.

  **   If  there  are  several  programs  in  the  stack,  the  correct
       program  will  be  identified  in the  job  log.    The original
       escape message  is  not removed.    Each  program in  the  stack
       (that uses  the same technique)  would handle  the non-monitored
       escape message in the same manner.

Tool Error Handling
-------------------

This  is  the same  code  as provided  in  the DUPSTDSRC  tool  (it has
additional standard source).

It has the following advantages:

  **   All escape  messages  are  monitored for  so  that  the  CPA0701
       Inquiry  message will  not  occur.   This  is  the same  as  the
       Simple solution described previously.

  **   The escape  message and a previous diagnostic  are bubbled up to
       the  previous  program.   The  escape message  and  any previous
       diagnostic  message  are  removed,  thus  making  the   job  log
       cleaner.   This has the  disadvantage of making the  audit trail
       more  difficult  to follow  in the  case  of an  error occurring
       deep in the  program stack.   It  is good for  tool use  because
       most  errors will  be  bubbled up  to  a  command entry  display
       where  the message is  obvious to the  user and he  will not see
       the Function Check message (CPF9999).

Command parameters
------------------

None.

Restrictions
-------------

None.

Prerequisites
-------------

None.

Implementation
--------------

None.  To allow a  simple SEU copy function,  you should use CPYTAA  to
place the documentation in a source member.

Objects used by the tool
------------------------

None.
					

Added to TAA Productivity tools April 1, 1995


Home Page Up to Top