Here's how I did it:
In your CL pgm, specify an input and output file.
OVRDBF FILE(INPUT) TOFILE(&PGMLIB/QCLSRC) MBR(&EDTXTO)
OVRDBF FILE(OUTPUT) TOFILE(&PGMLIB/QCLSRC) MBR(&EDLOG)
Both of these are text type file members that I have in my QCLSRC file. The input file contains FTP commands that will log me into the remote system and perform certain functions. The text below will log the user EDIADMIN into the system using the password "password", then to the ls command which will list the contents of the default FTP home directory of that server, then it will end.
ediadmin password
ls
quit
The output file is a log of what happened when the ftp commands ran.
To run this from a CL:
FTP RMTSYS(system name goes here)
The commands in the input file will run.
In this instance, it will contain a list of the files on the remote system because I did the "LS" command.
You can then write an RPG pgm to read the log file, get the file names and then do another FTP session to "GET" the files and put them on the 400 somewhere and then delete the ones on the server - whether they be 997s, 850s, etc.
This is all done from OUTSIDE the TLE system. The physical file you load this data into should have one field in it - either 132 or 80 bytes long, depending on your trading partner and what they're sending to you.
At this point, you will have to use the TLE API to transfer data in and out of the mailbox. The pgm is caled CED810ZB. The parms are below:
TLE API pgm is CED810ZB. Parms for this API are as follows:
1. Session type - Char(1)
'1'= Send
'2'= Receive
2. Network ID - Char(2)
Trusted Link standard Network ID in uppercase letters OR
Trusted Link custom network ID (1 letter, 1 number) OR
Trusted Link pseudo network ID
3. Record Length - Char(3)
Record length of the physical file on the 400 that is
being used. Must be 80 or 132.
4. File,Lib & mbr name of physical file - Char(30)
File, Library and Member name of the physical file on the
400 that is being used.
positions 01-10 - File name
positions 11-20 - Library name (blanks defaults to *CURLIB)
positions 21-30 - Member name (blanks defaults to filename)
5. Add/Replace Records - Char(1)
"A" = Adds to existing records.
"R" = Clears the file before replacing records.
6. File wrapped/unwrapped - Char(1)
"W" = Wrapped records.
"U" = Unwrapped records.
Use only for pseudo networks. For all other networks,
leave blank.
Hope this helps!!
Tom