FTP Import

Hi All,

This is the snippet of code that I've written to import an order from FTP for further processing in Navision. The same script which is generating through this code is running completely fine if use command prompt to execute each step manually. But if I am executing this then the files are not imported from the FTP.


RetailSetup.GET;

SalesFile := ENVIRON('TEMP') + '\' + 'FTPScript.bat';

CLEAR(FTPScript);
FTPScript.CREATE(SalesFile);
FTPScript.WRITEMODE(TRUE);
FTPScript.TEXTMODE(TRUE);
FTPScript.WRITE('@ECHO OFF');
FTPScript.WRITE('CD ' + ENVIRON('TEMP'));
FTPScript.WRITE('> script.ftp ECHO open ' + RetailSetup."FTP IP Address");
FTPScript.WRITE('>>script.ftp ECHO USER ' + RetailSetup."FTP User ID");
FTPScript.WRITE('>>script.ftp ECHO ' + RetailSetup."FTP Password");
FTPScript.WRITE('>>script.ftp ECHO CD ' + 'OutBox/Orders/');
FTPScript.WRITE('>>script.ftp ECHO prompt');
FTPScript.WRITE('>>script.ftp ECHO bin');
FTPScript.WRITE('>>script.ftp ECHO lcd ' + RetailSetup."Magento Order File Import Path");
FTPScript.WRITE('>>script.ftp ECHO mget ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO CD ' + '/OutBox/Orders/Archive/');
FTPScript.WRITE('>>script.ftp ECHO mput ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO CD ' + '/OutBox/Orders/');
FTPScript.WRITE('>>script.ftp ECHO mdel ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO Bye');
FTPScript.WRITE('FTP -s:Ftpscript.ftp -n ' + RetailSetup."FTP IP Address");
FTPScript.WRITE('TYPE NUL >script.ftp');
FTPScript.WRITE('DEL /F script.ftp');
FTPScript.WRITE(':retry_del');
FTPScript.WRITE('DEL "' + SalesFile + '" > NUL');
FTPScript.WRITE('if exist "' + SalesFile + '" goto retry_del');
FTPScript.CLOSE;

IF ISCLEAR(lAutWshShell) THEN
CREATE(lAutWshShell);
lBlnWaitOnReturn := TRUE;
lAutWshShell.Run(SalesFile,lIntWindowType,lBlnWaitOnReturn);
CLEAR(lAutWshShell);

Can please someone suggest what's wrong with this code.

Answers

Sign In or Register to comment.