ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

ALCOBJ a *USRSPC

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

  • ALCOBJ a *USRSPC

    I have to modify a CL program to check if a user space(UR5301SPC) still exists after an RPG program runs.

    I know I can use the ALCOBJ command in CL but what is the CPF indicator I use if the user space still exists. In my CL book I have CPF1002 which is cannot allocate object , CPF1040 maximum number of objects allocated and CPF1085 object not allocated but how do I do the reverse?

    Thanks,

    DAC

  • #2
    Re: ALCOBJ a *USRSPC

    Hi DAC:

    If you have no error message (CPF1002/1040/1085) you have successfully allocated the object......therefore the object exists.

    By the way....another method of checking for potentially returned cpf messages (instead of the manual)
    1. Prompt the command.
    2. Bring your cursor to the top of the page where the command is in white.
    3. F1
    4. page down to the end of the help text where all potential error messages are listed.

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: ALCOBJ a *USRSPC

      Why not

      PHP Code:
      CHKOBJ OBJ(MyLib/MyUsrSpcOBJTYPE(*USRSPC)
      MONMSG CPF9801 EXEC(DO)
        
      SNDPGMMSG MSG('The object MyUsrSpc in library MyLib type *USRSPC not found')
      ENDDO 
      Philippe

      Comment


      • #4
        Re: ALCOBJ a *USRSPC

        Question:

        I issue a wrkobj ur5301spc and I get this:

        Object Type Library Attribute Text
        UR5301SPC *USRSPC DACLIB USRSPC WORK SPC

        Here is my CL program
        PHP Code:
        *************** Beginning of data ************************************* 
                     
        PGM                                                        
                     DCL        
        VAR(&MAILMBRTYPE(*CHARLEN(50)               
                     
        DCL        VAR(&SUBJECTTYPE(*CHARLEN(50) +             
                                  
        VALUE('BPCSUSRF/UR5301SPC work space')        
                     
        DCL        VAR(&TEXTTYPE(*CHARLEN(100VALUE('The +    
                                  BPCSUSRF/UR5301SPC work space still +         
                                  exist, please review the UR5301 process'
        )     
                                                                                
                     
        ALCOBJ     OBJ((DACLIB/UR5301SPC *USRSPC *EXCL))           
                     
        MONMSG     MSGID(CPF0000EXEC(DO) 
        When I run the program in debug it goes over the ALCOBJ command to my enddo. It never executes my do statement.

        Why is this when the user space exists?

        DAC

        Comment


        • #5
          Re: ALCOBJ a *USRSPC

          please read my previous post.
          Philippe

          Comment


          • #6
            Re: ALCOBJ a *USRSPC

            An object that exists is not consequently allocated.
            What you need is the CL-Command CHKOBJ! See Mercury's post!

            For more information about the two commands have a look at the following links or (simply prompt the commands on your iSeries and press F1 for help).
            ALCOBJ
            CHKOBJ

            At the end of the documentations (and help) all message ids that can be returned are listed.

            Birgitta

            Comment


            • #7
              Re: ALCOBJ a *USRSPC

              My object exists:
              Object Type Library Attribute Text
              UR5301SPC *USRSPC DACLIB USRSPC WORK SPC

              Here is my CL program
              PHP Code:

                        DCL        
              VAR(&MAILMBRTYPE(*CHARLEN(50)
                           
              DCL        VAR(&SUBJECTTYPE(*CHARLEN(50) +
                                        
              VALUE('BPCSUSRF/UR5301SPC work space')
                           
              DCL        VAR(&TEXTTYPE(*CHARLEN(100VALUE('The +
                                        BPCSUSRF/UR5301SPC work space still +
                                        exist, please review the UR5301 process'
              )

                           
              CHKOBJ     OBJ(DACLIB/UR5301SPCOBJTYPE(*USRSPC) +
                                        
              AUT(*ALL)

                           
              MONMSG CPF0000 EXEC(DO)
                           
              ADDLIBLE   LIB(KMLIB)
                           
              MONMSG     MSGID(CPF0000)
                           
              ADDLIBLE   LIB(KMDATA)
                           
              MONMSG     MSGID(CPF0000)

                           
              /* Create Mail Member */
                           
              KMLTXTM    MAILMBR(&MAILMBR) +
                                        
              TOADDR(DAVIDC@XXXXXXXXXXXXXX.COM) +
                                        
              SUBJECT(&SUBJECTTEXT(&TEXTSENDMBR(*NO)
                           
              /* Mail  */

                           
              RMVLIBLE   LIB(KMDATA)
                           
              RMVLIBLE   LIB(KMLIB)
                           
              ENDDO


                           ENDPGM 
              Problem: When I debug this program it goes from the chkobj command to the enddo command. It doesn't go into my loop. It should because the object exist. Does anyone see any issues with it or can recommend what I can do next?

              Thanks,

              DAC
              Last edited by jamief; February 18, 2010, 09:50 AM. Reason: Please use [ code] or [ php] tags on your code

              Comment


              • #8
                Re: ALCOBJ a *USRSPC

                This is typically a misunderstanding of the CHKOBJ command. Actually the program will go into the loop if the user space does NOT exist.
                Philippe

                Comment


                • #9
                  Re: ALCOBJ a *USRSPC

                  The problem is I have to do the reverse. I have to send an email if the object still exists. Does anyone have any recommendations?

                  DAC

                  Comment


                  • #10
                    Re: ALCOBJ a *USRSPC

                    here is a sample in RPG of checking lock status..
                    Just posting to post

                    Nice car Mercury!

                    PHP Code:


                         d alreadylocked   s               n
                         d cmdstring       s            256
                         d cmdlength       s             15  5
                         d somefield       s              5  0

                         D Locked          C                   00202

                           
                    //
                           //  external calls
                           //

                         
                    d $command        pr                  extpgm('QCMDEXC')
                         
                    d   command                    256
                         d   Length                      15  5

                          
                    /Free

                            
                    //--------------------------------------------------------
                            // MAIN PROGRAM
                            //--------------------------------------------------------

                             
                    cmdstring 'ALCOBJ OBJ((LBIFIL/BRC01LOCK *DTAARA *EXCL))';
                             
                    cmdlength = %len(%trim(cmdstring));

                             
                    dou Alreadylocked = *off;
                             
                    monitor;
                             
                    AlreadyLocked = *off;
                             
                    $command(cmdstringcmdlength);
                             
                    On-error Locked;
                              
                    somefield =  %Status;
                              
                    AlreadyLocked = *on;
                             
                    endmon;
                             
                    enddo;

                             *
                    inlr = *on;



                          /
                    End-Free 
                    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


                    • #11
                      Re: ALCOBJ a *USRSPC

                      Code:
                                   CHKOBJ     OBJ(DACLIB/UR5301SPC)   OBJTYPE(*USRSPC) +                                 
                                                AUT(*ALL)
                      
                                   MONMSG CPF0000 EXEC(GOTO SKIPIT)
                                   ADDLIBLE   LIB(KMLIB)
                                   MONMSG     MSGID(CPF0000)
                                   ADDLIBLE   LIB(KMDATA)
                                   MONMSG     MSGID(CPF0000)
                      
                                   /* Create Mail Member */
                                   KMLTXTM    MAILMBR(&MAILMBR) +
                                                TOADDR(DAVIDC@XXXXXXXXXXXXXX.COM) +
                                                SUBJECT(&SUBJECT) TEXT(&TEXT) SENDMBR(*NO)
                                   /* Mail  */
                      
                                   RMVLIBLE   LIB(KMDATA)
                                   RMVLIBLE   LIB(KMLIB)
                                  /* ENDDO*/
                      
                      SKIPIT:
                                   ENDPGM
                      I'm not anti-social, I just don't like people -Tommy Holden

                      Comment


                      • #12
                        Re: ALCOBJ a *USRSPC

                        Nasty CL

                        PHP Code:
                        CHKOBJ     OBJ(&LIBRARYOBJTYPE(*LIB)                   
                        MONMSG     MSGID(CPF0000EXEC(DO)                       
                        CHGVAR     VAR(&MSGTXTVALUE('Library ' *CAT &LIBRARY 
                                     *
                        BCAT 'not found or not available.')        
                        SNDPGMMSG  MSG(&MSGTXTTOPGMQ(*PRVTOMSGQ(*TOPGMQ) +   
                                     
                        MSGTYPE(*COMP)                              
                        GOTO       
                        CMDLBL(ENDOFPGM)                              
                        ENDDO 
                        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: ALCOBJ a *USRSPC

                          Originally posted by DAC
                          The problem is I have to do the reverse. I have to send an email if the object still exists. Does anyone have any recommendations?
                          This is a piece of cake

                          Look below.


                          Code:
                                       DCL        VAR(&EXIST) TYPE(*LGL) 
                                       
                                       CHGVAR &EXIST '1'
                          
                                       CHKOBJ     OBJ(DACLIB/UR5301SPC) OBJTYPE(*USRSPC) +
                                                    AUT(*ALL)
                                       MONMSG CPF9801 EXEC(CHGVAR &EXIST '0')
                          
                                       IF (&EXIST = '1')  EXEC(DO)
                          [INDENT]             ADDLIBLE   LIB(KMLIB)
                                       MONMSG     MSGID(CPF0000)
                                       ADDLIBLE   LIB(KMDATA)
                                       MONMSG     MSGID(CPF0000)
                                       /* Create Mail Member */
                                       KMLTXTM    MAILMBR(&MAILMBR) +
                                                    TOADDR(DAVIDC@XXXXXXXXXXXXXX.COM) +
                                                    SUBJECT(&SUBJECT) TEXT(&TEXT) SENDMBR(*NO)
                                       /* Mail  */
                          
                                       RMVLIBLE   LIB(KMDATA)
                                       RMVLIBLE   LIB(KMLIB)[/INDENT]
                          
                                       ENDDO
                          Philippe

                          Comment


                          • #14
                            Re: ALCOBJ a *USRSPC

                            Really ? Thanks Jamie.
                            Philippe

                            Comment


                            • #15
                              Re: ALCOBJ a *USRSPC

                              Was that really meant for me? (if so YES)
                              I hate when threads get hiJacked

                              sorry its my fault
                              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

                              Working...
                              X