-1

I am using a java library (edtftpj) to FTP a file from a web app hosted of a tomcat server to an MVS system.

The FTP transfer mode is ASCII and transfer is done using FTP streams. The data from a String variable is stored into an MVS dataset.

The problem is all the ampersand characters get converted to & . I have tried various escape characters including \& , ^& and X'50' (hex value), but none of it helped.

Anyone has any idea how to escape the ampersands please?

redDevil
  • 1,909
  • 17
  • 25
  • How are you storing the data in a dataset? Are you sure the file has literal ampersands in it before you transfer it? It's incredibly unlikely that FTP is to blame. – Wooble Mar 29 '12 at 17:16
  • I have a string like 'UK & US' . This is being FTP ed to a dataset like XYZ.ID188.D0329. This dataset will be newly created. I am not sure FTP is to blame either, but then again I am not sure where the problem is too.. – redDevil Mar 29 '12 at 17:22
  • Is this string inside an XML document by any chance? –  Mar 29 '12 at 17:46
  • Unfortunately using FTP in ASCII-mode to/from a MVS (z/OS) will always perform code page conversions. – IODEV Mar 29 '12 at 18:33
  • @achusonline: check out the ref links below on howto setup a working connection. – IODEV Mar 29 '12 at 19:30
  • thanks for the links, fortunately my data range in the file being FTPed is very limited, only a phone number and a region code.. and using the library i am working with now, these are getting FTPed correctly to the dataset.. – redDevil Mar 29 '12 at 19:36

2 Answers2

2

Nothing in the FTP protocol would cause this encoding behavior.

Representing & as & is an XML based escaping representation. Other systems might use the same scheme, but as a standard, this is an XML standard encoding.

Something in the reading of the data and writing of the data thinks it should be escaping this information and is doing the encoding.

If anything on the MVS system is using Java it is probably communicating via SOAP with some other connector, which implies XML, which could be causing the escape sequence to be happening.

Either way, the FTP protocol itself part is not part of the problem, ASCII transfer should only encode things like line endings, & is already a valid ASCII character and would not be affected. It is the MVS system that is doing this escaping if anything.

Binary transfer is preferred in almost every case, since it doesn't do any interpretation or encoding of the raw bytes.

  • Unfortunately using FTP in ASCII-mode to/from a MVS (z/OS) will always perform code page conversions. Please se my answer for more details... – IODEV Mar 29 '12 at 18:33
  • you don't have an answer, you posted the exact same thing as a comment to the question. Either way, my answer is still accurate, nothing about FTP itself would cause this. If you are correct, then it is the MVS system doing the encoding. –  Mar 29 '12 at 18:46
  • Sorry Jarrod, had some issues while posting the answer. Lessons learned: alway create submit an answer before making further comments ;-) – IODEV Mar 29 '12 at 18:58
  • I've been bleeding blood when struggling with this issue on several "ibm-shops"... – IODEV Mar 29 '12 at 19:10
  • Not the RFC ftp _protocol_ per se, but certainly the ftp _echo-system_ i.e (client & server).. – IODEV Mar 29 '12 at 19:22
  • 1
    found it! @JarrodRoberson you were right.. the problem was the data was being picked from a SQL server which was returning the data as `&` instead of `&`, dumb me.. never thought why while trying to escape & as %&% , it came to the dataset as %&%amp; – redDevil Mar 29 '12 at 19:26
-1

Using FTP in ASCII-mode to/from a MVS (z/OS) will always perform code page conversions (i.e ASCII <-> EBCDIC) for the data connection. Thus it's very important to setup the connection with the appropriate parameters depending on dataset type and page codes. Example:

site SBD=(IBM-037,ISO8859-1)
site TRAck
site RECfm=FB
site LRECL=80
site PRImary=5
site SECondary=5
site BLKsize=6233
site Directory=50

As alternative, use BINARY mode and manually perform the conversions with some of the standard tools or libraries on the receiving end.


Ref links:

1. Preset commands to tackle codepage problem.
2. Coverting ASCII to EBCDIC via FTP on MVS Host.
3. Transferring Files to and from MVS.
4. FTP code page conversion.
5. FTP File Transfer Protocol and Z/OS (pdf).

IODEV
  • 1,706
  • 2
  • 17
  • 20