15 pts.
 How can I list users whose status is disabled on AS/400 ?
Hello everybody ! I have to make a cl program in order to list users whose status is disabled. I wanted to know if someone had  tips for me. Thanks

Software/Hardware used:
AS/400
ASKED: May 9, 2011  4:50 PM
UPDATED: May 17, 2011  1:03 PM

Answer Wiki:
If you have the proper authority, you can DSPUSRPRF *ALL Output(*OUTFILE) Then do a Query or SQL of the file that was produced. Query based on user profile status, like UPSTAT = '*DISABLED'
Last Wiki Answer Submitted:  May 17, 2011  1:03 pm  by  CharlieBrowne   33,695 pts.
All Answer Wiki Contributors:  CharlieBrowne   33,695 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Thanks a lot, I’ll try tomorow

 15 pts.

 

I’m not sure what kinds of tips you need. This is a pretty straightforward process. Here’s a trivial sample CL program that prints such a list:

/* +
   CRTCLMOD MODULE( mylib/LSTUSRDSE )            +
            SRCFILE( mylib/QCLSRC )              +
            SRCMBR( LSTUSRDSE )                  +
            LOG( *NO )                           +
                                                 +
   CRTPGM PGM( mylib/LSTUSRDSE )                 +
          BNDDIR( QC2LE )                        +
          ACTGRP( *NEW )                         +
          USRPRF( *OWNER )                       +
*/
pgm  ( +
     )

   dcl   &msgdta      *char  128

   dcl   &NL          *char    1     value( x'15' )
   dcl   &x00         *char    1     value( x'00' )

   dcl   &rc          *int

   dcl   &eofUSRDSE   *lgl           value( '0' )


/* Compile over the IBM-supplied model file... */
   dclf  QADSPUPB

/* List user profiles to a temporary file... */
   dspusrprf   *ALL  output( *OUTFILE ) outfile( QTEMP/LSTUSRDSE )

/* ...and point the compiled file to our temporary one... */
   ovrdbf      QADSPUPB  tofile( QTEMP/LSTUSRDSE )

/* Set a trivial page heading... */
   chgvar           &msgdta       ( +
                                    'List Disabled Profiles' *cat  +
                                    &NL          *cat  +
                                    &NL          *cat  +
                                    &x00               +
                                  )

/* Assign our printed output to QPRINT... */
   ovrdbf      STDOUT  +
                 tofile( QPRINT )  +
                 ovrscope( *JOB ) +
                 share( *YES )

/* Print our trivial heading... */
   callprc        'printf'            ( +
                                        &msgdta        +
                                      ) +
                                rtnval( &rc )



/* Now loop through our temporary file until EOF... */

   dountil  ( &eofUSRDSE )

      rcvf
      monmsg ( cpf0864 )  exec( do )
         chgvar &eofUSRDSE   '1'
         iterate
      enddo

   /* If this one is '*DISABLED', print a line... */
      if ( &UPSTAT *eq '*DISABLED' )  do
         chgvar     &msgdta       ( +
                                    &UPUPRF      *cat  +
                                    '  '         *cat  +
                                    &UPTEXT      *cat  +
                                    &NL          *cat  +
                                    &x00               +
                                  )
         callprc  'printf'            ( +
                                        &msgdta        +
                                      ) +
                                rtnval( &rc )
      enddo
   enddo

/* Clear away our override... */
   dltovr      STDOUT  lvl( *JOB )

/* ...and get out of here... */
   return

endpgm

One specific thing to beware of is that this editor kind of trashes single- and double-quote marks under various circumstances. If you put this into a source member, look it over carefully to catch where single-quotes need to be manually typed over.

If the printed report is longer than a single page, you might consider adding a “page-heading” subroutine.

You can compile the module and create the program in any library you wish. Just be sure to use the example CRTCLMOD and CRTPGM parameters at the least. You can add additional parms, but you’ll have to debug oddities that will arise if you want to remove any from the minimum suggested parms.

Tom

 110,115 pts.