Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Data Representation in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
raveendra_ibm
Currently Banned

New User


Joined: 07 Jan 2006
Posts: 31

PostPosted: Sat Jan 07, 2006 7:01 pm    Post subject: Data Representation in COBOL
Reply with quote

Hi All,

Here is a sample code...

A PIC X(04) VALUE IS 'KLMN'.
B REDEFINES A PIC S9(04).
ADD 1000 TO B.
DISPLAY B.

This gives 134E as answer.

Could anyone please let me know how the data is actually stored and how this operation is actually performed.

Thanks and Regards,
Raveendra.
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jan 10, 2006 3:59 am    Post subject: Re: Data Representation in COBOL
Reply with quote

raveendra_ibm,

I just answered, I hope, this question for another member. Check this topic. if it doesn't answer your question please come back

http://www.ibmmainframes.com/viewtopic.php?t=7951&start=0&postdays=0&postorder=asc&highlight=

Luck,

Dave
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Tue Jan 10, 2006 9:10 am    Post subject: Re: Data Representation in COBOL
Reply with quote

Hi Raveendra,

Since you're trying to move an Alphanumeric value to a numeric field, the compiler rules dictate that the sending field be numeric and unsigned.

For example


Quote:
WORKING-STORAGE SECTION.
01 A PIC X(04).
01 B PIC 9(04).
PROCEDURE DIVISION.
MOVE 'ABCD' TO A
MOVE A TO B
DISPLAY 'VALUE OF B IS : ' B
STOP RUN.


In the above example 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".


Hope this helps.


Please let me know if I am wrong.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us