/FREE                                                                                                        

 // Copy the FTP input file shell to QTEMP.                                                                  

 command = 'CPYF FROMFILE(YOURLIB/QFTPSRC) TOFILE(QTEMP/QFTPSRC) +                                            

            FROMMBR(FTPSCRIPT) TOMBR(FTPSCRIPT) MBROPT(*REPLACE) +                                             

            CRTFILE(*YES)';                                                                                  

 callp(e) runclcmd(%TRIM(command):%len(%trim(command)));                                                     

 // Open the FTP input file shell in QTEMP.                                                                  

 command = 'OVRDBF FILE(QFTPSRC) TOFILE(QTEMP/QFTPSRC) MBR(FTPSCRIPT)';                                       

 callp(e) runclcmd(%TRIM(command):%len(%trim(command)));                                                     

 open QFTPSRC;                                                                                               

                                                                                                            

 // Loop through replacing FILENAME with the value from the input parameter.                                 

 Read QFTPSRC;                                       // Priming read.                                        

 DoW NOT %eof(QFTPSRC);                              // Begin main processing loop.                          

      position =%Scan('FILENAME':SRCDTA);                                                                    

      if position > 0;                                                                                       

          SRCDTA = %Replace(%TrimR(filename):SRCDTA:position:8);                                             

          Update FTPREC;                                                                                     

      endif;                                                                                                 

      Read QFTPSRC;                                  // Get next record for loop.                            

 EndDo;                                              // End main processing loop.                            

                                                                                                            

 // Close the FTP input file shell.                                                                          

 close QFTPSRC;                                                                                              

 *INLR = *On;                                        // End program.                                         

/END-FREE