views:

136

answers:

1

I am using FtpWebRequest to append data to a mainframe file. Each record appended is 50 characters long, and I am adding them one record at a time.

In our development environment, we do not have a mainframe, so my code was written and tested FTPing to a Windows-based FTP site instead of a mainframe. Initially, I was writing each record using a StreamWriter (using the stream from the FtpWebRequest) and writing each record using WriteLine (which automatically adds a CR/LF to the end).

When we ran this for the first time in the test environment (in which we're writing to an actual MVS mainframe), our mainframe contact said the CR/LFs were not able to be read by his program (a green-screen mainframe program of some sort - he's sent me screen captures, which is all I know of it).

I changed our code to use Write instead of WriteLine, but now my code executes successfully (i.e no thrown exceptions) when writing multiple records, but no matter how many records we append, he is only able to "see" the first record - according to his mainframe program, there is only one 50-character record in the file.

I'm guessing that to fix this, I need to write some other line-delimiting character into the end of the stream (instead of CR/LF) that the mainframe will recognize as a record delimiter. Anybody know what this is, or how else I can fix this problem?

+1  A: 

I actually had the exact same problem, and I fixed it by using just LF as the delimiter.

Also, on a side note, for sending the file I ended up writing a command line script and shelling out to the DOS ftp utility, because the built in .NET FTP class did not play nicely with how the mainframe formatted commands and the strange "directory" structure.

Jeremy
LF = "\n" and CR = "\r" right?
MusiGenesis
I've been through some pain already getting this far. I've already encountered the MVS directory structure issue - fortunately our target ended up being something as simple as "ftp://ggg.ddd.com//'FILE.EXT'" (with the extra forward-slash and the single quotes).
MusiGenesis
It sounds like adding LF instead of CR/LF may fix us. They guy said the record length was 50 characters. Do you think that means I should append 51 characters (the 50 + LF), or should the LF be the 50th character?
MusiGenesis
What issues did the built in class cause you with the command formatting? I'm asking because it wouldn't surprise me if fixing this line issue just exposed another problem. I have no direct access to this server - I have a webex to somebody there who does what I tell him over the phone.
MusiGenesis
Also, did you end up having to use NEL (0x15) instead of LF (0x10)? This particular mainframe uses EBCDIC, which apparently uses NEL.
MusiGenesis
Well, I ended up trying everything I could possibly think of to make this work, and the only thing that worked was to put CR/LF at the end of each line. Which was exactly what I was doing in the first place. I have no idea why it appeared to not be working for him originally.
MusiGenesis