Need to convert from hex to displayable format.



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

Need to convert from hex to displayable format.

Postby syannigeri » Fri Dec 25, 2009 8:46 pm

Hi,

I have a file which is in hex, S9(09)V99 Comp-3. How can i convert this to displayable format?

1. There is a way to convert using file aid, Let me know how to do using file aid?
2. Also Let me know how to convert using cobol, Let me know the PIC clause to be moved to, to get data in displayable format?

Thanks
Shanakrgouda
syannigeri
 
Posts: 20
Joined: Tue Dec 22, 2009 11:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to convert from hex to displayable format.

Postby Robert Sample » Sat Dec 26, 2009 10:33 am

What have you researched in the File Aid manual so far?
What have you researched in the COBOL manuals so far?
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need to convert from hex to displayable format.

Postby syannigeri » Sat Dec 26, 2009 6:44 pm

1. In File aid i know, I need to create a Copy book in HEX and Another in normal layout(PIC value of normal layout is not known).
2. Using cobol, I am not sure of the move statement

You guys need to confirm the below move will work or not?

MOVE S9(09)V99 COMP-3 to X(5) will work?
I calcualated X(5) using 9/2 = 4 +1..

What will happen to the Sign bit and the decimal bit?

Is that correct? Else let me know the method to convert HEX to a Displyable format...
syannigeri
 
Posts: 20
Joined: Tue Dec 22, 2009 11:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to convert from hex to displayable format.

Postby Robert Sample » Sun Dec 27, 2009 12:48 am

There is no decimal bit -- implied decimal point means implied; it is not explicit. Assuming you mean "human-readable" when you say "Displayable", your move will not provide you with the desired result. Moving to a variable defined as PIC 9(10).99 SIGN LEADING SEPARATE will let you see all the digits as well as the sign and decimal point. This does, however, take extra bytes for the sign and decimal point. Also, your calculation is off -- there are 11 digits in your number, not 9 (you must also consider the digits after the decimal point) so it actually requires six bytes to store the number not 5.

A File Aid copybook that contains the appropriate PIC for the variable will automatically display the value for you.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need to convert from hex to displayable format.

Postby syannigeri » Sun Dec 27, 2009 7:49 am

Thanks Robert for you valuable reply..

What will be the value of sign bit , when we move

MOVE PIC 9(10).99 SIGN LEADING SEPARATE to PIC X(06) ?

Thanks
Shankargouda
syannigeri
 
Posts: 20
Joined: Tue Dec 22, 2009 11:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to convert from hex to displayable format.

Postby dick scherrer » Sun Dec 27, 2009 8:55 am

Hello,

What will be the value of sign bit
There is no "sign bit" - neither in the comp-3 input nor the "displayable" output.

The sign of a packed-decimal (comp-3) data item is the low-order nibble (1/2 byte) of the least significant byte. Valid signs for a packed-decimal field are C (positive), D (negative), and F (implied positive). To see this view a comp-3 field in tso/ispf using HEX ON.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Need to convert from hex to displayable format.

Postby Robert Sample » Mon Dec 28, 2009 2:27 am

If you move PIC 9(10).99 SIGN LEADING SEPARATE to a PIC X(06) field, you'll lose the most significant digits -- what will actually be moved will be the last 3 digits before the decimal point, the decimal point, and the 2 digits after the decimal point. Asking about the "sign bit" indicates you have no understanding of how numbers are stored internally on a z/OS machine. You really, really, really need to spend several hours in manuals to grasp the fundamental differences between the internal representations of PIC X, numeric USAGE DISPLAY, numeric USAGE COMP, and numeric USAGE COMP-3 fields.

Asking about things like sign bits and decimal bits shows how much you need to hit the books -- giving you the right answers will not improve your understanding of the concepts that you have no clue about yet (such as internal representations). Study the manuals. Study the manuals. Study the manuals.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need to convert from hex to displayable format.

Postby dick scherrer » Mon Dec 28, 2009 4:18 am

Hello,

Study the manuals. Study the manuals. Study the manuals.
And a good place to start your "manual bookmark collection" is here:

http://publibz.boulder.ibm.com/cgi-bin/ ... 0/CONTENTS

This is the Table of Contents page for the Enterprise COBOL Language Reference Manual. In addition to the Table of COntents and the Appendix entries at the back of the manual, the material is also searchable by using the tubelight/flashlight near the top-left of each page.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Need to convert from hex to displayable format.

Postby syannigeri » Wed Dec 30, 2009 10:39 pm

COMP IS BINARY
COMP-3 IS PACKED DECIMAL

Is this forum not to discuss things and learn?
Or Its just to get ready made solutions ? :evil:
syannigeri
 
Posts: 20
Joined: Tue Dec 22, 2009 11:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to convert from hex to displayable format.

Postby dick scherrer » Mon Jan 04, 2010 6:06 am

Hello,

Your reply
COMP IS BINARY
COMP-3 IS PACKED DECIMAL

Is this forum not to discuss things and learn?
Or Its just to get ready made solutions ?
is most confusing. . . :?

You needed to post a short definition of comp and comp-3? Why?

It is our intent to provide you with ways to "discuss and learn" - -but most of the burden is yours. We try to provide guidance and when someone tries something that does not work, we try to help diagnose.

We typically do not provide "ready made custom solutions".

When you collect your thoughts, someone will be here.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post