View previous topic :: View next topic
|
Author |
Message |
dates
New User
Joined: 11 Mar 2008 Posts: 9 Location: LA,USA
|
|
|
|
I have Packed value of type S9(7) COMP-3 .
Now i need to store this value in a pre-defined field of type X(20). Is there a way i can do this ? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
dates
New User
Joined: 11 Mar 2008 Posts: 9 Location: LA,USA
|
|
|
|
MOVE will unpack the value and store it in X(20),
I want the packed value to be stored as it is in PACKED format in the X(20) field. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Redefining the COMP-3 field as PIC X will allow you to do this -
Code: |
03 WS-PACKED-VALUE PIC S9(07) COMP-3.
03 WS-PACKED-VALUE-X REDEFINES WS-PACKED-VALUE PIC X(04).
03 WS-TWENTY-BYTES PIC X(20) VALUE HIGH-VALUES.
03 WS-POS PIC 9(08) BINARY.
*
* LEFT-JUSTIFIED WITH LOW-ORDER HIGH-VALUES
*
MOVE WS-PACKED-VALUE-X TO WS-TWENTY-BYTES (1:LENGTH OF WS-PACKED-VALUE-X).
*
* RIGHT-JUSTIFIED WITH HIGH-ORDER HIGH-VALUES
*
COMPUTE WS-POS = (LENGTH OF WS-TWENTY-BYTES - LENGTH OF WS-PACKED-VALUE-X) + 1.
MOVE WS-PACKED-VALUE-X TO WS-TWENTY-BYTES (WS-POS:).
|
HIGH-VALUES are used as a placeholder for determining the length of the COMP-3 data. You can use an INSPECT to find this placeholder.
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I want the packed value to be stored as it is in PACKED format in the X(20) field. |
What should happen to the "other" bytes in the 20-byte field? Should they be unchanged or set to spaces or? |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Using a group move will move the bytes as is:
Code: |
01 PACKED-GROUP.
05 FILLER PIC X(16) VALUE 'EYECATCHER16: '.
05 YOUR-PACKED-FIELD PIC S9(7) COMP-3.
01 OUTPUT-DATA.
05 RECEIVING-FIELD PIC X(20).
.....
PROCEDURE DIVISION.
MOVE +1234567 to YOUR-PACKED-FIELD
MOVE PACKED-GROUP to RECEIVING_FIELD
....
|
|
|
Back to top |
|
|
|