|
|
![]() |
|
|
|
|
||
|
Which Commands Can Build Outfiles? Hey, Ted: You always do such a great job on Midrange Guru that I hate to even mention this comment, but your tip on using the Display Object Description (DSPOBJD) command for user profiles was a bow-wow. The Display User Profile (DSPUSRPRF) command has *OUTFILE capability with *ALL and you can get all sorts of different profile info, including group profiles, special authorities, etc. But don't sweat it. I'd rather have you doing this letter with the bow-wows than not have you doing it. -- John Thanks for your comments, John. Several other readers felt the same way. If you are looking for information specific to user profiles, the DSPUSRPRF command does the trick much better. In your "Odds and Ends" column in the November 8, 2002 issue of Midrange Guru, a reader asked for a method of placing user profile names into a file. While DSPOBJD may accommodate this person's specific needs, I find that DSPUSRPRF to a *OUTFILE allows for a greater level of analysis of my user community. For instance, you could then run a query over the file to determine who hasn't signed on in over 90 days or who's profile is disabled. While your solution will give them a list of user-profile names, using the DSPUSRPRF command to display users profile to an outfile seems a better way to do this, since other information about the user profiles will be available. While there is nothing wrong with this solution, another option is to use the DSPUSRPRF command. The DSPUSRPRF command creates an output file that provides the user profile names and additional information related to the user profile. The outfile of the Work with User Profiles (WRKUSRPRF) command is available on the DSPUSRPRF command.
Well, that's enough. I agree with all of you that DSPUSRPRF also provides a list of user profiles. Furthermore, I agree that DSPUSRPRF provides more information about user profiles than DSPOBJD does. Let's go back to the original question. "Work with User Profiles (WRKUSRPRF) command will not load a list of user profile names into a database file. Is there some other way to do this?" I gave the first solution that came to mind, to use DSPOBJD. It solved the questioner's problem. Had I thought of DSPUSRPRF, the question would probably never have been included in the "Odds and Ends" column, and we would have all been the poorer for it, as I will show you. Suppose the questioner had asked for an outfile of data area names. The Display Data Area (DSPDTAARA) command does not display a list of data areas. The Work with Data Areas command lists data areas to the display, but not to an outfile. However, DSPOBJD can produce a list of any type of object to an outfile, and that is why I included that question in Midrange Guru. As I said in that article, "I think a lot of us forget this command exists, since so many object-specific commands have *OUTFILE capabilities." Anyway, these readers piqued my curiosity, so I wrote a CL program to try to find out which DSPxxx and WRKxxx commands can write to an outfile and which ones can't. My program builds a work file, each record of which contains a command name and a value of Y or N. I used SQL to extract the following lists of commands. Unless there's a bug in my program, here are the V5R1 commands that can write to an outfile:
These are the commands that do not support the OUTPUT(*OUTFILE) option:
The list of commands that does not support OUTPUT(*OUTFILE) is quite a bit larger, but to be fair, many of them do not reference objects. DSPOBJD can handle most if not all of the object types that you might want a list of. That's why I think DSPOBJD is such a great tool and why I was glad to give it some publicity in Midrange Guru. For those who would like to double-check my work, I'm including the source code. Anyone who would like to know how to make CL write to disk files may also find my source code of interest. -- Ted CL program CMDS001C
/* List the names of all DSPxxx and WRKxxx commands to a file */
/* along with a flag telling whether or not they support the */
/* OUTPUT(*OUTFILE) parameter. */
/* Before compiling, set the value of the &LIB variable */
/* to the name of the library in which the work file should */
/* be built, and the value of &FILE to the work file name. */
/* To compile: */
/* CRTCLPGM PGM(xxx/CMDS001C) SRCFILE(xxx/QCLSRC) */
PGM
DCL VAR(&CMDSTR) TYPE(*CHAR) LEN(80)
DCL VAR(&TYPE) TYPE(*CHAR) LEN(1)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(80)
DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE(MYLIB)
DCL VAR(&FILE) TYPE(*CHAR) LEN(10) VALUE(COMMANDS)
DCLF FILE(QADSPOBJ)
MONMSG CPF0000 EXEC(GOTO ABEND)
/* Create list of DSPxxx and WRKxxx commands from QSYS */
DSPOBJD OBJ(QSYS/DSP*) OBJTYPE(*CMD) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ)
DSPOBJD OBJ(QSYS/WRK*) OBJTYPE(*CMD) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ) +
OUTMBR(*FIRST *ADD)
/* Clear or build the work file */
CLRPFM FILE(&LIB/&FILE)
MONMSG CPF3142 EXEC(DO)
CRTPF &LIB/&FILE RCDLEN(96)
ENDDO
/* Load the work file with the commands & flags */
WRTDBF ACTION(OPEN) DATA(&LIB *CAT '/' *CAT &FILE)
OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ)
READ:
RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO EOF)
CHGVAR VAR(&TYPE) VALUE('Y')
CHGVAR VAR(&CMDSTR) VALUE(&ODOBNM *BCAT +
'output(*outfile)')
/* Does this command support OUTPUT(*OUTFILE)? */
CALL PGM(QCMDCHK) PARM(&CMDSTR 80)
MONMSG MSGID(CPF0006) EXEC(DO)
READMSG:
RCVMSG RMV(*YES) MSG(&MSGTXT) MSGID(&MSGID)
IF (&MSGID *EQ ' ') +
THEN(GOTO ENDREADMSG)
IF (&MSGID *EQ 'CPD0043' *OR &MSGID *EQ +
'CPD0084' *OR &MSGID *EQ 'CPD0074') +
THEN(CHGVAR VAR(&TYPE) VALUE('N'))
/* to see the messages that are being evaluated, */
/* uncomment the next command */
/* WRTDBF ACTION(WRITE) DATA(&ODOBNM *BCAT &TYPE
*BCAT + &MSGID *BCAT &MSGTXT) */
GOTO READMSG
ENDREADMSG:
ENDDO
WRTDBF ACTION(WRITE) DATA(&ODOBNM *CAT ' ' *CAT
&TYPE)
GOTO READ
EOF:
WRTDBF ACTION(CLOSE)
RETURN /* normal end of job */
ABEND:
SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) +
MSGDTA('Unexpected error; see job log.') +
MSGTYPE(*ESCAPE)
MONMSG MSGID(CPF0000)
ENDPGM
Command WRTDBF
/* WRITE TO A DATABASE FILE */
/* TO CREATE: */
/* CRTCMD CMD(XXX/WRTDBF) PGM(XXX/WRTDBFR) */
CMD PROMPT('Write to Database File')
PARM KWD(ACTION) TYPE(*CHAR) LEN(8) MIN(1) +
EXPR(*YES) PROMPT('Action')
PARM KWD(DATA) TYPE(*CHAR) LEN(4096) EXPR(*YES) +
PROMPT('Data')
RPG program WRTDBFR:
* Write to a database file
* To compile:
* CRTBNDRPG PGM(XXX/WRTDBFR) SRCFILE(XXX/QRPGLESRC)
H dftactgrp(*no) actgrp(*caller)
FDBFile o f 4096 disk usropn extfile(FileName)
D WriteToDisk pr extpgm('WRTDBFR')
D Action 8a
D Data 4096
D WriteToDisk pi
D Action 8a
D Data 4096
D FileName s 20
D Output ds 4096
C select
C when Action = 'OPEN'
C eval FileName = Data
C open DBFile
C when Action = 'WRITE'
C eval Output = Data
C write DBFile Output
C when Action = 'CLOSE'
C close DBFile
C eval *inlr = *on
C other
C endsl
C return
|
Editors
Contact the Editors |
|
Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |