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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: simple MOVE PIC X(03) TO PIC 9(3)--> adding always a 0
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    Post subject: Re: simple MOVE PIC X(03) TO PIC 9(3)--> adding always a
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    Post subject: Re: simple MOVE PIC X(03) TO PIC 9(3)--> adding always a
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

Site Director


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

PostPosted: Fri Jan 19, 2007 9:01 pm    Post subject:
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    Post subject:
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    Post subject: Re: simple MOVE PIC X(03) TO PIC 9(3)--> adding always a
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    Post subject: Re: simple MOVE PIC X(03) TO PIC 9(3)--> adding always a
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: 3158
Location: Tucson AZ

PostPosted: Sun Jan 21, 2007 4:50 pm    Post subject: Re: simple MOVE PIC X(03) TO PIC 9(3)--> adding always a
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    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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Adding a descending character to a file Steve Ironmonger DFSORT/ICETOOL 3 Fri Jul 15, 2016 4:57 pm


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