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



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

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

Postby leon » Tue Mar 31, 2009 8:45 am

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!
leon
 
Posts: 40
Joined: Tue Nov 25, 2008 7:39 pm
Has thanked: 0 time
Been thanked: 0 time

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

 

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

Postby dick scherrer » Tue Mar 31, 2009 8:56 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

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

Postby leon » Tue Mar 31, 2009 9:29 am

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.
leon
 
Posts: 40
Joined: Tue Nov 25, 2008 7:39 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby dick scherrer » Tue Mar 31, 2009 9:39 am

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).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

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

Postby leon » Wed Apr 01, 2009 5:34 pm

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.
leon
 
Posts: 40
Joined: Tue Nov 25, 2008 7:39 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby dick scherrer » Wed Apr 01, 2009 11:42 pm

You're welcome :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post