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

moving a alpha value to a numeric data type


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

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Thu Nov 06, 2008 7:28 pm
Reply with quote

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

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Nov 06, 2008 7:30 pm
Reply with quote

Why do you think that should cause an error?
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Thu Nov 06, 2008 7:52 pm
Reply with quote

The datatype differs and it should be incompatible.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Nov 06, 2008 8:07 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Nov 06, 2008 8:07 pm
Reply with quote

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

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Nov 06, 2008 8:15 pm
Reply with quote

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
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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top