226 - Transfer complete.
250 - DELE command successful.
532 - A file or directory in the path name does not exist
550 - A file or directory in the path name does not exist
552 - Exceeded storage allocation
The following considerations should be taken in regards to the wide range of systems and implementation of SFTP executables:
- The only way I found that can consistently returns a error status code is the "-b" batch option. If you use HERE document or subshell-echo it returns zero even if there are errors.
- The FTP status code should be standard, but the message text can vary per system. SFTP does not have a standard status code (on our system), and message text can also vary by systems.
The Peoplecode statement for adding/loading a file is like:
The function (AddAttachment) calls ExecutePutAttachment API which examines the log file (ftp????_?????.log) for FTP status code then sets RETCODE as follows:
System Variable for &RETCODE | Value | FTP Code | Comments |
%Attachment_Success | 0 | ||
%Attachment_Failed | 1 | ||
%Attachment_Cancelled | 2 | user hit “CANCEL” instead of “Upload” | |
%Attachment_FileTransferFailed | 3 | ||
%Attachment_NoDiskSpaceAppServ | 4 | N/A for FTP | |
%Attachment_NoDiskSpaceWebServ | 5 | N/A for FTP | |
%Attachment_FileExceedsMaxSize | 6 | 552 | |
%Attachment_DestSystNotFound | 7 | ||
%Attachment_DestSysFailedLogin | 8 | 530 | sftp cannot authenticate |
%Attachment_FileNotFound | 9 | 550 | user “Upload” a 0-byte file; “View” file does not exist |
%Attachment_DeleteFailed | 10 | 552 | user hit “delete” but file does not exist |
%Attachment_NoFileName | 11 | user hit “Upload” without selecting a file | |
%Attachment_FileNameTooLong | 12 |
You can see not all status codes are related to FTP. This is due to the the fact only a portion of the transfer process utilizes ftp. Between Browser and Web Server, Web Server & App Server, App Server & DB Server FTP is not involved. I tried to test as many FTP codes as I can, these are the ones I see PS reports off the log file. For ex. if you set &MESSAGE_LVL (in FILE_ATTACH_WRK peoplecode) to a value of 1 or 2, you will see a detailed message box after each operation. This is the delivered code:
&RETCODE = AddAttachment(&URL_ID, &ATTACHSYSFILENAME, &FILEEXTENSION, &ATTACHUSERFILE, &FILESIZE);
:::::::::::::::::::::::::::::::::::::
If &MESSAGE_LVL = 1 Or
&MESSAGE_LVL = 2 Then
If (&RETCODE = %Attachment_Failed) Then
MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 2, "AddAttachment failed");
End-If;
:::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::
If (&RETCODE = %Attachment_DestSysFailedLogin) Then
MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 9, "AddAttachment failed: Unable to login into destination system for ftp");
End-If;
If (&RETCODE = %Attachment_FileNotFound) Then
MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 29, "The file was not found so the operation could not be completed.");
End-If;
/* Error Message for Invalid file or No file name */
If (&RETCODE = %Attachment_NoFileName) Then
MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 38, "AddAttachment failed: No File Name Specified.");
End-If;
::::::::::::::::::::::::::::::
The API AddAttachment will return zero if it sees this FTP session message in the log file:
226 Transfer complete.
so the SFTP will simply run:
echo "226 Transfer complete"
after it verifies a PUT operation is successful. Similarly, DeleteAttachment API is looking for:
250 DELE command successful
Next is a script that ties everything together.
Change Peoplesoft FTP to SFTP - Part 2 | Change Peoplesoft FTP to SFTP - Part4