ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Copy files from QDLS to IFS

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

  • Copy files from QDLS to IFS

    Hi,

    We got a situation in our application which uses QDLS folders. We are close to hit the limits on the folders. Hence, have to offload the files to IFS.

    As the application is very much tied to QDLS, we cannot completely eliminate them, but we want to create some offload process where on some regular intervals we want to move the files in QDLS folders to IFS directories and whenever required copy required files to folders from IFS directories.

    Any options on how to do this?

    Thanks in advance.
    Jayanthi

  • #2
    Re: Copy files from QDLS to IFS

    this will read all documents in QDLS/JAMIE Youll want to change JAMIE to the folder you want to read...then in the program use the mov command & qcmdexec to move from QDLS to your IFS/ROOT path

    Code:
          *================================================================
     
          *
          *================================================================
         H DFTACTGRP(*NO) BNDDIR('QC2LE')
          *
    
          **************************************************************************
        * * Prototypes and definitions for working with the IFS
          **************************************************************************
          *
          *  open -- open an IFS file
          *
         D open            pr            10i 0   ExtProc('open')
         D   filename                      *     value
         D   openflags                   10i 0   value
         D   mode                        10u 0   value options(*nopass)
         D   codepage                    10u 0   value options(*nopass)
          * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
          *  read -- read an IFS file
          *
         D read            pr            10i 0   ExtProc('read')
         D   filehandle                  10i 0   value
         D   datareceived                  *     value
         D   nbytes                      10u 0   value
          * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
          *  close- close an IFS file
          *
         D close           pr            10i 0   ExtProc('close')
         D   filehandle                  10i 0   value
          * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
          * values for oflag parameter, used by open()
         D O_RDONLY        s             10i 0   inz(1)
         D O_TEXTDATA      s             10i 0   inz(16777216)
    
          * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
         d opendir         PR              *   EXTPROC('opendir')
         d  dirname                        *   VALUE
    
         D readdir         PR              *   EXTPROC('readdir')
         D  dirp                           *   VALUE
    
         d xmlelement      s             50A   dim(9999)
         d bighunkdata     s          65535
         d bighunkdata2    s          65535
         d CodePage        S             10u 0 inz(819)
         d cr              C                   Const(x'0D')
         d data            s            256A
         d Data_Rec        S            256A
         d datasize        s              5  0
         d dh              S               *
         d Eol             C                   Const(x'0D25')
         d Error_Flag      S              1A   INZ('0')
         d File            S             50
         d FileName        S             50
         d Fp              S             10i 0
         d fnd             s              5  0
         d gt              s              5  0
         d len             s              5  0
         d lf              C                   Const(x'25')
         d lt              s              5  0
         d N               S              5  0
         d Name            S           2000A
         d Oflag           S             10i 0
         d Omode           S             10u 0
         d out30           s             30
         d PathName        S           2000A
         d R               S              5  0
         d Rc              S             10i 0
         d str             s              5  0
         d x               s              5  0
         À*
         À* Directory Entry Structure (dirent)
         À*
         d p_dirent        s               *
         d dirent          ds                  based(p_dirent)
         d   d_reserv1                   16A
         d   d_reserv2                   10U 0
         d   d_fileno                    10U 0
         d   d_reclen                    10U 0
         d   d_reserv3                   10I 0
         d   d_reserv4                    8A
         d   d_nlsinfo                   12A
         d     nls_ccsid                 10I 0 OVERLAY(d_nlsinfo:1)
         d     nls_cntry                  2A   OVERLAY(d_nlsinfo:5)
         d     nls_lang                   3A   OVERLAY(d_nlsinfo:7)
         d     nls_reserv                 3A   OVERLAY(d_nlsinfo:10)
         d   d_namelen                   10U 0
         d   d_name                     640A
          *---------------------------------------------------------
          * MAIN
          *---------------------------------------------------------
          *
          *
         c                   exsr      $GetFileName
          *
         c                   eval      *inlr = *on
          *---------------------------------------------------------
          *    $GetFileName - read thru directory and get filename
          *---------------------------------------------------------
         c     $GetFileName  begsr
          *
         c                   eval      pathname =  '/QDLS/JAMIE/'
         c                             + %trim(x'00')
         À*
         À* Step1: Open up the directory root and list all directories
         À*
         c                   eval      dh = opendir(%addr(PathName))
         À*
         c                   if        dh <>  *NULL
         &#192;*
         &#192;* Step2: Read each entry from the directory (in a loop)
         &#192;*
         c                   eval      p_dirent = readdir(dh)
         c                   dow       p_dirent <> *NULL
         &#192;*
         &#192;* FIXME: This code can only handle file/dir names 256 bytes long
         &#192;*         because thats the size of "Name"
         &#192;*
         c                   if        d_namelen < 256  and
         c                             %subst(d_name:1:1) <> 'Q'
         &#192;*
         c                   eval      Name = %subst(d_name:1:d_namelen)
         &#192;*
         &#192;*  skip directory . and ..
         &#192;*
         c                   if        Name <> '.'
         c                             and name <> '..'
         c                             and name <> *Blanks
         &#192;*
         c                   eval      out30 = name
         c     out30         dsply                   reply             1
    
    
         &#192;*
         c                   endif
         c                   endif
    
    
         c                   eval      p_dirent = readdir(dh)
         c                   enddo
         c                   endif
         &#192;*
          *
         c                   endsr
    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


    • #3
      Re: Copy files from QDLS to IFS

      --or--

      use command
      Code:
      strqsh
      this moves all files with any extension from the QDLS folder to the ROOT/ folder

      Code:
      mv  /qdls/jamie/*.*  /home/flanary/
      or put this in a cl program compile and run
      Code:
      pgm                                                                 
                   QSH        CMD('mv  /qdls/jamie/*.*          +         
                                /home/flanary/')                          
                                                                          
       endpgm
      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