How to redefine P9.2 to N ?

Question is as in topic. I need redefine P9.2 to N and i don’t know how :confused:

I have a month - P2 format, and i have a day in P2 format.
I need to redefine P9.2 to store day and month.

For example:
day := 25
month := 10
I need that P9.2 will be10.25

You can’t, because the internal representation is totally different - define a N field and MOVE the P field to it.

I’ve edited message after You answer me, sorry.

I have a month - P2 format, and i have a day in P2 format.
I need to redefine P9.2 to store day and month.

For example:
day := 25
month := 10
I need that P9.2 will be10.25

How do that ?

You must convert Packed to Numeric via an ASSIGN, MOVE, or COMPUTE statement. A REDEFINE of packed decimal will not result in usable data. In this case, the packed data does not contain the zone digit required in each byte of the unpacked field.

EG to convert 123456789.01 packed to unpacked

  12 34 56 78 90 1F --> F1 F2 F3 F4 F5 F6 F7 F8 F9 F0 F1  

A numeric 9.2 field requires 6 bytes for Packed and 11 bytes for Numeric (unpacked).

On the other hand, if you were interrogating an alpha field to determine whether the contents are packed or unpacked, then you might have something like

1 #ALPHA (A6)     1 REDEFINE #ALPHA  
  2 #PACKED (P9.2)

I thought that it could be done with redefinition only, but i see now that i have to use ASSIGN packed to numeric.

Thanks for Your help, Ralph Zborg and Wolfgang Winter :slight_smile:

As simple as that:

P92 := MONTH + (DAY / 100)

Just out of curiosity, why would you want to store a month and a day as a Packed field? Or, for that matter a numeric field. Why are you not storing the date as an alpha field? Or, if arithmetic is required, why not Date Format?

Just as a guess, is the year in there somewhere as well? If not, why is your target P9.2 and not P2.2?

steve