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
 
[Solved]Nonumeric movement to the numeric field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abhishekdutta

New User


Joined: 17 Mar 2005
Posts: 2
Location: bangalore

PostPosted: Thu Mar 17, 2005 8:10 pm    Post subject: Nonumeric movement to the numeric field
Reply with quote

What will happen if Nonumeric value is moved to a numeric field?
Compile error.
Runtime error.
Normal execution.
Back to top
View user's profile Send private message

mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1199
Location: India

PostPosted: Thu Mar 17, 2005 11:14 pm    Post subject:
Reply with quote

Quote:
Nonumeric value is moved to a numeric field


Normal execution.

If it's not an Interview Question, then:

You can Move a NonNumeric Value to a Numeric Item, only if the Nonnumeric value is stored as AlphaNumeric variable(X).

X TO 9 is possible, but you can not move A to 9.
Back to top
View user's profile Send private message
ragin

New User


Joined: 20 Feb 2005
Posts: 16

PostPosted: Fri Mar 18, 2005 8:17 am    Post subject: Hey there
Reply with quote

Hey dude,

This is an interview question commonly asked in i-flex.It depends on the value u move to the numeric field.
For Eg:

01 A PIC X(5) Value HI
01 B PIC 9(5)
MOVE A TO B.

Gives u Soc7 Error,since ur moving alphabets to numeric field.Now:

01 A PIC X(5) Value "12345"
01 B PIC 9(5)
MOVE A TO B.
Gives u the exact answer,since ur moving numerals to numerals.Got it dude????
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1199
Location: India

PostPosted: Fri Mar 18, 2005 12:58 pm    Post subject:
Reply with quote

No, you can Move Alphabetic data to Numeric, if the LValue is stored in Alphanumeric DataType (X).

See this sample Program.

Code:
EDIT       IBMMF.EXPERT.FORUM(SAMPLE) - 01.36              Columns 00001 00072
Command ===>                                                  Scroll ===> 005 
****** ***************************** Top of Data ******************************
000100        ID DIVISION.                                                     
000200        PROGRAM-ID. SAMPLE.                                             
000300        DATA DIVISION.                                                   
000310        WORKING-STORAGE SECTION.                                         
000320        01 A PIC X(2) VALUE "AB".                                       
000321        01 B PIC 99.                                                     
000330        PROCEDURE DIVISION.                                             
000600        PRA1.                                                           
000700            MOVE A TO B.                                                 
000701            DISPLAY "VALUE IS" B.                                       
000704            STOP RUN.                                                   
****** **************************** Bottom of Data ****************************


The output is:

Code:
********************************* TOP OF DATA **********************************
VALUE ISA2                                                                     
******************************** BOTTOM OF DATA ********************************


Quote:
01 A PIC X(5) Value HI
01 B PIC 9(5)
MOVE A TO B.

Gives u Soc7 Error,since ur moving alphabets to numeric field.Now:


Moving alphabets to numeric field at compile time will not give S0C7.

Code:
01 A PIC X(5) Value HI
01 B PIC 9(5)
MOVE A TO B.


You will get Compiler Error as:

Code:
IGYGR0145-S   "HI" was not defined as a "SYMBOLIC CHARACTERS" figurative constant.  "HI" was discarded.

IGYGR1080-S   A "VALUE" clause literal was not compatible with the data category of the subject data item.  The "VALUE"  clause was discarded.
                                                   
Back to top
View user's profile Send private message
narena

New User


Joined: 16 Mar 2005
Posts: 18

PostPosted: Fri Mar 18, 2005 3:24 pm    Post subject:
Reply with quote

Thanks for ur Answer Mcmillan
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 Select numeric portion from CHAR data... balaji81_k DB2 5 Sat Aug 19, 2017 1:51 am
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am


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