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

[Solved]Nonumeric movement to the numeric field


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1210
Location: India

PostPosted: Thu Mar 17, 2005 11:14 pm
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
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: 1210
Location: India

PostPosted: Fri Mar 18, 2005 12:58 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top