Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 4650
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: 8154
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: 6968
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: 1243
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 Setting Font Type for XMIT satish.ms10 All Other Mainframe Topics 3 Fri Sep 15, 2017 10:01 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us