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
 

 

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 Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts Include/omit with "ALL" pa... mgl DFSORT/ICETOOL 6 Wed Jun 14, 2017 2:31 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm


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