Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to store a Packed value in a Variable of PIC clause X?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dates

New User


Joined: 11 Mar 2008
Posts: 9
Location: LA,USA

PostPosted: Mon May 03, 2010 3:22 pm    Post subject: How to store a Packed value in a Variable of PIC clause X?
Reply with quote

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
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon May 03, 2010 3:39 pm    Post subject:
Reply with quote

COBOL MOVE verb? icon_confused.gif icon_neutral.gif
Back to top
View user's profile Send private message
dates

New User


Joined: 11 Mar 2008
Posts: 9
Location: LA,USA

PostPosted: Mon May 03, 2010 3:55 pm    Post subject: No
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Mon May 03, 2010 3:56 pm    Post subject: Reply to: How to store a Packed value in a Variable of PIC c
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon May 03, 2010 7:51 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue May 04, 2010 5:46 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us