ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Copy *savf to the IFS

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

  • Copy *savf to the IFS

    Is there a way to copy a *savf to the IFS. I save the source files in my library to a *savf several times a week. I would like to store the save file on the IFS but when I use CPYTOIMPF or CPYTOSTMF, I get errors indicating that the file I am copying is not a data base file. Is there a way to do this with out using FTP.

  • #2
    Just ignore this, I was doing something wrong. I found a previous post where I requested this same thing and used the solution I found there.

    I would delete this request if I knew how.

    Comment


    • #3
      Greg,

      I would like to be able to save directly to ifs stream file.

      This would save a significant amount of time and i/o.

      Jim

      Comment


      • #4
        You may try the following small SQLRPGLE program.

        Code:
         DCL-S  ParToIFSFile  VarChar(256) inz('/home/Dir/XYSAVF.savf');                
         DCL-S  ParFromObj    VarChar(256) inz('/QSYS.lib/XXLIB.lib/XYSAVF.file');        
        
         DCL-S  MyFromBlob    SQLType(BLOB_FILE);                                          
         DCL-S  MyToBlob      SQLTYPE(BLOB_FILE);                                          
         //-------------------------------------------------------------------------------
           Exec SQL   Set Option  Commit=*NONE, DatFmt=*ISO, TimFmt=*ISO,                  
                                  Naming=*SYS,  CloSQLCsr=*EndActGrp;                      
        
           //Save file Information                                                        
           MyFromBLOB_Name = %Trim(ParFromObj);                                            
           MyFromBLOB_NL   = %Len(%Trim(MyFromBLOB_Name));                                        
           MyFromBLOB_FO   = SQFRD;                            //Read Only          
        
           //IFS File Information                                                
           MyToBLOB_Name = %Trim(ParToIFSFile);                                  
           MyToBLOB_NL   = %Len(%Trim(MyToBLOB_Name));                                  
           MyToBLOB_FO   = SQFOVR;                            //Replace if exists
        
           Exec SQL Set :MyToBLOB = :MyFromBLOB;                                  
           If SQLCODE < *Zeros;                                                  
              Dsply ('Error: ' + %Char(SQLCODE));                                
           Else;                                                                  
              Dsply 'Success';                                                    
           EndIf;                                                                
        
          *InLR       = *On;
        Birgitta
        Last edited by B.Hauser; July 21, 2018, 12:36 AM.

        Comment


        • #5
          A cpy statement is all you need....

          CPY OBJ('/QSYS.LIB/libnam.LIB/filename.FILE') TOOBJ('/home/dir/savfname.savf')

          Comment

          Working...
          X