RPGLE FTP – Get, Put, Delete cheque for successful transmission Part 2

First practice 2 empty source members inwards a source physical file that volition move used during FTP . Make certain the library of the source physical file is inwards your library list.
Click hither to read this Tutorial from beginning

Member    Type  Text
FTP_IN    TXT   FTP Input file
FTP_OUT   TXT   FTP Output file
Now nosotros need to override these files either inwards a CL or RPGLE programme earlier using them inwards FTP.
OVRDBF FILE(INPUT) TOFILE(*LIBL/SRC) MBR(FTP_IN)
OVRDBF FILE(OUTPUT) TOFILE(*LIBL/SRC) MBR(FTP_OUT)

Now your sample code for the RPGLE programme doing the FTP

finput     uf a e             disk    rename(src:i_rec)    f                                     usropn                  foutput    if a e             disk    rename(src:o_rec)    f                                     usropn        *Date/Time Stamps                                                        d                 ds                                                      d @DateTime                       z                                       d  @DteStmp                       d   overlay(@DateTime : 1)              d  @TimStmp                       t   overlay(@DateTime : 12)                                                                                        *   Execute Influenza A virus subtype H5N1 Command                                                    d ExcCmd          PR                  ExtPgm('QCMDEXC')                   d  Cmd_Str                     512a   Options(*VARSIZE)                   d                                     Const                               d  Cmd_Len                      15p five Const                                d $date           second             10a      d $time           second             10a      d @CmdStr         second            512a   inz            d @Apostr         second              1a   inz(X'7D')      //Open the input file c                   opened upwards      input       //Delete whatever information that may move at that topographic point from previous move c                   dou       %eof(input)            c                   read      input                  c                   if        %eof(input)            c                   teach out                            c                   endif                            c                   delete    i_rec                  c                   enddo               //First nosotros write the Userid too Password c                   eval      srcdta = %trim($userid) + ' ' +         c                                      %trim($password)                  c                   write     i_rec                         //In illustration nosotros need to laid the NAMEFMT c                   eval      srcdta = 'namefmt 1'   c                   write     i_rec                   //Set remote directory c                   eval      srcdta = 'cd ' + %trim($remote_dir_path)   c                   write     i_rec                                          //Set local directory c                   eval      srcdta = 'lcd ' + %trim($local_dir_path)      c                   write     i_rec                                  //Put the file c                   eval      srcdta = 'put ' + %trim($file_name)    c                   write     i_rec                                  //Put the file inwards a unlike cite c                   eval      srcdta = 'put ' + %trim($from_file_name)  + ' ' + c                    %trim($to_file_name) c                   write     i_rec             //Get the file                    c                   eval      srcdta = 'get ' + %trim($file_name)    c                   write     i_rec                                  //Get the file inwards a unlike cite c                   eval      srcdta = 'get' + %trim($from_file_name)  + ' ' + c                    %trim($to_file_name) c                   write     i_rec      //Get the file inwards a unlike cite merely it already exists c                   eval      srcdta = 'put ' + %trim($from_file_name)  + ' ' + c                    %trim($to_file_name) + ' (replace' c                   write     i_rec      //Delete a file on the remote organisation c                   eval      srcdta = 'delete ' + $file_name  c                   write     i_rec                              //Quit ftp c                   eval      srcdta = 'quit'                    c                   write     i_rec                  //Close the input file c                   unopen     input                                            //Tag your file inwards the FTP reply or outfile file for tardily lookup – non necessary //Get fourth dimension postage stamp                                                                              c                   fourth dimension                    @datetime                         c                   deed      @DteStmp      $date                             c                   deed      @TimStmp      $time    // Open Output file                         c                   opened upwards      output                //Write file cite amongst appointment too fourth dimension                          c                   eval      srcdta = '--->'                                  c                   write     o_rec                                            c                   eval      srcdta = 'FTP for file ' + %trim($file_name)+   c                                      ' starting at ' + $date + $time        c                   write     o_rec   //Close the output file                                         c                   unopen     output                          //FTP to remote organisation c                   eval      @CmdStr = 'FTP RMTSYS(' + @Apostr +            c                                        %Trim($hostname or IP address) + @Apostr + ')'      c                   callp     ExcCmd(%Trim(@CmdStr) :                        c                                   %Len(%Trim(@CmdStr)))      //All done 

Click hither for side past times side Chapter


Sumber http://www.mysamplecode.com/