View previous topic :: View next topic
|
Author |
Message |
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
Hi,
I tried reading a file which has alpha values to a file structure with numeric data type.But no error was thrown. Can anyone explain why it happens?
ex: FILEA
field1 field2
aaaa bbbb
cccc dddd
file structure which holds the record read from FILEA
01 in-rec
05 in-field1 pic 9(4)
05 in-field2 pic 9(4)
Thanks! |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Why do you think that should cause an error? |
|
Back to top |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
The datatype differs and it should be incompatible. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Look at section 6.2.24.1 of the Language Reference manual (link at the top of the page). Table 44 explicitly states that moves of alphanumeric (that is, PIC X) elementary fields to numeric (PIC 9) elementary fields is allowed, subject to the condition that MOVE of literals can only contain numeric characters. Variables can have anything in them and will move okay. Sure the data is not valid for the receiving field, but COBOL will do the move anyway assuming that you the programmer know what you're doing.
Of course, if you then attempt to add or subtract or multiply or divide wtih IN-FIELD1 you'll get an abend of the S0C7 variety, but that's arithmetic and not MOVE. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
The READ does not map to fields, only to the record (01-level).
there was no move of alpha data to numeric with the READ. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Quote: |
The datatype differs and it should be incompatible |
You're receiving the data in field "in-rec" which, as a group field, is alphanumeric.
So far there's no compatibility problem.
Now if you try to do some maths with the numeric fields, then you may have problems... |
|
Back to top |
|
|
|