View previous topic :: View next topic
|
Author |
Message |
udit_adhlakha
New User
Joined: 19 Feb 2008 Posts: 5 Location: India
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
udit_adhlakha
New User
Joined: 19 Feb 2008 Posts: 5 Location: India
|
|
|
|
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 |
|
|
|