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
 

 

moving a alpha value to a numeric data type

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: moving a alpha value to a numeric data type
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

Moderator Team Head


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

PostPosted: Thu Nov 06, 2008 7:30 pm    Post subject: Reply to: moving a alpha value to a numeric data type
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    Post subject:
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Nov 06, 2008 8:07 pm    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Thu Nov 06, 2008 8:07 pm    Post subject:
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: 1228
Location: Israel

PostPosted: Thu Nov 06, 2008 8:15 pm    Post subject: Reply to: moving a alpha value to a numeric data type
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    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
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


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