home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
3x400
/
qryf.lzh
/
QRYF.CLP
next >
Wrap
Text File
|
1987-09-04
|
5KB
|
97 lines
/*-------------------------------------------------------------------*/
/* PURPOSE: CCP for the QRYF command, create a temp QRY application */
/* METHOD: The QRYF passes the request, this program sets it up */
/* and calls QRYFR to generate the UDS statements, uses */
/* the CRTQRYAPP command to create the query and runs it */
/* */
/* INVOKED: QRYF command */
/* SCHEDULE: On request */
/* */
/* PROGRAMMER: Robert Hughes DATE: 08/87 */
/* REVISED: F------- L-------- DATE: mm/yy */
/* REASON: */
/*-------------------------------------------------------------------*/
PGM PARM(&FILE &FORMAT &TITLE &FIELDS &MBR)
DCL VAR(&FILE) TYPE(*CHAR) LEN(20)
DCL VAR(&FNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&FLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&FPARM) TYPE(*CHAR) LEN(21)
DCL VAR(&MBR ) TYPE(*CHAR) LEN(10)
DCL VAR(&TITLE ) TYPE(*CHAR) LEN(32)
DCL VAR(&FORMAT) TYPE(*CHAR) LEN(10)
DCL VAR(&FIELDS) TYPE(*CHAR) LEN(512)
DCL VAR(&MMSG) TYPE(*LGL) VALUE('0')
DCL VAR(&MSGID ) TYPE(*CHAR) LEN( 7)
DCL VAR(&MSGF ) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(100)
DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
MONMSG MSGID(CPF0000 RPG0000 IDU0000) EXEC(GOTO +
CMDLBL(ERROR))
/* Extract file.lib names and setup parm to pass to QRYFR */
CHGVAR VAR(&FNAM) VALUE(%SST(&FILE 1 10))
CHGVAR VAR(&FLIB) VALUE(%SST(&FILE 11 10))
CHGVAR VAR(&FPARM) VALUE(&FNAM │< '.' ││ &FLIB)
/* Setup a work source file in QTEMP */
CRTSRCPF FILE(QRYF.QTEMP) MAXMBRS(2) SIZE(500 100 10)
MONMSG MSGID(CPF7302) EXEC(CHGVAR VAR(&MMSG) +
VALUE('1')) /* Make MONMSG IF/ELSE */
IF COND(&MMSG) THEN(DO)
CLRPFM FILE(QRYF.QTEMP) MBR(QRYF)
CLRPFM FILE(QRYF.QTEMP) MBR(COPY)
ENDDO
ELSE CMD(DO)
ADDPFM FILE(QRYF.QTEMP) MBR(QRYF)
ADDPFM FILE(QRYF.QTEMP) MBR(COPY)
ENDDO
/* Call the RPG pgm QRYFR to write the UDS statements */
OVRDBF FILE(QCLSRC) TOFILE(QRYF.QTEMP) MBR(QRYF)
OVRDBF FILE(QCLSRC2) TOFILE(QRYF.QTEMP) MBR(COPY)
CALL PGM(QRYFR.QGPL) PARM(&FPARM &FORMAT &TITLE +
&FIELDS)
/* Use CRTQRYAPP to create the QRY program */
DLTPGM PGM(QRYF.QTEMP)
MONMSG MSGID(CPF0000)
CRTQRYAPP APP(QRYF.QTEMP) SRCFILE(QRYF.QTEMP)
MONMSG MSGID(IDU0000) EXEC(GOTO CMDLBL(ERROR))
/* If &MBR = *OPNQRYF then extract the data to a temporary file and */
/* run the QRYDTA from it. (QRYDTA cannot run from a OPNQRYF) */
IF COND(&MBR *EQ '*OPNQRYF') THEN(DO)
DLTF FILE(QRYFWRK.QTEMP)
MONMSG MSGID(CPF0000)
CRTDUPOBJ OBJ(&FNAM) FROMLIB(&FLIB) OBJTYPE(*FILE) +
TOLIB(QTEMP) NEWOBJ(QRYFWRK)
FMTDTA INFILE((&FNAM.&FLIB)) OUTFILE(QRYFWRK.QTEMP) +
SRCFILE(QRYF.QTEMP) SRCMBR(COPY) +
OPTION(*NOPRT)
OVRDBF FILE(&FNAM) TOFILE(QRYFWRK.QTEMP) SECURE(*YES)
QRYDTA APP(QRYF.QTEMP) OUTPUT(*LIST)
ENDDO
/* Else use QRYDTA against the actual file to create the report */
ELSE CMD(DO)
IF COND(&MBR *NE '*FIRST') THEN(OVRDBF +
FILE(&FNAM) TOFILE(&FNAM.&FLIB) MBR(&MBR))
ELSE CMD(OVRDBF FILE(&FNAM) TOFILE(&FNAM.&FLIB))
QRYDTA APP(QRYF.QTEMP) OUTPUT(*LIST)
ENDDO
GOTO CMDLBL(END)
/* Error handling routine to receive any *ESCAPE messages and resend +
them to the user and then end with a CPF9898 *ESCAPE message */
ERROR: RCVMSG MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) +
MSGFLIB(&MSGFLIB)
IF COND(&MSGID *EQ ' ') THEN(GOTO CMDLBL(FAIL))
SNDPGMMSG MSGID(&MSGID) MSGF(&MSGF.&MSGFLIB) +
MSGDTA(&MSGDTA) MSGTYPE(*INFO)
GOTO CMDLBL(ERROR)
FAIL: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG.QSYS) MSGDTA('The +
QRYF command failed to complete, review +
prior messages') MSGTYPE(*ESCAPE)
END: ENDPGM