ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Cpyfrmimpf fails

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

  • Cpyfrmimpf fails

    I have a system for updating files where the user is creating a text file from a database system. This is placed on the IFS where a monitoring program is watching the folder. If file is there then it runs another program to cpyfrmimpf to an iSeries file.

    If the file copies ok then the file is moved to an archive folder and all is well. If the folder is empty then an error is generated CPF2817, e-mail is sent to user BUT the system can not move the file to the archive folder because it is locked and in use (CPFA09E). Can't even manually delete it from PC.

    The only way to release the file is to end my system and restart.

    How can the called RPGLE program release the empty file. All commands are done within my RPGLE. The monitor program calls the applicable program that does the cpyfromimpf and does the processing then once done returns with *INlr on to the monitoring program that is attempting to do the move.

    Any ideas will be greatly appreciated.

    thnx
    Bill
    Bill
    "A good friend will bail you out of jail,
    A true friend would be sitting beside you saying,
    'Wow, that was fun.'"

  • #2
    Re: Cpyfrmimpf fails

    Hi Bill,

    Have you tried the same by using CLP by MONMSG command and if the problem arises you can Check out(CHKOUT) the corresponding object.
    So that you can access the same from another program as the locks will not present.

    PRADEEP
    Pradeep

    Comment


    • #3
      Re: Cpyfrmimpf fails

      A wild-butt guess would be that the monitoring program is using the IFS api's, and the file handle ID that was generated with the "OPEN" is not being "closed" if there was an error calling the program that has the CPYFRMIMPF. In other words, if there is a problem with the copy, a CLOSE is not being performed against the file handle ID, so its still open, which means there's a lock on the file.
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment


      • #4
        Re: Cpyfrmimpf fails

        Text for message cpf2817
        Message ID . . . . . . . . . : CPF2817
        Message file . . . . . . . . : QCPFMSG
        Library . . . . . . . . . : QSYS

        Message . . . . : Copy command ended because of error.
        Cause . . . . . : An error occurred while the file was being copied.
        Recovery . . . : See the messages previously listed. Correct the errors,
        and then try the request again.
        Sounds like there is another error message that can be monitored for

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

        Comment


        • #5
          Re: Cpyfrmimpf fails

          I am monitoring for all errors.

          Program 1 = Monitors fodler for a file, if one arrives I call program 2 which does the cpyfrminp, processes the record then returns rto program 1. If program 2 detects an error, bad file, empty file it returns to program 1 with the error. Program 1 then attempts to move the IFS file to another folder but can not because it is still locked in program 2.

          I have changed program 1 when it gets the IFS file information to check the size, if size is zero then I send an e-m ail and move it to the archive folder.

          But why is program 2 in the prior scenario still locking the file after the CPF2817 is issued? I can not even manually delete the file from the IFS.

          Thnx
          Bill
          Bill
          "A good friend will bail you out of jail,
          A true friend would be sitting beside you saying,
          'Wow, that was fun.'"

          Comment


          • #6
            Re: Cpyfrmimpf fails

            Could you post the code for program 2?

            When you say you have to end the system to clear the problem, are you talking about an IPL, or do you mean end the subsystem to shut these jobs down. If you can clear it by shutting down the jobs / subsystem, then it is likely a file handle being left open. File handles are job specific, and should be forced to close at EOJ.
            Michael Catalani
            IS Director, eCommerce & Web Development
            Acceptance Insurance Corporation
            www.AcceptanceInsurance.com
            www.ProvatoSys.com

            Comment


            • #7
              Re: Cpyfrmimpf fails

              Here's a summary of the code that does the copy and monitors for the failure:
              PHP Code:
              d Main            Pi
              d FileToProc                   125                        In
              -coming Parm
               
              *   
              d FirstCmd        c                   Const('CPYFRMIMPF FROMSTMF(''')                          
              d SecondCmd       c                   Const(''') TOFILE(*Libl/ITMRESP) -                       
              d                                     MBROPT(*REPLACE) RCDDLM(*CR) -                           
              d                                     STRDLM(*NONE)'
              )                                           
               *
              d ThirdCmd        c                   Const(' RPLNULLVAL(*FLDDFT)')                            
              d Quote           c                   Const('''')                                              
              d Commd           s            255     Inz                                                     
               
              *     Sample Command                                                                                        
               
              *        CPYFRMIMPF FROMSTMF('/QNTC/WindowsServer/FIXTURES/ITEM201005210910.txt')          
               *        
              TOFILE(*Libl/ITMRESPMBROPT(*REPLACERCDDLM(*CR
               *        
              RPLNULLVAL(*FLDDFT)                                                                   

                 
              LongFile =  %Trim(Server) + %Trim(FileToProc);                // File Name Will Be        
                                                                                                           
                 
              Commd = %Trim(FirstCmd) +  %Trim(LongFile) + %Trim(SecondCmd) + // assemble the command                                                  
                         
              ThirdCmd ;                                                                        
                                                                                                           
                 
              ErrorFlg As400cmd(Commd);                                    // process the command     
                 
              If ErrorFlg <> and ErrorFlg <> -1;                           // any errors e-mail and return                           
                    
              Im_Error 'Error in Commd check dump ' ErrorCPF;                                    
                                                                                                           
                  
              // Send email to user                                                                    
                  
              Subject 'Item Xfer FILE ERROR ';                                                       
                  
              Message Subject + %Trim(FileToProc) +                                                  
                          
              ' has error in processing file. Contact DbAdmin.';                               
                  
              ToEmail   = %Trim(CcEmail)   + '@Mail.com';                                          
                  
              Othermail = %Trim(Othermail) + '@Mail.com';                                          
                  
              SndEMailSubject Message ToEmail OtherMail Aok );                               
                  
              ProcErr = *On;                                                                           

                                                                                      
                    
              Dump;                                                             
                    *
              Inlr = *On;                                                      
                    Return;                                                           
                 Endif; 
              If it doesn't fail then the copy was successful and the ITMRESP file is opened , read and processed.

              Thnx
              Bill
              "A good friend will bail you out of jail,
              A true friend would be sitting beside you saying,
              'Wow, that was fun.'"

              Comment


              • #8
                Re: Cpyfrmimpf fails

                Michael,

                Only IFS APIs being used are to get the folder directory list checking the file name. It is program 2 that is locking the IFS file becuase if it is successful then it returns and program 1 moves the IFS file to another folder just fine.

                Thnx
                Bill
                "A good friend will bail you out of jail,
                A true friend would be sitting beside you saying,
                'Wow, that was fun.'"

                Comment


                • #9
                  Re: Cpyfrmimpf fails

                  Does program 2 run in an activation group other than *NEW? If so, you could change that program to *NEW, which will force everything to get closed down when the program returns. I cant tell from the code posted which activation group its running in, or if its a non-ILE program.
                  Michael Catalani
                  IS Director, eCommerce & Web Development
                  Acceptance Insurance Corporation
                  www.AcceptanceInsurance.com
                  www.ProvatoSys.com

                  Comment

                  Working...
                  X