Announcement

Collapse
No announcement yet.

Job Description - Library List Retrieval

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Job Description - Library List Retrieval

    Does anyone have a starting point of retrieving ALL Job Descriptions from a system (Library/JobD) and being able to retrieve the Library List associated to that Job Description?

    We need to do a serious clean up of our Production systems. Too many issues to define... but, suffice to say -- it would be a lot simpler if I could retrieve all Library Lists and associated Job Descriptions in a single place.

    Does such a beast exist?

    Thanks!!
    -Rick

    _____________________________

    Need a Managed File Transfer Solution -OR- iSeries Encryption?
    GoAnywhere and Crypto Complete by Linoma Software


  • #2
    Re: Job Description - Library List Retrieval

    i wrote one years ago...somewhere...oh yeah....

    it's not the prettiest (and most likely not the most efficient way...) but you can take a look at the Add Library To Job Descriptions command on my website...it's in the downloads section.http://tommyholden.com (i wrote this waaay before i got heavy into APIs...don't shoot the messenger...)
    Last edited by tomholden; January 13, 2011, 03:32 PM.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Job Description - Library List Retrieval

      It's the QWDRJOBD APi.

      Look this links :
      http://www.mcpressonline.com/program...ary-lists.html
      http://www.code400.com/forum/showthr...g-API-QWRDJOBD
      http://www.think400.dk/apier_3.htm#eks0013
      Patrick

      Comment


      • #4
        Re: Job Description - Library List Retrieval

        see i told you....
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: Job Description - Library List Retrieval

          One thing to keep in mind is that you will likely need authority equivilent to SECOFR authority to pull this off and get everything. The list api's will need it or they will only return the jobd's the user is authorized to. The api to list the library list within a jobd will also need the same authority to display it. Otherwise, the api's appear to run fine and will give you a list, but its simply not complete and there's no error saying that the list isnt complete.

          So you can combine the above api's in Patricks post (I havent checked out Toms) and feed it with the data from a list object API that filters on *ALL/*ALL *JOBD.
          Last edited by MichaelCatalani; January 13, 2011, 03:43 PM.
          Michael Catalani
          IS Director, eCommerce & Web Development
          Acceptance Insurance Corporation
          www.AcceptanceInsurance.com
          www.ProvatoSys.com

          Comment


          • #6
            Re: Job Description - Library List Retrieval

            Tom's is the old DSP* to *PRINT (or *OUTFILE if applicable) and parse the heck out of it...as i said it was before i got into APIs. if i had to do it over again (and thankfully i don't have the necessity) i would use the APIs. one other note...if you have the object owned by a *ALLOBJ authorized user & use adopted authority it'd be fine as well
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: Job Description - Library List Retrieval

              Just for Reference and Follow up ... this is what I'm doing so far:

              Created Command to pass the Search Lib Parameter
              Created CLLE to process/find all instances of the Search Lib withing ALL JobDs on the system
              Created RPGLE to pull the Library List out of each JobD (Thanks to MARC_D from this Cod400 Post)

              This process just loops through ALL JobDs, retrieves the Library List associated to each, then loops through that list to see if the Search Lib exists. If it does, it adds a record to a table in a "Temp" library under the name of the Search Lib. At the end of the process, it displays the table and all entries for viewing. You can use it for visual reference (DSPPFM &RetainLib/&SrchLib). Or, you can use this table to feed another process if necessary.

              Command:
              Code:
                           CMD        PROMPT('Get Library Lists from JobD')
              
                 /* PARAMETERS */
              
                           PARM       KWD(SRCHLIB) TYPE(*CHAR) LEN(10) MIN(1) +
                                        PROMPT('Search for Library:')
              CLLE:

              Code:
                 
                 /****************************************************************/
                 /*                                                              */
                 /* PGM:          GetLibLCL                                      */
                 /*                                                              */
                 /* DESCRIPTION:  Retrieve the Library List of a Job Description */
                 /*                                                              */
                 /* WRITTEN BY:   Rick Elliott                                   */
                 /*                                                              */
                 /* Date Written: 01.14.2011                                     */
                 /*                                                              */
                 /* Notes: *This job will create a table called ALLJOBDS in the  */
                 /*         Temporary Library Designated by "RETAINLIB" below.   */
                 /*         If ALLJOBDS already exists, it uses it.  Delete this */
                 /*         file to force a re-load of all Job Descriptions to   */
                 /*         search through.                                      */
                 /*                                                              */
                 /*        *A table will be created in "RETAINLIB" with the name */
                 /*         of the Library Parameter passed (&SrchLib).  This    */
                 /*         table will have a record with each Job Description   */
                 /*         that is found on the system with has &SrchLib as an  */
                 /*         entry in its Library List.                           */
                 /*                                                              */
                 /*        *The table (&RetainLib/&SrchLib) will be displayed at */
                 /*         the end of this process showing each JobD found.     */
                 /*                                                              */
                 /*        *&RetainLib/&SrchLib is retained for additional       */
                 /*         processing needs or can be deleted as necessary.     */
                 /*                                                              */
                 /*                                                              */
                 /****************************************************************/
              
              Pgm &SrchLib
              
              /* Parameters - Passed In */
                 Dcl  &SrchLib    *Char   10
              
              /* Parameters - GetLibL */
                 Dcl  &JobD       *Char   20
                 Dcl  &LibL       *Char 2750
                 Dcl  &LibLCnt    *Int     2
              
              /* Working Variables */
                 Dcl  &Looping    *Lgl     1  '1'
                 Dcl  &FoundOne   *Lgl     1  '0'
                 Dcl  &X          *Int     4
                 Dcl  &Pos        *Int     4
                 Dcl  &NumFound   *Int     4
                 Dcl  &NumFoundC  *Char    4
                 Dcl  &strLib     *Char   10
                 Dcl  &Error      *Char   75
                 Dcl  &RetainLib  *Char   10  Value( 'Retain15' )
                 Dcl  &Db2CMD     *Char 1024
                 Dcl  &User       *Char   10
                 Dcl  &JobName    *Char   10
                 Dcl  &JobNo      *Char    6
                 Dcl  &QSHFile    *Char   60
              
              /* Declare file for Display Objects */
                 DCLF QSYS/QADSPOBJ
              
                 ChgVar &SrchLib ( &SrchLib )
                 MonMsg mch3601 exec( Do )
                    ChgVar &Error ( 'Syntax:  GETLIBL <LibName>' )
                    Goto Error
                 EndDO
              
                 CallSubR Setup
              
              /* Loop through AllJobDs */
                 DoWhile &Looping
              
                    RcvF
                    MonMsg cpf0864 exec( Do )
                       ChgVar &Looping '0'
                       Iterate
                    EndDO
              
                    ChgVar &JobD     ( &ODOBNM *CAT &ODLBNM )
                    ChgVar &LibL     ( ' ' )
                    ChgVar &LibLCnt  ( 0 )
                    ChgVar &X        ( 1 )
                    ChgVar &Pos      ( 1 )
                    ChgVar &FoundOne ( '0' )
              
                    Call GetLibLR ( &JobD &LibL &LibLCnt )
                    ChgVar &NumFoundC ( &LibLCnt )
              
                    DoUntil ( ( &X *GT &LibLCnt ) *OR &FoundOne )
              
                       ChgVar &strLib ( %SubString( &LibL &Pos 10 ) )
              
                       If ( ( &strLib *EQ ' ' )        *OR +
                            ( &strLib *NE &SrchLib ) ) Then( Do )
                          ChgVar &X   ( &X + 1 )
                          ChgVar &Pos ( &Pos + 11 )
                          Iterate
                       EndDO
              
                       Else ( Do )
                          ChgVar &FoundOne ( '1' )
                          ChgVar &NumFound ( &NumFound + 1 )
                          Leave
                       EndDO
              
                    EndDO
              
                    ChgVar &Error ( ' ' )
                    If ( &FoundOne ) Then( Do )
                       CallSubR ListEntry
                       If ( &Error *NE ' ' ) Then( Goto Error )
                    EndDO
              
                 EndDO
              
                 ChgVar &Error ( 'No Job Description(s) found searching for ' *Cat &SrchLib )
              
              /* Show what you found */
                 If ( &NumFound *GT 0 ) Then( Do )
                    ChgVar &NumFoundC ( &NumFound )
                    ChgVar &Error ( 'JobD Search for Lib: ' +
                                          *Cat &SrchLib   *TCat ' - Found ' +
                                          *Cat &NumFoundC *Cat ' JobDs' )
              
                    DspF file( &RetainLib/&SrchLib )
              
                 EndDO
              
              /* Display Messages */
              
              Error:
              
                 SndPgmMsg msg( &Error ) msgtype( *Comp )
              
              /* Environment Cleanup */
                 RmvEnvVar  envvar( QIBM_QSH_CMD_OUTPUT )
                 RmvEnvVar  envvar( QIBM_QSH_CMD_ESCAPE_MSG )
                 RmvEnvVar  envvar( LName )
                 RmvEnvVar  envvar( FName )
              
                 DltSplF    file( *Select )                         +
                          select( *Current *All *All QP0ZSPWP )
                 MonMsg cpf0000
              
                 DltSplF    file( *Select )                         +
                          select( *Current *All *All QZSHSH   )
              
                 MonMsg cpf0000
              
              /* ********************************************************************* */
              /*                            END of JOB                                 */
              /* ********************************************************************* */
              
              /* ===================================================================== */
              /* Must have found someting -- add it to the list */
              SubR ListEntry
              
                 AddEnvVar  envvar( DLib )                          +
                             value( &ODLBNM )                       +
                           replace( *Yes )
              
                 AddEnvVar  envvar( DFil )                          +
                             value( &ODOBNM )                       +
                           replace( *Yes )
              
                 ChgVar  &Db2CMD ( 'db2 "Insert into $LName.$FName +
                                              ( JobDLib, JobDFil ) +
                                         Values +
                                              ( ''$DLib'', ''$DFil'' )"' )
                 StrQSH cmd( &Db2CMD )
                 MonMsg  qsh0005
              
                 RmvEnvVar  envvar( DLib )
                 RmvEnvVar  envvar( DFil )
              
              EndSubR
              
              /* ===================================================================== */
              /* Get all the Pre-Processing stuff out of the way */
              SubR Setup
              
              /* Make sure Library exists before continuing */
                 ChkObj     obj( &RetainLib )                       +
                        objtype( *Lib )
                 MonMsg cpf0000 exec( Do )
                    CrtLib &RetainLib                               +
                           type( *Test )                            +
                         crtaut( *All )                             +
                           text( 'Temporary Library for Work' )    
                 EndDO
                 
              /* Get List of Job Descriptions on System */
              /*  (No need to rebuild if already there) */
                 ChkObj     obj( &RetainLib/AllJobDs )              +
                        objtype( *FILE )
                 MonMsg cpf0000 exec( Do )
                    DspObjD    obj( *ALL/*ALL )                     +
                           objtype( *JOBD )                         +
                            output( *OUTFILE )                      +
                           outfile( &RetainLib/AllJobDs )
                 EndDO
              
              /* Get rid of previous versions of Library Search */
                 DltF    &RetainLib/&SrchLib
                 MonMsg  cpf0000
              
              /* Retrieve User Name */
                 RtvJobA user( &User )                              +
                          job( &JobName )                           +
                          nbr( &JobNo )
              
              /* Create file for UserJob QSH Output */
                 CrtPF   &RetainLib/&User  rcdlen( 300 )
                 MonMsg  cpf0000 exec( Do )
                    ClrPFM &RetainLib/&User
                    MonMsg cpf0000
                 EndDO
              
                 ChgVar &QSHFile ( 'FILE=/qsys.lib/' *TCAT +
                                    &RetainLib       *TCAT +
                                   '.lib/'           *TCAT +
                                    &User            *TCAT +
                                   '.file/'          *TCAT +
                                    &User            *TCAT +
                                   '.mbr' )
              
                 AddEnvVar  envvar( QIBM_QSH_CMD_OUTPUT )           +
                             value( &QSHFile ) +
                           replace( *Yes )
                 AddEnvVar  envvar( QIBM_QSH_CMD_ESCAPE_MSG )       +
                             value( Y )                             +
                           replace( *Yes )
                 AddEnvVar  envvar( LName )                         +
                             value( &RetainLib )                    +
                           replace( *Yes )
                 AddEnvVar  envvar( FName )                         +
                             value( &SrchLib )                      +
                           replace( *Yes )
              
                 ChgVar  &Db2CMD ( 'db2 "Create Table $LName.$FName ( +
                                                JobDLib Char( 15 ), +
                                                JobDFil Char( 15 ) +
                                         )"' )
                 StrQSH cmd( &Db2CMD )
                 MonMsg  qsh0005
              
              /* Point to Output File */
                 OvrDbf  QADSPOBJ                                   +
                         &RetainLib/AllJobDs
              
              EndSubR
              
              EndPGM
              RPGLE:
              Code:
                   H DFTACTGRP(*NO) OPTION(*SRCSTMT : *NODEBUGIO)
              
                    //************************************************************
                    // RTVJOBD - Retrieve Job Description Command Proc Pgm.
                    //           This program returns the library list
                    //           of the specified Job Description ("jobd").
                    //           In addition, the number of library names
                    //           in the jobd's library lis is also returned.
                    //           See the associated RTVJOBD CMD source for use
                    //           in CL.
              
                    // TIP: The return variables in your CL program should be defined as follows:
                    //           DCL &JobD    TYPE(*CHAR) LEN(20)
                    //           DCL &LibL    TYPE(*CHAR) LEN(2750)
                    //           DCL &LibLCnt TYPE(*INT)  LEN(2)
              
                   D GetLibLR        PR
              
                   D  szJobD                       20A   Const
                   D  rtnLIBL                    2750A
                   D  rtnLIBLCount                  5I 0
              
                   D GetLibLR        PI
                   D  szJobD                       20A   Const
                   D  rtnLIBL                    2750A
                   D  rtnLIBLCount                  5I 0
              
                    /COPY QSYSINC/QRPGLESRC,QWDRJOBD
                    /COPY QSYSINC/QRPGLESRC,QUSEC
              
                    // Retrieve Job Description
                   D RtvJobDAPI      PR                  ExtPgm( 'QWDRJOBD' )
                   D  szRtnBuffer               65535A   OPTIONS( *VARSIZE )
                   D  nRtnBufLen                   10I 0 Const
              
                    // Specify 'JOBD0100'
                   D  apiFormat                     8A   Const
                   D  JobD                         20A   Const
                   D  api_error                          LikeDS( QUSEC )
              
                   D JobD            DS                  LikeDS( QWDD0100 )
                   D                                     Based( pJobD )
              
                   D JobDInfo        DS                  LikeDS( QWDD0100 )
              
                   D LibList         S             11A   Based( pLIBL ) DIM( 250 )
                   D LibL            S           2750A   Based( pLIBL )
                   D APIErrDS        DS                  LikeDS( QUSEC )
              
                    /FREE
                     *INLR = *ON;
              
                     // Sadly, with this API, we need to call it twice to get the LibL
                     // First call: Get the length of the data to be returned.
              
                     APIErrDS         = *ALLX'00';
                     APIErrDS.QUSBPRV = %size( APIErrDS );
                     JobDInfo         = *ALLX'00';
                     RtvJobDAPI( JobDInfo
                               : %size( JobDInfo )
                               : 'JOBD0100'
                               : szJOBD
                               : APIErrDS );
              
                     If APIErrDS.QUSBAVL = 0;
              
                        pJobD = %Alloc( JobDInfo.QWDBAVL );
                        JOBD = *ALLX'00';
              
                     // Second call: Get the library list.
                        RtvJobDAPI( JOBD
                                  : JobDInfo.QWDBAVL
                                  : 'JOBD0100'
                                  : szJOBD
                                  : APIErrDS );
                        If %Parms >= 3;
                           rtnLIBLCount = JobD.QWDNLILL;
                        EndIF;
              
                        If %Parms >= 2;
                           pLibl   = pJobD + JobD.QWDOILL;
                           rtnLibl = %subst( LIBL : 1 : JobD.QWDNLILL * %size( LibList ) );
              
                        EndIF;
                        DeAlloc pJobD;
                     EndIF;
                    /END-FREE
              -Rick

              _____________________________

              Need a Managed File Transfer Solution -OR- iSeries Encryption?
              GoAnywhere and Crypto Complete by Linoma Software

              Comment


              • #8
                Re: Job Description - Library List Retrieval

                FastOne:

                Sorry I missed this post....I had a few days off

                Check out Craig Rutledge's JCRLJOBD here:
                http://www.jcrcmds.com/jcrdown2.html

                JCRLJOBD - Find Library on JOBD libl

                Determine if a library is on the library list of any jobd.
                Library on JOBD libl (LIBLE): . . .__________Library Name
                This is very helpful when wanting to cleanup or delete a library as you check to see if there will be any problems before hand. End result is a spooled file listing all JOBDs that use the selected library.
                Yeah I know a week late and a dollar short

                Best of Luck
                GLS
                Last edited by GLS400; January 20, 2011, 03:23 PM.
                The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                Comment

                Working...
                X