Even simpler, can you define the COBOL field as PIC 999 USAGE BINARY?  That 
will give you a 2-byte binary field.  You can simply address the 2nd byte for 
values in your specified range.  

--
 
Donald Grinsell
State of Montana
406-444-2983
[email protected]

"No one should negotiate their dreams.  Dreams must be free to fly high.  No 
government, no legislature, has a right to limit your dreams.  You should never 
agree to surrender your dreams."
~ Jesse Jackson

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of John McKown
Sent: Wednesday, September 17, 2014 12:14 PM
To: [email protected]
Subject: Re: Data Conversion

On Wed, Sep 17, 2014 at 12:05 PM, Scott Ford 
<[email protected]> wrote:
> Guys/Gals:
>
> I have a fundamental question to ask. We have a Cobol routine passing a set 
> of parms ..one of the parms is a number PIC 999.
>
> The called program is in HLASM and receives the parms and we have WORKAREA 
> dsect setup and address it with a using.
>
> My issue is I must convert this PIC 999 field to a DC   x’00’ field in 
> Assembler. Is my assumption correct that at I have to translate the PIC 999 
> with a TROT or TR with a hex table to build the DC x’00’ field ? If I am 
> passing 241  , the hex value I am expecting is  x’F1’. I must be
>
> able to convert a range from 128-255 …
>
>
> I appreciate any help …I want to just make sure my thinking is correct.
>
> Regards,
>
> Scott

What is the COBOL USAGE of the PIC 999 field? If it is the default of USAGE 
DISPLAY, then the data is in character format. If you want a 3 digit decimal 
number coming in and a one byte hexadecimal equivalent going out, then the 
simpliest way is to PACK the PIC 999 USAGE DISPLAY field to packed decimal, 
then CVB to convert it to a binary number, then return the last byte of that 
number. But it is _much_ easier to just do something in pure COBOL. Such as:

WORKING-STORAGE.
77  INPUT-DECIMAL PIC 999 USAGE DISPLAY.
77 OUTPUT-BINARY PIC S9(4) COMP.
77 OUTPUT-HEX PIC X.
...
MOVE INPUT-DECIMAL TO OUTPUT-BINARY.
MOVE OUTPUT-BINARY(2:1) TO OUTPUT-HEX.


If you really need HLASM, then something like:

ZAP DOUBLE,=PL8'0'
PACK DOUBLE+6(2),PIC999(3)
CVB R1,DOUBLE
STC R1,HEXVALUE
...
DOUBLE DS D'0'

Where PIC999 stands in for how you really point to the area containing the PIC 
999 USAGE DISPLAY passed in from COBOL.

--
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
[email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to