Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary Fields

Status
Not open for further replies.

GaryS2002

Programmer
Mar 27, 2002
8
0
0
US
I am trying to convert a file that has packed binary fields. The files were created on a S36, and now reside on an AS400. I am trying to write a program that takes those fields and writes to another file that those fields are uncomped. When I run my program I keep getting file accessed with wrong record length. Is there a special way in cobol to handle those kinds of fields. Thanks in advance for any help anyone can provide me.
 
Hi,

perhaps you can put the problem giving definitions and statements here....

Regards,

Crox
 
Crox,
Thanks for replying. Here is what I have. These files were created using RPG. With RPG there is a code you can use that declares a field or array as binary packed. This file I am working with declares an array as 20 entries at size 7, it is however binary packed. Now I know that a straight binary is half of the actual size, and you declare it as a comp field in coobol. But when it is packed do I declare it as comp-3 and take half + 1? If you need more info let me know nad I will get the file specs. Thanks alot for all your help.
 
If you need more info let me know nad I will get the file specs.

That would be very helpful... Tom Morrison
 
On my RPG program print out. I have an extension that declares a field name, occurs clause, size of entry, and decimal position, looking like this

E 20 7 0 VL

Then when I get to the I specification

I P 215 294 VL

Now when you take and figure 215-294+1 you get 80, but when you look at the extension specification 20*7 you get 140. My problem is how do I declare the elements from the I specification in cobol? I did this I used comp-3 taking 12/2+1 which would get 7 then took that 20 times. When I compiled my program with xref it reported my file length as 500 somthing. It needs to be 384.
 
I am no great RPG expert -- fair warning. [glasses]

80 / 20 = 4. So there seem to be 4 character positions used to represent 7 digits. But this is exactly the number of character positions that a packed decimal (COMP-3) item would take. So I would think that you should be using a COBOL description of (for example):
Code:
    03  my-number  PIC S9(7) COMP-3 OCCURS 20.
I am not sure where the 12 came from in your "12/2+1" expression. Tom Morrison
 
Thank you I am going to try that. I must have got a bad print out from the client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top