Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 2502
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 Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us