View previous topic :: View next topic
|
Author |
Message |
sunny_io
New User
Joined: 11 Jul 2007 Posts: 68 Location: noida
|
|
|
|
Hi All.
Pls look at the follwoing code
05 CC-00000000000 PIC X(11) VALUE
'00000000000'.
05 D17625-MEMBER-ID PIC 9(11).
MOVE CC-00000000000 TO D17625-MEMBER-ID
This move is working fine. But I wanted to understand what is going on at background. How is the move able to assign char data to numeric data ( is it always allowed ?)
Secondly if it is allowed.. then when does actual type checking happen or is there sometype of type conversion happening..
Pls throw as much light as possible..
Thanks
Sunny |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
If you run the compile with LIST (not OFFSET) you will see the MOVE statement is converted into a pseudo-assembler MVC instruction. This instruction moves 11 bytes from one field to another field -- as long as they are both USAGE DISPLAY. Note that the sending field does not even have to have numeric data; you can move anything from a variable to a PIC 9(11) USAGE DISPLAY field.
Attempting to do any arithmetic with the field, however, will cause problems unless all 11 characters are actually numeric digits. And you will also run into issues when fields are converted (USAGE COMP, COMP-3, etc) as these types of moves require numeric data or generally a S0C7 abend occurs. |
|
Back to top |
|
|
sunny_io
New User
Joined: 11 Jul 2007 Posts: 68 Location: noida
|
|
|
|
Hi
Thanks for the reply
One more query I had ..
MOVE CC-00000000000 TO D17625-MEMBER-ID
Considering what I have as pic clause and what I'm moving ..
Although 05 CC-00000000000 PIC X(11) VALUE
'00000000000'.
is character by PIC clause but has zeroes in it..
Would I stil get Soc 7 if I manipulate D17625-MEMBER-ID ?? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Not the way you've got things defined -- COBOL doesn't care where the data came from, only that each digit is numeric when being used for arithmetic or other numeric operation. |
|
Back to top |
|
|
|