View previous topic :: View next topic |
Author |
Message |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Mon Apr 19, 2004 2:17 pm Post subject: simple doubt in COBOL |
|
|
Code: |
WORKING-STORAGE SECTION.
01 WS-FLD1 PIC X(04).
01 WS-FLD3 PIC 9(04).
PROCEDURE DIVISION.
MOVE 'ABCD' TO WS-FLD1
MOVE WS-FLD1 TO WS-FLD3
DISPLAY 'VALUE OF FLD3 IS : ' WS-FLD3
STOP RUN.
|
Why ws-fld3 shows ABC4 in the output ? |
|
Back to top |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Mon Apr 19, 2004 2:49 pm Post subject: |
|
|
Hi Vijay,
Since you're trying to move X'C1C2C3C4' (an A/N value) to a numeric field, the compiler rules dictate that the sending field be numeric and unsigned.
It looks like it doesn't care about the non-sign digits (GIGO), but forces the 4 high order sign bits of the low order digit to X'F', overlaying the X'C' that's there. Since the low order bits of that digit is X"4" the full byte is X'F4' or a DISPLAY "4".
Perhaps you can answer a question: Why are you moving Alphas to a numeric field?
Regards, Jack. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
kirank Beginner
Joined: 21 Apr 2004 Posts: 61 Topics: 33 Location: hyderabad
|
Posted: Wed Apr 21, 2004 6:57 am Post subject: |
|
|
Hi,
For the above question, as per my knowledge , it will give SOC7 error. but u said to add CBL NUMPROC(PFD) . so, if add CBL NUMPROC(PFD) , does it gives ABCD. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Apr 21, 2004 8:38 am Post subject: |
|
|
Kirank
Quote: |
For the above question, as per my knowledge , it will give SOC7 error. but u said to add CBL NUMPROC(PFD) . so, if add CBL NUMPROC(PFD) , does it gives ABCD.
|
No it does not give you a SOC7 , it will have ABC4 and see slade's post for explanation.
Adding the NUMPROC(PFD) as compiler option will give you ABCD
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|