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: 7996
Location: Bellevue, IA

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: 6966
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: 1226
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 Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts JCL to get submitted once dataset has... vinu78 JCL & VSAM 17 Thu Feb 16, 2017 7:32 am


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