Binary Files 
Author Message
 Binary Files

I haven't programmed in cobol for almost 20 years and now I have a COBOL
project dumped on me and I am having to relearn some stuff.

Here is the situation. I need some help with reading a binary file. I am
receiving a binary data file via network connection to our local NT
workstation. I must then process this file to generate a report but seem
to be having some difficulty reading it. The FD looks something like
this:

01 INPUT.
  02 FIELD-A  PIC 9(5) COMP-3.
  02 FIELD-B  PIC 9(9) COMP-3.
  02 FIELD-C  PIC X(25).
  ETC....

The comp-3 fields process just fine, but field-c comes in and goes out
as garbage fields. It obviously is not being converted properly.

I am guessing (but not sure) that the problem lies in the File Control
area. Can anyone give me some advice here?

Right now I am using ORGANIZATION IS BINARY SEQUENTIAL, which does not
seem to be working.

Thanks
Mark Roberts

--== Sent via Deja.com http://www.*-*-*.com/
---Share what you know. Learn what you don't.---



Sat, 10 Nov 2001 03:00:00 GMT  
 Binary Files
I'm a mainframe programmer who has never programmed in PC COBOL, I was
surprised to see that COMP-3 worked.  My question is - does your
receiving computer and the sending computer use the same character
code?  (EBCDIC, ASCII, UNICODE)??
Quote:

> I haven't programmed in cobol for almost 20 years and now I have a COBOL
> project dumped on me and I am having to relearn some stuff.

> Here is the situation. I need some help with reading a binary file. I am
> receiving a binary data file via network connection to our local NT
> workstation. I must then process this file to generate a report but seem
> to be having some difficulty reading it. The FD looks something like
> this:

> 01 INPUT.
>   02 FIELD-A  PIC 9(5) COMP-3.
>   02 FIELD-B  PIC 9(9) COMP-3.
>   02 FIELD-C  PIC X(25).
>   ETC....

> The comp-3 fields process just fine, but field-c comes in and goes out
> as garbage fields. It obviously is not being converted properly.

> I am guessing (but not sure) that the problem lies in the File Control
> area. Can anyone give me some advice here?

> Right now I am using ORGANIZATION IS BINARY SEQUENTIAL, which does not
> seem to be working.

> Thanks
> Mark Roberts

> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---



Sat, 10 Nov 2001 03:00:00 GMT  
 Binary Files

Quote:

> I haven't programmed in cobol for almost 20 years and now I have a COBOL
> project dumped on me and I am having to relearn some stuff.

> Here is the situation. I need some help with reading a binary file. I am
> receiving a binary data file via network connection to our local NT
> workstation. I must then process this file to generate a report but seem
> to be having some difficulty reading it. The FD looks something like
> this:

> 01 INPUT.
>   02 FIELD-A  PIC 9(5) COMP-3.
>   02 FIELD-B  PIC 9(9) COMP-3.
>   02 FIELD-C  PIC X(25).
>   ETC....

> The comp-3 fields process just fine, but field-c comes in and goes out
> as garbage fields. It obviously is not being converted properly.

> I am guessing (but not sure) that the problem lies in the File Control
> area. Can anyone give me some advice here?

> Right now I am using ORGANIZATION IS BINARY SEQUENTIAL, which does not
> seem to be working.

Mark,

The fact that the comp-3 fields are working and the PIC X is not leads
me to believe that you have an EBCDIC file from an IBM mainframe that
you are processing in the ASCII environment.

What COBOL compiler are you using, and someone here should be able to
tell you how to get it to read an EBCDIC file.  

-------------------------
Trust the computer industry to shorten "Year 2000" to Y2K.  It was
this
kind of thinking that caused the problem in the first place.

Try a better search engine: http://www.google.com

Visit my updated website at
http://www.geocities.com/Eureka/2006/



Sat, 10 Nov 2001 03:00:00 GMT  
 Binary Files


Quote:
> I'm a mainframe programmer who has never programmed in PC COBOL, I was
> surprised to see that COMP-3 worked.  My question is - does your
> receiving computer and the sending computer use the same character
> code?  (EBCDIC, ASCII, UNICODE)??

