D X S 3U 0 inz( x'16' ) D Y S 2S 0 /free Y = %div(X:16)*10 + %rem(X:16);
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
How to Read 1 Byte Packed Data
Collapse
X
-
How to Read 1 Byte Packed Data
The value in the “un-signed” packed field can be different every time (not always 16). So, how can I extract the value of a variable in a similar manner as below? The value that I need is 16 as opposed to X’16’. Ps. Thanks for everyone’s quick responses yesterday!
Comment
-
How to Read 1 Byte Packed Data
Declare the variable as a one-byte unsigned binary value.- [*]Divide the binary value by 16, discard the remainder.[*]Multiply by 10.[*]Add the remainder of the binary value divided by 16.[/list]In pseudo RPG:
PACKED = %div(UBIN1:16)*10 + %REM(UBIN1:16);
Comment
-
How to Read 1 Byte Packed Data
Try this. Some people more familiar with BIFs could probably find cleaner way, but this will work. It includes code for converting both directions using the same data structure. I posted this before seeing Gene's post. His is cleaner looking, but if you're doing millions of records, the data structure method will probably be more efficient (only one DIV operation). But experiment with both.
Code
Comment
-
How to Read 1 Byte Packed Data
Melanie Thomas wrote: > The value in the "un-signed" packed field can be different every time > (not always 16). So, how can I extract the value of a variable in a > similar manner as below? The value that I need is 16 as opposed to > X'16'. Melanie, How about something like this: D ds D cInput 1 D xZeroF 1 Inz(x'0F') D nOutput 1 2p 1 C* C Eval cInput = x'16' C Eval cInput = x'99' C* C Eval *InLR = *On This puts your one byte at the head of a 3.1 packed decimal field. Displaying the values of nOutput after the execution of these two instructions show values of 16.0 and 99.0 . Bill
Comment
-
-
How to Read 1 Byte Packed Data
We receive a file from a mainframe that packs 2 bytes of data into 1 byte. When I try to access the data on the AS400, I receive a decimal data error. When I view the file using DSPPFM and then switch to hexadecimal, I can see the two numbers that are packed into the 1 byte. How can I access the value of this field?
Code
Comment
-
How to Read 1 Byte Packed Data
I am a COBOL programmer. Here's how to do it in COBOL. First create a 99v9 comp-3 work field (wrkfld). Move your 1 byte field into the first position of the work field. Now do whatever you want with the work field (contains 16.0). Michael Dratwa
Comment
Comment