One of the sad things that has come out of Sterling Commerce's long running desire to sunset the Gentran:Server for Windows line has been an ever shortening list of resources that can truly make gentran sing, so when I see a peace of code like this where someone has answered one of my long running questions I take notice. Historically speaking Gentran:Server for Windows was originally a communications server with a translator built into it and nobody did it better than Sterling Commerce; however, over time they lost interest in expanding the products supported communication standards and since then most people don't even associate Gentran with the subject any more.
OK so here is the long running question: How can I connect to an FTP server and pull down only the files I need, the catch being you don't know the name of the files in advanced and second you don't want to pull all the files.
// FTP with read individual files.
scriptvar string[20] Directory;
string [100] DIR_COMMAND;
integer iCnt;
integer iIndex;
string [100] OneLine;
string [100] GetFile;
DIR_COMMAND = "EDI/SAPOUT/" + Directory;
FtpSetMode(ASCII);
FtpChangeDir(DIR_COMMAND);
if DoRcv then
iCnt = FtpGetDir(FALSE); // TRUE = LIST FALSE = NLST
iIndex = 0;
while iIndex < iCnt do
begin
FtpGetDirString(iIndex, OneLine);
GetFile = OneLine;
if left(GetFile,3) = "EDI" then
FtpRcvMsg(GetFile);
FtpDelete(GetFile);
end
iIndex = iIndex + 1;
end
end
SetStatus(SUCCESS);
No comments:
Post a Comment