Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving unpacked numeric to packed numeric

Status
Not open for further replies.

Tarbux

Programmer
Sep 16, 2006
3
0
0
AP
Hi guys,

I'm currently working on something which requires me to move an unpacked numeric to a packed numeric variable in a copybook.

02 UNPACKED-NUMBER PIC S9(13)V9(02).

02 PACKED-NUMBER PIC S9(13)V9(02) COMP-3.

I remember that someone told me this can't be done but I'm not sure if I remember it correctly. Is this possible? I tried displaying it also just to see but nothing comes up.

I also tried using the REDEFINES verb and I get weird values when displayed. So I'm not sure if I'm doing it right.

02 W-REDEFINED-NUM PIC S9(13)V9(02) COMP-3.
02 W-TEMP REDEFINES W-REDEFINED-NUM.
03 W-TEMP2 PIC S9(13)V9(02).

Am I doing something wrong? Please help. I'm using Microfocus by the way.
 
The packed number
PIC S9(13)V9(02) COMP-3
is ceil((13+2)/2) = ceil(7.5) = 8 Bytes long /where ceil() is upper integer part of the number/, but the number
PIC S9(13)V9(02)
is 13+2=15 Bytes long.

Therefore your redefinition don't work.
So try this:
Code:
02  W-REDEFINED-INPUT.
    03 FILLER           PIC X(7).     
    03 W-REDEFINED-NUM  PIC S9(13)V9(02) COMP-3.
02  W-TEMP           REDEFINES W-REDEFINED-INPUT.
    03   W-TEMP2     PIC S9(13)V9(02).

But simply moving this
Code:
MOVE UNPACKED-NUMBER TO PACKED-NUMBER
should work.
 
Simply MOVE UNPACKED-NUMBER to PACKED_NUMBER.

Then work with PACKED-NUMBER.

SLN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top