You are on the same track I am - MicroFocus, Fujitsu and Realia (at
the very least) all store COMP-3 numbers using the same binary method
as the IBM Mainframe.  

Signed Usage DISPLAY items are another story altogether.....

-------------------------
Trust the computer industry to shorten "Year 2000" to Y2K.  It was
this
kind of thinking that caused the problem in the first place.

Try a better search engine: http://www.google.com

Visit my updated website at
http://www.geocities.com/Eureka/2006/



Sat, 10 Nov 2001 03:00:00 GMT  
 Binary Files
This is a very good question. They were sending an ascii file and I had
the reverse problem. I could read the character fields, but not the comp
fields. After a long discussion with them, I got them to send me a
binary file so that I could read the comp. Now, I can't read the
character fields. I think my PC compiler has the option to read EBCDIC,
I will try that, also, I have a EBCDIC -> ASCII converter. I wiil need
to experiment with that.


Quote:

> I'm a mainframe programmer who has never programmed in PC COBOL, I was
> surprised to see that COMP-3 worked.  My question is - does your
> receiving computer and the sending computer use the same character
> code?  (EBCDIC, ASCII, UNICODE)??


> > I haven't programmed in cobol for almost 20 years and now I have a
COBOL
> > project dumped on me and I am having to relearn some stuff.

> > Here is the situation. I need some help with reading a binary file.
I am
> > receiving a binary data file via network connection to our local NT
> > workstation. I must then process this file to generate a report but
seem
> > to be having some difficulty reading it. The FD looks something like
> > this:

> > 01 INPUT.
> >   02 FIELD-A  PIC 9(5) COMP-3.
> >   02 FIELD-B  PIC 9(9) COMP-3.
> >   02 FIELD-C  PIC X(25).
> >   ETC....

> > The comp-3 fields process just fine, but field-c comes in and goes
out
> > as garbage fields. It obviously is not being converted properly.

> > I am guessing (but not sure) that the problem lies in the File
Control
> > area. Can anyone give me some advice here?

> > Right now I am using ORGANIZATION IS BINARY SEQUENTIAL, which does
not
> > seem to be working.

> > Thanks
> > Mark Roberts

> > --== Sent via Deja.com http://www.deja.com/ ==--
> > ---Share what you know. Learn what you don't.---

--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


Sat, 10 Nov 2001 03:00:00 GMT  
 Binary Files


Quote:
>This is a very good question. They were sending an ascii file and I had
>the reverse problem. I could read the character fields, but not the comp
>fields. After a long discussion with them, I got them to send me a
>binary file so that I could read the comp. Now, I can't read the
>character fields. I think my PC compiler has the option to read EBCDIC,
>I will try that, also, I have a EBCDIC -> ASCII converter. I wiil need
>to experiment with that.

There are various ways to translate to and from EBCDIC/ASCII, but you need
to do it at the field level.  Try

INSPECT FIELD-B CONVERTING EBCDIC-TABLE TO ASCII-TABLE.

Quote:
>> > to be having some difficulty reading it. The FD looks something like
>> > this:

>> > 01 INPUT.
>> >   02 FIELD-A  PIC 9(5) COMP-3.
>> >   02 FIELD-B  PIC 9(9) COMP-3.
>> >   02 FIELD-C  PIC X(25).
>> >   ETC....

>> > The comp-3 fields process just fine, but field-c comes in and goes
>out
>> > as garbage fields. It obviously is not being converted properly.

