ftping packed decimal

merge
merge used Ask the Experts™
on
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.
Comment
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

Author

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

Commented:
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.

Commented:
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.

Commented:
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:

http://www.as400.ibm.com/developer/dbcs/dbcs_chapt3.pdf

Author

Commented:
newmang,
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.

Commented:
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,
                0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
                0x40,0x5A,0x7F,0x7B,0x5B,0x6C,0x50,0x79,0x4D,0x5D,0x5C,0x4E,0x6B,0x60,0x4B,0x61,
                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0x7A,0X5E,0x4C,0x7E,0x6E,0x6F,
                0x7C,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,
                0xD7,0xD8,0xD9,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0x5B,0xE0,0x5D,0x5E,0x6D,
                0x60,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96,
                0x97,0x98,0x99,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xC0,0x6A,0xD0,0xA1,0x7F,
                0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0X8E,0x8F,
                0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
                0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
                0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
                0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
                0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
                0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};


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

     if (argc < 2)
          exit(1);

     if ((fptr_in  = fopen(argv[1],"rb")) == NULL ||
          (fptr_out = fopen(argv[2],"wb")) == NULL)
               {
               printf("\n\aNominate input and output file names\n");
               fcloseall();
               exit(1);
               }
     printf("A2E (c) G. Newman 1994\nConverting %s to %s\n",argv[1],argv[2]);
     while((in_char=fgetc(fptr_in))!=EOF)
          {
          count++;
          fputc(table[in_char],fptr_out);
          }
     fcloseall();
     printf("%u characters processed.",count);
     return;
}



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

Commented:
ahoffmann

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.

Cheers
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
Computer101
Community Support Moderator

Commented:
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
Computer101
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