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
 
Unpacking COMP-3 Field which has spaces Leads to "40404

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Unpacking COMP-3 Field which has spaces Leads to "40404
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: 3158
Location: Tucson AZ

PostPosted: Mon Jul 09, 2007 7:14 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Jul 09, 2007 9:39 pm    Post subject:
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    Post subject:
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    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 COMP Variables Mismatch gayu7 COBOL Programming 5 Wed Dec 20, 2017 5:06 pm
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 Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 9 Thu Dec 14, 2017 3:52 pm
No new posts CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm
No new posts how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am

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