ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

retrieving current lib

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

  • retrieving current lib

    Anyone know how to retrieve your jobs current library

    library set with chgcurlib command..

    it must be in an API.... I just cant remember


    thanks
    Jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: retrieving current lib

    CL command RTVJOBA CURLIB(&CURLIB)
    Never trust a dog to watch your food.

    Comment


    • #3
      Re: retrieving current lib

      Thank You -- but I need to do this inside the RPG its API QUSRJOBI format JOBI0700 (I think) 1st ibm says its only good for interactive jobs ????? second I cant get it to work on either.........

      Code:
           H DEBUG
            * -------------------------------------------------------------
            * Data Structure for API: Retrieve Job Information
            * -------------------------------------------------------------
           d current         s             10
            *
            * Program Info
            *
           d                SDS
           d  @PGM                   1     10
           d  @PARMS                37     39  0
           d  @JOB                 244    253
           d  @USER                254    263
           d  @JOB#                264    269  0
            *
            * Parameter 1 - Recieve Variable
            * ------------------------------
            *  Eight different formats - only JOBI0700 is used
           D RCVVAR          DS
            * Format JOBI0700
            *
           D  BYTRTN                 1      4B 0
           D  BYTVAL                 5      8B 0
           D  QJOBNM                 9     34
           D  JOBNAM                 9     18
           D  USRNAM                19     28
           D  JOBNBR                29     34
           D  INTID                 35     50
           D  JOBSTS                51     60
           D  JOBTYP                61     61
           D  SUBTYP                62     62
           D  RESRV                 63     64
           D  SYSLIB                65     68B 0
           D  PRDLIB                69     72B 0
           D  CURLIB                73     76B 0
           D  USRLIB                77     80B 0
           D  LIB1                  81    336
           D  LIB2                 337    553
            *
            * Parameter 2 - Length of RCVVAR
            * ------------------------------
           D LGTRCV          DS
           D  BIN4A                  1      4B 0 INZ(111)
            *
            * Parameter 3 - Format wanted for RCVVAR (one of 4 possibly)
            * ----------------------------------------------------------
           D FMTNAM          DS
           D  FORMAT                 1      8    INZ('JOBI0700')
            *
            * Parameter 4 - Qualified Job Name
            * --------------------------------
           D QUALJB          DS
           D  IJOBNM                 1     10
           D  IJOBUS                11     20
           D  IJOBNB                21     26
            *
            * Parameter 5 - Internal job
            * --------------------------
           D INTJOB          DS            16
            *
            * Parameter 6 - API Error
            * -----------------------
           D APIERR          DS           256
           D  APILEN                 1      4B 0 INZ(256)
           D  APIERL                 5      8B 0
           D  APIMSG                 9     15
           D  APIDTA                17    256
            *
            * -------------------------------------------------------------
            * Main
            * -------------------------------------------------------------
            *
            * Retrieve Job Information - QUSRJOBI
            * -----------------------------------
           c                   eval      IJOBNM = @JOB
           c                   eval      IJOBUS = @USER
           c                   eval      IJOBNB = %editc(@JOB#:'X')
           C                   EXSR      RTVJOB
            *
           C                   DUMP
           C                   RETURN
            *
            * -------------------------------------------------------------
            * Retrieve Job Information
            * -------------------------------------------------------------
            *
           C     RTVJOB        BEGSR
            *
           C                   CALL      'QUSRJOBI'
           C                   PARM                    RCVVAR                         User Space
           C                   PARM                    LGTRCV                         Length of Receiver
           C                   PARM                    FMTNAM                         Format Name
           C                   PARM                    QUALJB                         Qualified Job Name
           C                   PARM      *BLANK        INTJOB           16            Internal Job iden.
           C                   PARM                    APIERR                         API Error
            * If API-Error, reset RCVVAR
            * --------------------------
           C     APIERL        IFGT      *ZERO
           C                   RESET                   RCVVAR
           C                   ENDIF
            *
           C                   ENDSR
            *
      Attached Files
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: retrieving current lib

        OK... correct me if I'm wrong Sandy .. but, if I kill all the golphers .. they'll lock me up and throw away the key!! (Oh wait... sorry... having a memory lapse)

        But.. could you not use the INFDS?

        Comment


        • #5
          Re: retrieving current lib

          I dont see it in there...... what possition???


          jamie
          "protect the golphers"
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: retrieving current lib

            What about from QUSRJobI?

            Comment


            • #7
              Re: retrieving current lib

              PHP Code:
              HDFTACTGRP(*NOACTGRP(*CALLERTHREAD(*SERIALIZE)                           
               *-------------------------------------------------------------------*       
               *                                                                   *       
               *  
              Programmer Name ......: KpMac                                    *       
               *  
              Date Created .........: XX/XX/XXXX                               *       
               *  
              Application ..........:                                          *       
               *                                                                   *       
               *-------------------------------------------------------------------*       
               *          
              L O G   O F   M O D I C I C A T I O N S                  *       
               *                                                                   *       
               * 
              Autor ID Flag Date Mod |   Description of modification        *       
               * ---------|------|----------|------------------------------------- *       
               * 
              xxxxxxxx xx01 mm/dd/yy xxxxxx                               *       
               *-------------------------------------------------------------------*       
               *                                                                           
               *-------------------------------------------------------------------*       
               *                           
              Prototypes                              *       
               *-------------------------------------------------------------------*       
               *                                                                           
              DgetLibList...                                                           
              D                 PR                  ExtPgm('QUSRJOBI')                 
              D RcvVar                     32767    Options(*VarSize)                  
              D LengthRcv                     10I 0 Const                              
              D FormatName                     8A   Const                              
              D QualJobName                   26    Const                              
              D InternalJobId                 16    Const                              
              D Error_ds                      15                                       
               
              *                                                                       
              D ds_job10700     Ds         32767                                       
              D  BytesRtn                     10I 0                                    
              D  BytesAvl                     10I 0                                    
              D  JobName                      10A                                      
              D  UserId                       10A                                      
              D  JobNumber                     6A                                      
              D  IntJobId                     16A                                      
              D  JobStatus                    10A                                      
              D  JobType                       1A                                      
              D  JobSubType                    1A                                      
              D  Reserved                      2A                                      
              D  NbrSysLibs                   10I 0                                    
              D  NbrPrdLibs                   10I 0                                    
              D  NbrCurLibs                   10I 0                                    
              D  NbrUsrLibs                   10I 0                                    
              D  Filler                    32685    Varying                            
              D
              SysLibList                     *                                      
              DPrdLibList                     *                                      
              DCurLibList                     *                                      
              DUsrLibList                     *                                      
              D                                                                        
               
              *                                                                       
              D ds_Error        Ds            15                                       
              D  BytesProvided                10I 0 inz
              (%size(ds_Error))               
              D  BytesAvail                   10I 0                                    
              D  ErrorId                       7                                       
               
              *                                                                       
               *-------------------------------------------------------------------*   
               *                          
              Data Structs                             *   
               *-------------------------------------------------------------------*   
               *                                                                       
               *                                                                         
               *-------------------------------------------------------------------*     
               *                           
              Constants                               *     
               *-------------------------------------------------------------------*     
               *                                                                         
               *-------------------------------------------------------------------*     
               *                          
              Stand Alone                              *     
               *-------------------------------------------------------------------*     
               *                                                                         
              D Position        S             10I 0 Inz(0)                               
              D LibsToSkip      S             10I 0 Inz(0)                               
              D idx             S             10I 0 Inz(0)                               
              D LibraryList     S          32767A   Varying                              
              D Display_String  S             10A                                        
              D                                                                          
               
              *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*     
               *                             
              Main                                  *     
               *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*     
               *                                                                         
               /
              free                                                                     
                 getLibList
              (ds_job10700:%Size(ds_job10700):'JOBI0700'                       
                            
              :'*' : *Blanks ds_Error);                                     
                                                                                            
                 
              LibsToSkip NbrSysLibs NbrPrdLibs NbrCurLibs;                         
                 
              Position   = (LibsToSkip 11) + 81;                                       
                                                                                            
                 
              LibraryList = %SubSt(ds_job10700:Position:NbrUsrLibs 11);                
                                                                                            
                 For 
              idx=1 to NbrUsrLibs;                                                   
                   
              Display_String = %SubSt(LibraryList:(idx*11)-10:10);                     
                   
              Dsply Display_String;                                                    
                 EndFor;                                                                    
                                                                                            
                                                                                            
                 *
              InLr = *on;                                                               
                  Return;                                                                   
                                                                                            
               /
              end-free                                                                    
               
              *=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*        
               *                           
              Procedures                              *        
               *=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*      
               * 
              Last edited by kpmac; March 23, 2006, 03:33 PM.
              Predictions are usually difficult, especially about the future. ~Yogi Berra

              Vertical Software Systems
              VSS.biz

              Comment


              • #8
                Re: retrieving current lib

                Does that actually work

                thank you sir!
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: retrieving current lib

                  Yessssirrrrreeee bob!
                  Last edited by kpmac; February 7, 2006, 01:11 PM.
                  Predictions are usually difficult, especially about the future. ~Yogi Berra

                  Vertical Software Systems
                  VSS.biz

                  Comment


                  • #10
                    Re: retrieving current lib

                    Didn't see a Date on that script KP .. whats'a'matta? Think you're gonna show your age?

                    Comment


                    • #11
                      Re: retrieving current lib

                      Okay lets revisit this guy...........The code does list the entire library list but.......It doesnt identify the current library. It will just always give you the last library in the library list. I know Im slow and just now got to this......Can someone test this to make sure I'm correct on this.



                      jamie
                      All my answers were extracted from the "Big Dummy's Guide to the As400"
                      and I take no responsibility for any of them.

                      www.code400.com

                      Comment


                      • #12
                        Re: retrieving current lib

                        Okay this works for me anyone in a testing mood.....

                        PHP Code:
                        ==>
                         
                             
                        d SkipLibs        s              3  0
                             d Current         s             10

                              
                        //
                              //  External Calls
                              //

                             
                        d $GetLibList     PR                  ExtPgm('QUSRJOBI')
                             
                        d RcvVar                     32767    Options(*VarSize)
                             
                        d LengthRcv                     10I 0 Const
                             
                        d FormatName                     8A   Const
                             
                        d QualJobName                   26    Const
                             
                        d InternalJobId                 16    Const
                             
                        d Error_ds                      15

                              
                        //
                              //  Data Structures
                              //

                             
                        d ds_job10700     Ds         32767
                             d  BYTRTN                       10i 0
                             d  BYTVAL                       10i 0
                             d  QJOBNM                 9     34
                             d  JOBNAM                 9     18
                             d  USRNAM                19     28
                             d  JOBNBR                29     34
                             d  INTID                 35     50
                             d  JOBSTS                51     60
                             d  JOBTYP                61     61
                             d  SUBTYP                62     62
                             d  RESRV                 63     64
                             d  SYSLIB                       10i 0
                             d  PRDLIB                       10i 0
                             d  CURLIB                       10i 0
                             d  USRLIB                       10i 0
                             d  LIB1                  81    336


                             d ds_Error        Ds            15
                             d  BytesProvided                10I 0 inz
                        (%size(ds_Error))
                             
                        d  BytesAvail                   10I 0
                             d  ErrorId                       7


                              
                        /Free

                                 
                        //------------------------------------------------
                                 //       C a l c u l a t i o n  S p e c s
                                 //------------------------------------------------

                                    
                        $getLibList(ds_job10700:%Size(ds_job10700):'JOBI0700'
                                               
                        :'*' : *Blanks ds_Error);

                                    
                        SkipLibs  = (SysLib  PrdLib)*11;
                                    
                        Current   = %trim(%subst(LIB1:SkipLibs 1:10));

                                      if 
                        curlib = *zeros;
                                        
                        current '*NONE';
                                      endif;

                                    
                        Dsply Current;
                                    *
                        inlr = *on;
                              /
                        end-free
                               
                        //-------------------------------------------------------- 
                        Attached Files
                        All my answers were extracted from the "Big Dummy's Guide to the As400"
                        and I take no responsibility for any of them.

                        www.code400.com

                        Comment


                        • #13
                          Re: retrieving current lib

                          Maybe I'm missing something but cant you use the program data structure to see what library the object is in?
                          Predictions are usually difficult, especially about the future. ~Yogi Berra

                          Vertical Software Systems
                          VSS.biz

                          Comment


                          • #14
                            Re: retrieving current lib

                            Not really ........ I have multiple files spread out across multiple companies in multiple libraries on the same box....Some files are in all libraries some are not.

                            I just want to know what the current library is at the time of the call so I can put it back when Im done screwing with it


                            jamie
                            All my answers were extracted from the "Big Dummy's Guide to the As400"
                            and I take no responsibility for any of them.

                            www.code400.com

                            Comment


                            • #15
                              Re: retrieving current lib

                              OK, I know I'm not the brightest light in the socket.
                              Can some patient person explain why Jamie can't do a call to a cl program, RTVJOBA on the CL and pass it back as a parameter to the RPG.
                              I know there's a reason, but I don't know what.

                              Comment

                              Working...
                              X