[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FTPAPI - Translation issue.



Hello MDiaz,

On 6/7/2011 8:14 AM, mdiazp01@xxxxxxxxx wrote:
> I debugged your code and noticed that IF_READ is called which does a
> conversion to ASCII.

Only if you specify ASCII mode.  (If you use binary mode, it shouldn't 
do any conversion.)   However, even if it's ASCII mode, when the file on 
the server is marked with CCSID 37, the server should be translating it 
back to CCSID 37.

If you want IF_READ to translate it to a different CCSID besides 819, 
you can do that by calling FTP_codePage() prior to the transfer.  But I 
don't think that'll solve your problem because, again, the server is 
going to translate it back to the CCSID of the file.  The problem isn't 
that FTPAPI is translating it, the problem (as I understand it) is that 
the server is assigning the wrong CCSID to the file.

> I do agree that 819 is a more reasonable value for files in IFS so I am
> inclined to change my code to read these files using 819 instead.

Okay.  If nothing else, it matches the default that IBM uses.

> With regards to your last suggestion of uploading and then use CHGATR, I
> was under the impression that translation would only happen when a file is
> created. I will keep this suggestion handy from now on.

I'm suggesting that you send the file in binary mode -- not ASCII mode. 
  In Binary mode no translation is done at all.  If your source data is 
CCSID 37, and the result is CCSID 37, then this is the most reasonable 
thing to do!

You don't want to translate it EBCDIC->ASCII, then have it go over the 
network and get converted from ASCII->EBCDIC.  The main problem with 
that is the danger of an EBCDIC character that doesn't exist in the 
flavor of ASCII (iso 8859-1) that you're translating to...  that 
character would not be translated back to the original value, causing a 
bit of a mess.

So if your source and destination are the same CCSID, use 
FTP_binaryMode() to put the thing into binary mode, and then send it.

The only remaining problem after the trnasfer is that the FTP server may 
have marked the file with the wrong CCSID.  It didn't translate the 
data, so you know the resultant file's data will be CCSID 37.  But the 
server may not know that, and may have marked the result file with the 
default CCSID of 819.

In that case, you just do CHGATR to change the CCSID to 37.

You're right that CHGATR won't do any translation -- and that's good, 
because the data is ALREADY in CCSID 37, we don't want to translate it. 
  We just want to change the file's description so that the system knows 
it's 37.

I hope that's clearer.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------