HP3000-L Archives

November 2005, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Glenn Mitchell <[log in to unmask]>
Reply To:
Glenn Mitchell <[log in to unmask]>
Date:
Fri, 25 Nov 2005 14:58:27 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (58 lines)
Pete - 

For details on how COBOL stores packed decimal data, see
http://www.discinterchange.com/TechTalk_Packed_fields_.html

What language are you doing the unpacking in?

If the language supports packed decimal data, then you're all set once you
figure out the length of each of the packed sub-fields (look for the
non-numeric sign nibbles in a hex dump of the data or locate a COBOL
copybook defining the field).

If not, you might take the following general approach:

1.  location = 1; accum = 0
2.  Access the byte at location.
3.  Shift the byte right 4 bits to get the high-order nibble (divide by 16
is one way to do this). 
4.  Multiply accum by 10 and add high-order nibble.
5.  And the byte with x'0F' to get the low-order nibble (or multiply the
high-order nibble from step 3 by 16 and subtract it).
6.  If low-order nibble is > 9 then it's a sign nibble (x'0d' = negative,
others generally positive); set the accum sign and exit.
7.  multiply accum by 10 and add low-order nibble.
8.  add 1 to location
9.  repeat steps starting at step 2

This assumes the field is ALL packed decimal data.  If it is not, you'll
have to skip over the ASCII pieces.

Regards.

Glenn
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On Behalf
Of Peter Osborne
Sent: Friday, November 25, 2005 2:03 PM
To: [log in to unmask]
Subject: [HP3000-L] Packed Fields

Hi All,

I'm looking at a field in a dataset. It's an X40 field but it seems that the
data stored in it is server integers "packed" by a Cobol program. I've used
the program to change the values that are stored in this field and the data
is indeed changing but I cannot figure out how the data is actually stored. 
Is there a formula on how one would unpack a field that has been packed by a
Cobol program?

Thanks,
Pete

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2