Re: Setting A Hex Value in COBOL
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 1 Jun 2007 02:36:23 +1200
"William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx> wrote in message
news:2Fs7i.159356$oS7.144347@xxxxxxxxxxxxxxxxxxxxxxxxx
"Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5c6j97F2ve8jcU1@xxxxxxxxxxxxxxxxxxxxx
<snip>
Remember that CH-E5-BIN is a binary halfword (two bytes). Therefore,What Pette says above is true AND FALSE. As the OP mentioned an IBM
although the value is 'three digits' it can be accommodated into a single
byte. In fact, any value up to 255 would be OK... (It is only 'three
digits' because you are thinking in decimal :-))
mainframe compiler, this will totally depend upon what setting of TRUNC is
specified - and how the field is used. If one wants to be "totally safe"
it is NEVER a "good idea" to put a 3 (decimal) digit value into a field
defined with "PIC 9(2)" - regardless of USAGE (unless using an implementer
defined usage that SAYS this is OK, such as COMP-5 or COMP-X in some
compilers).
I was aware of the TRUNC NOTRUNC options but I believe that neither of them
will affect this - correct me if I'm wrong. The field is defined as 4 digits
and is binary, a value no greater than 255 is being placed in it. Truncation
to 4 digits or non-truncation of 5 digits will have no effect on this
particular case, as far as I can see. I have used exactly this approach on a
number of installations and never had a problem with it. (Maybe they all had
the same defaults).
There is no question of a PIC 9(2) field being involved... It is a halfword
redefined to PIC XX.
I posted because the OP was getting a lot of whys and wherefores when really
all that was needed was a simple "yes" or "no".
Pete.
.
- Follow-Ups:
- References:
- Setting A Hex Value in COBOL
- From: gary
- Re: Setting A Hex Value in COBOL
- From: Pete Dashwood
- Re: Setting A Hex Value in COBOL
- From: William M. Klein
- Setting A Hex Value in COBOL
- Prev by Date: Re: Setting A Hex Value in COBOL [correction]
- Next by Date: Re: Setting A Hex Value in COBOL
- Previous by thread: Re: Setting A Hex Value in COBOL
- Next by thread: Re: Setting A Hex Value in COBOL
- Index(es):