/* ************************************************************************** */
/* DBG186CL: WRKUSROUTQ CPP - Work with User Outque                           */
/* 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        PARM(&QUALOUTQ &OVRUSER)
  DCL        VAR(&EMPTY) TYPE(*CHAR) LEN(10) VALUE(' ')
  DCL        VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
  DCL        VAR(&LMTCPB) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MBROPT) TYPE(*CHAR) LEN(8)
  DCL        VAR(&OUTQ) TYPE(*CHAR) LEN(10)
  DCL        VAR(&OVRUSER) TYPE(*CHAR) LEN(10)
  DCL        VAR(&OUTQLIST) TYPE(*CHAR) LEN(275)
  DCL        VAR(&OUTQNAME) TYPE(*CHAR) LEN(10)
  DCL        VAR(&QUALOUTQ) TYPE(*CHAR) LEN(20)
  DCL        VAR(&QUALOUTQ2) TYPE(*CHAR) LEN(20)
  DCL        VAR(&RTNLIB) TYPE(*CHAR) LEN(10)
  DCL        VAR(&STARTPOS) TYPE(*DEC) LEN(3 0) VALUE(1)
  DCL        VAR(&USER) TYPE(*CHAR) LEN(10)
  DCLF       FILE(DBGUOL00) RCDFMT(PFUOL)
/* ************************************************************************** */
/*  GLOBAL MESSAGE MONITOR                                                    */
/* ************************************************************************** */
  MONMSG     MSGID(CPF0000 RPG0000 QRG0000 RSF0000 +
               MCH0000) EXEC(GOTO CMDLBL(##ERROR))
  GOTO       CMDLBL(##NOERROR)
##ERROR:
  MOVDIAGMSG
  MONMSG     MSGID(CPF0000)
  RSNESCMSG
  MONMSG     MSGID(CPF0000)
  RETURN
##NOERROR:
/* ************************************************************************** */
/*  START OF MAINLINE CODE                                                    */
/* ************************************************************************** */
/* Parse command parameter */
  CHGVAR     VAR(&OUTQ) VALUE(%SST(&QUALOUTQ 1 10))
  CHGVAR     VAR(&LIBRARY) VALUE(%SST(&QUALOUTQ 11 10))
/* Set CPYSPLF option initially so existing data is flushed first */
  CHGVAR     VAR(&MBROPT) VALUE('*REPLACE')
/* Get user level (determines if F21=Cmd & swapping *OUTQs enabled */
  RTVUSRPRF  LMTCPB(&LMTCPB)
  RTVJOBA    USER(&USER)
/* Drag in user's default *OUTQ if required */
  IF (&OUTQ *EQ '*JOB') THEN(DO)
    RTVJOBA    OUTQ(&OUTQ) OUTQLIB(&LIBRARY)
    CHGVAR     VAR(%SST(&QUALOUTQ 1 10)) VALUE(&OUTQ)
    CHGVAR     VAR(%SST(&QUALOUTQ 11 10)) VALUE(&LIBRARY)
  ENDDO
/* First time through? Create required runtime objects in QTEMP */
/* DBG1860W holds the data from the QUSLSPL API */
  CHKOBJ     OBJ(QTEMP/DBG1860W) OBJTYPE(*FILE)
  MONMSG     MSGID(CPF9801) EXEC(DO)
    RTVOBJD    OBJ(DBG1860W) OBJTYPE(*FILE) RTNLIB(&RTNLIB)
    CRTDUPOBJ  OBJ(DBG1860W) FROMLIB(&RTNLIB) +
                 OBJTYPE(*FILE) TOLIB(QTEMP)
  ENDDO
  OVRDBF     FILE(DBG1860W) TOFILE(QTEMP/DBG1860W)
/* DBG1871W holds the output from the CPYSPLF command */
  CHKOBJ     OBJ(QTEMP/DBG1871W) OBJTYPE(*FILE)
  MONMSG     MSGID(CPF9801) EXEC(DO)
    CRTPF      FILE(QTEMP/DBG1871W) RCDLEN(259) +
                 SIZE(500000 10000)
  ENDDO
/* DBG1872W holds the formatted data after processing DBG1871W */
  CHKOBJ     OBJ(QTEMP/DBG1872W) OBJTYPE(*FILE)
  MONMSG     MSGID(CPF9801) EXEC(DO)
    CRTPF      FILE(QTEMP/DBG1872W) RCDLEN(255) +
                 SIZE(500000 10000)
  ENDDO
/* QTEMP/FTPSRC Holds the batch FTP instructions */
  CHKOBJ     OBJ(QTEMP/FTPSRC) OBJTYPE(*FILE)
  MONMSG     MSGID(CPF9801) EXEC(DO)
    CRTSRCPF   FILE(QTEMP/FTPSRC) RCDLEN(132)
    ADDPFM     FILE(QTEMP/FTPSRC) MBR(FTPIN)
    ADDPFM     FILE(QTEMP/FTPSRC) MBR(FTPOUT)
  ENDDO
/* QTEMP/DBG186DQ Holds pending subfile requests */
  CHKOBJ     OBJ(QTEMP/DBG186DQ) OBJTYPE(*DTAQ)
  MONMSG     MSGID(CPF9801) EXEC(DO)
    CRTDTAQ    DTAQ(QTEMP/DBG186DQ) MAXLEN(7) SEQ(*KEYED) +
                 KEYLEN(10) TEXT('DBG186DQ - Subfile +
                 requests')
  ENDDO
  CALL       PGM(QCLRDTAQ) PARM('DBG186DQ' 'QTEMP')
/* If dealing with user's spool files only */
  IF         COND(&OUTQ *EQ '*USRSPLF') THEN(DO)
/* If no overriding profile specified, use current */
    IF         COND(&OVRUSER *EQ '*CURRENT') THEN(CHGVAR +
                 VAR(&OVRUSER) VALUE(&USER))
/* Build file from selected user's spool files */
    CALL       PGM(DBG188R4) PARM(&OVRUSER '*ALL' &MBROPT)
    GOTO       CMDLBL(WRKUSROUTQ)
  ENDDO
/* If dealing with multiple *OUTQs */
  IF         COND(&OUTQ *EQ '*OUTQLIST') THEN(DO)
    OVRDBF     FILE(DBGUOL00) POSITION(*KEYAE 1 PFUOL &USER)
/* Loop through the 25 *OUTQ slots in the data area */
TOPOFLOOP:
    RCVF       RCDFMT(PFUOL)
    MONMSG     MSGID(CPF0864 CPF4137) EXEC(GOTO +
                 CMDLBL(WRKUSROUTQ))
/* Quit when all user's records read */
    IF         COND(&ULUSER *NE &USER) THEN(GOTO +
                 CMDLBL(WRKUSROUTQ))
/* Load outfile with spoolfile lists of the *OUTQ in the current slot */
/* (ignoring missing/unauthorised *OUTQs) */
    CHKOBJ     OBJ(&ULOUTL/&ULOUTQ) OBJTYPE(*OUTQ) AUT(*USE)
    MONMSG     MSGID(CPF9800) EXEC(GOTO CMDLBL(NEXTOUTQ))
    CHGVAR     VAR(&QUALOUTQ2) VALUE(&ULOUTQ || &ULOUTL)
    CALL       PGM(DBG188R4) PARM('*ALL' &QUALOUTQ2 &MBROPT)
NEXTOUTQ:
    CHGVAR     VAR(&MBROPT) VALUE('*ADD')
    GOTO       CMDLBL(TOPOFLOOP)
  ENDDO
/* Load outfile with the spoolfile in the single *OUTQ requested */
ONEOUTQ:
  CHGVAR     VAR(&QUALOUTQ2) VALUE(&OUTQ || &LIBRARY)
  CALL       PGM(DBG188R4) PARM('*ALL' &QUALOUTQ2 &MBROPT)
/* Bring up the screen display */
WRKUSROUTQ:
  DLTOVR     FILE(DBGUOL00)
  MONMSG     MSGID(CPF9841)
  CALL       PGM(DBG186R4) PARM(&QUALOUTQ &LMTCPB &OVRUSER)
  DLTOVR     FILE(DBG1860W)
  RETURN
ENDPGM

-- MartinRowe - 24 Jun 2005
Topic revision: r2 - 01 Oct 2014 - 19:37:01 - UnknownUser
 
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