Converting String to EBCDIC

Hi,

Here’s what I need to do:

Convert a string to EBCDIC, append it to a flat file,
If the fields needs to be packed decimal, first pack it then convert??

After the flat file has been created, FTP it to mainframe.

If anyone can give me any idea on how to do this that would be great!

I have read other posts about the stringToByte service, but when I run it with a string it doesn’t seem to give me what I’m looking for, for example an input of ‘-21’ it returns: ‘[B@1ec90c3’ and in EBCDIC, the proper output should be ‘2J’.

Any ideas?

Keith,

If you have not seen this old post,please check it for some idea,
http://www.wmusers.com/wmusers/messages/117/42553.shtml

HTH,
RMG

Thanks for the quick response, I actually read though that post and I hope you pardon my ignorance but I am fairly new to all this… so that read about as easy as chinese arithmetic after a night of drinking… Is there a key point out of that post that you can summerize that I could use?

Thanks again!

Keith,

Sorry i am not very much helpful on converting EBCDIC…

I think you are trying to convert ASCII (-21) to EBCDIC 2J…

When using stringTobytes,did you set anything in encoding?

How you are communicating from WM to Mainframe.Is it via FTP or MQ or Mainframe Adapter or MIS?

http://www.wmusers.com/wmusers/messages/117/30819.shtml

HTH,
RMG

We’re sending it via FTP… I was told that perhaps the FTP adapter has a built in ASCII to EBCDIC encoder?

In the stringToBytes the encoding that is use is CP037, which from what I’ve read is what should be used… Only the output doesn’t match what i was expecting.

While ftp’eing the file to mainframe what is the mode you are using?binary or ASCII mode?Pls try setting binary as per the thread.

http://www.wmusers.com/wmusers/messages/117/189.shtml

Ok, so yes that can be done.

So first step, set mode to binary… what are the rest of the steps?

I’m still very confused on how to get a list of strings and fields that need to be packed into a fixed length flat file before sending it via FTP.

Sorry i am not helpful much on this…

Try asking the same to “Jon Baumgardner” which you can get his id from the above link.He might be better contact for dealing WM processing to Mainframe.

HTH,
RMG

Keith wrote:

"I have read other posts about the stringToByte service, but when I run it with a string it doesn’t seem to give me what I’m looking for, for example an input of ‘-21’ it returns: ‘[B@1ec90c3’ and in EBCDIC, the proper output should be ‘2J’. "

The stringToByte service will not do entirely what you want. The output you are seeing is the Java address of the resulting byte array structure, not a string represenation of a zoned decimal. Once converted to bytes, the data isn’t really human readable. You’ll need to do some extra work to create zoned/packed decimal representations. The links on the post that RMG referred to provide good definitions of what signed/zoned and packed decimal are if you need some more definition.

“Convert a string to EBCDIC, append it to a flat file,
If the fields needs to be packed decimal, first pack it then convert??”

Close. You definitely need to convert fields that should be zoned or packed decimal (they are not the same thing) using some Java code. This will probably be the hardest part for you if you’re not familiar with packed/zoned data and not a Java programmer. You might want to team up with someone within your company to do this part.

You may not need to convert to EBCDIC yourself as the mainframe normally can do the conversion for you–quite often as part of the FTP server facilities. If you need to do the convert, the stringToBytes call with code page/encoding as CP037 should do the trick. The pub.client:ftp service accepts an encoding parameter when the content parameter is a string, which if you set to CP037 should do the same thing as stringToBytes. Curiously, the pub.client.ftp:put does not accept a encoding parameter.

If you don’t do the EBCDIC conversion yourself, set the transfer mode to ASCII, which flags the mainframe to convert it. If you do the conversion, set the mode to binary.

As always, someone please correct me if I’m wrong on any detail here. I’m doing a lot of this from memory.

HTH.