View previous topic :: View next topic
|
Author |
Message |
jruiza
New User
Joined: 31 Aug 2005 Posts: 23
|
|
|
|
Not well experinced in CObol mainframe,so a question than can be easy for any of you..
doing a simple move from char to pic but adding always a 0 at the end
WORKING AREA
01 WS-CA-100 PIC X(03).
01 B-CA-100 PIC 9(03).
sECTION:
MOVE WS-CA-100 TO B-CA100.
dDISPLAYS:
ATRIB-CA: 76
B-CA100: 760
Thanks,
Jordi |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Jordi,
Check this link to a Previous Post. I think this will explain what is happening. If you still have questions, please come back. |
|
Back to top |
|
|
jruiza
New User
Joined: 31 Aug 2005 Posts: 23
|
|
|
|
I read the explanation but is still not clear for me how to resolve my problem
Thanks,
Jordi
DavidatK wrote: |
Jordi,
Check this link to a Previous Post. I think this will explain what is happening. If you still have questions, please come back. |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Jordi,
When you moved '76 ' (notice the blank) the space was converted to a zero in the result. The system was trying to do what it thought you wanted.
I'd suggest checking the sending field before doing the move and doing whatever is necessary for your situation. You might treat this as an error, you might replace any spaces with zeros, or you might write code to use only the digits provided (after making sure that the field contains no alpha characters). |
|
Back to top |
|
|
jruiza
New User
Joined: 31 Aug 2005 Posts: 23
|
|
|
|
then, you suggest to handle the problem as an error checking positions and doing whateber necessary dpending on situation.
can be a solution but I was thinking in a general solution ...
any idea?
Thx
dick scherrer wrote: |
Hello Jordi,
When you moved '76 ' (notice the blank) the space was converted to a zero in the result. The system was trying to do what it thought you wanted.
I'd suggest checking the sending field before doing the move and doing whatever is necessary for your situation. You might treat this as an error, you might replace any spaces with zeros, or you might write code to use only the digits provided (after making sure that the field contains no alpha characters). |
|
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Jordi,
Try this:
COMPUTE B-CA-100 = FUNCTION NUMVAL (WS-CA-100) |
|
Back to top |
|
|
sachin_star3 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 78 Location: pune
|
|
|
|
jruiza wrote: |
Not well experinced in CObol mainframe,so a question than can be easy for any of you..
doing a simple move from char to pic but adding always a 0 at the end
WORKING AREA
01 WS-CA-100 PIC X(03).
01 B-CA-100 PIC 9(03).
sECTION:
MOVE WS-CA-100 TO B-CA100.
dDISPLAYS:
ATRIB-CA: 76
B-CA100: 760
Thanks,
Jordi |
========================================
ANSWER:
1] IN ALPHANUMERIS THE DATA IS STORED FROM LEFT TO RIGHT AND REMAINING CHARACTER FILL BY SPACES
2] AND IN NUMERIC FIELD THE DATA IS STORED FROM RIGHT TO LEFT
AND REMAINING PLACES ARE FILLED BY ZEROS
SO IN YOUR MOVE YOU MOVE ALPHANUMERIC TO NUMERIC
SO DATA STORED FROM LEFT TO RIGHT AND AND ONE FIELD IS REMAIN BY ZERO BECAUSE YOU MOVE INTO NUMERIC CLAUSE
SURE!
FROM - SACHIN BORASE
PUNE
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
sachin_star3 wrote: |
2] AND IN NUMERIC FIELD THE DATA IS STORED FROM RIGHT TO LEFT |
Numeric fields are stored aligned to the decimal point and zero filled both left and right.
Lose the caps.... |
|
Back to top |
|
|
|