MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

simple doubt in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Mon Apr 19, 2004 2:17 pm    Post subject: simple doubt in COBOL Reply with quote

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
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Mon Apr 19, 2004 2:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Apr 19, 2004 2:56 pm    Post subject: Reply with quote

Vijay,

Add this line at the top of your program.i.e before ID division.

Code:

CBL NUMPROC(PFD)


And now run the program and look at the output. And here is the explanation of NUMPROC

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/2.4.34?DT=20020923143836

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kirank
Beginner


Joined: 21 Apr 2004
Posts: 61
Topics: 33
Location: hyderabad

PostPosted: Wed Apr 21, 2004 6:57 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 21, 2004 8:38 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group