On 06-Feb-2017 13:20 -0700,
jjeffre...@gmail.com wrote:
> Anyone know how to get input and then with an IF statement RUNQRY
> with print or display within an CLP CLLE program?
Send User Message (SNDUSRMSG) can send a stored or impromptu message,
and enable obtaining a reply value into a CL variable [without
compiling/using a display file, as would be required with Send/Receive
File (SNDRCVF)].
PGM
DCL &OUTSPEC *CHAR 8
DCL &OUTTYPE *CHAR 8 '*PRINTER'
SndUsrMsg MSG('Direct Query Output to? (*PRINT or *)') +
DFT(*PRINT) MSGTYPE(*INQ) TOMSGQ(*) +
MSGRPY(&OUTSPEC) VALUES(* *PRINT)
If (&OutSpec *eq '*') Then(ChgVar &OutType '*DISPLAY')
/* '*N' occurs for no reply; defaults to *PRINTER */
RUNQRY TheLib/TheQuery OUTTYPE(&OutType)
ENDPGM
Creating a Command Definition (*CMD) object is an alternative means
to effect the presentation of a[n effectively dynamic] display file; the
Command Processing Program (CPP) would obtain the value specified on the
parameter by the user, and then utilize some means to enable the
invoking program to obtain the value -- a bit query, but the value could
even be returned via another parameter in the command that has been
defined with *YES for the Return Value (RTNVAL). More simply/direct
however, would be to create a command/CPP that would be specific to
running the query with the only parameter being the output
specification; i.e. the RUNQRY is encapsulated in that CPP:
Command source:
CMD RunThatQRY
PARM OUTPUT *CHAR RSTD(*YES) +
SPCVAL((* *) (*PRINT P)) MIN(0) LEN(1) +
CHOICE(*VALUES) PROMPT('Report output') DFT(*)
CPP source:
PGM PARM(&OUTSPEC)
DCL &OUTSPEC *CHAR 1
DCL &OUTTYPE *CHAR 8 '*PRINTER'
/* any value other than '*' runs with printer output */
If (&OutSpec *eq '*') Then(ChgVar &OutType '*DISPLAY')
RUNQRY TheLib/TheQuery OUTTYPE(&OutType)
ENDPGM
I wonder however, if perhaps coding the following [with any desired
adjustments made to selective prompt specifications and/or parameter
specifications], might effect what is required, without ceding too much
control to the user?:
? RUNQRY ?-QRY(THELIB/THEQUERY) ?-QRYFILE((*SAME))
?-RCDSLT(*NO) ?-OUTFORM(*RUNOPT)
?-PRTDFN(*RUNOPT) ?-OUTFILE(*N) ?-AUT(*RUNOPT)
?-FORMSIZE(*RUNOPT) ?-FORMTYPE(*RUNOPT)
?-COPIES(*RUNOPT) ?-LINESPACE(*RUNOPT)
??OUTTYPE(*DISPLAY) /* ?-PRTDEV(*RUNOPT) */
MONMSG CPF6801 EXEC(DO)
/* handler for the user having exited without Enter */
ENDDO
--
Regards, Chuck