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 Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


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