Page 1 of 1

convert Pic 9(8) comp. to pic 9(8)?

PostPosted: Tue Mar 31, 2009 8:45 am
by leon
hi,my friends,

I have a dataset in cobol, display the content of one record as following(file aid hex on):

AA62    2A1
CCFF0386FCF
 116212f3211

how to read the Hex x(01328f63), and then convert it decimal?
is the hex field pic 9(8) comp. or pic 9(4) comp. ? after conversion, is the
decimal field pic 9(8)? could you give me a good idea or suggestion? thank you
very much!

Re: convert Pic 9(8) comp. to pic 9(8)?

PostPosted: Tue Mar 31, 2009 8:56 am
by dick scherrer
Hello,

One suggestion is that you practice using the "Code" tag and the Preview function. Rather than posting info that becomes nearly un-readable, the Code tag makes thing quite readable and preserves alignment. You can see how your post will appear to the forum by using Preview. When you like the way your post appears, Submit. Look at your data above.

You mention "after conversion" - i see no need for any conversion so far.
is the hex field pic 9(8) comp. or pic 9(4) comp. ?
It could be either or neither. . .

From the data alone, there is no way to know for sure how the fields are defined. There is code somewhere that created the file and that code should contain the proper definitions for the fields. The 4 bytes could be a 3-byte packed-decimal field (comp-3) followed by some hex byte. It cound be 2 9(4) comp fields or 2 s9(4) comp fields or a combination.

Re: convert Pic 9(8) comp. to pic 9(8)?

PostPosted: Tue Mar 31, 2009 9:29 am
by leon
thanks, Mr. D,
right now I need import the dataset to MS ACCESS, when I FTP and get one text file, I can't
display the Hex data, so the first step is convert the hex to decimal in cobol. by the way, the Hex field's
definition is Pic 9(4) comp. could you furtherly tell me how to convert the hex to decimal, do you
have some sample code? thanks for your patient.

Re: convert Pic 9(8) comp. to pic 9(8)?

PostPosted: Tue Mar 31, 2009 9:39 am
by dick scherrer
Hello,

by the way, the Hex field's definition is Pic 9(4) comp.
That picture does not use all of the "hex field". Do you know what the value should be? Pic 9(4) is only 2 bytes. . .

The way to make these bytes usable (once the length/type is resolved) is to define a new edited (containing the sign and a decimal point if needed) output field for each packed or binary numeric. You can create an easily usable file for download by using STRING and creating a tab-delimited file of the original character fields and the edited numeric fields.

It is most cumbersome to try to use packed or binary mainframe data on the pc (most find it far too much effort).

Re: convert Pic 9(8) comp. to pic 9(8)?

PostPosted: Wed Apr 01, 2009 5:34 pm
by leon
thanks, Mr. D, your are correct, the definition is pic 9(8) comp. I got it.

my idea is:

read hexField
move hexField to decField (definition is pic 9(8).)
move decField to output-decField
write ourput-decField.

it works well and I got a correct textfile, thanks again.

Re: convert Pic 9(8) comp. to pic 9(8)?

PostPosted: Wed Apr 01, 2009 11:42 pm
by dick scherrer
You're welcome :)

d