Moving Hex values to Display Format



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

Moving Hex values to Display Format

Postby archana_p85 » Fri Dec 19, 2008 9:28 am

Hi,

I want to move HEX value to display format.
please find below the example of my requirement. Here i want to move(Bolded Field) value 15 to display format and use it for addition.
it tried moving to 9(2),s9(4) comp-3.But value is not moving correctly.
please let me know, what declaration should i Use?

Example:

::MISS/CATHERINE
11DCEE6CCECCDCDC
5149221313859955

Thanks,
Archana
archana_p85
 
Posts: 6
Joined: Sat Dec 13, 2008 6:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Moving Hex values to Display Format

Postby dick scherrer » Fri Dec 19, 2008 9:40 am

Hello,

Is there some reason you want to make the intermediate move to "display format"?

Is the value to accumulate fifteen or is it really 21?
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: Moving Hex values to Display Format

Postby archana_p85 » Fri Dec 19, 2008 9:52 am

Hi Dick,

The value is 15 only. I want to use value 15 as index and want to increment the same.

I tried moving to 9(2) or comp variables,but the value is populating as '0050'


Thanks,
Archana
archana_p85
 
Posts: 6
Joined: Sat Dec 13, 2008 6:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Moving Hex values to Display Format

Postby dick scherrer » Fri Dec 19, 2008 10:07 am

Hello,

What should happen when the input value is x'1C'?
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: Moving Hex values to Display Format

Postby archana_p85 » Fri Dec 19, 2008 11:36 am

sorry for confusing :(

Actual value is 21
archana_p85
 
Posts: 6
Joined: Sat Dec 13, 2008 6:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Moving Hex values to Display Format

Postby dick scherrer » Fri Dec 19, 2008 11:47 am

Hello,

If the byte is a true binary value, you can move that one byte to the low-order byte of a 2-byte comp field.
01  comp-num         pic 9(4) comp.
01  comp-num-r redefines the-comp-num.
    05  filler          pic x.
    05  calc-byte       pic x.


in the procedure code,
move zeros to comp-num
move the input byte to calc-byte.

comp-num can now be used to subscript an array (or it can be incremented and then used as the subscript). it is not displayable, but is completely useful for calculating/incrementing.
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


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post