ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

chkobj problem

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

  • chkobj problem

    hi guys...i am having a problem with my clle pgm...as you can see on my code below here
    Code:
    PGM        PARM(&INSCD)                                     
                                                                
    DCL        VAR(&INSCD) TYPE(*CHAR) LEN(10)                  
                                                                
    ADDLIBLE   LIB(BILLPxxx)                                    
    MONMSG     MSGID(CPF0000)                                   
                                                                
    CHKOBJ     OBJ(QTEMP/LNGxxx) OBJTYPE(*FILE)                 
    MONMSG MSGID(CPF9801) EXEC(DO)                              
    CRTDUPOBJ  OBJ(LNGxxx) FROMLIB(*LIBL) OBJTYPE(*FILE) +      
        TOLIB(QTEMP) NEWOBJ(*OBJ) DATA(*NO)                     
    ENDDO                                                       
                                                                
    CHKOBJ     OBJ(QTEMP/LNGNVATxxx) OBJTYPE(*FILE)             
    MONMSG MSGID(CPF9801) EXEC(DO)                              
    CRTDUPOBJ  OBJ(LNGNVATxxx) FROMLIB(*LIBL) OBJTYPE(*FILE) +  
    TOLIB(QTEMP) NEWOBJ(*OBJ) DATA(*NO)                         
    ENDDO                                                       
    
    OVRDBF     FILE(LNGxxx) TOFILE(QTEMP/LNGxxx) MBR(*FIRST)   
    OVRDBF     FILE(LNGNVATxxx) TOFILE(QTEMP/LNGNVATxxx) +     
               MBR(*FIRST)                                     
                                                               
    CALL       PGM(LNGNVARNEW) PARM(&INSCD)                    
                                                               
                                                               
    CHKOBJ     OBJ(PMDATPLNS/LNGNVASND) OBJTYPE(*FILE)         
                           
    MONMSG     MSGID(CPFA0A0) EXEC(DO)                     
    CPYF       FROMFILE(*LIBL/LNGNVA) +                        
                 TOFILE(PMDATPLNS/LNGNVASND) MBROPT(*REPLACE)  
                 ENDDO                                           
                                                               
    CHKOBJ     OBJ(PMDATPLNS/LNGNVASND) OBJTYPE(*FILE)         
    MONMSG     MSGID(CPFA0A9) EXEC(DO)                         
    CRTDUPOBJ  OBJ(LNGNVA) FROMLIB(*LIBL) OBJTYPE(*FILE) +     
                 TOLIB(PMDATPLNS) NEWOBJ(LNGNVASND) DATA(*YES) 
               ENDDO      
                                         
     RMVLIBLE   LIB(BILLPYMN)   
     MONMSG     MSGID(CPF0000)
    after i call the pgm i want to send the object to the designated library but first i have to check the object if is already exist then the program would execute cpyf replace....and if the object doesn't exist
    the cl would create it...but so far i'am stuck on the cpyf command because it doesn't send the file to library that i want...please....really need help....thanks

  • #2
    Re: chkobj problem

    if you're just going to replace the file's data every time regardless of whether it exists or not then why not just do something like this:
    Code:
    DLTF THISLIB/THISFILE
    MONMSG CPF0000
    CPYF THISLIB/THISFILE THATLIB/THATFILE CRTFILE(*YES)
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: chkobj problem

      Hi opunx:

      You are only doing the cpyf when you get error message CPFA0A0.
      CPFA0A0 is not generated from the chkobj command. Valid error messages are:
      CPF9801 Object &2 in library &3 not found.
      CPF9802 Not authorized to object &2 in &3.
      CPF9810 Library &1 not found.
      CPF9815 Member &5 file &2 in library &3 not found.
      CPF9820 Not authorized to use library &1.
      CPF9830 Cannot assign library &1.
      CPF9899 Error occurred during processing of command.
      To see the valid error messages on any IBM command....Prompt on that command ..... move your cursor to the top of the page ....... press help key ........and page down to the bottom of the help text

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

      Comment


      • #4
        Re: chkobj problem

        Originally posted by tomholden View Post
        if you're just going to replace the file's data every time regardless of whether it exists or not then why not just do something like this:
        Code:
        DLTF THISLIB/THISFILE
        MONMSG CPF0000
        CPYF THISLIB/THISFILE THATLIB/THATFILE CRTFILE(*YES)
        hi tom, i am trying to avoid using the dltf command....is it possible using IF command??? like on RPGLE if %found then exec CPYF???

        Comment


        • #5
          Re: chkobj problem

          no you'd have to use CHKOBJ and monitor for the appropriate messages, etc. what's the difference between deleting the file & replacing the contents? a couple of nano-seconds. to use monmsg for this you'll have to use "bass-ackwards" logic:
          Code:
                    CHKOBJ     OBJ(PMDATPLNS/LNGNVASND) OBJTYPE(*FILE)         
                                 
                    MONMSG     MSGID(CPF9801) EXEC(goto next)                     
                    CPYF       FROMFILE(*LIBL/LNGNVA) +                        
                       TOFILE(PMDATPLNS/LNGNVASND) MBROPT(*REPLACE)  
                    ENDDO 
          NEXT:
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #6
            Re: chkobj problem

            I would suggest that you also check the file for locks before the delete/copy with *REPLACE.
            Regards

            Kit
            http://www.ecofitonline.com
            DeskfIT - ChangefIT - XrefIT
            ___________________________________
            There are only 3 kinds of people -
            Those that can count and those that can't.

            Comment


            • #7
              Re: chkobj problem

              Originally posted by tomholden View Post
              no you'd have to use CHKOBJ and monitor for the appropriate messages, etc. what's the difference between deleting the file & replacing the contents? a couple of nano-seconds. to use monmsg for this you'll have to use "bass-ackwards" logic:
              Code:
                        CHKOBJ     OBJ(PMDATPLNS/LNGNVASND) OBJTYPE(*FILE)         
                                     
                        MONMSG     MSGID(CPF9801) EXEC(goto next)                     
                        CPYF       FROMFILE(*LIBL/LNGNVA) +                        
                           TOFILE(PMDATPLNS/LNGNVASND) MBROPT(*REPLACE)  
                        ENDDO 
              NEXT:
              Tom is correct -- the MONMSG lends itself to "negative logic."

              Another approach I've seen is:
              Code:
              DCL  &FOUNDIT  *LGL
              CHKOBJ     OBJ(PMDATPLNS/LNGNVASND) OBJTYPE(*FILE)         
                                     
              MONMSG    MSGID(CPF9801) (CHGVAR  &FOUNDIT  '0')
              ELSE                                 (CHGVAR  &FOUNDIT '1')
              
              IF  (&FOUNDIT *EQ '1')  THEN(CPYF FROMFILE(*LIBL/LNGNVA) +                        
                           TOFILE(PMDATPLNS/LNGNVASND) MBROPT(*REPLACE))
              Note: I just checked the forum from a library. Hopefully my response (i.e. the code) is correct with respect to matching parens etc.

              However, what kit said about locks is also a good idea.
              http://www.linkedin.com/in/chippermiller

              Comment


              • #8
                Re: chkobj problem

                Originally posted by tomholden View Post
                no you'd have to use CHKOBJ and monitor for the appropriate messages, etc. what's the difference between deleting the file & replacing the contents? a couple of nano-seconds. to use monmsg for this you'll have to use "bass-ackwards" logic:
                Code:
                          CHKOBJ     OBJ(PMDATPLNS/LNGNVASND) OBJTYPE(*FILE)         
                                       
                          MONMSG     MSGID(CPF9801) EXEC(goto next)                     
                          CPYF       FROMFILE(*LIBL/LNGNVA) +                        
                             TOFILE(PMDATPLNS/LNGNVASND) MBROPT(*REPLACE)  
                          ENDDO 
                NEXT:
                thank u very much...it works....

                Comment

                Working...
                X