View previous topic :: View next topic
|
Author |
Message |
sudhakar_lendave
New User
Joined: 21 Nov 2006 Posts: 48 Location: mumbai
|
|
|
|
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-RECORD.
05 A PIC X(5) VALUE ALL SPACES.
05 B REDEFINES A
PIC 9(5).
01 C PIC 9(5) VALUE ALL ZEROS.
PROCEDURE DIVISION.
MOVE '231' TO A.
DISPLAY 'A : ', A.
DISPLAY 'B : ', B.
STOP RUN.
|
Now when i execute this code
This means a and B both contains '231 '
Since B is PIC 9(5), it should show 00231
I am not getting why this is happening.
What should i do to get 00231?
Sudhakar. |
|
Back to top |
|
|
dr_te_z
New User
Joined: 08 Jun 2007 Posts: 71 Location: Zoetermeer, the Netherlands
|
|
|
|
move 231 to B. |
|
Back to top |
|
|
sudhakar_lendave
New User
Joined: 21 Nov 2006 Posts: 48 Location: mumbai
|
|
|
|
thanks dr_te_z,
but the thing is my variable A gets populated whenever i read a file. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Why should B display 00231? |
|
Back to top |
|
|
sudhakar_lendave
New User
Joined: 21 Nov 2006 Posts: 48 Location: mumbai
|
|
|
|
Sorry steve i wasn't specific.
Actually whenever i read a file, A gets the data in it.
Now i wanted this A should be compared with C which is numeric.
So i think, redefining A with B will give me B as a numeric.
and now i can compare B and C.
But it's not working. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
all you have when you redefine an alpha field as numeric is a numeric field that has been populated with alpha data.
you need to extract the numeric value (COBOL intrinsic function NUMVAL) from the alpha field, storing the results in a numeric field, then make your compare. |
|
Back to top |
|
|
sudhakar_lendave
New User
Joined: 21 Nov 2006 Posts: 48 Location: mumbai
|
|
|
|
Thanks Dick.. it's working now.
________________
Sudhakar. |
|
Back to top |
|
|
|