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

simple MOVE PIC X(03) TO PIC 9(3)--> adding always a 0


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

New User


Joined: 31 Aug 2005
Posts: 23

PostPosted: Fri Jan 19, 2007 7:37 pm
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jan 19, 2007 8:38 pm
Reply with quote

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
View user's profile Send private message
jruiza

New User


Joined: 31 Aug 2005
Posts: 23

PostPosted: Fri Jan 19, 2007 8:51 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 19, 2007 9:01 pm
Reply with quote

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
View user's profile Send private message
jruiza

New User


Joined: 31 Aug 2005
Posts: 23

PostPosted: Fri Jan 19, 2007 10:00 pm
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jan 19, 2007 11:27 pm
Reply with quote

Jordi,

Try this:

COMPUTE B-CA-100 = FUNCTION NUMVAL (WS-CA-100)
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Sun Jan 21, 2007 2:40 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Jan 21, 2007 4:50 pm
Reply with quote

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.... icon_rolleyes.gif
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 Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Adding first / last acct numerber to ... DFSORT/ICETOOL 7
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Adding 'ODD' and 'EVEN' indicator at ... DFSORT/ICETOOL 6
Search our Forums:

Back to Top