000000 01  ASCII-TABLE.
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"000102039C09867F978D8E0B0C0D0E0F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"101112139D8508871819928F1C1D1E1F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"80818283840A171B88898A8B8C050607".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"909116939495960498999A9B14159E1A".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"20A0A1A2A3A4A5A6A7A8D52E3C282B7C".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"26A9AAABACADAEAFB0B121242A293B7E".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"2D2FB2B3B4B5B6B7B8B9CB2C255F3E3F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"BABBBCBDBEBFC0C1C2603A2340273D22".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"C3616263646566676869C4C5C6C7C8C9".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"CA6A6B6C6D6E6F7071725ECCCDCECFD0".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"D1E5737475767778797AD2D3D45BD6D7".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"D8D9DADBDCDDDEDFE0E1E2E3E45DE6E7".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"7B414243444546474849E8E9EAEBECED".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"7D4A4B4C4D4E4F505152EEEFF0F1F2F3".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"5C9F535455565758595AF4F5F6F7F8F9".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"30313233343536373839FAFBFCFDFEFF".
000000
000000 01  EBCDIC-TABLE.
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"000102030405060708090A0B0C0D0E0F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"101112131415161718191A1B1C1D1E1F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"202122232425262728292A2B2C2D2E2F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"303132333435363738393A3B3C3D3E3F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"404142434445464748494A4B4C4D4E4F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"505152535455565758595A5B5C5D5E5F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"606162636465666768696A6B6C6D6E6F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"707172737475767778797A7B7C7D7E7F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"808182838485868788898A8B8C8D8E8F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"909192939495969798999A9B9C9D9E9F".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"A0A1A2A3A4A5A6A7A8A9AAABACADAEAF".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF".
000000     05  FILLER                      PIC X(16)   VALUE
000000               X"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF".

Warren Porter -- Remove numbers to reply.



Sat, 10 Nov 2001 03:00:00 GMT  
 Binary Files


:>I'm a mainframe programmer who has never programmed in PC COBOL, I was
:>surprised to see that COMP-3 worked.  My question is - does your
:>receiving computer and the sending computer use the same character
:>code?  (EBCDIC, ASCII, UNICODE)??

Data can be sent in ASCII or BINARY.

Considers the following description:

           01  Employee-Record.
               05  Last-Name       PIC  X(10).
               05  First-Name      PIC  X(10).
               05  Hourly-Pay      PIC  S9(5)V99  COMP-3.

The records as it appears on MVS:
                  'JONES     '    D1D6D5C5E24040404040
                  'BOB       '    C2D6C240404040404040
                  +28.50          0002850C

As it appears on the PC when shipped in Ascii:
                  'JONES     '    4A4F4E45532020202020
                  'BOB       '    424f4220202020202020
                  +26.50          0002650C

The character x'85' is lower case 'e' in EBCDIC and gets converted to x'65'
which is lower case in ASCII. No good.

As it appears on the PC when shipped in Binary:


                  +28.50          0002850C

The number is accurate but the text is not printable. A problem.

If one cannot arrange to get the data converted to text on the mainframe,
i.e., have a file created with  

               05  Hourly-Pay PIC +9(5)V99

One must ship the data in BINARY (to ensure exact transmission) and then
convert the character strings to ASCII.

   [ snipped ]

--


http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel



Sun, 11 Nov 2001 03:00:00 GMT  
 Binary Files
You'll have to dump the file and examine it.


Quote:
>I haven't programmed in cobol for almost 20 years and now I have a COBOL
>project dumped on me and I am having to relearn some stuff.

>Here is the situation. I need some help with reading a binary file. I am
>receiving a binary data file via network connection to our local NT
>workstation. I must then process this file to generate a report but seem
>to be having some difficulty reading it. The FD looks something like
>this:

>01 INPUT.
>  02 FIELD-A  PIC 9(5) COMP-3.
>  02 FIELD-B  PIC 9(9) COMP-3.
>  02 FIELD-C  PIC X(25).
>  ETC....

>The comp-3 fields process just fine, but field-c comes in and goes out
>as garbage fields. It obviously is not being converted properly.

>I am guessing (but not sure) that the problem lies in the File Control
>area. Can anyone give me some advice here?

>Right now I am using ORGANIZATION IS BINARY SEQUENTIAL, which does not
>seem to be working.

>Thanks
>Mark Roberts

>--== Sent via Deja.com http://www.deja.com/ ==--
>---Share what you know. Learn what you don't.---



Mon, 12 Nov 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Reading a binary file / writing binary data to a file

2. Reading binary files, unflatten binary string

3. Converting VMS binary files to PC binary

4. Intel Hex file conversion to binary file question

5. Changing binary file to *.f90 file

6. File Upload Problems with binary files (ASCII works ok)

7. binary files and file descriptors

8. Output to binary file (was: Feed a binary file to awk?)

9. Binary filing and circular references

10. Binary-files in OmniBase

11. Binary filing classes bug ?

12. binary file read/write acces

 

 
Powered by phpBB® Forum Software