View previous topic :: View next topic
|
Author |
Message |
abhishekdutta
New User
Joined: 17 Mar 2005 Posts: 2 Location: bangalore
|
|
|
|
What will happen if Nonumeric value is moved to a numeric field?
Compile error.
Runtime error.
Normal execution. |
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
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 |
|
|
ragin
New User
Joined: 20 Feb 2005 Posts: 16
|
|
|
|
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 |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
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 |
|
|
narena
New User
Joined: 16 Mar 2005 Posts: 18
|
|
|
|
Thanks for ur Answer Mcmillan |
|
Back to top |
|
|
|