IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unpacking COMP-3 Field which has spaces Leads to "40404


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Mon Jul 09, 2007 7:02 pm
Reply with quote

Hi,

I am Unpacking the COMP-3 fields to Numeric Fields (I have tried alphanumeric also).

The problem is as follows:


I have declared as:

WS-020-INFILE-PACKED17 PIC 9(017) COMP-3.
WS-020-OUTFILE-PACKED17 PIC X(017).

The movement is:

MOVE WS-020-INFILE-PACKED17 TO WS-020-OUTFILE-UNPACKED17.


Now, WS-020-INFILE-PACKED17 is all spaces in the file.


In the DISPLAYS , I get:

WS-020-INFILE-PACKED17 40404040404040404
WS-020-OUTFILE-UNPACKED17 40404040404040404


May I know why spaces are not coming and what should I do to not get the HEX values (for spaces) but get the spaces.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jul 09, 2007 7:14 pm
Reply with quote

Because the X'404040' becomes X'F4F0F4F004' which becomes X'F4F0F4F0F4' which is 40404.
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Mon Jul 09, 2007 7:33 pm
Reply with quote

Change this, but you will need to enlarge the picture size

WS-020-OUTFILE-PACKED17 PIC X(017).

WS-020-OUTFILE-PACKED17 PIC 9(017).
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Jul 09, 2007 9:39 pm
Reply with quote

Hello,

I believe this
Quote:
Change this, but you will need to enlarge the picture size
WS-020-OUTFILE-PACKED17 PIC X(017).
WS-020-OUTFILE-PACKED17 PIC 9(017).
is typo'ed.

If you have these fields
Quote:
WS-020-INFILE-PACKED17 PIC 9(017) COMP-3.
WS-020-OUTFILE-PACKED17 PIC X(017).
and want leading spaces before the actual digits, change WS-020-OUTFILE-PACKED17 PIC X(017) to WS-020-OUTFILE-PACKED17 PIC ZZZZZZZZZZZZZZZZ9. If you want leading zeros, use the PIC 9(17) recommended previoiusly. It would also be a good idea to make the field name more informative.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jul 10, 2007 1:09 am
Reply with quote

You can try:
Code:
 WS

WS-020-INFILE-PACKED17    PIC 9(017) COMP-3.
WS-020-INFILE-X           REDEFINES
WS-020-INFILE-PACKED17    PIC X(009).
WS-020-OUTFILE-PACKED17   PIC X(017).

PD

IF WS-020-INFILE-PACKED17 IS NOT NUMERIC     
   AND
   WS-020-INFILE-X = SPACES
   MOVE SPACES TO WS-020-OUTFILE-PACKED17
ELSE
   MOVE WS-020-INFILE-PACKED17 TO WS-020-OUTFILE-PACKED17   
END-IF



This assumes SPACES is the only non-packed value you'll have in your IP.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Join 2 files according to one key field. JCL & VSAM 3
Search our Forums:

Back to Top