/* ************************************************************************** */
/* DBG107CL:   CRTDBGSCP Validity Check pgm                                   */
/* Copyright (C) 2000  Martin Rowe  <martin@dbg400.net>                       */
/*                                                                            */
/* This program is free software; you can redistribute it and/or modify       */
/* it under the terms of the GNU General Public License as published by       */
/* the Free Software Foundation; either version 2 of the License, or          */
/* (at your option) any later version.                                        */
/*                                                                            */
/* This program is distributed in the hope that it will be useful,            */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of             */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              */
/* GNU General Public License for more details.                               */
/*                                                                            */
/* You should have received a copy of the GNU General Public License          */
/* along with this program; if not, write to the Free Software                */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307   USA */
/* ************************************************************************** */
PGM (&SCRIPT &LIBRARY &SCRIPTTYPE &PRIMARY1 &PRIMARY2 &PRIMARY3)
  DCL        VAR(&SCRIPT) TYPE(*CHAR) LEN(10)
  DCL        VAR(&SCRIPTTYPE) TYPE(*CHAR) LEN(5)
  DCL        VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
  DCL        VAR(&PRIMARY1) TYPE(*CHAR) LEN(10)
  DCL        VAR(&PRIMARY2) TYPE(*CHAR) LEN(10)
  DCL        VAR(&PRIMARY3) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(132)
  DCL        VAR(&MSGF) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)

  MONMSG     MSGID(CPF9999) EXEC(GOTO CMDLBL(ERROR))

/* Clear the message line of any prior errors                                 */
  SNDPGMMSG  MSGID(CPA2401) MSGF(QCPFMSG) TOPGMQ(*EXT) +
               MSGTYPE(*STATUS)
/* Check the library exists */
  CHKOBJ     OBJ(&LIBRARY) OBJTYPE(*LIB)
  MONMSG     MSGID(CPF9801) EXEC(DO)
    CHGVAR     VAR(&MSGDTA) VALUE('0000Library' |> +
                 &LIBRARY |< ' not found - please +
                 check')
    CHGVAR     VAR(&MSGID) VALUE(CPD0006)
    GOTO       CMDLBL(SEND)
  ENDDO
/* If using links, check the primary details */
  IF         COND(&SCRIPTTYPE *EQ '*LINK') THEN(DO)
    IF         COND(&PRIMARY1 *EQ ' ') THEN(DO)
      CHGVAR     VAR(&MSGDTA) VALUE('0000At least one +
                   primary file required for a *LINK based +
                   script')
      CHGVAR     VAR(&MSGID) VALUE(CPD0006)
      GOTO       CMDLBL(SEND)
    ENDDO
    IF         COND(&PRIMARY1 *NE ' ') THEN(DO)
      CHKOBJ     OBJ(&LIBRARY/&PRIMARY1) OBJTYPE(*FILE)
      MONMSG     MSGID(CPF9801) EXEC(DO)
        CHGVAR     VAR(&MSGDTA) VALUE('0000The first +
                     file' |> &PRIMARY1 |< ' doesn''t +
                     exist in' |> &LIBRARY)
        CHGVAR     VAR(&MSGID) VALUE(CPD0006)
        GOTO       CMDLBL(SEND)
      ENDDO
    ENDDO
    IF         COND(&PRIMARY2 *NE ' ') THEN(DO)
      CHKOBJ     OBJ(&LIBRARY/&PRIMARY2) OBJTYPE(*FILE)
      MONMSG     MSGID(CPF9801) EXEC(DO)
        CHGVAR     VAR(&MSGDTA) VALUE('0000The second +
                     file' |> &PRIMARY2 |> ' doesn''t +
                     exist in' |> &LIBRARY)
        CHGVAR     VAR(&MSGID) VALUE(CPD0006)
        GOTO       CMDLBL(SEND)
      ENDDO
    ENDDO
    IF         COND(&PRIMARY3 *NE ' ') THEN(DO)
      CHKOBJ     OBJ(&LIBRARY/&PRIMARY3) OBJTYPE(*FILE)
      MONMSG     MSGID(CPF9801) EXEC(DO)
        CHGVAR     VAR(&MSGDTA) VALUE('0000The third +
                     file' |> &PRIMARY3 |> ' doesn''t +
                     exist in' |> &LIBRARY)
        CHGVAR     VAR(&MSGID) VALUE(CPD0006)
        GOTO       CMDLBL(SEND)
      ENDDO
    ENDDO
  ENDDO
ENDOK:
  RETURN

ERROR:
/* Receive CPF9999 message                                                    */
  RCVMSG     MSGTYPE(*LAST) MSGDTA(&MSGDTA) MSGID(&MSGID) +
               MSGF(&MSGF) SNDMSGFLIB(&MSGFLIB)
  MONMSG     MSGID(CPF9999)

/* Receive last exception message. If none, receive last message of any sort  */
  RCVMSG     MSGTYPE(*EXCP) MSG(&MSGDTA)
  IF         COND(&MSGID = ' ') THEN(DO)
    RCVMSG     MSGTYPE(*LAST) MSG(&MSGDTA)
  ENDDO
  CHGVAR     VAR(&MSGDTA) VALUE('0000' *TCAT &MSGDTA)
  CHGVAR     VAR(&MSGID) VALUE(CPD0006)

SEND:
  SNDPGMMSG  MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +
               MSGTYPE(*DIAG)
  MONMSG     MSGID(CPF9999)

  SNDPGMMSG  MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)

ENDPGM

-- MartinRowe - 24 Jun 2005
Topic revision: r1 - 24 Jun 2005 - 05:08:26 - MartinRowe
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding DBG/400? Send feedback