ftping packed decimal

merge used Ask the Experts™
I have a file that contains a packed decimal value and I want to ftp the file up to the mainframe, but during the ftping, the format of the packed decimal field becomes corrupted.  How can I get around this or resolve this?

Thanks in advance.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
switch to bin mode, using ftp's  bin  command


I have tried to send it over as binary, but the file comes out stranger than sending it ASCII

odd, perhaps there is a bug in either the server of client, have you tried different clients?

what happens if you convert it into another format, say uuencoded or zipped and then send it. then convert it back at the other end.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

I presume when you say that you are transferring to a mainframe that it is going to an IBM mainframe (ie with EBCDIC as the native codeset). If you use the binary transfer you will get an untransformed file.

Depending on the system you are transferring FROM the coding for packed decimal data may well be different and therefore the results will not be as you want it. Is the data completely binary or is there some printable text involved as well? If so you must be aware that using a binary transfer will stuff up the transfer of this printable data if the native language of the sender is ASCII and that of the receiver is EBCDIC - for example in ASCII 'A' is 41h whereas in EBCDIC it is C1h.

Can you identify how the packed decimal is stored on your system - especially the sign nibble.

This might get you something, although it's pretty dry reading and I don't think it was meant to me understood by mortals.  It's assuming you can access FTP sessions on the IBM side, and that you can use the FTP client on the IBM to get files from elsewhere:



I have some printable text in my file along with the packed decimal field.  As for the packed decimal field, I am not totally sure of the format.  I am using a dll that was provided by someone that takes care of this conversion.

If you have printable text and you are ftping from an ASCII based system to an EBCDIC based system then you will not be able to use a binary transfer as the printable text will be garbled in the transfer as the bit layout of each byte remains unaltered.

For example - if you transfer an "Z" it will start out as 5Ah and will stay as 5Ah once it gets to the EBCDIC host. 5Ah in the EBCDIC code set is a "!" character. Other codes don't even match up with anything printable - an "A" which is 41H will stay as 41H on the EBCDIC system and this is not even a printable character.

From memory I had a similar problem in 1994 when we were transferring a lot of files from an NCR mainframe to an IBM system, the way I got around the problem was to use a small program in the NCR system to convert the printable characters in the ASCII file to the EBCDIC codeset and then use a binary transfer to send the resultant file to the EBCDIC system.

If this is of any assistance I have attached the source for the program I used at the time.

Cheers - Gavin


     PROGRAM          :     A2E
     AUTHOR          :      G. Newman
     DATE          :     5/11/1994
     PLATFORM     :     DOS
     COMPILER     :     BORLAND C++ 4.0

     This application is used to translate the displayable characters
     within a file from ASCII to EBCDIC while leaving the non-display
     characters intact.

#include  <stdio.h>
#include  <stdlib.h>

char copyright[] = "Copyright (c) - G. Newman - 1994";

char table[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,

void main(int argc,char *argv[])
int                in_char;
FILE                *fptr_in;
FILE                *fptr_out;
unsigned int     count=0;

     if (argc < 2)

     if ((fptr_in  = fopen(argv[1],"rb")) == NULL ||
          (fptr_out = fopen(argv[2],"wb")) == NULL)
               printf("\n\aNominate input and output file names\n");
     printf("A2E (c) G. Newman 1994\nConverting %s to %s\n",argv[1],argv[2]);
     printf("%u characters processed.",count);

converting from ASCII to EBCDIC:

  dd if=your-ascii-file of=your-ebcdic-file conv=ebcdic

exchange if= with of= to convert the other way arround


You are correct but the problem is that if he has a file that has partly printable ASCII text and partly binary data then a blanket conversion of ASCII to EBCDIC wont work.

Hello all,
I am Computer101, a moderator from Experts-Exchange and also an expert within this topic area. This question has been open a long time.  What I am going to do is allow feedback from the questioner and experts.  If it is not resolved, I will delete or accept an answer based on the info I have been given, Experts, feel free to offer input.  I will monitor these questions for a period of 3-5 days and come back and evaluate.  I will have another moderator (who is also an expert in this topic area) look at the question also to ensure we do the right thing for this question.

Thank you
Community Support Moderator

I'll leave it up to you Computer101 (or may I call you 101 for short?)

Cheers - Gavin
Points reduced to 0 and placed in PAQ.

Thank you
Community Support Moderator

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial