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

Why Moving to s9(9)v IS TAKING - AS 0'S


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

New User


Joined: 19 Feb 2008
Posts: 5
Location: India

PostPosted: Mon Jun 16, 2008 7:59 pm
Reply with quote

Hi all,

i have these two variables :

WS-NUM1 9(9) VALUE 07-7-1297.
WS-NUM2 S9(9)V COMP-3.

now if i do the following move

MOVE ws-NUM1 to WS-NUM2 it is giving me the following results- :

WS-NUM2 = 070701297 i.e. it is replacing all the - in WS-NUM1 by spaces.

Can anyone please explain why this is happening.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jun 16, 2008 8:05 pm
Reply with quote

A dash is x'60' so rather than abending it is taking the numeric portion of what is suppose to be zoned decimal. GIGO
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 16, 2008 8:34 pm
Reply with quote

The compiler probably generates a ZAP instruction to move the data to the COMP-3 field. ZAP instructions assume the zones are valid and converts only the value parts of each byte -- as long as the last 4 bits of the byte are in the 0 to 9 range you won't get an abend.

If you know you've got bad data, you should be coding
Code:

IF WS-NUM1 NUMERIC
    MOVE WS-NUM1 TO WS-NUM2
ELSE ....
Back to top
View user's profile Send private message
udit_adhlakha

New User


Joined: 19 Feb 2008
Posts: 5
Location: India

PostPosted: Tue Sep 09, 2008 6:41 pm
Reply with quote

Robert Sample wrote:
The compiler probably generates a ZAP instruction to move the data to the COMP-3 field. ZAP instructions assume the zones are valid and converts only the value parts of each byte -- as long as the last 4 bits of the byte are in the 0 to 9 range you won't get an abend.

If you know you've got bad data, you should be coding
Code:

IF WS-NUM1 NUMERIC
    MOVE WS-NUM1 TO WS-NUM2
ELSE ....


Forgot to mention but the suggestion that was provided did work. Many thanks.
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 Moving Or setting POINTER to another ... COBOL Programming 2
No new posts LOAD JCL for db2 table, taking too lo... DB2 5
No new posts Moving a COMP-3 Variable to a Numeric... COBOL Programming 2
No new posts Moving a PS file as body of a mail! JCL & VSAM 4
No new posts Moving UDB database to Db2 on z/OS DB2 4
Search our Forums:

Back to Top