|
|
EBCDIC packed fields conversion
Hi. I have a need to generate an EBCDIC file on a Unix platform to FTP
up to a mainframe. The file will then be read by COBOL modules on the
mainframe. I have a specific file layout that I need to create which
contains some packed fields. My question is how to create an EBCDIC
based file on a Unix platform that contains packed data fields? Is
this even possible? Thank you.
|
|
0
|
|
|
|
Reply
|
eric.roelofs (1)
|
12/13/2004 10:00:17 PM |
|
"eric" <eric.roelofs@ubs.com> writes:
> Hi. I have a need to generate an EBCDIC file on a Unix platform to FTP
> up to a mainframe. The file will then be read by COBOL modules on the
> mainframe. I have a specific file layout that I need to create which
> contains some packed fields. My question is how to create an EBCDIC
> based file on a Unix platform that contains packed data fields? Is
> this even possible? Thank you.
Does "dd conv=ebcdic" do anything useful?
--
M�ns Rullg�rd
mru@inprovide.com
|
|
0
|
|
|
|
Reply
|
iso
|
12/13/2004 10:09:19 PM
|
|
"M�ns Rullg�rd" <mru@inprovide.com> wrote in message news:yw1xwtvlj1f4.fsf@ford.inprovide.com...
: "eric" <eric.roelofs@ubs.com> writes:
:
: > Hi. I have a need to generate an EBCDIC file on a Unix platform to FTP
: > up to a mainframe. The file will then be read by COBOL modules on the
: > mainframe. I have a specific file layout that I need to create which
: > contains some packed fields. My question is how to create an EBCDIC
: > based file on a Unix platform that contains packed data fields? Is
: > this even possible? Thank you.
:
: Does "dd conv=ebcdic" do anything useful?
No - it translates EBCDIC to ascii (and there are two ways to do that and some
IBM EBCDIC symbols have NO matching representation in ASCII) and it
converts fixed width fields to linefeed terminated lines, stripping trailing spaces.
It will trash packed fields.
Dan Mercer
:
: --
: M�ns Rullg�rd
: mru@inprovide.com
|
|
0
|
|
|
|
Reply
|
Dan
|
12/13/2004 10:39:53 PM
|
|
"Dan Mercer" <dmercer@mn.rr.com> writes:
> "M�ns Rullg�rd" <mru@inprovide.com> wrote in message news:yw1xwtvlj1f4.fsf@ford.inprovide.com...
> : "eric" <eric.roelofs@ubs.com> writes:
> :
> : > Hi. I have a need to generate an EBCDIC file on a Unix platform to FTP
> : > up to a mainframe. The file will then be read by COBOL modules on the
> : > mainframe. I have a specific file layout that I need to create which
> : > contains some packed fields. My question is how to create an EBCDIC
> : > based file on a Unix platform that contains packed data fields? Is
> : > this even possible? Thank you.
> :
> : Does "dd conv=ebcdic" do anything useful?
>
> No - it translates EBCDIC to ascii
My "man dd" tell me this:
Conversions:
ascii Convert EBCDIC to ASCII.
ebcdic Convert ASCII to EBCDIC.
ibm Convert ASCII to alternate EBCDIC.
(and a bunch of others)
> (and there are two ways to do that and some IBM EBCDIC symbols have
> NO matching representation in ASCII)
I'm not doubting that.
> and it converts fixed width fields to linefeed terminated lines,
> stripping trailing spaces.
That would be conv=unblock.
> It will trash packed fields.
Would you care to elaborate a little on the structure of the input
data, and the required structure of the output file? I'm pretty sure
there's a simple way to get the job done, as long as the output is
representable as a sequence of bytes.
--
M�ns Rullg�rd
mru@inprovide.com
|
|
0
|
|
|
|
Reply
|
iso
|
12/13/2004 11:17:47 PM
|
|
M�ns Rullg�rd <mru@inprovide.com> writes:
> "eric" <eric.roelofs@ubs.com> writes:
>
> > Hi. I have a need to generate an EBCDIC file on a Unix platform to FTP
> > up to a mainframe. The file will then be read by COBOL modules on the
> > mainframe. I have a specific file layout that I need to create which
> > contains some packed fields. My question is how to create an EBCDIC
> > based file on a Unix platform that contains packed data fields? Is
> > this even possible? Thank you.
>
> Does "dd conv=ebcdic" do anything useful?
I doubt it. conv=ebcdic converts text, ie non packad data.
You will have to distinguish text encoded in EBCDIC and binary data.
Some binary data are plain 2-complement binary integers like usual.
Decimal Packed data consists in writting the number in base ten, then
substituting sixteen for ten:
123456 = 1*10^5 + 2*10^4 + 3*10^3 + 4*10^2 + 5*10^1 + 6*10^0
1*16^5 + 2*16^4 + 3*16^3 + 4*16^2 + 5*16^1 + 6*16^0 = 1193046
The trick is that when you hex-dump binary 1193046 you read it
as 123456, on big-endian machines like EBCDIC ones use to be.
If you use 32-bit fields, you must ensure that the data is written
in big-endian (in C use htonl).
(defun write-32-bit-big-endian (val out)
(write-byte (ldb (byte 8 24) val) out)
(write-byte (ldb (byte 8 16) val) out)
(write-byte (ldb (byte 8 8) val) out)
(write-byte (ldb (byte 8 0) val) out))
(progn (with-open-file (out "/tmp/out" :element-type '(unsigned-byte 8)
:direction :output :if-exists :supersede)
(write-32-bit-big-endian (parse-integer "123456" :radix 16) out))
(ext:shell "od -tx1 /tmp/out"))
0000000 00 12 34 56
0000004
There is the problem of the sign, with several encoding possible.
A common encoding for the sign is to add a low order digit equal
to 12 for + or 13 for -.
12(dec) = C(hex) = credit
13(dec) = D(hex) = debit
So -123456 (dec) would be stored as 01 23 45 6D (hex)
and 123456 (dec) would be stored as 01 23 45 6C (hex)
But you'd better refer to the specifications of the main frame file
format to learn the details of the encoding used.
--
__Pascal Bourguignon__ http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.
|
|
0
|
|
|
|
Reply
|
Pascal
|
12/13/2004 11:28:59 PM
|
|
|
4 Replies
685 Views
(page loaded in 0.072 seconds)
Similiar Articles: EBCDIC packed fields conversion - comp.unix.programmerHi. I have a need to generate an EBCDIC file on a Unix platform to FTP up to a mainframe. The file will then be read by COBOL modules on the mainfra... unsigned long -> ascii conversion - comp.lang.asm.x86EBCDIC packed fields conversion - comp.unix.programmer ibm Convert ASCII to alternate EBCDIC. (and a bunch of ... there's a simple way to get the job done, as long as ... Reading in pre-fixed file layout - comp.soft-sys.sasEBCDIC packed fields conversion - comp.unix.programmer Reading in pre-fixed file layout - comp.soft-sys.sas EBCDIC packed fields conversion - comp.unix.programmer The file ... emails on mainframe - comp.soft-sys.sasEBCDIC packed fields conversion - comp.unix.programmer I have a need to generate an EBCDIC file on a Unix platform to FTP up to a mainframe. ... EBCDIC Conversion FAQs ... Hex to ascii - comp.lang.asm.x86EBCDIC packed fields conversion - comp.unix.programmer VEDIT Hex, EBCDIC, ASCII, Binary, Text Editor, Conversion ... Convert a simple EBCDIC text file. VEDIT Hex, EBCDIC, ASCII, Binary, Text Editor, Conversion ...Convert a simple EBCDIC text file. EBCDIC files that do not contain packed-decimal fields are easily translated to ASCII by the standard VEDIT package. EBCDIC, ASCII and Numbers Conversion - eDiscovery Services, Data ...The only truly portable way to convert such records is on a per field basis. Typically, from EBCDIC to ASCII, and numeric fields, packed decimal fields etc are ... 7/23/2012 6:28:49 AM
|
|
|
|
|
|
|
|
|