85 pts.
 Is an FTP finished?
RPG
If a file is being FTP'ed into a file in the IFS of the iSeries, how can I tell from a CL program when the transfer is complete?

Software/Hardware used:
ASKED: May 9, 2005  1:53 PM
UPDATED: October 24, 2010  9:15 AM

Answer Wiki:
If you use the DSPLNK command for the IFS path, you can specify OUTPUT(*PRINT) which will generate a listing of all the files in the folder. If you copy the spool file (QSYSPRT) to a database file, your CL program can then read through the listing to determine whether or not the file has arrived. I've used this method on many an occasion. All the best Jonathan
Last Wiki Answer Submitted:  May 10, 2005  4:31 am  by  astradyne   370 pts.
All Answer Wiki Contributors:  astradyne   370 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Jonathan,
Thanks for your suggestion and it will be helpful to me.
However, it slightly misses the point of my question. If a large file is being sent via FTP, how do I know if the entire file has been transferred?
For example, if I try to copy the FTP target file, and the transfer is still taking place, will I be locked out from doing the copy?

 85 pts.

 

I dont think you can. One way to avoid this problem is that the sending system put files with an extension eg. “xxxxxx.wrk” and when the file is completely transfered it renames the file to “xxxxxx.rdy”. At your side you only read files that has the “.rdy” extension. By doing it this way you should be confident that you only receives files that are completely transfered.

 0 pts.

 

I read this somewhere and put it in my outlook notes. I don’t recall the details.

FTP – batch technique
OVRDBF INPUT
OVRDBF OUTPUT
Scan OUTPUT for word
‘successful’

 875 pts.

 

if you can change hte ftp script that put the file (ifs or not), you can just add a APPEND to a file (ISERIE) wich as a trigger on it.

A record with field like this :
FILE
DATE
TIME
STATUS
PATH (if IFS)

In the trigger :
If STATUS = OK, the Call CL associated withe the FILE…

In this way you can easy manage a history of file transfer…
Just an idea.

 0 pts.

 

Are you receiving this file or sending this file? If you are sending you can check for FTP message 226, which indicates that the transfer is complete. Before starting the FTP session, override file OUTPUT to a file member on your system (usually libname/QFTPSRC(membername)). This will cause the output of the FTP session to be written to this member. Then after the FTP session is over, read the member, and message 226 indicates that the transfer is complete.

 110 pts.

 

Sorry that I didn’t clarify that my program is at the receiving end of the FTP transmission. My program will process the file by doing a MOV and then a CPYFRMSTMF. What I am looking for is an easy test in CL to determine that the FTP transmission to the file has completed before I do the copy.
I have just tried to use the CHKOUT CL commnad and that seems to issue an escape message if the FTP is still taking place. This seems to be what I need. Is anyone familar with the CHKOUT who can verify this usage?

 85 pts.

 

I’ve seen a simpler method (i.e. without having to use CHKOUT). Request a blank file (signal file) to be sent when transfer is complete and monitor for the signal file. If you see the signal file, it means the sender acknowledges the fact that everything has been transferred as required.

 0 pts.

 

My first guess would be to call the Retrieve Object References (QP0LROR) API to see if any FTP job still has a reference to the file.

CHKOUT might succeed or fail depending on various circumstances at different points in the transfer. And you’ll want to make sure that you issue a CHKIN if CHKOUT succeeds.

Tom

 108,330 pts.